/* ==========================================================================
   Alexandria — a private reading room
   Design language: editorial minimalism, parchment & ink, amber annotations.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-reading: "Crimson Pro", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --bg: #fbf7ef;
  --bg-deep: #f5eee1;
  --surface: #fffdf8;
  --surface-2: #f8f2e7;
  --surface-3: #f2e9da;
  --ink: #1c1917;
  --ink-2: #3f3a35;
  --muted: #6b6258;
  --faint: #7a6f62;
  --border: #e9e0d1;
  --border-strong: #d8cbb6;

  --accent: #b45309;
  --accent-hover: #96420a;
  --accent-soft: #fbefd8;
  --accent-ink: #7c2d12;
  --on-accent: #fffaf1;

  --green: #4d7c0f;
  --green-soft: #eef4dc;
  --blue: #1d4ed8;
  --blue-soft: #e8edfc;
  --red: #b91c1c;
  --red-soft: #fbeaea;
  --gold: #c99a3f;
  --purple: #6d28d9;

  --radius-xs: 7px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-sm: 0 2px 8px -2px rgba(28, 25, 23, 0.08);
  --shadow-md: 0 14px 36px -18px rgba(28, 25, 23, 0.22), 0 2px 6px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 40px 80px -32px rgba(28, 25, 23, 0.35);

  --sidebar-w: 274px;
  --topbar-h: 78px;
  --content-max: 1320px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 200ms;
}

[data-theme="dark"] {
  --bg: #131110;
  --bg-deep: #0d0c0b;
  --surface: #1b1816;
  --surface-2: #221e1b;
  --surface-3: #2a2521;
  --ink: #f4eee5;
  --ink-2: #ddd5c9;
  --muted: #a89e91;
  --faint: #8a8177;
  --border: #2e2925;
  --border-strong: #413a33;

  --accent: #e8a04a;
  --accent-hover: #f2b668;
  --accent-soft: #2b2117;
  --accent-ink: #f3c58b;
  --on-accent: #1a1108;

  --green: #a8c86b;
  --green-soft: #22280f;
  --blue: #9bb7ff;
  --blue-soft: #1a2036;
  --red: #f09191;
  --red-soft: #2d1717;
  --gold: #ddb06a;
  --purple: #c4b5fd;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
}

/* 2. Reset & base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 88% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--gold) 8%, transparent), transparent 55%);
}

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.15; letter-spacing: -0.015em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
strong { font-weight: 600; }
small { font-size: 12px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: top var(--speed) var(--ease);
}
.skip-link:focus { top: 12px; }

.scroll-thin { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* 3. Typography helpers ---------------------------------------------------- */
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
.serif { font-family: var(--font-display); }
.reading { font-family: var(--font-reading); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--border-strong);
}
.eyebrow.no-rule::before { display: none; }
.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: -0.01em; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; } .mt-5 { margin-top: 36px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--bg-deep) 88%, transparent));
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 0;
  margin-bottom: 20px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--on-accent);
  background:
    radial-gradient(120% 120% at 20% 10%, color-mix(in srgb, var(--accent) 60%, var(--gold)), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 16px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  flex: none;
}
.brand-mark--sm { width: 30px; height: 30px; border-radius: 9px; }
.brand-word {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.brand-word small {
  font-family: var(--font-sans);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

.sidebar-capture { padding: 0 4px 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 18px 12px 7px;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  transition: background var(--speed), color var(--speed);
}
.nav-link svg { color: var(--faint); transition: color var(--speed); flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link:hover svg { color: var(--accent); }
.nav-link.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border);
}
.nav-link.is-active svg { color: var(--accent); }
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  translate: 0 -50%;
  width: 3px;
  height: 20px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}
.nav-count {
  margin-left: auto;
  font-style: normal;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  min-width: 22px;
  text-align: center;
}
.nav-link.is-active .nav-count { background: var(--surface-3); color: var(--ink-2); }
.nav-count.is-accent { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 2px 6px;
  border-radius: 5px;
}

.sidebar-tags { padding: 0 4px; margin-top: 4px; }
.tag-mini-list { display: flex; flex-direction: column; }
.tag-mini {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  color: var(--muted);
  transition: background var(--speed), color var(--speed);
}
.tag-mini:hover { background: var(--surface-2); color: var(--ink); }
.tag-mini i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tag-color, var(--accent));
  flex: none;
}
.tag-mini span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-mini em { margin-left: auto; font-style: normal; font-size: 10px; color: var(--faint); }

