/* ==========================================================================
   Griper — "Editorial instrument"
   Fraunces (serif display) / Inter (body) / JetBrains Mono (data columns).
   Restrained burnt-rust accent, hairline + frosted-glass panels, a pain-score
   meter as the recurring motif, dense topographic linework behind everything.
   Three hand-tuned themes — light, dark (warm charcoal), green (deep forest,
   Nomad Partners-inspired). Every text/accent pair verified >= WCAG AA on
   both solid and glass surfaces in all three.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;

  /* type scale — 12 · 13 · 15 · 18 · 24 · 34 · 48 */
  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-18: 1.125rem;
  --fs-24: 1.5rem;
  --fs-34: clamp(1.85rem, 4.4vw, 2.35rem);
  --fs-48: clamp(2.3rem, 6.2vw, 3.35rem);

  /* letter-spaced small-caps eyebrow */
  --eyebrow-tracking: 0.15em;

  /* 8px base spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --maxw: 900px;
  --row-h: 36px;

  /* motion — values from the skill's Complex tier, exits ~60% of enters */
  --dur-fast: 130ms;
  --dur: 230ms;
  --dur-slow: 420ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --stagger: 34ms;

  --z-topbar: 40;
  --z-modal: 90;
  --z-gate: 100;
  --z-toast: 120;

  /* dense topographic linework, inline SVG (no image asset). Tinted at use via
     a solid --linework fill + this as a mask, so each theme picks its own tone
     and strength. 11 flowing contour lines — echoes the Nomad Partners hero. */
  --linework-lines: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='1600'%20height='1100'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M-40%2070%20C%20300%2010%20560%20125%20920%2070%20S%201400%2025%201720%2090'/%3E%3Cpath%20d='M-40%20165%20C%20240%20215%20620%20110%20960%20165%20S%201380%20205%201720%20150'/%3E%3Cpath%20d='M-40%20260%20C%20300%20200%20560%20315%20920%20260%20S%201400%20215%201720%20280'/%3E%3Cpath%20d='M-40%20355%20C%20240%20405%20620%20300%20960%20355%20S%201380%20395%201720%20340'/%3E%3Cpath%20d='M-40%20450%20C%20300%20390%20560%20505%20920%20450%20S%201400%20405%201720%20470'/%3E%3Cpath%20d='M-40%20545%20C%20240%20595%20620%20490%20960%20545%20S%201380%20585%201720%20530'/%3E%3Cpath%20d='M-40%20640%20C%20300%20580%20560%20695%20920%20640%20S%201400%20595%201720%20660'/%3E%3Cpath%20d='M-40%20735%20C%20240%20785%20620%20680%20960%20735%20S%201380%20775%201720%20720'/%3E%3Cpath%20d='M-40%20830%20C%20300%20770%20560%20885%20920%20830%20S%201400%20785%201720%20850'/%3E%3Cpath%20d='M-40%20925%20C%20240%20975%20620%20870%20960%20925%20S%201380%20965%201720%20910'/%3E%3Cpath%20d='M-40%201020%20C%20300%20960%20560%201075%20920%201020%20S%201400%20975%201720%201040'/%3E%3C/svg%3E");

  /* --- dark palette (default): warm forest-charcoal, burnt-rust accent --- */
  --bg: #141712;          /* green channel a hair highest — reads dark-green-black, not gray */
  --bg-elev: #191d16;
  --surface: #1c201a;
  --surface-2: #232821;
  --border: #333a30;
  --border-strong: #47503f;
  --text: #f2efe8;        /* 15.7:1 on --bg */
  --text-muted: #9b9385;  /* 5.95:1 on --bg */
  --text-faint: #918978;  /* 5.2:1 on --bg, ~5.0:1 on the glass panels */
  --accent: #d2793c;      /* muted burnt-rust — 5.6:1 on --bg, AA for links/labels */
  --accent-strong: #e28d52;
  --accent-weak: rgba(210, 121, 60, 0.13);
  --accent-ink: #1a130c;  /* 5.6:1 on --accent for on-accent text */
  --danger: #e8695d;
  --danger-weak: rgba(232, 105, 93, 0.15);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border);
  --shadow-3: 0 30px 70px -14px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--border);
  --glow: 0 0 16px rgba(210, 121, 60, 0.20);
  --grid-dot: rgba(242, 239, 232, 0.035);
  --scan-line: rgba(242, 239, 232, 0.016);
  --linework: rgba(242, 239, 232, 0.065);

  /* frosted-glass elevated surfaces — translucent tint + blur over the
     linework. Kept ~70% opaque so even the faint text tier holds >= AA. */
  --glass-bg: rgba(25, 30, 23, 0.70);
  --glass-border: rgba(242, 239, 232, 0.10);
  --glass-blur: blur(14px) saturate(1.25);
  --glass-shadow: 0 12px 34px -14px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(242, 239, 232, 0.04);
}

