/* ─── Links! – Claude-inspired B/W Design ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #ffffff;
  --bg-soft:   #f9fafb;
  --bg-muted:  #f3f4f6;
  --border:    #e5e7eb;
  --border-md: #d1d5db;
  --text:      #0a0a0a;
  --text-2:    #374151;
  --text-3:    #6b7280;
  --text-inv:  #ffffff;
  --accent:    #0a0a0a;
  --accent-h:  #1f2937;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --warn-brd:  #fcd34d;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --ok:        #059669;
  --ok-bg:     #f0fdf4;
  --r:         8px;
  --r-sm:      4px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.35rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.1rem;  font-weight: 600; }
h4 { font-size: .95rem;  font-weight: 600; }
p  { color: var(--text-2); }
small, .small { font-size: .825rem; color: var(--text-3); }
a  { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--text-3); }

code, pre {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .875em;
  background: var(--bg-muted);
  border-radius: var(--r-sm);
  padding: .1em .35em;
}

/* ── Layout ── */
.wrap        { max-width: 680px; margin: 0 auto; padding: 0 1.25rem; }
.wrap-wide   { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.wrap-narrow { max-width: 480px; margin: 0 auto; padding: 0 1.25rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1.25rem;
  border-radius: var(--r);
  font-size: .9rem; font-weight: 500;
  cursor: pointer; border: 1.5px solid transparent;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
  text-decoration: none; line-height: 1;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: var(--text-inv); border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: var(--text-inv); }

.btn-outline {
  background: var(--bg); color: var(--text); border-color: var(--border-md);
}
.btn-outline:hover { border-color: var(--accent); background: var(--bg-muted); }

.btn-ghost {
  background: transparent; color: var(--text-3); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }

.btn-danger {
  background: var(--danger-bg); color: var(--danger); border-color: #fca5a5;
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: .35rem .85rem; font-size: .825rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.1rem; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text-2); }
.form-label .req { color: var(--danger); margin-left: .2em; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: .6rem .8rem;
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: .9rem; font-family: inherit; color: var(--text);
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,10,10,.07);
}
.form-input.error, .form-select.error { border-color: var(--danger); }
.form-hint { font-size: .8rem; color: var(--text-3); }
.form-hint.warn { color: var(--warn); }
.form-hint.danger { color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:520px){ .form-row { grid-template-columns: 1fr; } }

/* ── Cards ── */
.card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-sm { padding: 1rem 1.25rem; }

/* ── Selection Cards (for mode/storage picking) ── */
.choice-grid { display: grid; gap: .75rem; }
.choice-grid-2 { grid-template-columns: 1fr 1fr; }
.choice-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media(max-width:560px) { .choice-grid-2, .choice-grid-3 { grid-template-columns: 1fr; } }

.choice-card {
  border: 1.5px solid var(--border); border-radius: var(--r);
  padding: 1rem 1.1rem; cursor: pointer; position: relative;
  transition: border-color .15s, background .15s;
  background: var(--bg);
}
.choice-card input[type=radio] {
  position: absolute; opacity: 0; pointer-events: none;
}
.choice-card:hover { border-color: var(--border-md); background: var(--bg-soft); }
.choice-card.selected, .choice-card input:checked ~ * { color: inherit; }
.choice-card.selected {
  border-color: var(--accent);
  background: var(--bg-soft);
  box-shadow: 0 0 0 2px rgba(10,10,10,.06);
}
.choice-card .choice-title { font-weight: 600; font-size: .95rem; margin-bottom: .2rem; }
.choice-card .choice-desc  { font-size: .825rem; color: var(--text-3); }
.choice-badge {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .15em .55em; border-radius: 99px;
  background: var(--bg-muted); color: var(--text-3);
  margin-left: .5em; vertical-align: middle; text-transform: uppercase; letter-spacing: .03em;
}
.badge-recommended { background: var(--text); color: var(--text-inv); }
.badge-warn  { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-brd); }
.badge-danger{ background: var(--danger-bg); color: var(--danger); }

/* ── Alerts / Notices ── */
.alert {
  padding: .75rem 1rem; border-radius: var(--r); font-size: .875rem;
  border: 1.5px solid; margin-bottom: 1rem;
  display: flex; gap: .6rem; align-items: flex-start;
}
.alert-warn  { background: var(--warn-bg);   color: var(--warn);   border-color: var(--warn-brd); }
.alert-ok    { background: var(--ok-bg);     color: var(--ok);     border-color: #6ee7b7; }
.alert-info  { background: var(--bg-soft);   color: var(--text-2); border-color: var(--border); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }

/* ── Progress / Steps ── */
.steps { display: flex; align-items: center; gap: 0; margin-bottom: 2.5rem; flex-wrap: wrap; }
.step  { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-3); }
.step-dot {
  width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text-3);
}
.step.active .step-dot { background: var(--accent); border-color: var(--accent); color: var(--text-inv); }
.step.done   .step-dot { background: var(--bg-muted); border-color: var(--border-md); color: var(--text-3); }
.step.active .step-label { color: var(--text); font-weight: 600; }
.step-sep { width: 24px; height: 1.5px; background: var(--border); margin: 0 .25rem; flex-shrink: 0; }

/* ── Setup Page ── */
.setup-shell {
  min-height: 100vh; display: flex; align-items: flex-start; justify-content: center;
  padding: 3rem 1rem 4rem;
}
.setup-box { width: 100%; max-width: 600px; }
.setup-logo { font-size: 1.4rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: 2.5rem; }
.setup-logo span { opacity: .35; }
.setup-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .4rem; }
.setup-sub   { color: var(--text-3); margin-bottom: 2rem; }