.sidebar-footer { margin-top: auto; padding-top: 18px; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  transition: border-color var(--speed), background var(--speed);
}
.sidebar-user:hover { border-color: var(--border-strong); background: var(--surface); }
.sidebar-user > svg { color: var(--faint); margin-left: auto; flex: none; }
.sidebar-user-meta { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-meta strong { font-size: 12.5px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-meta small { font-size: 10px; color: var(--faint); }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
  background:
    radial-gradient(120% 120% at 30% 20%, var(--accent-soft), color-mix(in srgb, var(--accent) 24%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
}
.avatar-btn { cursor: pointer; padding: 0; }

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

/* 5. Topbar ---------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(20px, 3vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar-brand { display: none; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.topbar-heading { min-width: 0; }
.topbar-kicker {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1.2;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin-top: 3px;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  width: min(380px, 32vw);
  margin-left: auto;
  padding: 0 10px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  transition: border-color var(--speed), box-shadow var(--speed), background var(--speed);
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-xs); }
.search-trigger svg { color: var(--faint); flex: none; }
.search-trigger-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--faint);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
.icon-btn.is-active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }

.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* 6. Buttons, chips, badges ------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: transform var(--speed) var(--ease), background var(--speed), border-color var(--speed), color var(--speed), box-shadow var(--speed);
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn svg { flex: none; }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 18px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-dark { background: var(--ink); color: var(--bg); }
.btn-dark:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--ink); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 20%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 14%, var(--surface)); }

.btn-sm { height: 34px; padding: 0 13px; font-size: 12px; gap: 6px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 11px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-round { border-radius: var(--radius-full); }
.btn-icon { width: 34px; padding: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--speed), border-color var(--speed), background var(--speed);
}
.chip:hover { border-color: var(--border-strong); color: var(--ink); }
.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.chip.is-active svg { color: currentColor; }
.chip svg { color: var(--faint); }
.chip--accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-ink); }
.chip--outline { background: transparent; }
.chip-count {
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 99px;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  white-space: nowrap;
}
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge--green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge--blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge--red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--tag-color, var(--muted));
  background: color-mix(in srgb, var(--tag-color, var(--muted)) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color, var(--muted)) 18%, transparent);
  transition: background var(--speed);
  max-width: 100%;
}
.tag:hover { background: color-mix(in srgb, var(--tag-color, var(--muted)) 16%, transparent); }
.tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 7. Page scaffold --------------------------------------------------------- */
.page {
  width: 100%;
  max-width: var(--content-max);
  padding: 32px clamp(20px, 3vw, 40px) 80px;
  margin: 0 auto;
}
.page--narrow { max-width: 920px; }
.page--wide { max-width: 1480px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.page-head h1, .page-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 46px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.02;
}
.page-head .subtitle {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  max-width: 62ch;
  line-height: 1.6;
}
.page-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.section-head .link-more {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--speed), gap var(--speed);
}
.section-head .link-more:hover { color: var(--accent); gap: 7px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.panel-pad { padding: 22px; }

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* 8. Flash & toasts -------------------------------------------------------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash-stack:empty { display: none; }
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: slideDown 300ms var(--ease);
}
.flash--notice { border-color: color-mix(in srgb, var(--green) 25%, var(--border)); }
.flash--notice .flash-icon { color: var(--green); }
.flash--alert { border-color: color-mix(in srgb, var(--red) 30%, var(--border)); }
.flash--alert .flash-icon { color: var(--red); }
.flash-icon { display: grid; place-items: center; flex: none; }
.flash-message { flex: 1; }
.flash-dismiss { background: transparent; border: 0; color: var(--faint); padding: 4px; border-radius: 4px; }
.flash-dismiss:hover { color: var(--ink); background: var(--surface-2); }

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  animation: toastIn 320ms var(--ease);
}

/* 9. Link cards ------------------------------------------------------------ */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(296px, 1fr));
  gap: 22px;
}
.links-list { display: flex; flex-direction: column; gap: 12px; }

.link-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed), border-color var(--speed);
  min-width: 0;
}
.link-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.link-card.is-processing { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }

.link-card-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  overflow: hidden;
}
.link-card-media img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease), filter var(--speed);
}
.link-card:hover .link-card-media img { transform: scale(1.03); }
.media-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(140deg,
      hsl(var(--hue, 30) 42% 88%) 0%,
      hsl(calc(var(--hue, 30) + 34) 38% 79%) 55%,
      hsl(calc(var(--hue, 30) + 12) 45% 72%) 100%);
  color: hsl(var(--hue, 30) 38% 24%);
}
[data-theme="dark"] .media-fallback {
  background:
    linear-gradient(140deg,
      hsl(var(--hue, 30) 26% 20%) 0%,
      hsl(calc(var(--hue, 30) + 34) 24% 14%) 60%,
      hsl(calc(var(--hue, 30) + 12) 30% 24%) 100%);
  color: hsl(var(--hue, 30) 45% 78%);
}
.media-fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(currentColor 0.5px, transparent 0.5px);
  background-size: 14px 14px;
  opacity: 0.12;
}
.media-fallback .media-initial {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 600;
  opacity: 0.85;
  line-height: 1;
}
.media-fallback .media-domain {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}
.media-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
}
.media-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: color-mix(in srgb, #1c1917 72%, transparent);
  color: #fff8ee;
  backdrop-filter: blur(8px);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.media-type svg { color: #f0c58b; }
.fav-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, #1c1917 58%, transparent);
  color: #fff8ee;
  backdrop-filter: blur(8px);
  transition: background var(--speed), color var(--speed), transform var(--speed);
}
.fav-btn:hover { background: color-mix(in srgb, #1c1917 80%, transparent); transform: scale(1.08); }
.fav-btn.is-active { color: #f2c14e; }
.fav-btn.is-active svg { fill: #f2c14e; }
.fav-btn--plain { background: transparent; color: var(--faint); }
.fav-btn--plain:hover { background: var(--surface-2); color: var(--accent); }
.fav-btn--plain.is-active { color: var(--gold); }

.link-card-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px 17px 15px;
  flex: 1;
  min-width: 0;
}
.link-card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--faint);
  min-width: 0;
}
.link-card-meta .domain {
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-card-meta .sep { width: 2px; height: 2px; border-radius: 50%; background: var(--border-strong); flex: none; }
.link-card-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.015em;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-card:hover .link-card-title { color: var(--accent-ink); }
.link-card-excerpt {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  flex-wrap: wrap;
}
.link-card-tags { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; flex: 1; }
.link-card-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 10px;
  color: var(--faint);
  white-space: nowrap;
}
.link-card-stats span { display: inline-flex; align-items: center; gap: 3px; }

.card-ai-state {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
}
.card-ai-state .pulse-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
.card-ai-state.is-failed { color: var(--red); }
.card-ai-state.is-skipped { color: var(--faint); }

.link-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity var(--speed);
}
.link-card:hover .link-card-actions, .link-card:focus-within .link-card-actions { opacity: 1; }
.link-card-actions .fav-btn { opacity: 1; }

/* list view */
.links-list .link-card { flex-direction: row; align-items: stretch; }
.links-list .link-card-media { width: 230px; aspect-ratio: auto; flex: none; min-height: 150px; }
.links-list .link-card-body { padding: 18px 22px; }
.links-list .link-card-title { font-size: 24px; -webkit-line-clamp: 2; }
.links-list .link-card-excerpt { -webkit-line-clamp: 2; max-width: 90ch; }
.links-list .link-card-actions { position: absolute; top: 10px; right: 10px; opacity: 1; z-index: 4; }
.links-list .link-card-media .media-badges { position: absolute; }
@media (max-width: 760px) {
  .links-list .link-card { flex-direction: column; }
  .links-list .link-card-media { width: 100%; aspect-ratio: 16 / 8; min-height: 0; }
}

/* 10. Empty state ---------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 54px 28px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  margin-bottom: 16px;
}
.empty-state h3 { font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.empty-state p { color: var(--muted); font-size: 13.5px; max-width: 46ch; margin-top: 6px; line-height: 1.6; }

/* 11. Command palette ------------------------------------------------------ */
.palette {
  width: min(660px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 80px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  overflow: visible;
  margin-top: 12vh;
}
.palette::backdrop {
  background: color-mix(in srgb, #14110e 55%, transparent);
  backdrop-filter: blur(6px);
}
.palette-panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: paletteIn 220ms var(--ease);
}
.palette-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.palette-search-icon { color: var(--accent); flex: none; }
.palette-search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 16px;
  color: var(--ink);
}
.palette-search input::placeholder { color: var(--faint); }
.palette-close { border: 0; background: var(--surface-2); color: var(--muted); width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; }
.palette-close:hover { color: var(--ink); }
.palette-results { overflow-y: auto; padding: 8px; flex: 1; }
.palette-hint { padding: 18px 14px; color: var(--faint); font-size: 12.5px; }
.palette-quick { display: flex; flex-direction: column; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--speed);
  min-width: 0;
}
.palette-item:hover, .palette-item.is-selected { background: var(--surface-2); }
.palette-item > svg { color: var(--faint); flex: none; }
.palette-item-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--accent);
  flex: none;
  overflow: hidden;
}
.palette-item-icon img { width: 100%; height: 100%; object-fit: cover; }
.palette-item-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.palette-item-body strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item-body small { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-group-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 12px 12px 6px;
}
.palette-footer {
  display: flex;
  gap: 16px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 10px;
  color: var(--faint);
}
.palette-footer span { display: flex; align-items: center; gap: 4px; }
.palette-footer .kbd { height: 17px; min-width: 17px; font-size: 9px; }