/* Light theme lives in two places: the media query below (OS-light, nothing
   stored) and the [data-theme="light"] block further down (explicit toggle). */

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #ece4d3;          /* beige — clearly not white */
    --bg-elev: #e5dcc7;
    --surface: #f3ecdd;     /* light beige, still reads beige not white */
    --surface-2: #e4dac5;
    --border: #d8cdb4;
    --border-strong: #c3b699;
    --text: #1c1a15;        /* 13.7:1 on --bg */
    --text-muted: #5f5849;  /* 5.6:1 on --bg */
    --text-faint: #6b6252;  /* 4.75:1 on --bg */
    --accent: #9c4917;      /* same rust hue, nudged darker for the beige ground — 4.9:1 */
    --accent-strong: #82380f;
    --accent-weak: rgba(156, 73, 23, 0.10);
    --accent-ink: #f3ecdd;
    --danger: #9e3220;
    --danger-weak: rgba(158, 50, 32, 0.10);
    --shadow-1: 0 1px 2px rgba(40, 34, 20, 0.07), 0 0 0 1px var(--border);
    --shadow-2: 0 14px 30px -14px rgba(40, 34, 20, 0.20), 0 0 0 1px var(--border);
    --shadow-3: 0 30px 66px -18px rgba(40, 34, 20, 0.26), 0 0 0 1px var(--border);
    --glow: none;
    --grid-dot: rgba(28, 26, 21, 0.05);
    --scan-line: rgba(28, 26, 21, 0.012);
    --linework: rgba(28, 26, 21, 0.05);
    --glass-bg: rgba(243, 236, 221, 0.72);
    --glass-border: rgba(28, 26, 21, 0.09);
    --glass-blur: blur(12px) saturate(1.1);
    --glass-shadow: 0 12px 30px -16px rgba(40, 34, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ece4d3;
  --bg-elev: #e5dcc7;
  --surface: #f3ecdd;
  --surface-2: #e4dac5;
  --border: #d8cdb4;
  --border-strong: #c3b699;
  --text: #1c1a15;
  --text-muted: #5f5849;
  --text-faint: #6b6252;
  --accent: #9c4917;
  --accent-strong: #82380f;
  --accent-weak: rgba(156, 73, 23, 0.10);
  --accent-ink: #f3ecdd;
  --danger: #9e3220;
  --danger-weak: rgba(158, 50, 32, 0.10);
  --shadow-1: 0 1px 2px rgba(40, 34, 20, 0.07), 0 0 0 1px var(--border);
  --shadow-2: 0 14px 30px -14px rgba(40, 34, 20, 0.20), 0 0 0 1px var(--border);
  --shadow-3: 0 30px 66px -18px rgba(40, 34, 20, 0.26), 0 0 0 1px var(--border);
  --glow: none;
  --grid-dot: rgba(28, 26, 21, 0.05);
  --scan-line: rgba(28, 26, 21, 0.012);
  --linework: rgba(28, 26, 21, 0.05);
  --glass-bg: rgba(243, 236, 221, 0.72);
  --glass-border: rgba(28, 26, 21, 0.09);
  --glass-blur: blur(12px) saturate(1.1);
  --glass-shadow: 0 12px 30px -16px rgba(40, 34, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

:root[data-theme="dark"] { color-scheme: dark; }

/* --- green: forest, Nomad Partners-inspired. Explicit only (never an OS
   preference). Same rust accent as dark, reused; warm gray-green muted text.
   Lifted a notch off near-black toward a real green. Contrast on the
   #14241A ground: text 14:1, accent 5.0:1, muted 6.2:1, faint 5.6:1 — all
   clear AA, ~4.9:1+ on the glass surfaces. --- */
:root[data-theme="green"] {
  color-scheme: dark;
  --bg: #14241a;
  --bg-elev: #182a1e;
  --surface: #1a2c20;
  --surface-2: #223a2c;
  --border: #324a3a;
  --border-strong: #45614d;
  --text: #f1eee4;
  --text-muted: #9aa396;
  --text-faint: #909c8b;
  --accent: #d2793c;
  --accent-strong: #e28d52;
  --accent-weak: rgba(210, 121, 60, 0.14);
  --accent-ink: #12140c;
  --danger: #ef8a7e;
  --danger-weak: rgba(239, 138, 126, 0.16);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border);
  --shadow-3: 0 30px 70px -14px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--border);
  --glow: 0 0 16px rgba(210, 121, 60, 0.22);
  --grid-dot: rgba(241, 238, 228, 0.04);
  --scan-line: rgba(241, 238, 228, 0.016);
  --linework: rgba(220, 235, 224, 0.07);   /* slightly cool tint */
  --glass-bg: rgba(26, 44, 32, 0.66);
  --glass-border: rgba(220, 235, 224, 0.11);
  --glass-blur: blur(14px) saturate(1.3);
  --glass-shadow: 0 12px 34px -14px rgba(0, 0, 0, 0.66), inset 0 1px 0 rgba(220, 235, 224, 0.05);
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

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

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-15);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* faint topographic linework behind everything — inline SVG, no image asset.
   The line shape is one mask layer; a soft top-anchored vignette is a second,
   intersected, so the lines fade out toward the edges and never compete with
   text. Colour comes from --linework so each theme gets its own tone. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--linework);
  -webkit-mask-image: var(--linework-lines), radial-gradient(ellipse 150% 130% at 50% 8%, #000 40%, transparent 92%);
  mask-image: var(--linework-lines), radial-gradient(ellipse 150% 130% at 50% 8%, #000 40%, transparent 92%);
  -webkit-mask-size: cover, cover;
  mask-size: cover, cover;
  -webkit-mask-position: center, center;
  mask-position: center, center;
  -webkit-mask-repeat: no-repeat, no-repeat;
  mask-repeat: no-repeat, no-repeat;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

/* smooth theme swap — only while JS is flipping the attribute */
:root.theme-anim,
:root.theme-anim body,
:root.theme-anim body * {
  transition:
    background-color var(--dur) var(--ease-in-out),
    border-color var(--dur) var(--ease-in-out),
    color var(--dur) var(--ease-in-out),
    box-shadow var(--dur) var(--ease-in-out) !important;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

img { max-width: 100%; display: block; }

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }

::selection { background: var(--accent-weak); color: var(--text); }

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

svg { flex: none; }
.i { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i--fill { fill: currentColor; stroke: none; }

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1, h2, h3 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: 0;
}
h1 { font-weight: 600; line-height: 1.16; letter-spacing: -0.005em; }

.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; }

/* letter-spaced small-caps eyebrow — a quiet organizing label, never shouty.
   Real caps + a nudge of size so it reads as small-caps where the font has
   no true sc set. */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  font-weight: 500;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: var(--eyebrow-tracking);
  color: var(--text-faint);
}
.eyebrow-accent { color: var(--accent); }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: var(--sp-3);
  z-index: 1000;
  padding: var(--sp-2) var(--sp-3);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  transition: top var(--dur) var(--ease-out);
}
.skip-link:focus { top: var(--sp-3); }

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-weak);
}