.setup-actions { display: flex; gap: .75rem; margin-top: 2rem; justify-content: space-between; }
.setup-actions-right { display: flex; gap: .75rem; }

/* ── Welcome Page ── */
.welcome-shell {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 2rem;
}
.welcome-logo { font-size: 2.5rem; font-weight: 800; letter-spacing: -.04em; margin-bottom: 1rem; }
.welcome-logo span { opacity: .3; }
.welcome-tagline { font-size: 1.1rem; color: var(--text-3); margin-bottom: 2.5rem; max-width: 400px; }

/* ── Navigation / App Shell ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  border-right: 1.5px solid var(--border);
  background: var(--bg-soft);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto;
  z-index: 50;
}
.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.15rem; font-weight: 800; letter-spacing: -.025em;
  border-bottom: 1.5px solid var(--border);
}
.sidebar-logo span { opacity: .35; }

.sidebar-nav { padding: .75rem .75rem; flex: 1; }
.nav-section-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); padding: .5rem .5rem .25rem; margin-top: .5rem;
}
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem; border-radius: var(--r-sm);
  font-size: .875rem; color: var(--text-2); text-decoration: none;
  cursor: pointer; transition: background .12s, color .12s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-muted); color: var(--text); }
.nav-item.active { background: var(--bg-muted); color: var(--text); font-weight: 600; }
.nav-item svg { flex-shrink: 0; opacity: .6; width: 15px; height: 15px; }
.nav-item.active svg { opacity: 1; }

.folder-indent { padding-left: 1.75rem; }
.folder-link   { font-size: .85rem; }

.sidebar-bottom {
  padding: .75rem; border-top: 1.5px solid var(--border);
  font-size: .8rem; color: var(--text-3);
}
.sidebar-user { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; }
.sidebar-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}

/* ── Main content ── */
.main-content {
  margin-left: 240px; flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}
@media(max-width:768px) {
  .sidebar { width: 100%; position: static; height: auto; border-right: none; border-bottom: 1.5px solid var(--border); }
  .main-content { margin-left: 0; }
  .app-shell { flex-direction: column; }
}

.topbar {
  height: 56px; border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem;
  background: var(--bg); position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-weight: 600; flex: 1; }

.page-body { padding: 1.75rem 1.5rem; flex: 1; }

/* ── Links ── */
.links-grid { display: grid; gap: .6rem; }

.link-card {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--bg);
  transition: border-color .12s, box-shadow .12s;
}
.link-card:hover { border-color: var(--border-md); box-shadow: var(--shadow); }
.link-card.locked { opacity: .7; }

.link-favicon {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--bg-muted); display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0; overflow: hidden;
}
.link-favicon img { width: 100%; height: 100%; object-fit: contain; }

.link-info { flex: 1; min-width: 0; }
.link-name { font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-url  { font-size: .775rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.link-actions { display: flex; gap: .3rem; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.link-card:hover .link-actions { opacity: 1; }
.link-lock-icon { color: var(--text-3); font-size: .85rem; }

/* ── Folders ── */
.folder-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .75rem; cursor: pointer;
  border-radius: var(--r-sm); transition: background .12s;
  user-select: none;
}
.folder-header:hover { background: var(--bg-muted); }
.folder-header .folder-name { font-weight: 600; font-size: .9rem; flex: 1; }
.folder-header .folder-count { font-size: .775rem; color: var(--text-3); }
.folder-chevron { transition: transform .2s; color: var(--text-3); }
.folder-chevron.open { transform: rotate(90deg); }
.folder-body { padding-left: .5rem; padding-bottom: .5rem; }

/* ── FAB ── */
.fab {
  position: fixed; bottom: 1.75rem; right: 1.75rem;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 300; line-height: 1;
  box-shadow: var(--shadow-md); cursor: pointer; border: none;
  transition: background .15s, transform .12s, box-shadow .15s;
  z-index: 100;
  text-decoration: none;
}
.fab:hover { background: var(--accent-h); color: var(--text-inv); transform: scale(1.07); box-shadow: 0 8px 20px rgba(0,0,0,.15); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg); border-radius: var(--r); width: 100%; max-width: 440px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1.5px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 1.2rem; line-height: 1; padding: .2rem; border-radius: var(--r-sm); }
.modal-close:hover { background: var(--bg-muted); color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1.5px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

/* ── Settings ── */
.settings-section { margin-bottom: 2.5rem; }
.settings-section h3 { margin-bottom: 1rem; padding-bottom: .6rem; border-bottom: 1.5px solid var(--border); }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 0; border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: .9rem; }
.settings-row-desc  { font-size: .8rem; color: var(--text-3); }

/* ── Misc ── */
.divider { height: 1.5px; background: var(--border); margin: 1.5rem 0; }
.tag {
  display: inline-block; font-size: .75rem; padding: .15em .6em;
  border-radius: 99px; background: var(--bg-muted); color: var(--text-3);
  border: 1px solid var(--border);
}
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .775rem; }
.font-mono { font-family: 'SF Mono','Fira Code',monospace; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toggle ── */
.toggle {
  position: relative; width: 38px; height: 22px;
  cursor: pointer; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border-md); border-radius: 99px;
  transition: background .2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked ~ .toggle-knob { transform: translateX(16px); }

/* ── Print / Misc ── */
@media print { .sidebar, .fab, .topbar { display: none !important; } .main-content { margin-left: 0 !important; } }