/* 12. Popovers ------------------------------------------------------------- */
.avatar-menu { position: relative; }
.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 232px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: slideDown 160ms var(--ease);
}
.popover-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
  min-width: 0;
}
.popover-head div { min-width: 0; display: flex; flex-direction: column; }
.popover-head strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover-head small { font-size: 10px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
}
.popover-item:hover { background: var(--surface-2); color: var(--ink); }
.popover-item svg { color: var(--faint); }
.popover-item.is-danger:hover { background: var(--red-soft); color: var(--red); }
.popover-item.is-danger:hover svg { color: var(--red); }
.popover-sep { height: 1px; background: var(--border); margin: 5px 0; }
button.popover-item { font: inherit; cursor: pointer; }

/* 13. Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.field .hint { font-size: 11px; color: var(--faint); line-height: 1.5; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  padding: 10px 12px;
  transition: border-color var(--speed), box-shadow var(--speed);
  min-height: 40px;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.textarea { resize: vertical; line-height: 1.6; min-height: 110px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6258' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.checkbox { display: flex; align-items: flex-start; gap: 9px; font-size: 12px; color: var(--muted); }
.checkbox input { margin-top: 3px; accent-color: var(--accent); }
.input-affix { position: relative; }
.input-affix .input { padding-right: 40px; }
.input-affix .affix-btn {
  position: absolute; right: 4px; top: 50%; translate: 0 -50%;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--faint); border-radius: 6px;
}
.input-affix .affix-btn:hover { color: var(--ink); background: var(--surface-2); }

/* 14. Dashboard ------------------------------------------------------------ */
.dash-hero {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(700px 280px at 100% -20%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 60%),
    linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface-2) 55%, var(--surface)));
  padding: clamp(24px, 3.4vw, 40px);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.dash-hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  pointer-events: none;
}
.dash-hero .greeting-line {
  font-family: var(--font-display);
  font-size: clamp(32px, 4.4vw, 52px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin-top: 10px;
}
.dash-hero .greeting-line em { font-style: italic; color: var(--accent); }
.dash-hero .greeting-sub {
  color: var(--muted);
  font-size: 14px;
  margin-top: 10px;
  max-width: 56ch;
  line-height: 1.6;
}
.capture-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 7px 7px 7px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  max-width: 700px;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.capture-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent), var(--shadow-sm);
}
.capture-form > svg { color: var(--faint); flex: none; }
.capture-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}
.capture-form input::placeholder { color: var(--faint); }
.dash-hero-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 11px;
  color: var(--faint);
}
.dash-hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.dash-hero-meta strong { color: var(--ink-2); font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}
.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  overflow: hidden;
  transition: border-color var(--speed), transform var(--speed) var(--ease), box-shadow var(--speed);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-card .stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.stat-card .stat-label svg { color: var(--accent); }