.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-12); }

/* icon-only */
.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  font-size: 18px;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.iconbtn:active { transform: scale(0.94); }

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

.search-input,
.control-select {
  width: 100%;
  height: 44px;
  padding: 0 var(--sp-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-15);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus,
.control-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak), var(--glow);
}
.search-input[aria-invalid="true"] { border-color: var(--danger); }
.search-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-weak); }

.control-select {
  height: 34px;
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--sp-6);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 14px, calc(100% - 11px) 14px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Top bar + view nav
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-mark {
  color: var(--accent);
  text-shadow: var(--glow);
  animation: caret 1.2s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0.35; } }
.brand-name { color: var(--text); }

.viewnav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.viewnav-tab {
  position: relative;
  padding: var(--sp-2) var(--sp-3);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.viewnav-tab:hover { color: var(--text); }
.viewnav-tab.is-active { color: var(--accent-ink); background: var(--accent); }
.viewnav-count {
  display: inline-block;
  min-width: 16px;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 10px;
  line-height: 15px;
  text-align: center;
}
.viewnav-tab.is-active .viewnav-count { background: rgba(0, 0, 0, 0.18); color: var(--accent-ink); }

.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.signout {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-faint);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out);
}
.signout:hover { color: var(--danger); }

/* Social links — muted by default, accent on hover. Reused in the footer. */
.social-links { display: inline-flex; align-items: center; gap: 2px; }
.social-link {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}
.social-link svg { width: 18px; height: 18px; display: block; }
.social-link:hover { color: var(--accent); background: var(--accent-weak); }

/* theme toggle — cycles dark → light → green → dark. The button shows the
   icon for the *current* theme; all three icons stack in one grid cell and
   the inactive ones scale/rotate out. */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .i { grid-area: 1 / 1; opacity: 0; transform: rotate(-90deg) scale(0.4); transition: transform var(--dur) var(--ease-out), opacity var(--dur-fast) var(--ease-out); }
.theme-toggle .i-active { opacity: 1; transform: none; }

/* Default (no explicit choice): follow the OS. */
@media (prefers-color-scheme: dark)  { :root:not([data-theme]) .theme-toggle .i-moon { opacity: 1; transform: none; } }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .theme-toggle .i-sun  { opacity: 1; transform: none; } }

:root[data-theme="dark"]  .theme-toggle .i-moon { opacity: 1; transform: none; }
:root[data-theme="light"] .theme-toggle .i-sun  { opacity: 1; transform: none; }
:root[data-theme="green"] .theme-toggle .i-leaf { opacity: 1; transform: none; }