.stat-card .stat-value {
  font-family: var(--font-display);
  font-feature-settings: "lnum" 1;
  font-variant-numeric: lining-nums;
  font-size: 38px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-meta { font-size: 10.5px; color: var(--faint); margin-top: 5px; }
.stat-card .stat-spark { position: absolute; right: 14px; bottom: 14px; opacity: 0.5; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr);
  gap: 26px;
  margin-top: 36px;
  align-items: start;
}
.dash-col { display: flex; flex-direction: column; gap: 34px; min-width: 0; }
.dash-aside { display: flex; flex-direction: column; gap: 18px; position: sticky; top: calc(var(--topbar-h) + 20px); }

.continue-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.continue-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--speed);
  min-width: 0;
}
.continue-item:last-child { border-bottom: 0; }
.continue-item:hover { background: var(--surface-2); }
.progress-ring {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress, 35) * 1%), var(--surface-3) 0);
}
.progress-ring::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--surface); }
.progress-ring svg { position: relative; color: var(--accent); }
.continue-body { min-width: 0; flex: 1; }
.continue-body strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-body small { display: block; color: var(--faint); font-size: 10.5px; margin-top: 3px; }
.continue-item > svg { color: var(--faint); flex: none; }

.aside-panel { padding: 18px; }
.aside-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 14px;
}
.aside-title a { color: var(--faint); }
.aside-title a:hover { color: var(--accent); }

.week-chart { display: flex; align-items: flex-end; gap: 7px; height: 72px; }
.week-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.week-bar i {
  width: 100%;
  max-width: 26px;
  border-radius: 4px 4px 2px 2px;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-3));
  min-height: 3px;
  transition: background var(--speed);
}
.week-bar:hover i { background: var(--accent); }
.week-bar.is-today i { background: var(--accent); }
.week-bar small { font-size: 8.5px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }

.category-list { display: flex; flex-direction: column; gap: 10px; }
.category-row { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.category-row .cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.category-row .cat-count { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.category-bar { width: 72px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex: none; }
.category-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); opacity: 0.75; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

.random-pick {
  position: relative;
  padding: 20px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
    var(--ink);
  color: var(--bg);
  overflow: hidden;
}
[data-theme="dark"] .random-pick { background: radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 60%), var(--surface-2); }
.random-pick .eyebrow { color: color-mix(in srgb, var(--bg) 60%, transparent); }
.random-pick .eyebrow::before { background: color-mix(in srgb, var(--bg) 30%, transparent); }
.random-pick h3 { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.15; margin-top: 10px; }
.random-pick p { font-size: 11.5px; line-height: 1.55; opacity: 0.68; margin-top: 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.random-pick .pick-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.random-pick .pick-foot small { font-size: 10px; opacity: 0.6; }
.random-pick .btn { background: color-mix(in srgb, var(--bg) 92%, transparent); color: var(--ink); }
.random-pick .btn:hover { background: var(--bg); }

.ai-nudge {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.ai-nudge svg { color: var(--accent); flex: none; margin-top: 1px; }
.ai-nudge strong { display: block; font-size: 12.5px; color: var(--accent-ink); }
.ai-nudge p { font-size: 11px; color: color-mix(in srgb, var(--accent-ink) 80%, var(--muted)); line-height: 1.5; margin-top: 3px; }
.ai-nudge a { font-size: 11px; font-weight: 600; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

/* 15. Library page --------------------------------------------------------- */
.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  margin-bottom: 22px;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background var(--speed), color var(--speed), box-shadow var(--speed);
}
.segmented a:hover { color: var(--ink); }
.segmented a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 600; }
.segmented a .n { font-size: 9.5px; color: var(--faint); }
.library-toolbar .spacer { flex: 1; }
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  min-width: 200px;
  flex: 1;
  max-width: 320px;
}
.toolbar-search svg { color: var(--faint); flex: none; }
.toolbar-search input { border: 0; outline: 0; background: transparent; font-size: 12px; width: 100%; }
.toolbar-search input::placeholder { color: var(--faint); }
.toolbar-select {
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background-color: var(--surface);
  font-size: 11.5px;
  color: var(--muted);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23998f83' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.view-toggle a { display: grid; place-items: center; width: 32px; height: 32px; color: var(--faint); background: var(--surface); }
.view-toggle a:hover { color: var(--ink); background: var(--surface-2); }
.view-toggle a.is-active { color: var(--accent); background: var(--accent-soft); }

.active-filters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.active-filters .filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 6px 0 10px;
  border-radius: 99px;
  font-size: 10.5px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}
.filter-pill a { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: inherit; }
.filter-pill a:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.library-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--faint);
}
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 34px; }
.pagination a, .pagination span {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.pagination a:hover { border-color: var(--border-strong); color: var(--ink); }
.pagination .is-current { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* 16. Link detail ---------------------------------------------------------- */
.link-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 34px; align-items: start; }
.detail-main { min-width: 0; }
.detail-aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.detail-hero { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.detail-media { position: relative; aspect-ratio: 16 / 8; background: var(--surface-2); }
.detail-media img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.detail-media .media-fallback { position: absolute; }
.detail-head { padding: 24px 26px 22px; }
.detail-kicker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.025em;
}
.detail-sub { margin-top: 10px; font-family: var(--font-reading); font-size: 18px; line-height: 1.55; color: var(--muted); }
.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 11px;
  color: var(--faint);
}
.detail-meta span { display: inline-flex; align-items: center; gap: 5px; }
.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.detail-actions .spacer { flex: 1; }

.ai-panel {
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(500px 180px at 100% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%),
    var(--surface);
  padding: 22px 24px;
  margin-top: 18px;
}
.ai-panel-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.ai-panel-head .spark-mark {
  display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 7px; background: var(--accent-soft); color: var(--accent); flex: none;
}
.ai-panel-head h2 { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.ai-panel-head .badge { margin-left: auto; }
.ai-summary { font-family: var(--font-reading); font-size: 18px; line-height: 1.65; color: var(--ink-2); }
.ai-points { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.ai-points li { display: flex; gap: 10px; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.ai-points li::before {
  content: counter(point);
  counter-increment: point;
  flex: none;
  display: grid; place-items: center;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 9px; font-weight: 700;
  margin-top: 1px;
}
.ai-points { counter-reset: point; }
.ai-skeleton { display: flex; flex-direction: column; gap: 9px; }
.skeleton-line {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.6s infinite;
}
.skeleton-line:nth-child(2) { width: 88%; }
.skeleton-line:nth-child(3) { width: 72%; }

.detail-section { margin-top: 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 22px 24px; }
.detail-section h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.notes-area { border: 0; background: transparent; padding: 0; min-height: 120px; font-family: var(--font-reading); font-size: 17px; line-height: 1.65; width: 100%; resize: vertical; color: var(--ink); }
.notes-area:focus { outline: 0; }
.notes-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 10px; color: var(--faint); }
.notes-status { display: inline-flex; align-items: center; gap: 5px; }
.notes-status.is-saving { color: var(--accent); }

.aside-block { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: 16px; }
.aside-block h3 { font-size: 10px; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; color: var(--faint); margin-bottom: 11px; }
.meta-list { display: flex; flex-direction: column; gap: 9px; }
.meta-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 11.5px; }
.meta-row dt { color: var(--faint); flex: none; }
.meta-row dd { margin: 0; text-align: right; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.related-list { display: flex; flex-direction: column; gap: 11px; }
.related-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px; margin: -8px; border-radius: 9px; transition: background var(--speed); }
.related-item:hover { background: var(--surface-2); }
.related-thumb { width: 42px; height: 42px; border-radius: 8px; overflow: hidden; flex: none; background: var(--surface-3); display: grid; place-items: center; color: var(--accent); }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-body { min-width: 0; }
.related-body strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; font-weight: 500; line-height: 1.4; }
.related-body small { display: block; font-size: 9.5px; color: var(--faint); margin-top: 2px; }

/* 17. Ask ------------------------------------------------------------------ */
.ask-hero { text-align: center; max-width: 740px; margin: 20px auto 30px; }
.ask-hero h1 { font-family: var(--font-display); font-size: clamp(36px, 5vw, 56px); font-weight: 500; letter-spacing: -0.03em; line-height: 1; }
.ask-hero h1 em { font-style: italic; color: var(--accent); }
.ask-hero p { color: var(--muted); font-size: 14px; margin-top: 12px; }
.ask-box {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 14px 14px 12px;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.ask-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 9%, transparent), var(--shadow-sm); }
.ask-box textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: var(--font-reading);
  font-size: 19px;
  line-height: 1.5;
  min-height: 60px;
  color: var(--ink);
}
.ask-box textarea::placeholder { color: var(--faint); }
.ask-box-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.ask-box-foot small { font-size: 10px; color: var(--faint); }
.ask-suggestions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 16px auto 36px; max-width: 760px; }
.ask-suggestion { font-size: 11px; color: var(--muted); border: 1px solid var(--border); background: var(--surface); padding: 6px 11px; border-radius: 99px; transition: all var(--speed); }
.ask-suggestion:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

.ask-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 26px; align-items: start; }
.answer-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 24px 26px;
  box-shadow: var(--shadow-xs);
  animation: fadeUp 500ms var(--ease);
}
.answer-head { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.answer-head .answer-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); flex: none; }
.answer-head strong { font-size: 12px; }
.answer-head small { display: block; font-size: 9.5px; color: var(--faint); }
.answer-question { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.2; margin-bottom: 16px; }
.answer-body { font-family: var(--font-reading); font-size: 18px; line-height: 1.7; color: var(--ink-2); }
.answer-body p + p { margin-top: 12px; }
.answer-body ul { list-style: disc; padding-left: 20px; margin: 10px 0; }
.answer-body li { margin: 4px 0; }
.answer-body strong { color: var(--ink); }
.answer-body code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 2px 5px; border-radius: 4px; }
.answer-sources { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.answer-sources h3 { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.source-pills { display: flex; flex-direction: column; gap: 6px; }
.source-pill { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; font-size: 11.5px; background: var(--surface-2); transition: background var(--speed); }
.source-pill:hover { background: var(--surface-3); }
.source-pill .n { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 4px; background: var(--surface); font-size: 9px; color: var(--accent); font-weight: 700; flex: none; }
.source-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-history { display: flex; flex-direction: column; gap: 6px; }
.history-item { display: block; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); transition: border-color var(--speed); }
.history-item:hover { border-color: var(--border-strong); }
.history-item strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11.5px; font-weight: 500; line-height: 1.4; }
.history-item small { display: block; font-size: 9.5px; color: var(--faint); margin-top: 4px; }

.ask-loading { display: none; align-items: center; gap: 10px; padding: 22px; color: var(--accent); font-size: 12px; }
.ask-loading.is-visible { display: flex; }