/* --------------------------------------------------------------------------
   Page shell + view transitions
   -------------------------------------------------------------------------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-8);
}

#main { view-transition-name: stage; }

::view-transition-old(stage) { animation: stage-out var(--dur) var(--ease-in-out) both; }
::view-transition-new(stage) { animation: stage-in var(--dur-slow) var(--ease-out) both; }
@keyframes stage-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes stage-in { from { opacity: 0; transform: translateY(12px); } }

/* --------------------------------------------------------------------------
   Hero + search
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  padding: var(--sp-6) var(--sp-5) var(--sp-7);
  margin-bottom: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 12% -10%, var(--accent-weak), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
/* No in-hero linework layer — the page pattern now shows through the frosted
   glass, and a second sharp copy on top would fight it. */
.hero > * { position: relative; }

.hero-title {
  font-size: var(--fs-48);
  line-height: 1.14;
  max-width: 24ch;
  margin-bottom: var(--sp-4);
  text-wrap: balance;
}
.hero-sub {
  color: var(--text-muted);
  max-width: 58ch;
  margin-bottom: var(--sp-5);
}

.search {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.search-field {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.search-field::before {
  content: "";
  position: absolute;
  left: var(--sp-3);
  width: 16px; height: 16px;
  border: 1.75px solid var(--text-faint);
  border-radius: 50%;
  box-shadow: 8px 8px 0 -6.5px var(--text-faint);
  transform: rotate(-45deg);
  pointer-events: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.search-field:focus-within::before { border-color: var(--accent); box-shadow: 8px 8px 0 -6.5px var(--accent); }
.search-field .search-input { padding-left: var(--sp-7); }

/* scanning state on submit */
.search.is-loading #search-button { color: transparent; position: relative; }
.search.is-loading #search-button::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  border: 2px solid var(--accent-ink);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border);
}
.control { display: inline-flex; align-items: center; gap: var(--sp-2); }
.control-label { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-faint); }
.control-toggle { cursor: pointer; }
.control-toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 34px; height: 20px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.control-toggle input::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform var(--dur) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.control-toggle input:checked { background: var(--accent-weak); border-color: var(--accent); }
.control-toggle input:checked::after { transform: translateX(14px); background: var(--accent); }
.control-toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.control-toggle .control-label { color: var(--text-muted); }

/* Collapsed-by-default extra filters (min pain score, exclude terms) so they
   don't crowd the main control row for people who don't need them. */
.controls-more {
  margin-top: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
}
.controls-more-summary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  cursor: pointer;
  color: var(--text-faint);
  list-style: none;
  padding: var(--sp-1) 0;
  transition: color var(--dur-fast) var(--ease-out);
}
.controls-more-summary::-webkit-details-marker { display: none; }
.controls-more-summary::before {
  content: "+";
  display: inline-block;
  width: 1em;
  text-align: center;
  color: var(--text-muted);
}
.controls-more[open] .controls-more-summary::before { content: "\2013"; }
.controls-more-summary:hover { color: var(--text-muted); }
.controls-more-body {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  padding: var(--sp-3) 0 var(--sp-1);
}
.control-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
}
.control-num,
.control-text {
  height: 32px;
  padding: 0 var(--sp-2);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.control-num { width: 6.5rem; }
.control-text { width: 16rem; max-width: 100%; }
.control-num::placeholder,
.control-text::placeholder { color: var(--text-faint); }
.control-num:focus,
.control-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.tag-beta {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 4px;
  vertical-align: 1px;
}

.source-note {
  margin-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Chip rows
   -------------------------------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.chip-row-label {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: var(--eyebrow-tracking);
}
.chip-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.chip {
  padding: 5px var(--sp-3);
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.chip:active { transform: translateY(0); }

/* --------------------------------------------------------------------------
   Results bar + status
   -------------------------------------------------------------------------- */

.results { scroll-margin-top: 80px; }

.results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.results-count { font-family: var(--font-display); font-size: var(--fs-24); font-weight: 500; letter-spacing: -0.005em; }
.results-bar-right { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.results-sort { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-faint); }
#sort-label { color: var(--accent); }
.results-actions { display: flex; gap: var(--sp-2); }

/* --------------------------------------------------------------------------
   Notices — one visual language for two patterns:
   .banner  in-flow, sticky, retry button (blocking errors)
   .toast   floating, auto-dismiss (non-blocking issues)
   Severity is a coloured accent bar + matching icon: info / warning / error.
   -------------------------------------------------------------------------- */

.notice-icon { flex: none; display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; }
.notice-icon .i { width: 18px; height: 18px; }
.notice-msg { font-size: var(--fs-13); line-height: 1.5; color: var(--text); }
.notice-msg + .banner-actions { margin-top: var(--sp-3); }
.notice-action,
.notice-close {
  flex: none;
  color: var(--text-faint);
  transition: color var(--dur-fast) var(--ease-out);
}
.notice-action { font-family: var(--font-mono); font-size: var(--fs-12); text-decoration: underline; text-underline-offset: 2px; }
.notice-action:hover, .notice-close:hover { color: var(--text); }
.notice-close { display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-sm); }
.notice-close .i { width: 15px; height: 15px; }

/* --- banner --- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-1);
  animation: drop-in var(--dur) var(--ease-out) both;
}
.banner-body { flex: 1; min-width: 0; }
.banner-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.banner .notice-icon { color: var(--text-faint); }
.banner-warning { border-left-color: var(--accent); background: var(--accent-weak); }
.banner-warning .notice-icon { color: var(--accent); }
.banner-error { border-left-color: var(--danger); background: var(--danger-weak); }
.banner-error .notice-icon { color: var(--danger); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px); } }

/* --- toast region + toasts --- */
.toast-region {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  width: min(360px, calc(100vw - var(--sp-6)));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease-out) both;
}
.toast .notice-msg { flex: 1; min-width: 0; }
.toast .notice-icon { color: var(--text-faint); }
.toast-warning { border-left-color: var(--accent); }
.toast-warning .notice-icon { color: var(--accent); }
.toast-error { border-left-color: var(--danger); }
.toast-error .notice-icon { color: var(--danger); }
.toast.is-leaving { animation: toast-out var(--dur-fast) var(--ease-in-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

/* No backdrop-filter -> fall back to an opaque surface (declared after the
   glass rules above so it wins when the @supports query matches). */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .banner { background: var(--surface); }
  .banner-warning { background: var(--accent-weak); }
  .banner-error { background: var(--danger-weak); }
  .toast { background: var(--surface); }
}

/* --- inline field hint (validation) --- */
.field-hint {
  margin-top: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--danger);
  animation: drop-in var(--dur-fast) var(--ease-out) both;
}

/* --------------------------------------------------------------------------
   Competitor check
   -------------------------------------------------------------------------- */

.competitor-check {
  margin-bottom: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.competitor-summary {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  transition: background-color var(--dur-fast) var(--ease-out);
}
.competitor-summary::-webkit-details-marker { display: none; }
.competitor-summary::before {
  content: "+";
  color: var(--accent);
  font-weight: 700;
  transition: transform var(--dur) var(--ease-out);
}
.competitor-check[open] .competitor-summary::before { transform: rotate(45deg); }
.competitor-summary:hover { background: var(--surface-2); }
.competitor-summary-title { font-size: var(--fs-13); }
.competitor-summary-hint { margin-left: auto; font-size: var(--fs-12); color: var(--text-faint); }
.competitor-note { padding: 0 var(--sp-4); color: var(--text-muted); font-size: var(--fs-13); }
.competitor-niche { color: var(--accent); font-family: var(--font-mono); }
.competitor-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
}
.competitor-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.competitor-link:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--accent-weak); }
.competitor-link-label { font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text); }
.competitor-link-sub { font-size: var(--fs-12); color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Result rows + signal meter
   -------------------------------------------------------------------------- */

.result-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }

/* Section divider inside the results list — splits "already solved" off. */
.result-group-break {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px dashed var(--border-strong);
}
.result-group-break:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.result-group-sub { font-size: var(--fs-12); color: var(--text-faint); }

.solved-hidden-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--fs-13);
}

.result {
  position: relative;
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}
.result:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.result:hover .signal-meter-fill { filter: brightness(1.25); }

.result-rank {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  color: var(--text-faint);
  padding-top: 2px;
}
.result-main { min-width: 0; }

.result-niche {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
}
.result-niche b { color: var(--text-muted); font-weight: 500; }

.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.result-title {
  font-family: var(--font-mono);
  font-size: var(--fs-15);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.result-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.result-excerpt {
  margin-top: var(--sp-2);
  color: var(--text-muted);
  font-size: var(--fs-13);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-reason {
  margin-top: var(--sp-2);
  padding-left: var(--sp-3);
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-size: var(--fs-12);
  font-style: italic;
}

.result-meta {
  margin-top: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-faint);
}
.result-meta b { color: var(--text-muted); font-weight: 600; }
.result-meta .sep { margin: 0 var(--sp-2); opacity: 0.5; }

/* signal meter — the recurring motif */
.signal-meter {
  margin-top: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.signal-meter-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}
.signal-meter-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  box-shadow: var(--glow);
  transform-origin: left;
  animation: meter-fill var(--dur-slow) var(--ease-out) both;
}
@keyframes meter-fill { from { transform: scaleX(0); } }
.signal-meter-value {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}
.badge-ask { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.badge-signal-strong { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
.badge-signal-weak { border-color: var(--border-strong); color: var(--text-muted); }
.badge-ai { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.badge-similar { border-color: var(--border-strong); color: var(--text-faint); background: transparent; }
/* "already solved" — deliberately de-emphasised (dashed, faint) so it never
   reads as a pain signal. It's a "this isn't what you're looking for" mark. */
.badge-solved { border-style: dashed; border-color: var(--border-strong); color: var(--text-faint); background: transparent; }

/* bookmark star */
.result-star {
  align-self: start;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.result-star svg { width: 18px; height: 18px; }
.result-star:hover { color: var(--accent); background: var(--accent-weak); }
.result-star:active { transform: scale(0.85); }
.result-star[aria-pressed="true"] { color: var(--accent); }
.result-star:disabled { opacity: 0.35; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Skeletons
   -------------------------------------------------------------------------- */

.skeleton-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.sk {
  border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-rank { width: 20px; height: 14px; }
.sk-title { width: 70%; height: 15px; margin-bottom: var(--sp-3); }
.sk-line { width: 100%; height: 10px; margin-bottom: var(--sp-2); }
.sk-line.short { width: 45%; }
.sk-meta { width: 30%; height: 10px; margin-top: var(--sp-3); }

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */

.empty {
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .empty { background: var(--surface); }
}
.empty-title { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-24); margin-bottom: var(--sp-2); }
.empty-body { color: var(--text-muted); font-size: var(--fs-13); max-width: 44ch; margin: 0 auto; }
.empty em { color: var(--accent); font-style: normal; font-family: var(--font-mono); }
.empty-actions { margin-top: var(--sp-4); display: flex; justify-content: center; gap: var(--sp-2); flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Compare view
   -------------------------------------------------------------------------- */

.compare-pickers {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--sp-3);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.compare-pickers .control { flex-direction: column; align-items: stretch; gap: var(--sp-1); min-width: 180px; flex: 1; }
.compare-arrow { color: var(--accent); font-family: var(--font-mono); padding-bottom: var(--sp-2); }

.compare-summary { margin-bottom: var(--sp-5); }
.compare-summary-head {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  color: var(--text-muted);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.compare-summary-head b { color: var(--text); }
.compare-summary-head .sep { margin: 0 var(--sp-2); color: var(--accent); }

.compare-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.compare-stat {
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.compare-stat-label { display: block; font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-faint); margin-bottom: var(--sp-2); }
.compare-stat-vals { font-family: var(--font-mono); font-size: var(--fs-15); }
.compare-stat-vals .sep { margin: 0 var(--sp-1); color: var(--text-faint); }
.compare-delta {
  display: inline-block;
  margin-top: var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  padding: 0 5px;
  border-radius: 4px;
}
.compare-delta.is-up { color: var(--accent); background: var(--accent-weak); }
.compare-delta.is-down { color: var(--danger); background: var(--danger-weak); }
.compare-delta.is-flat { color: var(--text-faint); }

.compare-note { margin-top: var(--sp-3); color: var(--text-muted); font-size: var(--fs-13); }

.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.compare-col {
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.compare-col-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--eyebrow-tracking);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.compare-badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: var(--fs-12);
  text-align: center;
}
.compare-none { color: var(--text-faint); font-size: var(--fs-13); font-style: italic; }

.brief-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.brief { display: flex; flex-direction: column; gap: 3px; }
.brief-title {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.brief-title:hover { color: var(--accent); text-decoration: underline; }
.brief-meta { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-faint); }
.brief-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }

.compare-moved { margin-bottom: var(--sp-4); }
.moved-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.moved { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.moved-nums { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-muted); }
.moved-nums .sep { margin: 0 var(--sp-1); color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Usage view
   -------------------------------------------------------------------------- */

#usage-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-4); }
.usage-group {
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.usage-group-title {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--eyebrow-tracking);
  color: var(--text-faint);
  margin-bottom: var(--sp-3);
}
.usage-stats { display: flex; flex-direction: column; gap: var(--sp-2); }
.usage-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px dashed var(--border);
}
.usage-stat:last-child { border-bottom: none; padding-bottom: 0; }
.usage-stat dt { font-size: var(--fs-13); color: var(--text-muted); }
.usage-stat dd { font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.usage-note { grid-column: 1 / -1; font-size: var(--fs-12); color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Watching view
   -------------------------------------------------------------------------- */

.watching-blurb { max-width: 60ch; color: var(--text-muted); font-size: var(--fs-15); margin-bottom: var(--sp-4); }

.watch-add { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.watch-add .search-input { flex: 1 1 260px; }

.watch-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.watch-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.watch-niche {
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: var(--fs-15);
}
.watch-niche:hover { color: var(--accent); text-decoration: underline; }
.watch-meta {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.watch-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: var(--fs-12);
  cursor: pointer;
  padding: 0;
  transition: color var(--dur-fast) var(--ease-out);
}
.watch-remove:hover { color: var(--danger, #e5484d); text-decoration: underline; }
.watch-empty { color: var(--text-muted); font-size: var(--fs-15); }

/* results-bar "watch this niche" toggle */
.watch-toggle.is-watching {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-weak);
}

/* --------------------------------------------------------------------------
   Auth gate
   -------------------------------------------------------------------------- */

body.is-gated { overflow: hidden; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-gate);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background:
    radial-gradient(130% 90% at 50% 0%, var(--accent-weak), transparent 55%),
    var(--bg);
}
.auth-gate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--linework);
  -webkit-mask-image: var(--linework-lines), radial-gradient(ellipse 90% 70% at 50% 42%, #000, transparent 72%);
  mask-image: var(--linework-lines), radial-gradient(ellipse 90% 70% at 50% 42%, #000, transparent 72%);
  -webkit-mask-size: 1600px 1100px, cover;
  mask-size: 1600px 1100px, cover;
  -webkit-mask-position: center, center;
  mask-position: center, center;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: gate-in var(--dur-slow) var(--ease-out) both;
}
@keyframes gate-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.auth-card .brand { font-size: var(--fs-18); }

/* --------------------------------------------------------------------------
   Frosted-glass elevated surfaces
   Translucent tint + backdrop blur over the linework. Placed after the
   individual panel rules so it wins the `background` layer by source order.
   @supports fallback keeps them fully opaque where backdrop-filter is absent.
   -------------------------------------------------------------------------- */

.competitor-check,
.compare-pickers,
.compare-col,
.compare-stat,
.usage-group,
.watch-item,
.auth-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* .hero keeps its accent-wash gradient on top of the glass tint */
.hero {
  background:
    radial-gradient(120% 140% at 12% -10%, var(--accent-weak), transparent 55%),
    var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .competitor-check,
  .compare-pickers,
  .compare-col,
  .compare-stat,
  .usage-group,
  .watch-item,
  .auth-card { background: var(--surface); border-color: var(--border); }
  .hero {
    background:
      radial-gradient(120% 140% at 12% -10%, var(--accent-weak), transparent 55%),
      var(--surface);
    border-color: var(--border);
  }
}

.auth-blurb { color: var(--text-muted); font-size: var(--fs-13); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-2); }
.auth-input { height: 44px; }
.auth-error { color: var(--danger); font-size: var(--fs-12); font-family: var(--font-mono); }

#auth-request, #auth-sent, #auth-verifying { animation: panel-in var(--dur) var(--ease-out) both; }
@keyframes panel-in { from { opacity: 0; transform: translateX(10px); } }

#auth-sent .auth-blurb b { color: var(--accent); font-family: var(--font-mono); }
#auth-retry { margin-top: var(--sp-1); align-self: flex-start; }

.signal-dots { display: inline-flex; gap: 6px; padding-top: var(--sp-1); }
.signal-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1s var(--ease-in-out) infinite;
}
.signal-dots span:nth-child(2) { animation-delay: 0.16s; }
.signal-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes pulse-dot { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }

/* --------------------------------------------------------------------------
   Thread detail modal
   In-app card built from data already on the row. The HN link is a single
   secondary action at the foot. Frosted-glass panel, same tokens as the
   other elevated surfaces.
   -------------------------------------------------------------------------- */

body.detail-open { overflow: hidden; }

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: detail-fade var(--dur-fast) var(--ease-out) both;
}

.detail-dialog {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: min(84vh, 780px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-3);
  animation: detail-in var(--dur) var(--ease-out) both;
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .detail-dialog { background: var(--surface); }
}

.detail-scroll {
  flex: 1 1 auto;
  min-height: 0;            /* let it shrink inside the dialog so it scrolls */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-6);
}
@keyframes detail-fade { from { opacity: 0; } }
@keyframes detail-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

.detail-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.detail-close:hover { color: var(--accent); background: var(--accent-weak); }
.detail-close .i { width: 18px; height: 18px; }

.detail-title {
  font-size: var(--fs-24);
  line-height: 1.25;
  padding-right: var(--sp-6);
  overflow-wrap: anywhere;
}

.detail-badges { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Heuristic pain signal and the AI assessment sit in separate boxes so they
   never read as one number. */
.detail-signals { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.detail-signal {
  flex: 1 1 220px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.detail-signal-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: var(--eyebrow-tracking);
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
}
.detail-signal.is-ai .detail-signal-label { color: var(--accent); }
.detail-signal-value {
  font-family: var(--font-mono);
  font-size: var(--fs-18);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.detail-signal-sub { margin-top: var(--sp-1); font-size: var(--fs-12); color: var(--text-muted); }
.detail-signal-sub.ai-reason {
  margin-top: var(--sp-2);
  padding-left: var(--sp-3);
  border-left: 2px solid var(--accent);
  font-style: italic;
}

.detail-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-faint);
}
.detail-meta b { color: var(--text-muted); font-weight: 600; }
.detail-meta .sep { margin: 0 var(--sp-2); opacity: 0.5; }

.detail-similar {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.detail-similar-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-muted);
}
.detail-similar-list {
  margin: var(--sp-2) 0 0;
  padding-left: var(--sp-4);
  font-size: var(--fs-13);
  color: var(--text-faint);
}
.detail-similar-list li { margin: var(--sp-1) 0; }

.detail-body-wrap {
  border-top: 1px dashed var(--border);
  padding-top: var(--sp-3);
}
.detail-body {
  color: var(--text-muted);
  font-size: var(--fs-13);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.detail-body.is-empty { font-style: italic; color: var(--text-faint); }

.detail-actions {
  flex: none;
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
  display: flex;
}
.detail-actions .btn { width: 100%; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  max-width: var(--maxw);
  margin: var(--sp-8) auto 0;
  padding: var(--sp-5) var(--sp-4) 0;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--fs-12);
  font-family: var(--font-mono);
}
.footer p + p { margin-top: var(--sp-2); }
.footer-social { display: flex; align-items: center; gap: var(--sp-1); margin-left: calc(var(--sp-1) * -1); }
.footer-social .social-link { width: 36px; height: 36px; }
.footer-social .social-link svg { width: 22px; height: 22px; }

/* --------------------------------------------------------------------------
   Entrance motion (JS-driven classes)
   -------------------------------------------------------------------------- */

.row-enter { animation: row-enter var(--dur-slow) var(--ease-out) both; animation-delay: var(--enter-delay, 0ms); }
@keyframes row-enter { from { opacity: 0; transform: translateY(14px); } }

/* Hero entrance — a premium staggered fade + rise on first load. The <head>
   script adds .js-hero-pending before first paint so there's no flash of the
   final position; bootApp() swaps it for .hero-in to play the sequence. A
   top-level failsafe in app.js reveals the hero even if boot never runs.
   prefers-reduced-motion: elements just appear (handled below + global block). */
@media (prefers-reduced-motion: no-preference) {
  .js-hero-pending .hero-title,
  .js-hero-pending .hero-sub,
  .js-hero-pending .search,
  .js-hero-pending .controls,
  .js-hero-pending .source-note { opacity: 0; }

  .hero-in .hero-title,
  .hero-in .hero-sub,
  .hero-in .search,
  .hero-in .controls,
  .hero-in .source-note {
    animation: hero-rise var(--dur-slow) var(--ease-out) both;
  }
  .hero-in .hero-title  { animation-delay: 40ms; }
  .hero-in .hero-sub    { animation-delay: 130ms; }
  .hero-in .search      { animation-delay: 220ms; }
  .hero-in .controls    { animation-delay: 300ms; }
  .hero-in .source-note { animation-delay: 370ms; }
}
@keyframes hero-rise { from { opacity: 0; transform: translateY(16px); } }

.anim-in { animation: anim-in var(--dur-slow) var(--ease-out) both; }
@keyframes anim-in { from { opacity: 0; transform: translateY(10px); } }

.just-saved { animation: just-saved var(--dur-slow) var(--ease-out); }
@keyframes just-saved {
  30% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.result.just-saved { box-shadow: 0 0 0 1px var(--accent), var(--shadow-2); }

.is-removing { animation: is-removing 200ms var(--ease-in-out) both; overflow: hidden; }
@keyframes is-removing { to { opacity: 0; transform: translateX(-16px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: calc(var(--sp-2) * -1); } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 680px) {
  .topbar-inner { flex-wrap: wrap; gap: var(--sp-3); }
  .viewnav { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .viewnav-tab { flex: 1; text-align: center; }
  .topbar-actions { margin-left: auto; }
  .hero { padding: var(--sp-5) var(--sp-4); }
  .search { flex-direction: column; }
  .search .btn-primary { height: 44px; }
  .result { grid-template-columns: 1.75rem 1fr auto; padding: var(--sp-3); gap: var(--sp-2); }
  .results-bar { flex-direction: column; align-items: flex-start; }
  .detail-modal { padding: 0; place-items: stretch; }
  .detail-dialog { max-width: none; max-height: 100dvh; border-radius: 0; border: none; }
  .detail-scroll { padding: var(--sp-5) var(--sp-4); }
  .detail-actions { padding: var(--sp-4); }
  .detail-signal { flex-basis: 100%; }
  .toast-region { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); width: auto; }
}

/* --------------------------------------------------------------------------
   Reduced motion — every animated thing lands on its final state instantly
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
  .signal-meter-fill { transform: none !important; }
  .brand-mark { animation: none !important; }
  .signal-dots span { animation: none !important; opacity: 0.7; }
}