/* 18. Collections & tags --------------------------------------------------- */
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.collection-card {
  position: relative;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color var(--speed), transform var(--speed) var(--ease), box-shadow var(--speed);
  overflow: hidden;
}
.collection-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.collection-card .collection-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); color: var(--accent); margin-bottom: 14px; }
.collection-card h3 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.collection-card .collection-count { font-size: 10.5px; color: var(--faint); margin-top: 2px; }
.collection-card .collection-preview { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.collection-card .collection-preview span { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-card .collection-bar { position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0.35; }
.tag-grid { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.tag-row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.tag-row:last-child { border-bottom: 0; }
.tag-row:hover { background: var(--surface-2); }
.tag-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tag-color, var(--accent)); flex: none; }
.tag-row .tag-name { font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-row .tag-slug { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.tag-row .tag-count { margin-left: auto; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tag-row .tag-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--speed); }
.tag-row:hover .tag-actions { opacity: 1; }

/* 19. Settings ------------------------------------------------------------- */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 34px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.settings-nav a { padding: 8px 11px; border-radius: 7px; font-size: 12px; color: var(--muted); }
.settings-nav a:hover { background: var(--surface-2); color: var(--ink); }
.settings-nav a.is-active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border); font-weight: 500; }
.settings-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.settings-section { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; scroll-margin-top: calc(var(--topbar-h) + 20px); }
.settings-section-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.settings-section-head .sec-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); color: var(--accent); flex: none; }
.settings-section-head h2 { font-family: var(--font-display); font-size: 23px; font-weight: 600; line-height: 1.15; }
.settings-section-head p { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.settings-section-head .head-status { margin-left: auto; flex: none; }
.settings-body { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.settings-body .form-row { gap: 14px; }
.settings-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.settings-actions .spacer { flex: 1; }
.integration-steps { display: flex; flex-direction: column; gap: 12px; counter-reset: step; }
.integration-step { display: flex; gap: 11px; font-size: 12px; color: var(--muted); line-height: 1.55; }
.integration-step::before {
  content: counter(step);
  counter-increment: step;
  flex: none;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 9.5px;
  font-weight: 700;
  margin-top: 1px;
}
.integration-step strong { color: var(--ink); }
.code-block {
  position: relative;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: color-mix(in srgb, var(--bg) 88%, transparent);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}
[data-theme="dark"] .code-block { background: var(--bg-deep); border: 1px solid var(--border); }
.code-block .copy-btn {
  position: absolute;
  right: 7px;
  top: 7px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 5px;
  background: color-mix(in srgb, var(--bg) 12%, transparent);
  color: color-mix(in srgb, var(--bg) 75%, transparent);
}
.code-block .copy-btn:hover { background: color-mix(in srgb, var(--bg) 22%, transparent); }
.token-field { display: flex; gap: 8px; align-items: center; }
.token-field .input { font-family: var(--font-mono); font-size: 11px; }
.danger-zone { border-color: color-mix(in srgb, var(--red) 25%, var(--border)); }
.danger-zone .settings-section-head .sec-icon { color: var(--red); background: var(--red-soft); }

/* 20. Quick add ------------------------------------------------------------ */
.capture-page { max-width: 720px; margin: 0 auto; padding-top: 20px; }
.capture-card { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); padding: clamp(24px, 4vw, 42px); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.capture-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent)); opacity: 0.7; }
.capture-card h1 { font-family: var(--font-display); font-size: clamp(32px, 4.5vw, 44px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.05; }
.capture-card .capture-sub { color: var(--muted); font-size: 13px; margin-top: 9px; }
.big-capture-form { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
.big-capture-input {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 4px 6px 4px 16px;
  background: var(--bg);
  transition: border-color var(--speed), box-shadow var(--speed);
}
.big-capture-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent); }
.big-capture-input svg { color: var(--faint); flex: none; }
.big-capture-input input { flex: 1; min-width: 0; height: 52px; border: 0; background: transparent; outline: 0; font-size: 15px; }
.capture-note { display: flex; gap: 8px; flex-wrap: wrap; }
.capture-recents { margin-top: 30px; }
.capture-recent-list { display: flex; flex-direction: column; gap: 2px; }
.capture-recent { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; font-size: 11.5px; color: var(--muted); }
.capture-recent:hover { background: var(--surface-2); color: var(--ink); }
.capture-recent .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0.5; flex: none; }
.capture-recent span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capture-recent small { margin-left: auto; color: var(--faint); font-size: 9.5px; white-space: nowrap; }
.capture-done { text-align: center; padding: 20px 0; }
.capture-done .done-mark { display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%; background: var(--green-soft); color: var(--green); margin: 0 auto 18px; }
.capture-done h1 { font-family: var(--font-display); font-size: 36px; font-weight: 500; }
.capture-done p { color: var(--muted); font-size: 13px; margin-top: 8px; }
.capture-done .done-actions { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }

/* 21. Auth ---------------------------------------------------------------- */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--bg); }
.auth-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 5vw, 64px);
  background:
    radial-gradient(900px 500px at 20% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    linear-gradient(160deg, #241d16, #15110d 75%);
  color: #f6efe3;
  overflow: hidden;
}
.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 245, 225, 0.09) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
  mask-image: linear-gradient(180deg, #000, transparent 80%);
}
.auth-visual .brand { color: #f6efe3; padding: 0; margin: 0; position: relative; z-index: 1; }
.auth-visual .brand-word small { color: rgba(246, 239, 227, 0.45); }
.auth-quote { position: relative; z-index: 1; max-width: 520px; }
.auth-quote blockquote {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.auth-quote blockquote em { color: #e8b06a; font-style: italic; }
.auth-quote cite { display: block; margin-top: 18px; font-style: normal; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(246, 239, 227, 0.45); }
.auth-features { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 11px; }
.auth-feature { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: rgba(246, 239, 227, 0.6); }
.auth-feature svg { color: #d79a4c; flex: none; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-form-wrap { width: min(400px, 100%); }
.auth-form-wrap .auth-logo-mobile { display: none; }
.auth-form-wrap h1 { font-family: var(--font-display); font-size: 38px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.05; }
.auth-form-wrap .auth-sub { color: var(--muted); font-size: 13px; margin-top: 8px; margin-bottom: 26px; }
.auth-form-wrap form { display: flex; flex-direction: column; gap: 14px; }
.auth-form-wrap .btn { height: 44px; }
.auth-foot { margin-top: 22px; font-size: 11.5px; color: var(--faint); }
.auth-foot a { color: var(--accent); font-weight: 500; }
.auth-note { display: flex; gap: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.auth-note svg { color: var(--accent); flex: none; margin-top: 1px; }

/* 22. Misc ---------------------------------------------------------------- */
.section-gap { margin-top: 40px; }
.kicker-line { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.kicker-line::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: 11.5px; font-weight: 600; }
.link-arrow:hover { text-decoration: underline; text-underline-offset: 2px; }
.dot-sep { width: 2px; height: 2px; border-radius: 50%; background: var(--faint); flex: none; }
.offline-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; text-align: center; }
.offline-page h1 { font-family: var(--font-display); font-size: 42px; font-weight: 500; }
.offline-page p { color: var(--muted); margin-top: 8px; }
.offline-mark { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin: 0 auto 20px; }

.mobile-nav { display: none; }

/* 23. Responsive ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .dash-grid { grid-template-columns: minmax(0, 1.6fr) 300px; gap: 20px; }
  .link-detail { grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; }
  .ask-layout { grid-template-columns: minmax(0, 1fr) 260px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 1000px) {
  :root { --sidebar-w: 0px; --topbar-h: 66px; }
  .sidebar { display: none; }
  .app-main { margin-left: 0; }
  .topbar-brand { display: flex; }
  .topbar-heading { display: none; }
  .page { padding-bottom: 110px; }
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 12px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    align-items: center;
    justify-content: space-around;
    gap: 4px;
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 56px;
    height: 50px;
    border-radius: 10px;
    color: var(--faint);
    font-size: 9px;
    font-weight: 500;
  }
  .mobile-nav-item.is-active { color: var(--accent); }
  .mobile-nav-item.is-active svg { stroke-width: 2.1; }
  .mobile-fab {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 80%, transparent);
    margin-top: -22px;
    flex: none;
  }
  .topbar-actions .topbar-add { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-aside { position: static; }
  .link-detail { grid-template-columns: 1fr; }
  .detail-aside { position: static; flex-direction: row; flex-wrap: wrap; }
  .detail-aside > * { flex: 1 1 260px; }
  .ask-layout { grid-template-columns: 1fr; }
  .ask-history-wrap { order: 2; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: none; }
  .toast-stack { bottom: calc(76px + env(safe-area-inset-bottom)); right: 14px; left: 14px; max-width: none; }
  .link-card-actions { opacity: 1; }
}

@media (max-width: 760px) {
  .search-trigger { width: auto; padding: 0; justify-content: center; border: 0; background: transparent; }
  .search-trigger .search-trigger-text, .search-trigger .kbd { display: none; }
  .search-trigger svg { width: 20px; height: 20px; color: var(--muted); }
  .topbar { gap: 10px; }
  .topbar-actions { margin-left: auto; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page { padding-top: 22px; }
  .page-head { margin-bottom: 18px; }
  .page-head h1, .page-title { font-size: 33px; }
  .dash-hero { border-radius: var(--radius-lg); padding: 22px 18px; }
  .dash-hero .greeting-line { font-size: 34px; }
  .capture-form { flex-wrap: nowrap; padding: 5px 5px 5px 12px; }
  .capture-form .btn span { display: none; }
  .capture-form .btn { width: 40px; padding: 0; }
  .links-grid { grid-template-columns: 1fr; gap: 14px; }
  .library-toolbar { gap: 8px; padding: 10px; }
  .toolbar-search { max-width: none; flex: 1 1 100%; }
  .segmented { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .library-toolbar .spacer { display: none; }
  .links-list .link-card-media { aspect-ratio: 16 / 9; }
  .detail-head { padding: 20px 18px; }
  .detail-title { font-size: 30px; }
  .detail-section { padding: 18px; }
  .ai-panel { padding: 18px; }
  .ai-summary { font-size: 17px; }
  .aside-block { padding: 14px; }
  .settings-body { padding: 18px; }
  .settings-section-head { padding: 16px 18px 14px; }
  .palette { margin-top: 6vh; }
  .auth-body { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-form-wrap .auth-logo-mobile { display: flex; margin-bottom: 28px; }
  .ask-hero { margin-top: 8px; }
  .ask-layout { gap: 18px; }
  .collection-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { gap: 9px; }
  .stat-card { padding: 13px 14px; }
  .stat-card .stat-value { font-size: 31px; }
  .stat-card .stat-label { font-size: 9px; }
  .topbar { padding: 0 14px; }
  .page { padding-left: 14px; padding-right: 14px; }
  .avatar-btn { width: 32px; height: 32px; }
  .flash { font-size: 12px; }
  .ask-box { padding: 10px; }
  .ask-box textarea { font-size: 17px; }
  .ask-suggestion { font-size: 10.5px; }
  .detail-actions .btn span { display: none; }
  .detail-actions .btn { width: 38px; padding: 0; }
}

/* 24. Motion -------------------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes paletteIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.links-grid > *, .collection-grid > *, .stat-grid > *, .dash-col > * {
  animation: fadeUp 480ms var(--ease) both;
}
.links-grid > *:nth-child(2), .stat-grid > *:nth-child(2) { animation-delay: 40ms; }
.links-grid > *:nth-child(3), .stat-grid > *:nth-child(3) { animation-delay: 80ms; }
.links-grid > *:nth-child(4), .stat-grid > *:nth-child(4) { animation-delay: 120ms; }
.links-grid > *:nth-child(5) { animation-delay: 160ms; }
.links-grid > *:nth-child(6) { animation-delay: 200ms; }
.links-grid > *:nth-child(n+7) { animation-delay: 240ms; }
.spin { animation: spin 900ms linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 25. Final polish --------------------------------------------------------- */
.fav-form { display: contents; }
.card-menu { position: relative; display: inline-flex; }
.card-popover { top: calc(100% + 6px); right: 0; width: 196px; }
.card-popover form, .popover form { margin: 0; width: 100%; }
.popover form .popover-item { width: 100%; }
.link-card .fav-btn { border: 0; }
.extract-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.extract-details summary::-webkit-details-marker { display: none; }
.extract-details summary::after {
  content: "+";
  font-size: 16px;
  color: var(--faint);
  line-height: 1;
}
.extract-details[open] summary::after { content: "−"; }
.extract-text {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: var(--font-reading);
  font-size: 16.5px;
  line-height: 1.72;
  color: var(--ink-2);
  max-height: 480px;
  overflow-y: auto;
}
.extract-text p + p { margin-top: 10px; }
.notes-form { display: flex; flex-direction: column; }
.tag-edit-form .hint { font-size: 10px; }
.hint code { background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.settings-section .divider { margin: 2px 0; }
.auth-form-wrap .flash { margin-bottom: 12px; }
.palette-item.is-selected { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.icon-btn.is-active { color: var(--accent); }

.detail-actions .fav-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--faint);
  border-radius: var(--radius-sm);
}
.detail-actions .fav-btn:hover { border-color: var(--border-strong); color: var(--accent); background: var(--surface-2); }
.detail-actions .fav-btn.is-active { color: var(--gold); background: var(--surface); }
.settings-nav { width: 220px; }
@media (max-width: 1000px) { .settings-nav { width: auto; } }

.stat-value, .dash-hero .greeting-line, .page-title, .detail-title { font-variant-numeric: lining-nums; }
.hide-mobile { display: inline; }
@media (max-width: 760px) { .hide-mobile { display: none; } }

.auth-flash {
  position: fixed;
  top: 18px;
  left: 50%;
  translate: -50% 0;
  width: min(440px, calc(100vw - 32px));
  z-index: 100;
}
.auth-flash .flash-stack { margin-bottom: 0; }
[data-theme="dark"] .random-pick {
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 60%),
    var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--ink);
}
[data-theme="dark"] .random-pick .eyebrow { color: var(--muted); }
[data-theme="dark"] .random-pick .eyebrow::before { background: var(--border-strong); }
[data-theme="dark"] .random-pick p { opacity: 0.8; }
[data-theme="dark"] .random-pick .pick-foot small { opacity: 0.7; }
[data-theme="dark"] .random-pick .btn { background: var(--accent); color: var(--on-accent); }
[data-theme="dark"] .random-pick .btn:hover { background: var(--accent-hover); }

/* 26. Import --------------------------------------------------------------- */
.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 26px;
  align-items: start;
}
.import-main { min-width: 0; }
.import-card {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.import-textarea {
  min-height: 220px;
  font-family: var(--font-reading);
  font-size: 16px;
  line-height: 1.6;
}
.file-drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  color: var(--muted);
  transition: border-color var(--speed), background var(--speed);
}
.file-drop:hover { border-color: var(--accent); background: var(--surface-2); }
.file-drop svg { color: var(--accent); flex: none; }
.file-drop div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-drop strong { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.file-drop small { font-size: 10px; color: var(--faint); }
.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.import-checks { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--muted); }
.import-checks span { display: flex; align-items: center; gap: 6px; }
.import-checks svg { color: var(--accent); flex: none; }
.import-slack {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  overflow: hidden;
}
.import-slack summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
}
.import-slack summary::-webkit-details-marker { display: none; }
.import-slack summary::after {
  content: "+";
  color: var(--faint);
  font-size: 16px;
  line-height: 1;
}
.import-slack[open] summary::after { content: "−"; }
.import-slack-body {
  padding: 4px 15px 18px;
  border-top: 1px solid var(--border);
}
.import-submit {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.import-submit .hint { margin-left: auto; }
.import-aside {
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.import-process { display: flex; flex-direction: column; gap: 13px; }
.import-process > div { display: flex; gap: 10px; align-items: flex-start; }
.import-process > div > span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 700;
  flex: none;
  margin-top: 1px;
}
.import-process p { font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.import-process strong { color: var(--ink-2); }
.import-privacy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--border));
}
.import-privacy svg { color: var(--accent); flex: none; margin-top: 1px; }
.import-privacy p { font-size: 10.5px; line-height: 1.55; color: var(--accent-ink); }

@media (max-width: 1000px) {
  .import-layout { grid-template-columns: 1fr; }
  .import-aside { position: static; flex-direction: row; flex-wrap: wrap; }
  .import-aside > * { flex: 1 1 260px; }
}
@media (max-width: 760px) {
  .import-card { padding: 18px; }
  .import-aside { flex-direction: column; }
  .import-submit .hint { margin-left: 0; flex-basis: 100%; }
}

.file-status {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: var(--faint);
}
.file-drop.has-file {
  border-style: solid;
  border-color: color-mix(in srgb, var(--green) 45%, var(--border));
  background: color-mix(in srgb, var(--green-soft) 65%, transparent);
}
.file-drop.has-file > svg { color: var(--green); }
.file-drop.has-file strong { color: var(--green); }
.file-drop.has-file .file-status { color: var(--green); font-weight: 500; }

/* Reddit fallback cover for text-only posts */
.reddit-cover {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 46px clamp(20px, 4vw, 34px) 20px;
  color: #f8ece2;
  background:
    radial-gradient(120% 110% at 100% 0%, rgba(255, 69, 0, 0.42), transparent 58%),
    linear-gradient(140deg, #25150f 0%, #3a1c12 55%, #1b1210 100%);
  gap: 8px;
  text-align: left;
}
.reddit-cover::after { opacity: 0.08; }
.reddit-cover-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(248, 236, 226, 0.62);
}
.reddit-cover-brand i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4500;
  box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.18);
}
.reddit-cover-sub {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: #fff4e9;
  overflow-wrap: anywhere;
}
.reddit-cover-stats {
  font-size: 10.5px;
  color: rgba(248, 236, 226, 0.55);
  font-variant-numeric: tabular-nums;
}
