/* ============================================================================
   Herald — design system. Plain CSS, no framework (keeps the WASM bundle from
   pulling a CSS-in-Rust toolchain). Premium dark theme built on CSS custom
   properties + modern CSS (color-mix, clamp, @media). Mobile-first.

   The 8 base palette vars (--bg/--panel/--border/--text/--muted/--accent/
   --danger/--ok) are the single source of truth: every layered surface, tint
   and shadow is *derived* from them via color-mix(), so the carnival easter
   egg (which only overrides those 8) re-tints the entire UI for free.

   TABLE OF CONTENTS
     1.  Tokens (:root)
     2.  Reset & base elements
     3.  Typography
     4.  Layout / shell + responsive drawer
     5.  Navigation (sidebar)
     6.  Topbar
     7.  Buttons (global base + variants)
     8.  Forms & inputs
     9.  Cards / tiles / panels
     10. Tables (.seo-table + pickers)
     11. Badges / chips / tags / pills
     12. Modals & sheets
     13. Toasts
     14. Dropdown / action menus
     15. Datepicker
     16. Viz / charts
     17. Page-specific (dashboard, filters, clusters, content editor)
     20. Utilities
     21. Accessibility & motion
   ============================================================================ */

/* ===== 1. TOKENS ========================================================== */
:root {
  /* Base palette — carnival overrides these 8; keep the names. */
  --bg:        #0D0F14;
  --panel:     #161A22;
  --border:    #262B36;
  --text:      #EDEFF4;
  --muted:     #9AA1B2;
  --accent:    #7C8CF8;   /* premium indigo (legacy cyan demoted to --data-1) */
  --danger:    #FF6B7E;
  --ok:        #7FE0A0;
  --trescored: #B21822;   /* brand red */

  /* Layered surfaces — derived */
  --surface-1: var(--panel);
  --surface-2: color-mix(in srgb, var(--panel) 88%, white 5%);
  --surface-3: color-mix(in srgb, var(--panel) 80%, white 9%);
  --surface-inset: color-mix(in srgb, var(--bg) 70%, black 30%);
  --border-subtle: color-mix(in srgb, var(--border) 60%, transparent);
  --border-strong: color-mix(in srgb, var(--border) 100%, white 10%);
  --text-subtle: color-mix(in srgb, var(--muted) 68%, var(--bg));
  --tp-1: color-mix(in srgb, var(--surface-3) 15%, transparent);
  --blur-1: blur(8px);

  /* Neutral hover/press tints — derived from --text so they invert sanely
     under carnival's light surfaces. */
  --hover-1: color-mix(in srgb, var(--text) 5%, transparent);
  --hover-2: color-mix(in srgb, var(--text) 9%, transparent);

  /* Semantic + data-viz palette (cyan lives here now). */
  --warning: #E6B14C;
  --success: var(--ok);
  --info:    #C0CAF5;
  --text-on-brand: #FFFFFF;
  --scrim: color-mix(in srgb, var(--bg) 60%, transparent);
  --data-1:  #70C3D5;
  --data-2:  var(--ok);
  --data-3:  var(--danger);
  --data-4:  var(--warning);
  --data-axis: var(--muted);
  --data-grid: color-mix(in srgb, var(--text) 7%, transparent);

  /* Tonal tints (bg = weak, border = soft, filled control = fill). */
  --accent-weak: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 36%, transparent);
  --accent-fill: color-mix(in srgb, var(--accent) 18%, transparent);
  --ok-weak:     color-mix(in srgb, var(--ok) 12%, transparent);
  --ok-soft:     color-mix(in srgb, var(--ok) 38%, transparent);
  --ok-fill:     color-mix(in srgb, var(--ok) 18%, transparent);
  --danger-weak: color-mix(in srgb, var(--danger) 12%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 38%, transparent);
  --danger-fill: color-mix(in srgb, var(--danger) 18%, transparent);
  --warn-weak:   color-mix(in srgb, var(--warning) 14%, transparent);
  --warn-soft:   color-mix(in srgb, var(--warning) 40%, transparent);
  --accent-glow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
                 0 8px 28px color-mix(in srgb, var(--accent) 22%, transparent);

  /* Fonts. V2 self-hosts Geist (see @font-face below); this :root fallback
     matches the .herald-window token so anything outside the app shell (e.g. the
     login gate) uses the same loaded family rather than unloaded Poppins. */
  --font-sans:    "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: var(--font-sans);
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  /* Fluid type scale. */
  --fs-xs: 11px;
  --fs-sm: clamp(12px, 0.85vw + 9px, 13px);
  --fs-md: 14px;
  --fs-lg: clamp(16px, 1.2vw + 12px, 20px);
  --fs-h3: clamp(15px, 1vw + 12px, 18px);
  --fs-h2: clamp(20px, 2vw + 13px, 28px);
  --fs-h1: clamp(26px, 3vw + 15px, 38px);

  /* Spacing (8px base). */
  --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. */
  --r-1: 6px; --r-2: 8px; --r-3: 12px; --r-4: 16px; --r-pill: 999px;

  /* Elevation. */
  --sh-1: 0 1px 2px rgba(0,0,0,0.30);
  --sh-2: 0 6px 22px rgba(0,0,0,0.38);
  --sh-3: 0 14px 48px rgba(0,0,0,0.52);

  /* Motion. */
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 260ms;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);

  /* Controls. */
  --control-h: 36px;

  /* Breakpoints (reference only — @media can't read vars):
     sm 640 · md 768 · lg 1024 · xl 1280 */
}

/* ===== 18b. LIGHT THEME ==================================================
   Toggled from the top bar (see theme.rs / ThemeToggle). Overrides the 8 base
   tokens plus the handful of derived tokens that bake in a dark assumption
   (surfaces lightened with white go invisible on white; shadows are heavy
   black). Everything else (--hover-*, --data-grid, --text-subtle,
   --surface-inset) derives from --text/--bg and inverts on its own. */
.light {
  --bg: #F7F8FA;
  --panel: #FFFFFF;
  --border: #D9DEE7;
  --text: #434343;
  --muted: #5B6472;
  --accent: #5564E8;
  --danger: #D33B4D;
  --ok: #2E9E5B;
  --surface-1: color-mix(in srgb, var(--panel) 97%, black 3%);
  --surface-2: color-mix(in srgb, var(--panel) 96%, black 4%);
  --surface-3: color-mix(in srgb, var(--panel) 92%, black 8%);
  --surface-inset: color-mix(in srgb, var(--bg) 90%, black 10%);
  --tp-1: color-mix(in srgb, var(--surface-3) 15%, transparent);
  --border-strong: color-mix(in srgb, var(--border) 100%, black 10%);
  --hover-1: color-mix(in srgb, var(--border) 5%, transparent);
  --hover-2: color-mix(in srgb, var(--border) 9%, transparent);
  --sh-1: 0 1px 2px rgba(16, 20, 32, 0.08);
  --sh-2: 0 6px 22px rgba(16, 20, 32, 0.10);
  --sh-3: 0 14px 48px rgba(16, 20, 32, 0.16);
  --scrim: color-mix(in srgb, var(--panel)83%, transparent);
}
.light, .light .main, .light .content { background: var(--bg); color: var(--text); }

/* Cross-fade the palette swap. `.theme-anim` is added to the shell only for
   the brief toggle window (see theme.rs), so the color/background/border/fill
   transition applies during the switch and then gets out of the way of normal
   snappy interactions. !important wins over per-component transitions so the
   whole UI fades together. Respects reduced-motion (no rule → instant swap). */
@media (prefers-reduced-motion: no-preference) {
  .theme-anim.shell, .theme-anim.shell * {
    transition:
      background-color var(--dur-3) var(--ease),
      border-color var(--dur-3) var(--ease),
      color var(--dur-3) var(--ease),
      fill var(--dur-3) var(--ease) !important;
  }
}

/* ===== 2. RESET & BASE ELEMENTS =========================================== */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 400;
  /* Poppins reads a touch wide; tighten tracking so dense table rows fit. */
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color var(--dur-1) var(--ease); }
a:hover { text-decoration: underline; }

/* Custom checkbox — the native white square clashed with the dark theme.
   appearance:none lets us rebuild it while keeping native semantics. */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-inset);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--accent); }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
/* The check mark — a CSS-drawn ✓ from two rotated borders. */
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.4; }

/* ===== 3. TYPOGRAPHY ====================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
h1 { font-weight: 800; font-size: var(--fs-h1); margin: 0 0 var(--sp-4); }
h2 { font-size: var(--fs-h2); margin: 0 0 var(--sp-3); }
h3 { font-size: var(--fs-h3); }

/* ===== 4. LAYOUT / SHELL + RESPONSIVE DRAWER ============================== */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
.main { display: flex; flex-direction: column; min-width: 0; }

/* min-height keeps the content area from collapsing across route swaps; the
   fade-in softens the page hand-off. */
.content {
  padding: clamp(16px, 3vw, 28px);
  min-height: 70vh;
}
/* Boot fallback surface — themed backdrop while the session resolves (AC #24).
   No text/spinner: the app fades in over it rather than flashing a screen. */
.boot-screen { min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.content > * { animation: page-mount 140ms ease-out; }
@keyframes page-mount {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Sidebar stacks on top of the content on small screens and becomes a
   fixed left rail at >=1024px. No drawer/hamburger — the collapsible nav
   groups (closed by default) keep the stacked block compact. */
.sidebar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 1024px) {
  .shell { grid-template-columns: 240px 1fr; }
  .sidebar { border-bottom: none; border-right: 1px solid var(--border); }
}

/* ===== 5. NAVIGATION (SIDEBAR) ============================================ */
.sidebar h1 {
  font-size: 13px;
  margin: 0 0 var(--sp-4);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
}
.sidebar nav a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--r-1);
  margin-bottom: 2px;
  color: var(--text);
  font-size: 13px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.sidebar nav a:hover { background: var(--hover-1); text-decoration: none; }
.sidebar nav a.active {
  background: var(--accent-weak);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar nav a.admin-only { color: var(--muted); }
.sidebar nav a.admin-only::after { content: " ·"; }

/* Collapsible <details> groups; the summary is the toggle, child <A>
   links indent under it so the hierarchy reads without a tree control. */
.sidebar .nav-group { margin: var(--sp-1) 0; }
.sidebar .nav-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--r-1);
  color: var(--muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  user-select: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.sidebar .nav-group > summary::-webkit-details-marker { display: none; }
.sidebar .nav-group > summary::marker { content: ""; }
.nav-chevron { flex: 0 0 auto; color: var(--muted); transition: transform var(--dur-2) var(--ease); }
.sidebar .nav-group[open] > summary .nav-chevron { transform: rotate(180deg); }
.sidebar .nav-group > summary:hover { background: var(--hover-1); color: var(--text); }
.sidebar .nav-group > summary:hover .nav-chevron { color: var(--accent); }
.sidebar .nav-group > a { padding-left: 24px; }

/* The Herald H1 doubles as the secret-menu cursor; the pulse signals the
   arrow-key affordance while the konami menu is open. */
.sidebar h1.lab-active { animation: lab-title-pulse 1.4s ease-in-out infinite; }
@keyframes lab-title-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== 6. TOPBAR ========================================================== */
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: 10px clamp(16px, 3vw, 24px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}

/* Theme toggle — animated sun/moon adapted from Adam Argyle's "theme-switch"
   GUI Challenge (github.com/argyleink/gui-challenges, MIT). De-nested into
   flat CSS, open-props easings inlined as literal cubic-beziers,
   @media (--motionOK) → prefers-reduced-motion, and the dark-state morph
   keyed off the .shell theme class instead of a [data-theme] attribute. */
.theme-toggle {
  --icon-fill: var(--muted);
  --icon-fill-hover: var(--text);
  inline-size: 29px;
  block-size: 29px;
  aspect-ratio: 1;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  outline-offset: 4px;
}
.theme-toggle > svg {
  inline-size: 100%;
  block-size: 100%;
  stroke-linecap: round;
}
.sun-and-moon > :is(.moon, .sun, .sun-beams) { transform-origin: center center; }
.sun-and-moon > :is(.moon, .sun) { fill: var(--icon-fill); }
.theme-toggle:is(:hover, :focus-visible) > .sun-and-moon > :is(.moon, .sun) { fill: var(--icon-fill-hover); }
.sun-and-moon > .sun-beams { stroke: var(--icon-fill); stroke-width: 2px; }
.theme-toggle:is(:hover, :focus-visible) .sun-and-moon > .sun-beams { stroke: var(--icon-fill-hover); }

/* Dark state = app default + carnival (the shell has no `.light`): the sun
   grows past its moon mask and the beams retract, forming the crescent. */
.shell:not(.light) .sun-and-moon > .sun { transform: scale(1.75); }
.shell:not(.light) .sun-and-moon > .sun-beams { opacity: 0; }
.shell:not(.light) .sun-and-moon > .moon > circle { transform: translateX(-7px); }
@supports (cx: 1px) {
  .shell:not(.light) .sun-and-moon > .moon > circle { transform: translateX(0); cx: 17px; }
}

@media (prefers-reduced-motion: no-preference) {
  .sun-and-moon > .sun {
    transition: transform .5s cubic-bezier(.5, 1.25, .75, 1.25); /* ease-elastic-3 */
  }
  .sun-and-moon > .sun-beams {
    transition:
      transform .5s cubic-bezier(.5, 1.5, .75, 1.25),           /* ease-elastic-4 */
      opacity .5s cubic-bezier(.25, 0, .3, 1);                  /* ease-3 */
  }
  .sun-and-moon .moon > circle {
    transition: transform .25s cubic-bezier(0, 0, 0, 1);        /* ease-out-5 */
  }
  @supports (cx: 1px) {
    .sun-and-moon .moon > circle { transition: cx .25s cubic-bezier(0, 0, 0, 1); }
  }
  .shell:not(.light) .sun-and-moon > .sun {
    transform: scale(1.75);
    transition-timing-function: cubic-bezier(.25, 0, .3, 1);
    transition-duration: .25s;
  }
  .shell:not(.light) .sun-and-moon > .sun-beams {
    transform: rotateZ(-25deg);
    transition-duration: .15s;
  }
  .shell:not(.light) .sun-and-moon > .moon > circle {
    transition-delay: .25s;
    transition-duration: .5s;
  }
}
/* ===== 7. BUTTONS ========================================================= */
button, input, select, textarea { font-family: inherit; }

/* Global base so the ~50 unclassed <button>s look intentional. Classed and
   carnival buttons win on specificity, so this never fights them. */
button {
  font: inherit;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  padding: var(--sp-2) var(--sp-3);
  transition: background var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease);
}
button:hover:not(:disabled) { border-color: var(--border-strong); background: var(--hover-2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primary (accent fill). Reusable + keeps the legacy form-actions selector. */
.btn-primary,
.kw-editor .form-actions button {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--r-1);
  padding: 7px 16px;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled),
.kw-editor .form-actions button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, white);
  box-shadow: var(--accent-glow);
}

/* Brand CTA — reserved for brand moments. */
.btn-brand { background: var(--trescored); color: var(--text-on-brand); border-color: transparent; font-weight: 600; }
.btn-brand:hover:not(:disabled) { background: color-mix(in srgb, var(--trescored) 88%, white); }

/* Destructive outline. */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-soft);
  border-radius: var(--r-1);
  padding: 7px 14px;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-weak); border-color: var(--danger); }

.link-button {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

/* ===== 8. FORMS & INPUTS ================================================== */
/* Global field chrome — promoted from .kw-editor so every page benefits.
   Text-ish types only; checkbox/radio/file/range keep native look. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select,
textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  padding: 7px 10px;
  font: inherit;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):hover,
select:hover,
textarea:hover { border-color: var(--border-strong); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
[aria-invalid="true"] { border-color: var(--danger) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-weak) !important; }
textarea { resize: vertical; }

/* ===== 9. CARDS / TILES / PANELS ========================================== */
.kpi-section { margin-bottom: var(--sp-2); }
.kpi-section h3 {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.6px; margin: 0 0 10px; font-weight: 600;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-3); }
.kpi-tile {
  display: block;
  background: var(--surface-2);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  color: var(--text);
  box-shadow: var(--sh-1);
  transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.kpi-tile:hover { border-color: var(--accent-soft); text-decoration: none; transform: translateY(-2px); box-shadow: var(--sh-2); }
.kpi-tile.static { cursor: default; }
.kpi-tile.static:hover { border-color: var(--border-subtle); transform: none; box-shadow: var(--sh-1); }
.kpi-name { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: var(--sp-2); }
.kpi-value { font-size: 22px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-value.large { font-size: 34px; }
.kpi-value.muted { color: var(--muted); font-weight: 400; }
.kpi-value.warn { color: var(--danger); }
.kpi-value.good { color: var(--ok); }
.kpi-context { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.kpi-context .delta { font-weight: 500; }
.kpi-context .delta.ok { color: var(--ok); }
.kpi-context .delta.danger { color: var(--danger); }
.kpi-warn { color: var(--danger); font-size: var(--fs-xs); margin-top: 6px; }
.kpi-unit { margin-bottom: var(--sp-1); }
.kpi-info { margin-left: var(--sp-1); opacity: 0.6; cursor: help; }

/* AC-155 baseline comparison: weekly YoY KPI small-multiples */
.kpi-charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.kpi-chart { min-width: 0; }
.kpi-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.cmp-group-title { margin: var(--sp-3) 0 var(--sp-2); font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-chart-head .delta { font-weight: 600; }
.kpi-chart-head .delta.ok { color: var(--ok); }
.kpi-chart-head .delta.danger { color: var(--danger); }
.kpi-chart-head .delta.expected { color: var(--muted); }
@media (max-width: 900px) { .kpi-charts { grid-template-columns: 1fr; } }

.north-star { margin-bottom: var(--sp-3); }
.north-star-link {
  display: block;
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-weak), transparent 55%),
    var(--surface-2);
  border-radius: var(--r-4);
  padding: var(--sp-5);
  color: var(--text);
  box-shadow: var(--sh-2);
  transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.north-star-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--sh-2); }
.north-star-header { display: flex; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.north-star-tag { background: var(--accent-weak); color: var(--accent); padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.north-star-header h3 { margin: 0; font-size: 14px; color: var(--text); font-weight: 500; }
.north-star-desc { margin: 0 0 var(--sp-2); max-width: 64ch; }

/* ===== 10. TABLES ========================================================= */
.seo-table { width: 100%; border-collapse: collapse; margin-top: var(--sp-2); font-size: 13px; }
.seo-table th {
  text-align: left; padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted); font-weight: 600; font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.5px;
  position: sticky; top: 0; background: var(--surface-1); z-index: 1;
}
.seo-table th.right { text-align: right; }
.seo-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.seo-table td.right { text-align: right; font-variant-numeric: tabular-nums; }
.seo-table tbody tr { transition: background var(--dur-1) var(--ease); }
.seo-table tbody tr:hover { background: var(--hover-1); }
.seo-table.clickable tbody tr { cursor: pointer; }
.seo-table.clickable tbody tr.row-selected { background: var(--accent-weak); }
.seo-table.clickable tbody tr.row-chart-hover { background: var(--accent-weak); }
/* Competitor comparison shading: leading = we rank higher than the
   competitor, trailing = we rank lower (or not at all). */
.seo-table tbody tr.row-leading  { background: var(--ok-weak); }
.seo-table tbody tr.row-leading:hover  { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.seo-table tbody tr.row-trailing { background: var(--danger-weak); }
.seo-table tbody tr.row-trailing:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.seo-table.compact td, .seo-table.compact th { padding: 6px 8px; }
.seo-table th.sortable { cursor: pointer; user-select: none; }
.seo-table th.sortable:hover { color: var(--text); }
.sort-arrow { color: var(--accent); font-size: 10px; }
.seo-table td.bulk-col, .seo-table th.bulk-col { width: 28px; padding-left: 6px; padding-right: 4px; text-align: center; }
.seo-table th.bulk-col { color: var(--muted); font-size: var(--fs-xs); }
.seo-table td.bulk-col input[type="checkbox"] { cursor: pointer; margin: 0; }
/* Bulk-checked rows get a visible cue linking the checkbox to the merge bar. */
.seo-table tbody tr.row-bulk-checked { background: var(--accent-weak); }
.seo-table tbody tr.row-bulk-checked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
/* Suppress text selection painting during click-and-drag row selection. */
.seo-table.dragging, .seo-table.dragging * { user-select: none; }

/* Expandable topic tree. Caret + (name over description) sit in one flex
   row that's indented by depth, so the caret stair-steps with nesting.
   align-items:center centres the caret against the whole text block, so a
   description stacked under the name doesn't shove the caret up. The glyph
   is a full-size triangle (▶/▼, not the tiny ▸/▾ variants). */
.topic-tree-cell { display: flex; align-items: center; gap: 6px; }
.topic-tree-text { display: flex; flex-direction: column; min-width: 0; }
.tree-caret {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 12px; line-height: 1; height: 24px; width: 24px; padding: 0;
  border-radius: 6px; flex: none;
}
.tree-caret:hover { color: var(--text); background: var(--hover-1); }
.tree-caret-spacer { display: inline-block; width: 24px; flex: none; }
.trend-cell { width: 140px; }

/* Mobile: dense tables scroll horizontally rather than crushing columns. */
@media (max-width: 768px) {
  .seo-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}

.kw-text { font-weight: 500; }
.kw-text.large { font-size: 22px; font-weight: 600; }
.page-url { font-size: 12px; color: var(--muted); }
.opp-type { font-weight: 500; }
.opp-evidence { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }

/* Scroll-capped picker tables (cluster members, competitor catalog). */
.member-keywords-scroll,
.competitor-picker-scroll {
  overflow-y: auto;
  scrollbar-color: var(--border) transparent;
  scrollbar-width: thin;
}
.member-keywords-scroll { max-height: 230px; }
.competitor-picker-scroll { max-height: 260px; margin-top: var(--sp-2); }
.member-keywords-scroll::-webkit-scrollbar,
.competitor-picker-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.member-keywords-scroll::-webkit-scrollbar-track,
.competitor-picker-scroll::-webkit-scrollbar-track { background: transparent; }
.member-keywords-scroll::-webkit-scrollbar-thumb,
.competitor-picker-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--panel); }
.member-keywords-scroll::-webkit-scrollbar-thumb:hover,
.competitor-picker-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.member-keywords-scroll .seo-table,
.competitor-picker-scroll .seo-table { margin-top: 0; }
.member-keywords-scroll .seo-table thead th,
.competitor-picker-scroll .seo-table thead th { position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
.member-keywords-scroll .seo-table th.pick-col,
.member-keywords-scroll .seo-table td.pick-col { width: 24px; padding-right: 0; }

.pager { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); justify-content: flex-end; }
.pager button { font-size: 12px; }
.pager button:disabled { color: var(--muted); }

/* ===== 11. BADGES / CHIPS / TAGS / PILLS ================================== */
.freshness { display: flex; gap: 6px; flex-wrap: wrap; }
.freshness .chip {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  color: var(--muted);
  position: relative;
  cursor: default;
}
.freshness .chip.ok { color: var(--ok); border-color: var(--ok-soft); background: var(--ok-weak); }
.freshness .chip.stale { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-weak); }

/* Hover tooltip on freshness chips — last-run + creds state. */
.chip-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 220px;
  padding: 10px 12px;
  background-color: color-mix(in srgb, var(--surface-3) 25%, transparent);
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  animation: transition-state 120ms ease-out;
  border-radius: var(--r-2);
  box-shadow: var(--sh-2);
  color: var(--text);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  pointer-events: none;
}
.freshness .chip:hover .chip-tooltip,
.freshness .chip:focus-within .chip-tooltip { display: flex; animation: transition-state 120ms ease-out; }
@keyframes transition-state {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chip-tooltip-name {
  font-weight: 600; color: var(--text); text-transform: uppercase;
  letter-spacing: 0.4px; font-size: 10px;
  border-bottom: 1px solid var(--border); padding-bottom: var(--sp-1); margin-bottom: 2px;
}
.chip-tooltip-row { display: flex; gap: var(--sp-2); align-items: baseline; }
.chip-tooltip-label { color: var(--muted); font-size: var(--fs-xs); min-width: 78px; }
.chip-tooltip-creds.ok      { color: var(--ok); }
.chip-tooltip-creds.bad     { color: var(--danger); }
.chip-tooltip-creds.unknown { color: var(--muted); }

.kw-tag { display: inline-block; margin-left: var(--sp-2); padding: 1px 8px; border-radius: var(--r-pill); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.kw-tag.branded { color: var(--accent); border: 1px solid var(--accent-soft); }
.kw-tag.non-branded { color: var(--muted); border: 1px solid var(--border); }
.kw-tag.clickable { cursor: pointer; user-select: none; }
.kw-tag.clickable:hover { filter: brightness(1.2); }
/* ADR-0007 cluster EV column: credible interval reads as a smaller muted suffix. */
.ev-cell .ev-ci { font-size: 0.82em; color: var(--muted); white-space: nowrap; }
.kw-tag.suppressed { color: var(--warning); border: 1px solid var(--warn-soft); }
.kw-tag.relevance.high { color: var(--ok); border: 1px solid var(--ok-soft); }
.kw-tag.relevance.medium { color: var(--warning); border: 1px solid var(--warn-soft); }
.kw-tag.relevance.low { color: var(--muted); border: 1px solid var(--border); }
.kw-tag.pinned { border: 1px solid var(--accent-soft); color: var(--accent); }
.kw-tag.status-pending  { color: var(--muted); border: 1px solid var(--border); }
.kw-tag.status-approved { color: var(--ok); border: 1px solid var(--ok-soft); }
.kw-tag.status-denied   { color: var(--danger); border: 1px solid var(--danger-soft); }
.kw-tag.attribution.website { color: var(--ok); border: 1px solid var(--ok-soft); }
.kw-tag.attribution.other_known { color: var(--muted); border: 1px solid var(--border); }
.kw-tag.attribution.unattributed { color: var(--danger); border: 1px solid var(--danger-soft); }
.kw-tag.confidence.high { color: var(--ok); border: 1px solid var(--ok-soft); }
.kw-tag.confidence.medium { color: var(--warning); border: 1px solid var(--warn-soft); }
.kw-tag.confidence.low { color: var(--danger); border: 1px solid var(--danger-soft); }
.kw-tag.confidence.unknown { color: var(--muted); border: 1px solid var(--border); }
.tag-list, .member-list { display: flex; gap: var(--sp-1); flex-wrap: wrap; }

.severity { padding: 1px 6px; border-radius: var(--r-1); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.5px; }
.severity.high { color: var(--danger); border: 1px solid var(--danger-soft); }
.severity.medium { color: var(--warning); border: 1px solid var(--warn-soft); }
.severity.low { color: var(--muted); border: 1px solid var(--border); }

.status-pill { padding: 1px 8px; border-radius: var(--r-pill); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid var(--border); color: var(--muted); }
.status-pill.approved { color: var(--ok); border-color: var(--ok-soft); }
.status-pill.deprioritized { color: var(--muted); border-color: var(--border); }
.status-pill.draft { color: var(--accent); border-color: var(--accent-soft); }
.status-pill.candidate { color: var(--warning); border-color: var(--warn-soft); }
.status-pill.needs_research { color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.status-pill.denied { color: var(--danger); border-color: var(--danger-soft); }
.status-pill.published { color: var(--ok); border-color: var(--ok-soft); }
.status-pill.archived { color: var(--muted); border-color: var(--border); }

.coverage { padding: 1px 8px; border-radius: var(--r-pill); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid var(--border); color: var(--muted); }
.coverage.strong { color: var(--ok); border-color: var(--ok-soft); }
.coverage.weak { color: var(--warning); border-color: var(--warn-soft); }
.coverage.none { color: var(--danger); border-color: var(--danger-soft); }

/* Suggested-topic quick-pick chips under the new-run typeaheads. */
.topic-chip-groups { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-2); }
.topic-chip-row { display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.topic-chip-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); min-width: 96px; }
.topic-chip { padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; border: 1px solid var(--border); background: transparent; color: var(--fg); cursor: pointer; }
.topic-chip:hover { border-color: var(--accent-soft); color: var(--accent); }
.topic-chip.is-active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.page-heading-row { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.page-count-badge {
  font-size: 12px; color: var(--muted);
  padding: 2px 10px; border: 1px solid var(--border);
  border-radius: var(--r-pill); font-variant-numeric: tabular-nums;
}
.row-count { margin: var(--sp-1) 0 var(--sp-2); font-variant-numeric: tabular-nums; }
.results-meta { min-height: 18px; margin: var(--sp-1) 0; }

/* Live job indicator — pulsing dot while a clustering job runs. */
.job-indicator {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 4px 12px; margin: var(--sp-1) 0 var(--sp-2);
  border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--surface-2); font-size: 12px;
}
.job-indicator-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: job-pulse 1.4s ease-in-out infinite; }
.job-indicator.status-pending { border-color: var(--warn-soft); }
.job-indicator.status-pending .job-indicator-dot { background: var(--warning); }
.job-indicator.status-running { border-color: var(--accent-soft); }
.job-indicator.status-running .job-indicator-dot { background: var(--accent); }
@keyframes job-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.75); }
}

/* ===== 12. MODALS & SHEETS ================================================ */
.detail-modal-backdrop {
  position: fixed; inset: 0;
  background: var(--scrim);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 4vw; z-index: 100; overflow-y: auto;
  scrollbar-color: var(--border) transparent; scrollbar-width: thin;
  animation: fade-in var(--dur-2) var(--ease);
}
.detail-modal-frame {
  background-color: color-mix(in srgb, var(--surface-2) 25%, transparent);
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  border-radius: var(--r-3);
  max-width: 960px; width: 100%; max-height: 90vh;
  overflow-y: auto; padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--sh-3);
  scrollbar-color: var(--border) transparent; scrollbar-width: thin;
  animation: modal-in var(--dur-3) var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.detail-modal-backdrop::-webkit-scrollbar,
.detail-modal-frame::-webkit-scrollbar { width: 10px; height: 10px; }
.detail-modal-backdrop::-webkit-scrollbar-track,
.detail-modal-frame::-webkit-scrollbar-track { background: transparent; }
.detail-modal-backdrop::-webkit-scrollbar-thumb,
.detail-modal-frame::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-1); }
.detail-modal-backdrop::-webkit-scrollbar-thumb:hover,
.detail-modal-frame::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.detail-modal-frame .kw-detail-header { top: 0; padding-top: var(--sp-1); padding-bottom: var(--sp-2); margin-top: -4px; z-index: 1; }

/* Short modals that embed the cluster picker. The picker's typeahead opens
   an absolutely-positioned dropdown that the frame's own scroll container
   (overflow-y:auto) would clip at the frame edge — a z-index bump can't
   escape an ancestor's overflow clip. Let these frames overflow so the
   dropdown overlays past the edge; the backdrop still scrolls if the form
   grows tall. */
.detail-modal-frame.picker-modal { overflow: visible; max-height: none; }
.detail-modal-frame.picker-modal .swipe-typeahead-dropdown { z-index: 120; }

/* Full-screen sheet on phones. */
@media (max-width: 640px) {
  .detail-modal-backdrop { padding: 0; align-items: stretch; }
  .detail-modal-frame { max-width: 100%; max-height: 100dvh; min-height: 100dvh; border-radius: 0; border: none; }
}

/* ===== 13. TOASTS ========================================================= */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column-reverse; gap: var(--sp-2);
  z-index: 200; pointer-events: none;
  max-width: min(420px, calc(100vw - 48px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background-color: color-mix(in srgb, var(--surface-3) 25%, transparent);
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  color: var(--text);
  border: 0 solid var(--border-subtle);
  border-left-width: 3px;
  border-radius: var(--r-2);
  padding: 11px 13px;
  box-shadow: var(--sh-2);
  font-size: 13px; line-height: 1.4;
  animation: toast-in 160ms var(--ease);
}
.toast-body { flex: 1 1 auto; word-break: break-word; }
.toast-dismiss {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 0 2px; margin-top: -2px;
  display: inline-flex; align-items: center;
}
.toast-dismiss:hover { color: var(--text); background: transparent; }
.toast.info    { border-left-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.toast.success { border-left-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.toast.error   { border-left-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.toast.info    .toast-body::before { content: "ⓘ  "; color: var(--accent); }
.toast.success .toast-body::before { content: "✓  "; color: var(--ok); }
.toast.error   .toast-body::before { content: "⚠  "; color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Full-width toasts on phones. */
@media (max-width: 640px) {
  .toast-container { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ===== 14. DROPDOWN / ACTION MENUS ======================================== */
.action-menu-wrap { position: relative; }
.action-menu-trigger { display: inline-flex; align-items: center; gap: 6px; }
.action-menu-trigger::after {
  content: ""; display: inline-block; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 4px solid currentColor; margin-top: 1px;
}
.action-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  min-width: 200px;
  background-color: var(--tp-1);
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  border-radius: var(--r-2);
  padding: var(--sp-1);
  display: flex; flex-direction: column;
  z-index: 20; box-shadow: var(--sh-2);
  animation: transition-state 120ms ease-out;
}
.action-menu button {
  text-align: left; background: transparent; border: none;
  color: var(--text); padding: 8px 10px; border-radius: var(--r-1);
  font: inherit; font-size: 13px; cursor: pointer;
}
.action-menu button:hover:not([disabled]) { background: var(--accent-weak); color: var(--accent); }
.action-menu button[disabled] { opacity: 0.5; cursor: not-allowed; }
.action-menu .menu-divider { height: 1px; background: var(--border); margin: var(--sp-1) 2px; }

/* ===== 15. DATEPICKER ===================================================== */
.datepicker { position: relative; display: inline-block; }
.datepicker-field {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-1);
  padding: 7px 10px; font: inherit; font-size: 13px;
  cursor: pointer; min-width: 140px; font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-1) var(--ease);
}
.datepicker-field:hover { border-color: var(--accent); }
.datepicker-field.empty .datepicker-value { color: var(--muted); }
.datepicker-icon { color: var(--muted); margin-left: auto; display: inline-flex; align-items: center; }
.datepicker-popover {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 111;
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  border-radius: var(--r-2); padding: var(--sp-3); min-width: 260px;
  box-shadow: var(--sh-3);
  animation: transition-state 120ms ease-out;
}
.datepicker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); gap: var(--sp-2); }
.datepicker-title { font-size: 13px; font-weight: 500; color: var(--text); }
.datepicker-nav {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--r-1); cursor: pointer; padding: 4px 8px;
  display: inline-flex; align-items: center;
}
.datepicker-nav:hover { color: var(--text); border-color: var(--accent); }
.datepicker-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  color: var(--muted); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.6px; text-align: center; margin-bottom: var(--sp-1);
}
.datepicker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepicker-day {
  background: transparent; color: var(--text); border: 1px solid transparent;
  border-radius: var(--r-1); padding: 6px 0; font: inherit; font-size: 12px;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.datepicker-day:hover { background: var(--accent-weak); }
.datepicker-day.muted { color: var(--muted); opacity: 0.5; }
.datepicker-day.today { border-color: var(--border-strong); color: var(--accent); }
.datepicker-day.selected { background: var(--accent); color: var(--bg); font-weight: 600; }
.datepicker-day.selected:hover { filter: brightness(1.05); }
.datepicker-foot { display: flex; gap: 6px; margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.datepicker-action { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-1); padding: 5px 10px; font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.datepicker-action:hover { color: var(--text); border-color: var(--accent); }

/* ===== 16. VIZ / CHARTS =================================================== */
.trend-wrap { margin-top: var(--sp-4); }
.trend-fallback { font-size: 12px; margin-top: var(--sp-3); }
.viz-chart { width: 100%; min-height: 120px; display: block; }
.viz-chart canvas, .viz-chart svg { outline: none; }
/* On-page engagement: heatmap + scroll-reach side by side, stacking narrow. */
.viz-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); align-items: start; }
@media (max-width: 900px) { .viz-pair { grid-template-columns: 1fr; } }
.viz-sparkline { width: 120px; min-height: 24px; height: 24px !important; }
.viz-chart-missing {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: var(--fs-xs);
  border: 1px dashed var(--border); border-radius: var(--r-1);
}
.viz-selected-summary { color: var(--text); font-size: var(--fs-xs); margin-top: var(--sp-1); font-variant-numeric: tabular-nums; }
/* Placeholder frame for a panel whose backend isn't wired yet (e.g. holdout). */
.viz-empty-frame {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 200px; padding: var(--sp-4);
  border: 1px dashed var(--border); border-radius: var(--r-3);
}
.viz-tooltip { min-width: 120px; }
.viz-tooltip-title { color: var(--text); font-weight: 600; margin-bottom: var(--sp-1); }
.viz-tooltip-row { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; font-size: 12px; }
.viz-tooltip-row strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-tooltip-delta { font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.viz-tooltip-delta.up { color: var(--ok); }
.viz-tooltip-delta.down { color: var(--danger); }
.viz-tooltip-delta.flat { color: var(--muted); }
/* Full-width KPI-tile sparkline (overrides the fixed table-cell size). */
.kpi-spark { margin-top: var(--sp-2); }
.kpi-spark .viz-sparkline { width: 100%; height: 30px !important; }
/* Period-over-period delta chip at the foot of a KPI tile. */
.kpi-period-delta { display: flex; gap: 6px; align-items: baseline; font-size: var(--fs-xs); margin-top: 4px; font-variant-numeric: tabular-nums; }
/* Funnel: normalized horizontal stage bars with conversion chips. */
.funnel { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.funnel-meta { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-xs); margin-bottom: 3px; }
.funnel-name { color: var(--text); font-weight: 500; }
.funnel-rate { font-variant-numeric: tabular-nums; }
.funnel-track { position: relative; background: var(--surface-1); border-radius: var(--r-1); height: 26px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: var(--r-1); background: linear-gradient(90deg, color-mix(in srgb, var(--data-1) 75%, transparent), var(--data-1)); transition: width var(--dur-3) var(--ease); }
.funnel-value { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: var(--fs-xs); color: var(--text); font-variant-numeric: tabular-nums; }
/* Selectable overview KPI tiles (analytics: tile picks the trend metric). */
.kpi-tile.selectable { cursor: pointer; transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease); }
.kpi-tile.selectable:hover { border-color: var(--accent); }
.kpi-tile.selectable.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.trend-legend { display: flex; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; flex-wrap: wrap; align-items: center; }
.trend-legend-item.line::before { content: "● "; color: var(--accent); }
.trend-legend-item.baseline::before { content: "− − "; }
.trend-legend-item.target::before { content: "− − "; color: var(--ok); }
.trend-legend-item.end { margin-left: auto; }
.trend-legend-item.deal::before { content: "│ "; color: var(--accent); font-weight: 700; }
.chart-summary { display: flex; align-items: baseline; gap: var(--sp-2); margin-top: 2px; }

/* North Star granularity toggle (Monthly / Daily) — AC #23. */
.ns-granularity { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 10px; }
.chart-delta { font-size: 14px; font-weight: 500; }
.chart-delta.ok { color: var(--ok); }
.chart-delta.danger { color: var(--danger); }
.chart-delta.muted { color: var(--muted); }

/* ===== 17. PAGE-SPECIFIC ================================================== */
.dashboard { display: flex; flex-direction: column; gap: var(--sp-2); }

/* Filters / toolbars */
.seo-filters { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4); flex-wrap: wrap; align-items: center; }
.seo-filters.wrap { flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.seo-filter { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 7px 10px; border-radius: var(--r-1); font: inherit; }
.seo-filter.wide { flex: 1 1 280px; min-width: 240px; }
.seo-filter.small { width: 100px; }
.seo-filters .checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.seo-filters .csv-link { margin-left: auto; }
.seo-filters button { font-size: 12px; padding: 7px 12px; }
.seo-filters button:hover:not([disabled]) { border-color: var(--accent); }

/* No `position: relative` here: the advanced-filter panel is in-flow and the
   source menu uses its own `.action-menu-wrap` as its positioning context.
   Keeping this static lets the CSV-import / autocomplete modals (rendered as
   children of this wrap) resolve their absolute backdrop against `.herald-main`
   and overlay the whole content area instead of being trapped behind the
   table (AC #9). */
.filter-panel-wrap { margin-bottom: var(--sp-4); }
.filter-panel-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.filter-panel-bar .csv-link { margin-left: auto; }
.filter-panel-bar .csv-link + .csv-link { margin-left: 0; }
.filter-toggle {
  text-align: center;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: var(--r-1); font: inherit; font-size: 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: var(--sp-2);
}
.filter-toggle:hover { border-color: var(--accent); }
.filter-count { background: var(--accent); color: var(--bg); border-radius: var(--r-pill); padding: 1px 8px; font-size: var(--fs-xs); font-weight: 600; min-width: 18px; text-align: center; }
.filter-panel { margin-top: var(--sp-2); background-color: color-mix(in srgb, var(--surface-3) 25%, transparent);
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  animation: transition-state 120ms ease-out; border-radius: var(--r-3); padding: var(--sp-4); box-shadow: var(--sh-2); 
}
.filter-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.filter-panel-actions { display: flex; gap: var(--sp-3); }
.filter-panel-body { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Pill-shaped export/action link, shared across toolbars. */
.csv-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--border);
  border-radius: var(--r-1); background: var(--surface-2);
  color: var(--accent); font-size: 12px; font-family: inherit; font-weight: inherit;
  cursor: pointer; text-decoration: none;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.csv-link:hover { background: var(--accent-weak); border-color: var(--accent); text-decoration: none; }
.csv-link[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Swipe-mode launcher — green + nudged to the far right so it stands
   out as the primary triage entry point on the keyword toolbar. */
.swipe-launch {
  background: var(--ok-weak); border-color: var(--ok); color: var(--ok);
  font-weight: 600;
}
.swipe-launch:hover { background: var(--ok); border-color: var(--ok); color: var(--surface-1); }

/* Page-level empty state. */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); padding: var(--sp-7) var(--sp-4); color: var(--muted); }
.empty-state p { margin: 0; font-size: 14px; }
.empty-state a { text-decoration: none; }
.empty-state-cta { display: inline-block; padding: 9px 18px; border: 1px solid var(--border); border-radius: var(--r-1); color: var(--accent); font-size: 13px; background: var(--surface-2); cursor: pointer; transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease); }
.empty-state-cta:hover { background: var(--accent-weak); border-color: var(--accent); }

/* Detail panels / modals body. */
.kw-detail { background-color: color-mix(in srgb, var(--surface-2) 25%, transparent); backdrop-filter: var(--blur-1); border-radius: var(--r-3); padding: var(--sp-4); margin-top: var(--sp-4); box-shadow: var(--sh-1); animation: transition-state 120ms ease-out;}
.kw-detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.kw-detail-header h3 { margin: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
/* Small "Close" affordance used on modal/panel headers. */
.dismiss { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 5px 10px; border-radius: var(--r-1); font: inherit; cursor: pointer; }
.dismiss:hover { border-color: var(--accent); color: var(--text); background: transparent; }
.kw-detail-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.kw-detail-subline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: var(--sp-4); font-size: 12px; }
.kw-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.kw-meta-label { font-size: var(--fs-md); color: var(--text); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.kw-meta-list { list-style: none; padding: 0; margin: var(--sp-2); font-size: 12px; line-height: 1.6; }
.kw-meta-list li { padding: 1px 0; }
.kw-detail-section { margin-top: var(--sp-4); }
/* Long-form "How it works" job description — looser leading for dense prose/math. */
.job-details-body { line-height: 1.55; max-width: 70ch; }
/* Dedicated topic detail screen (the detail sub-components were authored for
   the old modal frame, so re-establish width/padding here). */
.topic-detail-screen { max-width: 1200px; margin: 0 auto; padding: var(--sp-3) var(--sp-2); }
.topic-detail-screen .back-link { display: inline-block; margin-bottom: var(--sp-3); }
.topic-detail-screen .topic-keywords { margin-top: var(--sp-5); }
.topic-detail-screen .topic-keywords > h3 { margin-bottom: var(--sp-2); }
.kw-rationale { margin-bottom: var(--sp-3); }
.kw-related { list-style: none; padding: 0; margin: 0; }
.kw-related li { padding: 2px 0; font-size: 13px; }
.kw-related a { color: var(--accent); }
.kw-link { color: var(--accent); font-size: 12px; margin-left: auto; }
.status-link { text-decoration: none; }

/* Assigned-page card (topic detail) */
.assigned-page-cards { display: flex; flex-direction: column; gap: var(--sp-2); }
.assigned-page-card {
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.assigned-page-stats { display: flex; align-items: center; gap: var(--sp-4); }
.stat-inline { display: flex; flex-direction: column; }
.stat-inline .stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-inline .stat-value { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.assigned-page-stats .kw-link { margin-left: auto; }

/* Cluster stats grid. */
.cluster-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-2); margin: var(--sp-1) 0 var(--sp-4); }
.cluster-stats .stat { background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); padding: 8px 10px; }
.cluster-stats .stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.cluster-stats .stat-value { margin-top: 2px; font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Cluster action / member toolbars use the shared .kw-actions chrome. */
.cluster-actions { display: flex; margin: var(--sp-2) 0 var(--sp-4); gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.member-keywords-toolbar { display: flex; align-items: center; gap: 10px; margin: var(--sp-1) 0 6px; font-size: 12px; }
.split-cluster-form { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.split-cluster-form input[type="text"] { flex: 1 1 auto; font-size: 13px; }

/* Per-row + bar action buttons. */
.kw-actions { display: flex; gap: var(--sp-1); }
.kw-actions button { padding: 3px 9px; font-size: var(--fs-xs); border-radius: var(--r-1); cursor: pointer; border: 1px solid var(--border); background: transparent; color: inherit; }
.kw-actions button:hover:not([disabled]) { filter: brightness(1.15); }
.kw-actions button[disabled] { opacity: 0.4; cursor: not-allowed; }
.kw-actions .btn-approve { border-color: var(--ok-soft); color: var(--ok); background: transparent; }
.kw-actions .btn-deny    { border-color: var(--danger-soft); color: var(--danger); background: transparent; }

/* Publish target picker (content detail). */
.kw-publish-targets { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-1); font-size: var(--fs-xs); }
.kw-checkbox { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

.bulk-merge-bar {
  display: flex; align-items: center; gap: 10px; margin: var(--sp-2) 0; padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--accent-soft); border-radius: var(--r-2);
  position: sticky; top: 64px; z-index: 5; box-shadow: var(--sh-1);
}
.bulk-merge-bar select { padding: 6px 8px; font-size: 12px; min-width: 220px; }
.bulk-merge-bar button { padding: 6px 12px; font-size: 12px; }
.bulk-merge-bar button:hover:not(:disabled) { border-color: var(--accent); }

/* Compact modal hosting the shared ClusterPicker for bulk add-to-cluster. */
.bulk-cluster-modal { max-width: 520px; display: flex; flex-direction: column; gap: var(--sp-2); }
.bulk-cluster-title { margin: 0; }

/* Big approve/deny/neutral decision buttons (detail modal header, forms). */
.kw-decision-bar { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-3) 0 var(--sp-4); padding: var(--sp-3); background-color: color-mix(in srgb, var(--surface-inset) 25%, transparent); border: 1px solid var(--border); border-radius: var(--r-2); }
.kw-decision-bar .muted { display: flex; align-items: center; gap: 6px; flex: 1; }
.btn-approve.big, .btn-deny.big, .btn-neutral.big {
  padding: 8px 18px; font-size: 13px; font-weight: 600; border-radius: var(--r-1);
  border: 1px solid; cursor: pointer; font-family: inherit;
}
.btn-approve.big { background: var(--ok-fill); color: var(--ok); border-color: var(--ok-soft); }
.btn-approve.big:hover:not([disabled]) { background: color-mix(in srgb, var(--ok) 28%, transparent); }
.btn-deny.big { background: var(--danger-fill); color: var(--danger); border-color: var(--danger-soft); }
.btn-deny.big:hover:not([disabled]) { background: color-mix(in srgb, var(--danger) 26%, transparent); }
.btn-neutral.big { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-neutral.big:hover:not([disabled]) { color: var(--text); border-color: var(--accent); }
.btn-approve.big[disabled], .btn-deny.big[disabled], .btn-neutral.big[disabled] { opacity: 0.4; cursor: not-allowed; }
.member-remove { margin-left: var(--sp-1); background: transparent; border: none; color: var(--danger); cursor: pointer; padding: 0 2px; font-size: 12px; line-height: 1; }
.member-remove:hover { filter: brightness(1.2); background: transparent; }

/* Orphan-keywords banner on /clusters — quiet amber "you have work to do". */
.orphan-banner { background: var(--warn-weak); border: 1px solid var(--warn-soft); border-radius: var(--r-3); padding: 10px 14px; margin: var(--sp-2) 0 var(--sp-3); font-size: 13px; }
.orphan-banner-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.orphan-banner-row strong { font-weight: 500; }
.orphan-banner-bundle { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.orphan-banner-bundle input[type="text"] { flex: 1 1 auto; min-width: 200px; font-size: 13px; }
.orphan-banner button { background: var(--surface-2); color: var(--text); border: 1px solid var(--warn-soft); padding: 6px 12px; border-radius: var(--r-1); font: inherit; font-size: 12px; cursor: pointer; }
.orphan-banner button:hover:not([disabled]) { background: var(--warn-weak); border-color: var(--warning); }
.orphan-banner button[disabled] { opacity: 0.45; cursor: not-allowed; }
.orphan-banner .btn-approve { background: var(--surface-2); color: var(--ok); border-color: var(--ok-soft); font-weight: 500; }
.orphan-banner .btn-approve:hover:not([disabled]) { background: var(--ok-weak); border-color: var(--ok); }
.orphan-banner .orphan-explorer-link { color: var(--accent); font-size: 12px; text-decoration: none; border-bottom: 1px dashed transparent; }
.orphan-banner .orphan-explorer-link:hover { border-bottom-color: var(--accent); }

/* Collapsible "Manage cluster" panel. */
/* interpolate-size (scoped to the dropdown subtree) lets block-size: auto
   animate; inherited by ::details-content. Harmless where unsupported. */
.cluster-manage { margin-top: var(--sp-4); border-top: 1px solid var(--border); padding-top: var(--sp-3); interpolate-size: allow-keywords; }
.cluster-manage > summary { cursor: pointer; list-style: none; font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; padding: 4px 0; user-select: none; display: flex; align-items: center; gap: 6px; }
.cluster-manage > summary::-webkit-details-marker { display: none; }
.cluster-manage > summary::before { content: "▸"; display: inline-block; width: 1em; font-size: 1.5em; line-height: 1; color: var(--text); transition: transform 180ms var(--ease, ease); }
.cluster-manage[open] > summary::before { transform: rotate(90deg); }
.cluster-manage > *:not(summary) { margin-top: var(--sp-3); }

/* Smooth open/close: animate the content's height + opacity. The
   browser would normally show/hide it instantly; ::details-content +
   allow-discrete content-visibility keeps it visible through the close
   animation. Modern engines animate; older ones simply snap open. */
.cluster-manage::details-content {
  block-size: 0;
  overflow: hidden;
  opacity: 0;
  transition: block-size 200ms ease, opacity 200ms ease, content-visibility 200ms allow-discrete;
}
.cluster-manage[open]::details-content {
  block-size: auto;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .cluster-manage::details-content,
  .cluster-manage > summary::before { transition: none; }
}

/* Quick status changer at the top of the cluster detail modal. */
.cluster-status-quickedit { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.cluster-status-quickedit .kw-meta-label { margin: 0; }

/* StatusChip: a status pill that opens its own picker beneath it. */
.status-chip-picker { position: relative; display: inline-block; }
/* Click-away catcher behind the open picker (below the pop, above page). */
.status-pop-backdrop { position: fixed; inset: 0; z-index: 29; background: transparent; }
.status-pill.clickable { cursor: pointer; border: 1px solid transparent; background: none; font: inherit; }
.status-pill.clickable:hover { border-color: var(--border); }
.status-chip-caret { margin-left: 4px; font-size: 0.85em; opacity: 0.7; }
.status-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  margin: 0; padding: 4px; list-style: none; min-width: 9rem;
  background-color: var(--tp-1);
  backdrop-filter: var(--blur-1);
  -webkit-backdrop-filter: var(--blur-1);
  border-radius: var(--r-2);
  box-shadow: var(--sh-2);
  animation: transition-state 120ms ease-out;
}
.status-pop > li { margin: 0; }
.status-pop-item {
  display: block; width: 100%; text-align: left; padding: 5px 10px;
  background: none; border: 0; border-radius: var(--r-1, 4px); color: var(--text);
  font: inherit; cursor: pointer;
}
.status-pop-item:hover { background: var(--hover-2); }

/* Always-visible selected-cluster chips in the topic modal. */
.cluster-chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-1) 0; }
.cluster-chip-static {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-inset); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; text-decoration: none;
}
.cluster-chip-static:hover { border-color: var(--accent); color: var(--accent); }

/* ASCII directory tree in the topic "Preview subtree" output. */
.content-subtree-preview { margin-top: var(--sp-3); }
.content-subtree-tree {
  background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2);
  padding: var(--sp-2) 10px; margin: var(--sp-2) 0;
  font: 12px/1.5 var(--font-mono); color: var(--text);
  white-space: pre; overflow-x: auto; max-height: 320px; overflow-y: auto;
}

/* Competitor picker (collapsible <details>). */
.competitor-picker { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: 10px 14px; margin: var(--sp-3) 0; }
.competitor-picker > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); list-style: none; }
.competitor-picker > summary::-webkit-details-marker { display: none; }

/* Editor forms. */
.kw-editor .form-row { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.kw-editor .form-row.checkbox { flex-direction: row; align-items: center; gap: var(--sp-2); }
.kw-editor .form-row .checkbox-group { display: flex; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-1) 0; }
.kw-editor .form-row .checkbox-group .checkbox { color: var(--text); }
.kw-editor .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: var(--sp-3); }
.kw-editor .form-grid .form-row { margin-bottom: 0; }
.kw-editor .form-grid .form-row.full { grid-column: 1 / -1; }
.kw-editor textarea { min-height: 60px; }
.form-actions { display: flex; gap: var(--sp-3); align-items: center; margin-top: var(--sp-2); flex-wrap: wrap; }
.kw-editor .form-actions { display: flex; gap: var(--sp-3); align-items: center; margin-top: var(--sp-2); flex-wrap: wrap; }
.kw-editor .file-picker { display: flex; align-items: center; gap: var(--sp-3); padding-top: var(--sp-1); }
.kw-editor .file-picker .btn-secondary,
.kw-editor .file-picker .upload-picker { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: var(--r-1); font: inherit; font-size: 12px; cursor: pointer; }
.kw-editor .file-picker .upload-picker:hover { background: var(--hover-2); }
@media (max-width: 640px) { .kw-editor .form-grid { grid-template-columns: 1fr; } .kw-meta { grid-template-columns: 1fr; } }

/* Inline keyword picker. */
.kw-picker { border: 1px solid var(--border); border-radius: var(--r-2); padding: var(--sp-2) 10px; margin-bottom: var(--sp-3); background: var(--surface-inset); }
.kw-picker-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.kw-picker-head .kw-picker-title { font-size: 12px; color: var(--muted); }
.kw-picker-head .kw-picker-count { font-size: 12px; color: var(--text); }
.kw-picker-toolbar { display: flex; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-2); }
.kw-picker-toolbar input[type="search"] { flex: 1 1 auto; }
.kw-picker-toolbar select { width: auto; }
.kw-picker-toolbar .ghost { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: var(--r-1); font: inherit; font-size: 12px; cursor: pointer; }
.kw-picker-toolbar .ghost:hover { background: var(--hover-2); }
.kw-picker-scroll { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-2); }
.kw-picker-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kw-picker-table th, .kw-picker-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.kw-picker-table th { position: sticky; top: 0; background: var(--surface-1); color: var(--muted); font-weight: 500; z-index: 1; }
.kw-picker-table tbody tr:last-child td { border-bottom: none; }
.kw-picker-table tbody tr:hover { background: var(--hover-1); }
.kw-picker-table td.kw-pick-col { width: 24px; }
.kw-picker-table td.kw-status-col { width: 80px; color: var(--muted); }
.kw-picker-empty { padding: var(--sp-3); font-size: 12px; color: var(--muted); text-align: center; }

/* Section headers + admin/report actions. */
.section-head { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-4) 0 var(--sp-2); flex-wrap: wrap; }
.section-head h3 { margin: 0; }
.section-head .csv-link { margin-left: auto; }
.section-head button { font-size: 12px; padding: 7px 12px; }
.section-head button:hover:not([disabled]) { border-color: var(--accent); }
.action-cell { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.action-cell button { padding: 5px 10px; font-size: 12px; }
.action-cell button:hover:not(:disabled) { border-color: var(--accent); }
.opp-evidence.kpi-warn { color: var(--danger); }

/* Data-quality banner. */
.dq-banner { padding: 12px 16px; border-radius: var(--r-3); border: 1px solid var(--border); margin: var(--sp-2) 0 var(--sp-4); font-size: 12px; }
.dq-banner.ok { color: var(--ok); border-color: var(--ok-soft); background: var(--ok-weak); }
.dq-banner.warn { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-weak); }
.dq-banner ul { margin: 6px 0 0; padding-left: var(--sp-4); }

/* Content pipeline run surfaces. */
.stage-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-2); }
.stage-panel { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: 10px 14px; }
.stage-panel-header { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; user-select: none; }
.stage-panel-header:hover { color: var(--accent); }
.stage-twisty { color: var(--muted); font-size: 10px; width: 12px; }
.prompt-preview { background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); padding: var(--sp-2) 10px; font-size: 12px; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto; margin: 6px 0; }
.prompt-preview.wide { max-height: 480px; }

/* Content editor. */
.content-editor { margin-top: var(--sp-3); }
.editor-tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin: var(--sp-4) 0 var(--sp-3); }
.editor-tabs .tab { background: transparent; border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; font: inherit; }
.editor-tabs .tab:hover { color: var(--text); background: transparent; }
.editor-tabs .tab.active { color: var(--text); border-bottom-color: var(--accent); }
.editor-source { width: 100%; background: var(--surface-inset); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-2); padding: 12px 14px; font: 13px/1.5 var(--font-mono); resize: vertical; min-height: 320px; }
.editor-preview { background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); padding: var(--sp-4) var(--sp-5); min-height: 320px; line-height: 1.55; }
.editor-preview h1, .editor-preview h2, .editor-preview h3 { margin-top: 1.2em; }
.editor-preview p { margin: 0.6em 0; }
.editor-preview code { background: var(--hover-2); padding: 1px 4px; border-radius: var(--r-1); font-size: 12px; font-family: var(--font-mono); }
.editor-preview pre { background: var(--surface-inset); border-radius: var(--r-2); padding: 10px 12px; overflow-x: auto; }
.featured-image-preview { margin: var(--sp-2) 0 var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-start; }
.featured-image-preview img { max-width: 100%; max-height: 320px; border-radius: var(--r-2); border: 1px solid var(--border); }
.version-history-bar { display: flex; justify-content: space-between; align-items: center; margin: var(--sp-1) 0; flex-wrap: wrap; gap: var(--sp-2); }
.published-article { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: var(--sp-5) var(--sp-6); margin-top: var(--sp-4); line-height: 1.7; box-shadow: var(--sh-1); }
.published-article h1 { font-size: clamp(26px, 3vw + 14px, 34px); margin: 0.5em 0; }
.published-article h2 { font-size: var(--fs-h2); margin-top: 1.4em; }
.published-article p { margin: 0.7em 0; }

/* Editor: sticky top action bar (Save / Approve). */
.editor-topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-2) 0 var(--sp-3); margin-bottom: var(--sp-2); background: var(--bg); border-bottom: 1px solid var(--border); }
.editor-topbar-actions { display: flex; gap: var(--sp-3); align-items: center; }
.editor-topbar-actions button { background: var(--accent); color: var(--bg); border: 1px solid transparent; border-radius: var(--r-1); padding: 7px 16px; font-weight: 600; }
.editor-topbar-actions button:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, white); box-shadow: var(--accent-glow); }

/* Editor: title / SEO title / slug share one row. */
.editor-field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-bottom: 10px; }
.editor-field-row .form-row { margin-bottom: 0; }
@media (max-width: 720px) { .editor-field-row { grid-template-columns: 1fr; } }

/* Editor: markdown formatting toolbar. */
.md-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; padding: var(--sp-1) 0; }
.md-toolbar .md-btn { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-1); padding: 4px 9px; font: inherit; font-size: 12px; line-height: 1.4; cursor: pointer; }
.md-toolbar .md-btn:hover { background: var(--hover-2); border-color: var(--border-strong); }
.insert-component { position: relative; display: inline-block; margin-left: auto; }
.insert-component .insert-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 200px; max-height: 320px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-2); box-shadow: var(--sh-2); padding: var(--sp-1); display: flex; flex-direction: column; gap: 2px; }
.insert-component .insert-item { text-align: left; background: transparent; color: var(--text); border: none; border-radius: var(--r-1); padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.insert-component .insert-item:hover { background: var(--accent-weak); }
.insert-component .insert-empty { padding: 6px 10px; }

/* Editor preview & published view: MDX component placeholders. */
.cmp-preview { border-left: 3px solid var(--accent); background: var(--accent-weak); border-radius: var(--r-1); padding: var(--sp-2) var(--sp-3); margin: var(--sp-3) 0; }
.cmp-preview.cmp-self { color: var(--muted); }
.cmp-label { display: inline-block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); background: var(--surface-inset); border-radius: var(--r-pill); padding: 1px 8px; margin-bottom: var(--sp-1); }
.editor-preview-page { min-height: 320px; }

/* ===== 18. LAB / GAMES ==================================================== */
/* Overlay launcher: games render fixed over the current page (scrim lets the
   page read through behind the centered game window). */
.lab-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 4vh 4vw; overflow-y: auto;
  background:  color-mix(in srgb, var(--scrim) 7%, transparent);;
  backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px);
  animation: fade-in var(--dur-2) var(--ease);
}
.lab-overlay .lab-stage { min-height: 0; }
.lab-stage { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.lab-card { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: var(--sp-6) var(--sp-7); text-align: center; min-width: 320px; box-shadow: var(--sh-1); }
.lab-card h2 { margin: 0 0 var(--sp-2); font-size: 22px; letter-spacing: 0.02em; }
.lab-score { font-family: var(--font-mono); font-weight: 700; font-size: 48px; color: var(--accent); margin: var(--sp-4) 0; font-variant-numeric: tabular-nums; }
.lab-exit { display: inline-block; margin-top: var(--sp-3); color: var(--muted); font-size: 12px; }
.lab-game { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.lab-game-hud { display: flex; align-items: baseline; gap: var(--sp-3); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.lab-game-label { font-size: var(--fs-xs); letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; }
.lab-score-inline { font-size: 22px; font-weight: 700; color: var(--text); margin-right: var(--sp-2); }
.lab-score-inline.muted { color: var(--muted); }
.lab-canvas { background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); display: block; max-width: 100%; }
.lab-game-hint { margin-top: var(--sp-1); }

.leaderboard { margin-top: var(--sp-4); width: 100%; max-width: 420px; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: 14px 16px; }
.leaderboard-head { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-2); margin-bottom: var(--sp-2); }
.leaderboard-title { font-size: var(--fs-xs); letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.leaderboard-list { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
.leaderboard-list li { display: grid; grid-template-columns: 32px 1fr auto; align-items: baseline; padding: 4px 0; gap: var(--sp-3); }
.leaderboard-list li:nth-child(1) .leaderboard-score { color: var(--text); font-weight: 700; }
.leaderboard-rank { color: var(--muted); font-size: 12px; }
.leaderboard-user { color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-score { color: var(--text); font-weight: 600; }
.leaderboard-foot { border-top: 1px solid var(--border); margin-top: var(--sp-2); padding-top: var(--sp-2); text-align: right; }
.leaderboard-personal { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.leaderboard-submit { display: grid; grid-template-columns: 1fr 80px auto; gap: var(--sp-2); align-items: center; margin-bottom: 10px; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.leaderboard-name-input { background: var(--surface-inset); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-1); padding: 6px 8px; font-family: var(--font-mono); font-weight: 700; text-align: center; letter-spacing: 0.15em; text-transform: uppercase; }
.leaderboard-name-input:focus { outline: none; border-color: var(--text); }
.leaderboard-submit-btn { background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: var(--r-1); padding: 6px 12px; font: inherit; font-weight: 600; letter-spacing: 0.1em; cursor: pointer; }
.leaderboard-submit-btn:hover:not([disabled]) { border-color: var(--text); }
.leaderboard-submit-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* "Delayed loading": invisible for 220ms, then fades in — keeps fast
   responses from flashing a spinner. */
.suspense-delay { opacity: 0; animation: suspense-fade-in 200ms ease-out 220ms forwards; }
@keyframes suspense-fade-in { to { opacity: 1; } }

/* Carnival keyframes — movement is the whole point. */
@keyframes cv-wobble   { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes cv-bob      { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes cv-jitter   { 0% { transform: translate(0,0) rotate(0); } 25% { transform: translate(1px,-1px) rotate(0.6deg); } 50% { transform: translate(-1px,1px) rotate(-0.6deg); } 75% { transform: translate(1px,1px) rotate(0.4deg); } 100% { transform: translate(0,0) rotate(0); } }
@keyframes cv-rainbow  { to { filter: hue-rotate(360deg); } }
@keyframes cv-pop      { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
/* Buttons orbit + spin so they keep sliding out from under the cursor. */
@keyframes cv-dodge {
  0%   { transform: translate(0,0)     rotate(0deg); }
  20%  { transform: translate(6px,-4px) rotate(8deg); }
  40%  { transform: translate(-5px,5px) rotate(-10deg); }
  60%  { transform: translate(5px,4px)  rotate(7deg); }
  80%  { transform: translate(-6px,-3px) rotate(-6deg); }
  100% { transform: translate(0,0)      rotate(0deg); }
}

/* Legacy V1 palette vars — kept so any remaining var(--bg/--text) consumers
   stay on-theme; V2 token re-tint lives in `.herald-window.carnival` below. */
.carnival {
  --bg: #FFDDEE;
  --panel: #ffd0e8;
  --border: #ffb171;
  --text: #541c79;
  --muted: #f162a0;
  --accent: #70a9ff;
  --danger: #ff0000;
  --ok: #6af16e;
  font-family: "Comic Sans MS", "Marker Felt", "Bradley Hand", cursive;
}
/* ponytail: blanket Comic Sans + slow rainbow on every element is the cheap,
   honest way to guarantee "all elements change". Heavy `*` is fine for an
   easter egg; reduced-motion users get the look without the spinning (bottom). */
.carnival * { font-family: "Comic Sans MS", "Marker Felt", "Bradley Hand", cursive !important; }

/* Shell: sidebar + topbar */
.carnival .dash-sidebar { background: #fdafd2; border-right: 4px dashed #ffd016; }
.carnival .dash-brand { animation: cv-wobble 1.4s ease-in-out infinite; }
.carnival .dash-nav a { font-weight: 700; display: inline-block; animation: cv-bob 2s ease-in-out infinite; }
.carnival .dash-nav a:nth-child(3n+1) { color: #b8009a; animation-delay: 0s; }
.carnival .dash-nav a:nth-child(3n+2) { color: #008bb8; animation-delay: 0.3s; }
.carnival .dash-nav a:nth-child(3n+3) { color: #c2008a; animation-delay: 0.6s; }
.carnival .dash-nav a:hover { color: #ff0000; transform: scale(1.15) rotate(-4deg); }
.carnival .group-label { color: #cc0066 !important; animation: cv-wobble 2s ease-in-out infinite; }
.carnival .dash-topbar { background: linear-gradient(90deg, #ff9ac7, #fce191, #a5e1ff); border-bottom: 4px dashed #ee0f7e; backdrop-filter: none; }
.carnival .tb-avatar { animation: cv-pop 1.2s ease-in-out infinite; background: #ffcc00 !important; color: #cc0066 !important; }

/* Titles + headers — bright base color, then hue-rotate cycles the rainbow,
   plus a wobble so the text actually moves. */
.carnival h1, .carnival h2, .carnival h3, .carnival h4,
.carnival .section-head, .carnival .panel-head,
.carnival [class*="-title"], .carnival .sk-h1 {
  letter-spacing: normal;
  color: #ef47c8;
  text-shadow: 2px 2px 0 #16ecec;
  display: inline-block;
  transform-origin: center;
  animation: cv-rainbow 4s linear infinite, cv-wobble 2.2s ease-in-out infinite;
}
.carnival h1, .carnival .sk-h1 { font-size: 34px; }
.carnival h2 { font-size: 26px; }

/* Buttons — keep orbiting + spinning so they're a pain to click. Pointer events
   stay on (clickable, just evasive); hover spins them faster. */
.carnival button, .carnival .btn {
  font-family: inherit !important; font-weight: 700;
  border: 2px solid #2a0874; border-radius: 18px;
  cursor: pointer; animation: cv-dodge 2.4s ease-in-out infinite;
}
.carnival button:hover:not([disabled]), .carnival .btn:hover:not([disabled]) { animation-duration: 0.7s; }
.carnival button:nth-of-type(4n+1), .carnival .btn:nth-of-type(4n+1) { background: #ffcc00; color: #cc0066; animation-delay: 0s; }
.carnival button:nth-of-type(4n+2), .carnival .btn:nth-of-type(4n+2) { background: #ff66cc; color: white; animation-delay: 0.4s; }
.carnival button:nth-of-type(4n+3), .carnival .btn:nth-of-type(4n+3) { background: #66ccff; color: #2b1855; animation-delay: 0.8s; }
.carnival button:nth-of-type(4n+4), .carnival .btn:nth-of-type(4n+4) { background: #00cc66; color: white; animation-delay: 1.2s; }

/* Tables (the real table class is .seo-table; keep bare th/td as a fallback) */
.carnival .seo-table th, .carnival th { background: #cc0066 !important; color: #ffff66 !important; font-weight: 700 !important; text-transform: uppercase; letter-spacing: 1px; }
.carnival .seo-table tr:nth-child(odd) td, .carnival tr:nth-child(odd) td { background: #fff0a0; }
.carnival .seo-table tr:nth-child(even) td, .carnival tr:nth-child(even) td { background: #ffd0e0; }
.carnival .seo-table tr:hover td, .carnival tr:hover td { background: #66ffff !important; }
.carnival .seo-table td, .carnival td { color: #2b1855; border-bottom: 2px dashed #ff8833; }
.carnival code { background: #ffff66; color: #cc0066; padding: 2px 4px; border-radius: 4px; }

/* Cards / tiles / panels — current V2 class names */
.carnival .panel, .carnival .kpi-tile, .carnival .kpi-section, .carnival .an-tile,
.carnival .trend-card, .carnival .kw-detail {
  background: #fff0e0; border: 3px solid #ff8833; border-radius: 12px;
  animation: cv-jitter 3s ease-in-out infinite;
}
.carnival .panel:nth-of-type(even), .carnival .kpi-tile:nth-of-type(even) { animation-delay: 0.5s; }

/* Pills / chips / tags */
.carnival .status-pill, .carnival .status-chip, .carnival .kw-tag, .carnival .swipe-chip {
  animation: cv-pop 1.5s ease-in-out infinite;
  border: 2px solid #ffcc00 !important; font-weight: 700;
}

/* Inputs */
.carnival input[type="text"], .carnival input[type="date"], .carnival textarea, .carnival select { background: #ffffcc; color: #2b1855; border: 3px solid #ff66cc; border-radius: 12px; font-family: inherit; font-weight: 700; }
.carnival input[type="checkbox"] { border: 2px solid #cc0066; }
.carnival input[type="checkbox"]:checked { background: #ffcc00; border-color: #cc0066; }
.carnival input[type="checkbox"]:checked::after { border-color: #cc0066; }
.carnival .freshness .chip { background: #66ccff !important; color: #cc0066 !important; border: 2px solid #ffcc00 !important; font-weight: 700; }
.carnival .freshness .chip.stale { background: #ff66aa !important; color: #ffff66 !important; }
.carnival .freshness .chip.ok { background: #66ff99 !important; color: #2b1855 !important; }
.carnival .lab-canvas { border: 4px solid #cc0066; border-radius: 12px; }

/* Accessibility: opt out of the spinning/wobbling, keep the colors. */
@media (prefers-reduced-motion: reduce) {
  .carnival *, .carnival button, .carnival .btn { animation: none !important; }
}
.carnival .lab-game-label { color: #cc0066; font-weight: 700; }
.carnival .lab-score-inline { color: #2b1855; font-weight: 900; }

/* ===== 20. UTILITIES ====================================================== */
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.icon { display: inline-block; vertical-align: middle; flex: 0 0 auto; }

/* ===== 21. ACCESSIBILITY & MOTION ========================================= */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Comfortable touch targets on coarse pointers (phones/tablets). */
@media (pointer: coarse) {
  button, .csv-link, .filter-toggle, .datepicker-field, .empty-state-cta, .sidebar nav a {
    min-height: 44px;
  }
  .kw-actions button, .action-cell button, .pager button { min-height: 36px; }
}

@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;
  }
}

/* ============================================================
   /keywords/swipe — rapid approve/deny deck
   ============================================================ */

.swipe-page { display: flex; flex-direction: column; gap: var(--sp-3); }

.swipe-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-subtle);
}
.swipe-back { color: var(--muted); text-decoration: none; font-size: var(--fs-sm); }
.swipe-back:hover { color: var(--text); }
.swipe-progress { font-variant-numeric: tabular-nums; }

.swipe-card {
  background-color: color-mix(in srgb, var(--surface-3) 25%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  /* Kept in sync with the 240ms setTimeout in keywords_swipe.rs
     (perform_action) that advances to the next card. */
  transition: transform 0.24s var(--ease), opacity 0.24s var(--ease);
}
.swipe-card.leaving-left  { transform: translateX(-110%) rotate(-6deg); opacity: 0; }
.swipe-card.leaving-right { transform: translateX(110%) rotate(6deg); opacity: 0; }
.swipe-card.leaving-up    { transform: translateY(-110%);              opacity: 0; }

.swipe-keyword { 
  display: flex;
  flex-direction: column;
  gap: var(--sp-1); 
  text-align: center;
  margin: var(--sp-4);
}

.swipe-keyword h1 {
  font-size: clamp(28px, 4vw, 44px);
  margin: var(--sp-4);
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.swipe-pills { display: flex; gap: var(--sp-1); justify-content: center; flex-wrap: wrap; }

.swipe-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-2);
  justify-content: center;
}
.swipe-metric {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: var(--sp-2);
  display: flex; flex-direction: column; gap: 4px;
  align-items: center; text-align: center;
}
.swipe-metric-label { text-transform: uppercase; letter-spacing: 0.05em; }
.swipe-metric-value { font-size: var(--fs-md); font-variant-numeric: tabular-nums; word-break: break-all; }

/* Card content is centered; cluster suggestions sit up top, front and
   centre. The cluster picker + typeahead keep a usable width inside the
   centered column. These last three are scoped to the swipe card so the
   shared cluster picker in the keyword-detail modal is left untouched. */
.swipe-section { display: flex; flex-direction: column; gap: var(--sp-1); align-items: center; text-align: center; margin: var(--sp-4); }
.swipe-section h3 { margin: 0; font-size: var(--fs-sm); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.swipe-hint { color: var(--muted); cursor: help; font-size: var(--fs-s); text-transform: none; }
.swipe-card .cluster-picker { align-items: center; width: 100%; }
.swipe-card .swipe-chips { justify-content: center; }
.swipe-card .swipe-typeahead { width: 100%; max-width: 420px; }
.swipe-card .swipe-typeahead .seo-filter { width: 100%; box-sizing: border-box; }

.swipe-chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* Stacks the suggestion chips above the typeahead with breathing room
   between them (used by the swipe screen and the keyword modal). */
.cluster-picker { display: flex; flex-direction: column; gap: var(--sp-3); margin: 11px 0px 11px 0px; }
/* The similarity score trailing a chip's name — dimmed; the chip's own
   inline-flex gap supplies the spacing from the name. */
.pill-score { opacity: 0.7; font-weight: 400; font-size: var(--fs-sm); }
/* Larger, easier-to-read cluster chips. Each carries a 1–3 key hint. */
.swipe-chip {
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-lg);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
}
.swipe-chip:hover { border-color: var(--accent); }
/* A chip the keyword already belongs to (or is staged to join): solid
   accent fill so memberships read at a glance. Clicking it removes. */
.swipe-chip.is-selected {
  background: var(--accent); color: var(--surface-1);
  border-color: var(--accent);
}
.swipe-chip.is-selected:hover { border-color: var(--surface-1); }
.swipe-chip.is-selected .pill-score { color: var(--surface-1); }
/* Trailing "remove" glyph on a selected chip — dim until hovered. */
.swipe-chip-x { margin-left: 4px; font-size: var(--fs-sm); font-weight: 800; opacity: 0.85; }
.swipe-chip.is-selected:hover .swipe-chip-x { opacity: 1; }
.swipe-chip-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  /* Extra breathing room so the key hint reads as distinct from the
     cluster name (the flex gap already supplies the name↔score spacing). */
  margin-right: 8px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font-size: var(--fs-sm); font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.swipe-typeahead { position: relative; }
.swipe-typeahead-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; margin-top: 4px;
  max-height: 240px; overflow-y: auto;
  display: flex; flex-direction: column;
}
.swipe-typeahead-row {
  text-align: left; background: none; border: none;
  padding: 8px 12px; cursor: pointer; color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
}
.swipe-typeahead-row:hover { background: var(--hover-1); }
.swipe-typeahead-row.is-highlight { background: var(--accent-weak); color: var(--accent); }
.swipe-typeahead-row:last-child { border-bottom: none; }
.swipe-typeahead-create { color: var(--accent); font-weight: 500; }

/* Sits inline in the card flow, directly under the cluster picker. */
.swipe-actionbar {
  margin: var(--sp-4);
  display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-2);
  width: 100%;
}
.swipe-btn {
  padding: 10px 18px; border-radius: 8px; font-weight: 600;
  border: 1px solid var(--border); cursor: pointer;
  background: var(--surface-2); color: var(--text);
  font-size: var(--fs-sm);
}
.swipe-btn:disabled { opacity: 0.4; cursor: default; }
.swipe-btn-approve { background: var(--ok-weak); border-color: var(--ok); color: var(--ok); }
.swipe-btn-deny    { background: var(--danger-weak); border-color: var(--danger); color: var(--danger); }
.swipe-btn-skip    { background: var(--surface-2); }
.swipe-btn-undo    { background: var(--surface-2); }

.swipe-empty {
  text-align: center;
  padding: var(--sp-5) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
}
.swipe-empty h1 { margin: 0; }
.swipe-empty .swipe-btn { text-decoration: none; display: inline-block; }

.pill { display: inline-block; margin: 5px ; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-md); }
.pill-warn   { background: var(--danger-weak); color: var(--danger); }
.pill-accent { background: var(--accent-weak); color: var(--accent); }
.pill-link   { background: var(--surface-2); color: var(--text); text-decoration: none; }
.pill-link:hover { background: var(--hover-1); }

/* ---- Content pipeline UX overhaul ---- */

/* Prompt library: category sections. */
.prompt-category { margin-bottom: var(--sp-4, 20px); }
.prompt-category-title {
  margin: var(--sp-3, 14px) 0 var(--sp-2, 8px);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: var(--fs-md);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Template editor: prompt-key cell + inline custom-prompt editor. */
.stage-prompt-cell { display: flex; flex-direction: column; gap: 4px; }
.stage-custom-prompt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-inset);
}
.stage-custom-prompt input,
.stage-custom-prompt textarea { width: 100%; }

/* Run progress stepper (run detail page + progress modal). */
.stage-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: var(--sp-2, 8px) 0 var(--sp-3, 14px);
}
.stage-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: var(--fs-sm, 12px);
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-1);
  white-space: nowrap;
}
.stage-step-glyph { font-weight: 700; }
.stage-step-done   { color: var(--ok); border-color: var(--ok-soft); background: var(--ok-weak); }
.stage-step-failed { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-weak); }
.stage-step-active { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-weak); }
/* Pulse just the glyph on the running stage so "in progress" reads at a glance. */
.stage-step-active .stage-step-glyph { animation: stage-live-pulse 1.2s ease-in-out infinite; }
.stage-step-pending { opacity: 0.7; }
/* Not-yet-started stages: grayed, dashed preview chips to the right of the active one. */
.stage-step-upcoming { color: var(--muted); border-color: var(--border-subtle); border-style: dashed; opacity: 0.55; }
@keyframes stage-live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Stage definition cell in the template editor: type select + name +
   description, stacked. */
.stage-def-cell { min-width: 280px; }
.stage-def-cell select,
.stage-name-input { width: 100%; margin-bottom: 4px; }
.stage-desc { display: flex; flex-direction: column; gap: 3px; }
.stage-desc .editor-source { width: 100%; }
.stage-blurb { margin: 0 0 8px; font-style: italic; }

/* Read-only stage summary (metadata modal) + stage reference legend. */
.stage-summary { margin: 4px 0 0; padding-left: 20px; }
.stage-summary li { margin-bottom: 8px; }
.stage-reference { list-style: none; margin: 6px 0 12px; padding: 10px; border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--surface-inset); }
.stage-reference li { margin-bottom: 8px; }
.stage-reference li:last-child { margin-bottom: 0; }

/* Locked mandatory stage row (assemble) in the stage editor. */
.stage-locked-row { background: var(--surface-inset); opacity: 0.85; }
.stage-locked-row td { border-top: 1px dashed var(--border); }

/* Component palette in the content editor (Insert component). */
.component-palette .component-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.35rem 0;
}
.component-palette .component-item button { flex: none; }

/* ===== Keyword explorer: locale/time toolbar + SERP cells ===== */
.kw-metrics-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-5);
    padding: var(--sp-3) 0;
    margin-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border);
}
.kw-toolbar-group { display: flex; align-items: center; gap: var(--sp-2); }
.kw-toolbar-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.kw-toolbar-sep { color: var(--muted); }

.kw-mini-btn {
    display: inline-flex;
    align-items: center;
    height: var(--control-h);
    padding: 0 10px;
    font-size: var(--fs-sm);
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.kw-mini-btn:hover { color: var(--text); border-color: var(--accent); }

/* Preset time-period dropdown: a .kw-mini-btn trigger that drops a
   .status-pop panel beneath it (reuses the status-pop styling). */
.kw-period { position: relative; display: inline-block; }
.kw-period .kw-mini-btn { gap: 6px; }
.kw-period-caret { font-size: 0.8em; opacity: 0.7; }
.kw-period .status-pop { min-width: 11rem; }

/* Competition chip — low = easy (good), high = hard. */
.kw-tag.competition.low { color: var(--ok); border: 1px solid var(--ok-soft); }
.kw-tag.competition.medium { color: var(--warning); border: 1px solid var(--warn-soft); }
.kw-tag.competition.high { color: var(--danger); border: 1px solid var(--danger-soft); }

/* Position-change delta. Lower rank number is better, so up = improved. */
.pos-delta-up { color: var(--ok); font-variant-numeric: tabular-nums; }
.pos-delta-down { color: var(--danger); font-variant-numeric: tabular-nums; }

/* "Our page" / "Competitor" cells + the shared expander caret. */
.kw-serp-cell { display: inline-flex; align-items: center; gap: var(--sp-2); max-width: 220px; }
.kw-serp-link {
    color: var(--accent);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kw-serp-link:hover { text-decoration: underline; }
.kw-expand-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-1);
    color: var(--muted);
    cursor: pointer;
    font-size: var(--fs-md);
    line-height: 1;
}
.kw-expand-caret:hover { color: var(--text); border-color: var(--accent); background: var(--accent-weak); }

/* Lazy-loaded SERP expansion row. */
.kw-serp-row-hidden { display: none; }
.kw-serp-row > td { background: var(--surface-2); padding: var(--sp-3) var(--sp-4); }
.kw-serp-detail { display: flex; flex-wrap: wrap; gap: var(--sp-7); }
.kw-serp-col { flex: 1 1 280px; min-width: 240px; }
.kw-serp-col h4 {
    margin: 0 0 var(--sp-2);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.kw-serp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.kw-serp-list li { font-size: var(--fs-sm); }

/* ---- GEO scores page (/geo) ---- */
.geo-layout { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: var(--sp-5); align-items: start; }
.geo-topic-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.geo-topic-item {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left; cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-1); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-1);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.geo-topic-item:hover { background: var(--hover-1); }
.geo-topic-item.active { border-color: var(--accent); background: var(--surface-2); }
.geo-topic-name { font-weight: 600; font-size: 13px; }
.geo-detail { min-width: 0; }
.geo-charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.geo-chart { min-width: 0; }
@media (max-width: 900px) {
  .geo-layout { grid-template-columns: 1fr; }
  .geo-charts { grid-template-columns: 1fr; }
}


/* =============================================================================
   V2 "Modern" design system — ported verbatim from the design handoff
   (docs/design_handoff_v2_visual_update/reference/styles/{modern,pages}.css).
   Scoped under .herald-window; appended last so its component rules win the
   cascade over the pre-V2 bare rules above. Pre-V2 rules are removed
   screen-by-screen in PR 9. Geist/Geist Mono are self-hosted below.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/Geist-Variable.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/GeistMono-Variable.woff2") format("woff2");
}

/* ============================================================================
   Herald · Modern — a bold, lean restyle of the marketing dashboard.
   Light-first. Frosted, levitating panels on an ambient tinted field.
   Geist (lean grotesque) replaces Poppins. Indigo + Tresco red kept as brand.
   Standalone: does NOT depend on herald.css — every class the components use is
   styled here, with the same token names so charts & ports re-tint.
   ========================================================================== */

/* ---- Tokens: dark (shell without .light) ---------------------------------- */
.herald-window {
  --font-sans: "Geist", system-ui, -apple-system, sans-serif;

  --bg:            #0C0D11;
  --ambient-1:     rgba(99, 112, 245, 0.16);
  --ambient-2:     rgba(178, 24, 34, 0.10);
  --surface-2:     rgba(23, 25, 33, 0.66);   /* frosted panel */
  --surface-3:     rgba(255, 255, 255, 0.05);
  --surface-inset: rgba(255, 255, 255, 0.04);
  --hover-1:       rgba(255, 255, 255, 0.06);

  --text:          #F2F3F7;
  --muted:         #898FA3;

  --accent:        #8B97FF;
  --accent-weak:   rgba(139, 151, 255, 0.13);
  --accent-soft:   rgba(139, 151, 255, 0.38);
  --trescored:     #E04550;

  --ok:            #34C98E;
  --ok-weak:       rgba(52, 201, 142, 0.12);
  --ok-soft:       rgba(52, 201, 142, 0.36);
  --ok-fill:       rgba(52, 201, 142, 0.16);
  --danger:        #FF6571;
  --danger-weak:   rgba(255, 101, 113, 0.10);
  --danger-soft:   rgba(255, 101, 113, 0.34);
  --warning:       #E8B23E;
  --warn-weak:     rgba(232, 178, 62, 0.12);
  --warn-soft:     rgba(232, 178, 62, 0.36);

  --border:        rgba(255, 255, 255, 0.09);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.2);
  --panel-ring:    rgba(255, 255, 255, 0.07);

  --data-1:        #8B97FF;
  --data-grid:     rgba(255, 255, 255, 0.07);

  --r-1: 10px; --r-2: 14px; --r-3: 22px; --r-4: 28px; --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 16px;
  --fs-xs: 11px;
  --dur-1: 120ms; --dur-2: 200ms; --ease: cubic-bezier(0.2, 0, 0, 1);
  --blur-1: blur(16px);

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  --sh-2: 0 2px 4px rgba(0, 0, 0, 0.4), 0 24px 56px -16px rgba(0, 0, 0, 0.65);
}

/* ---- Tokens: light (the modern default) ----------------------------------- */
.herald-window.light {
  --bg:            #F2F2F4;
  --ambient-1:     rgba(91, 107, 240, 0.10);
  --ambient-2:     rgba(178, 24, 34, 0.055);
  --surface-2:     rgba(255, 255, 255, 0.66);
  --surface-3:     rgba(15, 18, 35, 0.04);
  --surface-inset: rgba(15, 18, 35, 0.035);
  --hover-1:       rgba(15, 18, 35, 0.045);

  --text:          #16181F;
  --muted:         #5D6270;   /* ≥5.4:1 on white; ≥4.6:1 over the 4–6% zone tints (AA) */

  --accent:        #4C5BE0;
  --accent-weak:   rgba(76, 91, 224, 0.08);
  --accent-soft:   rgba(76, 91, 224, 0.30);
  --trescored:     #B21822;

  --ok:            #0D6E4C;   /* darkened for AA over green-tinted surfaces */
  --ok-weak:       rgba(13, 110, 76, 0.09);
  --ok-soft:       rgba(13, 110, 76, 0.30);
  --ok-fill:       rgba(13, 110, 76, 0.11);
  --danger:        #BC2531;   /* darkened for AA on chips over danger-weak tint */
  --danger-weak:   rgba(188, 37, 49, 0.08);
  --danger-soft:   rgba(188, 37, 49, 0.30);
  --warning:       #8A5800;   /* darkened for AA on amber chips + ops zone */
  --warn-weak:     rgba(138, 88, 0, 0.10);
  --warn-soft:     rgba(138, 88, 0, 0.30);

  --border:        rgba(18, 22, 40, 0.10);
  --border-subtle: rgba(18, 22, 40, 0.07);
  --border-strong: rgba(18, 22, 40, 0.24);
  --panel-ring:    rgba(255, 255, 255, 0.75);

  --data-1:        #4C5BE0;
  --data-grid:     rgba(18, 22, 40, 0.07);

  --sh-1: 0 1px 2px rgba(22, 26, 48, 0.05), 0 16px 40px -16px rgba(22, 26, 48, 0.16);
  --sh-2: 0 2px 6px rgba(22, 26, 48, 0.06), 0 32px 64px -24px rgba(22, 26, 48, 0.24);
}

/* ---- Base / shell ---------------------------------------------------------- */
html, body { height: 100%; }
body { margin: 0; }

.herald-window {
  width: 100%; height: 100vh; height: 100dvh;
  display: grid; grid-template-columns: 224px 1fr;
  font-family: var(--font-sans);
  font-size: 13.5px; line-height: 1.5;
  color: var(--text);
  letter-spacing: -0.008em;
  background:
    radial-gradient(52% 44% at 12% -6%, var(--ambient-1), transparent 70%),
    radial-gradient(44% 38% at 96% 4%, var(--ambient-2), transparent 70%),
    radial-gradient(50% 60% at 70% 110%, var(--ambient-1), transparent 72%),
    var(--bg);
  transition: color var(--dur-2) var(--ease);
  overflow: hidden;
}
.herald-window *, .herald-window *::before, .herald-window *::after { box-sizing: border-box; }
.herald-window h2, .herald-window h3, .herald-window p { margin: 0; }
.herald-window a { color: var(--accent); text-decoration: none; }
.herald-window button { font-family: inherit; letter-spacing: inherit; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }

.herald-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.herald-scroll { flex: 1; min-height: 0; overflow: auto; padding: 68px clamp(22px, 3vw, 40px) 48px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---- Unified frost: one L-shaped glass region over the top + left edges.
   Progressive: two stacked layers — a wide, faint soft-blur apron (::before)
   and a tighter, stronger core (::after). Their staggered mask falloffs ramp
   the blur/tint up gradually, so there's no visible panel edge while cards
   scroll under. Both strips share each layer → no seam at the corner. */
.herald-window { position: relative; }
.herald-window::before, .herald-window::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  /* Pin each frost layer to its own compositor layer. Without this, the
     viewport-spanning backdrop-filter is re-rasterised on scroll and Chromium
     intermittently paints a blank (white) tile before the blur lands — the
     "weird white box while scrolling" (AC #12). These are leaf pseudo-elements
     with no positioned children, so the transform has no layout side effects. */
  transform: translateZ(0);
  will-change: transform;
}
.herald-window::before {
  z-index: 49;
  backdrop-filter: blur(3px) saturate(1.15);
  -webkit-backdrop-filter: blur(3px) saturate(1.15);
  background: color-mix(in srgb, var(--bg) 14%, transparent);
  mask-image:
    linear-gradient(to bottom, #000 22px, transparent 110px),
    linear-gradient(to right, #000 150px, transparent 300px);
  mask-composite: add;
  -webkit-mask-image:
    linear-gradient(to bottom, #000 22px, transparent 110px),
    linear-gradient(to right, #000 150px, transparent 300px);
}
.herald-window::after {
  z-index: 50;
  backdrop-filter: blur(11px) saturate(1.4);
  -webkit-backdrop-filter: blur(11px) saturate(1.4);
  background: color-mix(in srgb, var(--bg) 34%, transparent);
  mask-image:
    linear-gradient(to bottom, #000 18px, transparent 62px),
    linear-gradient(to right, #000 160px, transparent 240px);
  mask-composite: add;
  -webkit-mask-image:
    linear-gradient(to bottom, #000 18px, transparent 62px),
    linear-gradient(to right, #000 160px, transparent 240px);
}

/* ---- Sidebar: content rides above the shared frost --------------------------- */
.dash-sidebar { padding: 22px 16px; overflow: hidden auto; scrollbar-width: none; position: relative; z-index: 55; }
.dash-brand { display: flex; align-items: center; gap: 10px; margin: 0 6px 26px; }
.dash-brand .mark {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--trescored), color-mix(in srgb, var(--trescored) 62%, #000));
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--trescored) 55%, transparent);
}
.dash-brand .word { font-weight: 700; font-size: 14px; letter-spacing: 0.22em; }
.dash-nav { display: flex; flex-direction: column; gap: 2px; }
.dash-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: var(--r-pill);
  color: var(--muted); font-size: 13px; font-weight: 500;
  transition: color var(--dur-1) var(--ease);
}
.dash-nav a:hover { color: var(--text); background: var(--hover-1); }
.dash-nav a:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); }
.dash-nav a.active {
  color: var(--text); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  backdrop-filter: var(--blur-1); -webkit-backdrop-filter: var(--blur-1);
}
.dash-nav a.active .ni { color: var(--accent); opacity: 1; }
.dash-nav a .ni { width: 15px; height: 15px; flex: none; opacity: 0.75; }
.dash-nav .group-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em;
  margin: 18px 0 6px; padding: 0 12px; font-weight: 600; opacity: 0.8;
}

/* ---- Topbar: floats above the shared frost ---------------------------------- */
.herald-main { position: relative; }
.dash-topbar {
  /* Floats above .herald-scroll so content scrolls *under* it and through the
     shared frost apron (::before/::after) — that's the glass effect. */
  position: absolute; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  padding: 14px clamp(22px, 3vw, 40px) 12px;
}
.dash-topbar .spacer { flex: 1; }
.tb-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--trescored) 55%, var(--accent)));
  color: #fff; font-weight: 600; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.tb-avatar:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -5px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* Avatar dropdown — native <details>; the avatar is the toggle, the menu
   collapses the sign-out link. Same approach as the sidebar nav-groups. */
.tb-usermenu { position: relative; flex: none; }
.tb-usermenu > summary { cursor: pointer; list-style: none; user-select: none; }
.tb-usermenu > summary::-webkit-details-marker { display: none; }
.tb-usermenu > summary::marker { content: ""; }
.tb-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  min-width: 180px; display: flex; flex-direction: column; gap: 4px;
  padding: 8px; border-radius: var(--r-2);
  background: var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5);
  -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
}
.tb-menu-email {
  font-size: 12px; color: var(--muted);
  padding: 4px 8px 6px; border-bottom: 1px solid var(--panel-ring);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-menu .tb-signout {
  display: block; padding: 7px 8px; border-radius: var(--r-1);
  font-size: 13px; color: var(--text); text-decoration: none;
  transition: background var(--dur-1) var(--ease);
}
.tb-menu .tb-signout:hover { background: var(--hover-1); }
.date-range { display: inline-flex; align-items: center; gap: 8px; }
.date-sep { color: var(--muted); }

/* ---- Page head -------------------------------------------------------------- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 14px 0 22px; }
.dash-head h2 { font-size: 30px; font-weight: 650; letter-spacing: -0.035em; line-height: 1.1; margin-bottom: 6px; }
.dash-head .sub { color: var(--muted); font-size: 14px; }

/* ---- Panels: frosted + levitating ------------------------------------------ */
.panel {
  background: var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5);
  -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  border: none; box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-3); padding: 20px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .panel-head { padding: 18px 20px 0; margin-bottom: 8px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head .count {
  font-size: 11px; color: var(--muted); background: var(--surface-3);
  border-radius: var(--r-pill); padding: 2px 9px; font-variant-numeric: tabular-nums; font-weight: 550;
}
.panel-head .count.alert { color: #fff; background: var(--trescored); font-weight: 650; }
.panel-head .more { margin-left: auto; font-size: 12.5px; font-weight: 550; }
.panel-head .more:hover { text-decoration: underline; }

/* ---- Triage band: tinted frosted feature panel ------------------------------ */
.triage {
  border-radius: var(--r-4); padding: 22px; margin-bottom: 22px;
  background:
    radial-gradient(120% 160% at 0% 0%, var(--accent-weak), transparent 55%),
    var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5);
  -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
}
.triage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--text); }
.triage-head svg { color: var(--accent); }
.triage-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.triage-head .tcount {
  font-size: 11px; font-weight: 700; color: #fff; background: var(--trescored);
  border-radius: var(--r-pill); padding: 2px 10px; font-variant-numeric: tabular-nums;
}
.triage-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
/* nested panels inside the triage band sit flat — one level of levitation */
.triage .panel { box-shadow: inset 0 0 0 1px var(--border-subtle); background: var(--surface-inset); backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ---- KPI strip: lean, number-forward, no boxes ------------------------------ */
.kpi-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin-bottom: 22px; padding: 6px 0; }
@media (max-width: 1100px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } }
.kpi-tile {
  background: transparent; border: none; box-shadow: none;
  padding: 14px 22px 14px; cursor: default;
  border-left: 1px solid var(--border);
}
.kpi-tile:first-child { border-left: none; }
.kpi-name { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: 2px; }
.kpi-unit { margin-bottom: 6px; display: block; font-size: 10.5px; }
.kpi-value { font-size: 30px; font-weight: 650; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi-context { font-size: var(--fs-xs); color: var(--muted); margin-top: 5px; display: flex; flex-direction: column; gap: 2px; }
.kpi-context .delta { font-weight: 600; }
.kpi-context .delta.ok { color: var(--ok); }
.kpi-context .delta.danger { color: var(--danger); }
.kpi-target { font-size: 10.5px; }
.kpi-spark { margin-top: 8px; opacity: 0.9; max-width: 150px; }

/* ---- Insights ---------------------------------------------------------------- */
.insight-list { display: flex; flex-direction: column; }
.insight-row { display: flex; gap: 13px; padding: 13px 0; border-top: 1px solid var(--border-subtle); }
.insight-row:first-child { border-top: none; padding-top: 4px; }
.insight-ico {
  width: 36px; height: 36px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--muted);
}
.insight-ico.high { color: var(--danger); background: var(--danger-weak); }
.insight-ico.medium { color: var(--warning); background: var(--warn-weak); }
.insight-body { min-width: 0; flex: 1; }
.insight-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.insight-top .ttl { font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; }
.insight-ev { color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.insight-ev b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.insight-cta { margin-left: auto; align-self: center; }

.severity {
  padding: 1.5px 8px; border-radius: var(--r-pill); font-size: 10px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
.severity.high { color: var(--danger); background: var(--danger-weak); }
.severity.medium { color: var(--warning); background: var(--warn-weak); }
.severity.low { color: var(--muted); background: var(--surface-3); }
.type-tag {
  font-size: 10px; font-weight: 550; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); background: var(--surface-3); border-radius: var(--r-pill);
  padding: 1.5px 8px; white-space: nowrap;
}

/* link-button used as row CTA */
.csv-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text);
  font-size: 12px; font-weight: 550; white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.csv-link:hover { background: var(--accent-weak); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }

/* ---- Analytics ---------------------------------------------------------------- */
.an-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; align-items: start; }
.trend-card .tc-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.trend-card .tc-val { font-size: 28px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.trend-card .tc-delta { font-size: 13px; font-weight: 650; }
.trend-card .tc-delta.ok { color: var(--ok); }
.trend-card .tc-delta.danger { color: var(--danger); }
.svg-chart { display: block; width: 100%; overflow: visible; }

.metric-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.metric { background: var(--surface-3); border: none; border-radius: var(--r-2); padding: 12px 14px; }
.metric .ml { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; }
.metric .mv { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.3; margin-top: 2px; }
.metric .md { font-size: 11.5px; font-weight: 550; font-variant-numeric: tabular-nums; }
.metric .md.ok { color: var(--ok); }
.metric .md.danger { color: var(--danger); }
.metric .md.muted { color: var(--muted); }

.chan-list { display: flex; flex-direction: column; gap: 10px; }
.chan { font-size: 12.5px; }
.chan-top { display: flex; justify-content: space-between; margin-bottom: 5px; }
.chan-name { font-weight: 500; }
.chan-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.chan-track { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.chan-fill { height: 100%; border-radius: var(--r-pill); background: var(--accent); }

/* ---- Keywords table ------------------------------------------------------------ */
.seo-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.seo-table th {
  text-align: left; padding: 9px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.seo-table td { padding: 10px 20px; border-bottom: 1px solid var(--border-subtle); }
.seo-table tbody tr:last-child td { border-bottom: none; }
.seo-table th.right, .seo-table td.right { text-align: right; }
.seo-table td.right { font-variant-numeric: tabular-nums; }
.seo-table tbody tr:hover { background: var(--hover-1); }
.kw-text { font-weight: 500; }
.kw-tag {
  display: inline-block; margin-left: 8px; padding: 1.5px 8px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.kw-tag.branded { color: var(--accent); background: var(--accent-weak); }
.kw-tag.non-branded { color: var(--muted); background: var(--surface-3); }
.brand-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--trescored); margin-right: 6px; vertical-align: middle; }
.rank-cell { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.rank-num { font-weight: 650; }
.kw-spark { width: 92px; height: 26px; display: block; }
.pos-delta-up { color: var(--ok); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-delta-down { color: var(--danger); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Approvals ------------------------------------------------------------------ */
.appr-list { display: flex; flex-direction: column; gap: 10px; }
.appr-card {
  border-radius: var(--r-2); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  padding: 15px 16px;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.appr-card:hover { box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2); transform: translateY(-2px); }
.appr-card.resolved { opacity: 0.45; }
.appr-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.action-chip {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 2.5px 9px; border-radius: var(--r-pill);
}
.action-chip.create { color: var(--ok); background: var(--ok-weak); }
.action-chip.refresh { color: var(--accent); background: var(--accent-weak); }
.action-chip.prune { color: var(--muted); background: var(--surface-3); }
.status-pill {
  font-size: 10px; font-weight: 550; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2.5px 9px; border-radius: var(--r-pill); color: var(--muted); background: var(--surface-3);
}
.status-pill.candidate { color: var(--accent); background: var(--accent-weak); }
.appr-title { font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; margin-bottom: 3px; line-height: 1.4; }
.appr-diag { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin-bottom: 12px; }
.appr-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.appr-stat { font-size: 12px; }
.appr-stat .k { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 9.5px; font-weight: 600; display: block; }
.appr-stat .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.appr-stat .v.ev { color: var(--ok); }
.appr-actions { display: flex; align-items: center; gap: 8px; }
.btn-approve, .btn-deny {
  padding: 7px 16px; font-size: 12.5px; font-weight: 600; border-radius: var(--r-pill);
  cursor: pointer; border: none;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease), filter var(--dur-1) var(--ease);
}
.appr-actions .ghost { background: transparent; border: none; color: var(--muted); font-size: 12.5px; font-weight: 550; cursor: pointer; padding: 7px 6px; }
.appr-actions .ghost:hover { color: var(--text); }
.appr-resolved-note { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.appr-resolved-note.approved { color: var(--ok); }
.appr-resolved-note.denied { color: var(--danger); }
.appr-resolved-note .ghost { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; }

/* ---- Quick actions ---------------------------------------------------------------- */
.qa-list { display: flex; flex-direction: column; gap: 6px; }
.qa {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-2);
  color: var(--text);
}
.qa:hover { background: var(--hover-1); }
.qa .qa-ico {
  width: 32px; height: 32px; flex: none; border-radius: 10px;
  background: var(--accent-weak); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.qa .qa-txt { min-width: 0; }
.qa .qa-name { font-size: 13px; font-weight: 550; display: block; }
.qa .qa-sub { font-size: 11.5px; color: var(--muted); }
.qa .qa-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700;
  color: #fff; background: var(--trescored); border-radius: var(--r-pill); padding: 1.5px 8px;
  font-variant-numeric: tabular-nums;
}

/* ---- Grid helpers ------------------------------------------------------------------ */
.cols-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; align-items: start; }
.cols-2.even { grid-template-columns: 1fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---- Hover lift: every panel rises a touch with a gentler, deeper shadow ----- */
.panel, .triage {
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.panel:hover, .triage:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
}
/* Nested panels inside the triage band stay flat-ringed — lift, smaller shadow. */
.triage .panel:hover {
  box-shadow: inset 0 0 0 1px var(--border-subtle), var(--sh-1);
}

/* ====== Ops pages (Admin / Ingestion / LLM providers) ========================= */
code { font-family: "Geist Mono", monospace; font-size: 0.92em; }

/* Section block within an ops page */
.ops-section { margin-bottom: 22px; }
.ops-section > h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 12px; }
.meta-label {
  font-size: 10.5px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: 8px;
}
.subsection { margin-bottom: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section-head .meta-label { margin-bottom: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
  padding: 7px 15px; border-radius: var(--r-pill); border: none; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), filter var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--accent-soft), var(--sh-2); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1.5px 4px color-mix(in srgb, var(--text) 14%, transparent), inset 0 0 0 1px var(--panel-ring); }
.btn:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent), var(--sh-1); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1); }

/* Semantic hue per variant — the whole tonal recipe is derived from --bc. */
.btn.accept            { --bc: var(--ok);      --bc-soft: var(--ok-soft); }
.btn.primary, .btn.accent { --bc: var(--accent); --bc-soft: var(--accent-soft); }
.btn.warn              { --bc: var(--warning);  --bc-soft: var(--warn-soft); }
.btn.danger            { --bc: var(--danger);   --bc-soft: var(--danger-soft); }

/* Hued variants share the Close-button silhouette exactly — same flat surface,
   ring weight and shadow as the neutral .btn. Semantics carried by label color
   and a tinted ring only; a whisper of fill tint, no gradients, no highlights. */
.btn.accept, .btn.primary, .btn.accent, .btn.warn, .btn.danger {
  background: color-mix(in srgb, var(--bc) 8%, var(--surface-2));
  color: color-mix(in srgb, var(--bc) 85%, var(--text));
  box-shadow: inset 0 0 0 1px var(--bc-soft), var(--sh-1);
}
.btn.accept:hover, .btn.primary:hover, .btn.accent:hover, .btn.warn:hover, .btn.danger:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--bc) 13%, var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--bc-soft), var(--sh-2);
}
.btn.accept:active, .btn.primary:active, .btn.accent:active, .btn.warn:active, .btn.danger:active {
  transform: translateY(1px);
  box-shadow: inset 0 1.5px 4px color-mix(in srgb, var(--bc) 30%, transparent), inset 0 0 0 1px var(--bc-soft);
}
.btn.accept:focus-visible, .btn.primary:focus-visible, .btn.accent:focus-visible,
.btn.warn:focus-visible, .btn.danger:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--bc), var(--sh-1);
}

/* De-emphasized neutral — a quiet button for low-stakes / page-opening actions. */
.btn.quiet { background: transparent; color: var(--muted); box-shadow: none; }
.btn.quiet:hover { background: var(--hover-1); color: var(--text); transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1); }
.btn.quiet:active { transform: translateY(1px); box-shadow: inset 0 1.5px 4px color-mix(in srgb, var(--text) 12%, transparent); }

/* De-emphasized tonal — faint tinted fill, colored label, flat (no raise). */
.btn.soft {
  background: color-mix(in srgb, var(--bc, var(--muted)) 10%, transparent);
  color: color-mix(in srgb, var(--bc, var(--muted)) 84%, var(--text));
  box-shadow: inset 0 0 0 1px var(--bc-soft, var(--panel-ring));
}
.btn.soft:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--bc, var(--muted)) 16%, transparent); box-shadow: inset 0 0 0 1px var(--bc-soft, var(--panel-ring)), var(--sh-1); }
.btn.soft:active { transform: translateY(1px); box-shadow: inset 0 2px 5px color-mix(in srgb, var(--bc, var(--text)) 24%, transparent), inset 0 0 0 1px var(--bc-soft, var(--panel-ring)); }

.btn.sm { padding: 5px 12px; font-size: 11.5px; font-weight: 600; }

/* De-emphasized text button (modal Cancel, inline dismiss). */
.ghost {
  background: transparent; border: none; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--muted);
  padding: 7px 14px; border-radius: var(--r-pill);
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.ghost:hover { color: var(--text); background: var(--hover-1); }
.ghost:active { transform: translateY(1px); }

/* Button group — joins nearby buttons into one segmented unit: a single
   shared ring + shadow, hairline dividers between segments, rounded only on
   the outer ends. Segments don't lift individually (that would break the
   seam); they tint on hover and depress on click. */
.btn-group { display: inline-flex; align-items: stretch; border-radius: var(--r-pill); overflow: hidden; box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1); }
.btn-group > .btn { border-radius: 0; box-shadow: none; }
.btn-group > .btn:not(:first-child) { border-left: 1px solid var(--border-subtle); }
.btn-group > .btn:hover { transform: none; box-shadow: inset 0 0 0 999px var(--hover-1); }
.btn-group > .btn:active { transform: none; box-shadow: inset 0 2px 6px color-mix(in srgb, var(--text) 16%, transparent); }
.btn-group > .btn:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
/* Hued segments keep their tint; the divider reads against it. */
.btn-group > .btn.accept, .btn-group > .btn.primary, .btn-group > .btn.accent,
.btn-group > .btn.warn, .btn-group > .btn.danger { border-left-color: color-mix(in srgb, var(--bc) 40%, transparent); }
.btn-group > .btn.accept:hover, .btn-group > .btn.primary:hover, .btn-group > .btn.accent:hover,
.btn-group > .btn.warn:hover, .btn-group > .btn.danger:hover {
  background: color-mix(in srgb, var(--bc) 14%, var(--surface-2));
  box-shadow: none;
}
.btn-group > .btn.accept:active, .btn-group > .btn.primary:active, .btn-group > .btn.accent:active,
.btn-group > .btn.warn:active, .btn-group > .btn.danger:active {
  box-shadow: inset 0 2px 6px color-mix(in srgb, var(--bc) 38%, transparent);
}

/* ====== Competitors page ====================================================== */
/* Status tags (competitor + proposed-cluster + keyword triage). */
.kw-tag.status-active    { color: var(--ok); background: var(--ok-weak); }
.kw-tag.status-watching  { color: var(--accent); background: var(--accent-weak); }
.kw-tag.status-archived  { color: var(--muted); background: var(--surface-3); }
.kw-tag.status-pending   { color: var(--warning); background: var(--warn-weak); }
.kw-tag.status-denied    { color: var(--danger); background: var(--danger-weak); }
/* status-approved already defined above */

/* Rank-comparison row tints — green when we're ahead, red when behind/missing. */
.seo-table tr.row-leading > td:first-child  { box-shadow: inset 3px 0 0 var(--ok); }
.seo-table tr.row-trailing > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.seo-table tr.row-leading td  { background: color-mix(in srgb, var(--ok) 5%, transparent); }
.seo-table tr.row-trailing td { background: color-mix(in srgb, var(--danger) 5%, transparent); }

/* Inline link (audio-niche niceties): same accent treatment as nav links. */
.kw-link { color: var(--accent); font-weight: 550; cursor: pointer; }
.kw-link:hover { text-decoration: underline; }
.kw-text { font-weight: 600; letter-spacing: -0.01em; }
a.kw-text { color: inherit; text-decoration: none; }
a.kw-text:hover { color: var(--accent); text-decoration: underline; }

/* Competitor compare picker — collapsible checklist inside the dashboard. */
.competitor-picker {
  background: var(--surface-inset); border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring); overflow: hidden;
}
.competitor-picker > summary {
  display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none;
  padding: 10px 14px; font-size: 12.5px;
}
.competitor-picker > summary::-webkit-details-marker { display: none; }
.competitor-picker > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform var(--dur-1) var(--ease); }
.competitor-picker[open] > summary::after { transform: rotate(180deg); }
.competitor-picker > summary .muted { margin-left: auto; }
.competitor-picker > summary .meta-label + .muted { margin-left: 0; }
.competitor-picker-scroll { max-height: 220px; overflow: auto; padding: 0 14px 12px; }
.competitor-picker-scroll .seo-table { margin: 0; }

/* Checkbox-row form control (scrape modal market toggles). */
.form-row.checkbox-row { flex-direction: row; align-items: center; gap: 9px; font-size: 13px; color: var(--text); font-weight: 500; }
.form-row.checkbox-row input { width: auto; }
.action-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.link-button { background: none; border: none; color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; padding: 0; }
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }

/* Status tags (confidence scale, mirrors herald kw-tag) */
.kw-tag.confidence { margin-left: 0; }
.kw-tag.confidence.high { color: var(--ok); background: var(--ok-weak); }
.kw-tag.confidence.medium { color: var(--warning); background: var(--warn-weak); }
.kw-tag.confidence.low { color: var(--danger); background: var(--danger-weak); }
.kw-tag.confidence.unknown { color: var(--muted); background: var(--surface-3); }
.kw-tag.status-approved { color: var(--ok); background: var(--ok-weak); }

/* Banners */
.dq-banner { border-radius: var(--r-2); padding: 11px 14px; margin-bottom: 14px; font-size: 12.5px; }
.dq-banner.ok { color: var(--ok); background: var(--ok-weak); }
.dq-banner.warn { color: var(--warning); background: var(--warn-weak); }
.dq-banner ul { margin: 6px 0 0; padding-left: 18px; }
.dq-banner li { margin: 2px 0; }

/* Data-quality alert — the issues panel at the top of the DQ pane. Reads as an
   actionable alert (icon + heading + items), not a flat tinted strip. The warn
   state carries a left accent rail + a soft pulse so a glance tells the admin
   something needs attention (AC #22). */
.dq-alert {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--r-2); padding: 13px 16px; margin-bottom: 16px;
  box-shadow: inset 0 0 0 1px var(--panel-ring);
}
.dq-alert-icon {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; line-height: 1; color: #fff;
}
.dq-alert-body { min-width: 0; flex: 1; }
.dq-alert-title { font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em; }
.dq-alert-list { margin: 7px 0 0; padding-left: 18px; font-size: 12.5px; }
.dq-alert-list li { margin: 3px 0; }
.dq-alert.ok { color: var(--ok); background: var(--ok-weak); }
.dq-alert.ok .dq-alert-icon { background: var(--ok); }
.dq-alert.warn {
  color: var(--text); background: var(--warn-weak);
  border-left: 3px solid var(--warning);
  animation: dq-alert-pulse 2.2s var(--ease) infinite;
}
.dq-alert.warn .dq-alert-title { color: var(--warning); }
.dq-alert.warn .dq-alert-icon { background: var(--warning); }
@keyframes dq-alert-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--panel-ring), 0 0 0 0 color-mix(in srgb, var(--warning) 45%, transparent); }
  50% { box-shadow: inset 0 0 0 1px var(--panel-ring), 0 0 0 4px color-mix(in srgb, var(--warning) 0%, transparent); }
}

/* Filter bar */
.seo-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* Inputs / selects / textareas — one styled control vocabulary everywhere.
   Selects drop the native chrome (appearance: none) and get a drawn chevron. */
.field, .seo-filter, .seo-filters select, .seo-filters input,
.form-row select, .form-row input:not([type="checkbox"]), .form-row textarea {
  font-family: inherit; font-size: 12.5px; color: var(--text);
  background-color: var(--surface-2); border: none;
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-1); padding: 7px 11px;
  transition: box-shadow var(--dur-1) var(--ease);
}
select.field, select.seo-filter, .seo-filters select, .form-row select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1.5l6 6 6-6' fill='none' stroke='%23898f9b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field:hover, .seo-filter:hover, .seo-filters select:hover, .seo-filters input:hover,
.form-row select:hover, .form-row input:not([type="checkbox"]):hover, .form-row textarea:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--sh-1);
}
.field:focus, .seo-filter:focus, .seo-filters select:focus, .seo-filters input:focus,
.form-row select:focus, .form-row input:not([type="checkbox"]):focus, .form-row textarea:focus {
  outline: none; box-shadow: inset 0 0 0 1.5px var(--accent-soft), var(--sh-1);
}
.field::placeholder, .seo-filter::placeholder, .seo-filters input::placeholder { color: var(--muted); }
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
/* Controls inside modals sit on the same surface as the frame — step them
   down to the inset tone so the field reads as a field. */
.detail-modal-frame input:not([type="checkbox"]), .detail-modal-frame select, .detail-modal-frame textarea {
  background-color: var(--surface-inset);
}
textarea.field { resize: vertical; min-height: 64px; font-family: "Geist Mono", monospace; font-size: 11.5px; line-height: 1.5; }
select.field-inline {
  font-family: inherit; font-size: 12px; color: var(--text);
  background: var(--surface-3); border: none; border-radius: var(--r-pill);
  padding: 4px 9px; cursor: pointer;
}

/* SelectMenu — custom dropdown whose open menu reuses the .status-pop popover
   (AC #19). The closed trigger mirrors the styled select field; the menu is
   the same frosted popover as the status-chip picker. */
.select-menu { position: relative; display: inline-block; }
.select-menu-trigger {
  display: inline-flex; align-items: center; gap: 8px; justify-content: space-between;
  font-family: inherit; font-size: 12.5px; color: var(--text); cursor: pointer;
  background-color: var(--surface-2); border: none;
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-1); padding: 7px 11px; min-width: 7.5rem;
  transition: box-shadow var(--dur-1) var(--ease);
}
.select-menu-trigger:hover { box-shadow: inset 0 0 0 1px var(--border-strong), var(--sh-1); }
.select-menu-caret { font-size: 11px; opacity: 0.75; line-height: 1; }
.detail-modal-frame .select-menu-trigger { background-color: var(--surface-inset); }
/* Inside the picker popover, show the active option in the accent colour. */
.select-menu-pop .status-pop-item.current { color: var(--accent); font-weight: 600; }

/* Form grid (schedule editor, provider modal) */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-bottom: 14px; }
.form-row { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 550; }
.form-row.full { grid-column: 1 / -1; }
.form-row.checkbox { flex-direction: row; align-items: center; gap: 8px; padding-top: 18px; color: var(--text); }
.form-actions { display: flex; gap: 8px; align-items: center; }

/* Modal backdrop + frame live in the V2 Tables section (.detail-modal-backdrop
   is position:fixed there). A duplicate "house style" block here used to
   shadow it with position:absolute, which un-anchored the overlay from the
   viewport — see the avatar/topbar PR notes. Keep one source of truth. */
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.modal-head .dismiss { margin-left: auto; }

/* Editor card nested inside a panel/modal */
.kw-editor {
  background: var(--surface-inset); border-radius: var(--r-2);
  padding: 14px 16px; margin-top: 10px;
}

/* Meta column lists */
.kw-meta { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 10px; }
.kw-meta-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.kw-meta-list li { padding: 2px 0; }

/* Page test progress bar (test detail modal) — one segment per variant window */
.tt-prog { flex: 1 1 340px; min-width: 280px; max-width: 560px; }
.tt-prog-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tt-prog-top .meta-label { margin-bottom: 6px; }
.tt-prog-stats { font-size: 12.5px; font-variant-numeric: tabular-nums; margin-bottom: 9px; }
.tt-prog-stats b { font-weight: 650; }
.tt-prog-track { display: flex; gap: 3px; height: 8px; }
.tt-seg { flex: 1; min-width: 0; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.tt-seg:first-child { border-top-left-radius: 99px; border-bottom-left-radius: 99px; }
.tt-seg:last-child { border-top-right-radius: 99px; border-bottom-right-radius: 99px; }
.tt-seg-fill { height: 100%; background: var(--accent-soft); }
.tt-seg.cur .tt-seg-fill { background: var(--accent); }
.tt-prog-track.done .tt-seg-fill { background: var(--ok-soft); }
.tt-prog-legend { display: flex; gap: 3px; margin-top: 6px; }
.tt-prog-legend span {
  flex: 1; min-width: 0; font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tt-prog-legend span.cur { color: var(--accent); font-weight: 600; }

/* Table footer / pagination */
.table-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: var(--muted); font-size: 12px; }
.table-foot .pages { margin-left: auto; display: flex; gap: 5px; align-items: center; }
.pg-btn {
  min-width: 26px; height: 26px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--muted); background: var(--surface-2); border-radius: var(--r-1);
  box-shadow: inset 0 0 0 1px var(--panel-ring);
  transition: color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.pg-btn:hover:not(:disabled) { color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.pg-btn:disabled { opacity: 0.4; cursor: default; }
.pg-btn.num.on { color: var(--accent); background: var(--accent-weak); box-shadow: inset 0 0 0 1.5px var(--accent); }
.pg-size { padding: 4px 24px 4px 9px; font-size: 11.5px; margin-right: 6px; }

/* ====== Keyword explorer / clusters / topics ================================== */
.seo-filter.wide { width: 230px; }
.seo-filter.small { width: 104px; }

.page-heading-row { display: flex; align-items: baseline; gap: 12px; }
.count-badge {
  font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-3);
  border-radius: var(--r-pill); padding: 2.5px 10px; white-space: nowrap;
}

/* Collapsible advanced-filter panel (keyword explorer) */
.filter-panel-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-toggle {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font: inherit; font-size: 12.5px; font-weight: 550; color: var(--text);
  background: var(--surface-2); border: none; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-1); padding: 7px 12px;
}
.filter-toggle:hover { box-shadow: inset 0 0 0 1px var(--accent-soft), var(--sh-1); }
.filter-count {
  font-size: 10px; font-weight: 700; color: var(--bg); background: var(--accent);
  border-radius: var(--r-pill); padding: 1px 7px;
}
.filter-panel {
  background: var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5); -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
  border-radius: var(--r-3); padding: 16px 18px 18px; margin-bottom: 14px;
}
.filter-panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 12.5px; }
.filter-panel-header .dismiss { margin-left: auto; }
.filter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px) { .filter-grid { grid-template-columns: repeat(2, 1fr); } }
.f-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.f-field.span2 { grid-column: span 2; }
.f-field > input, .f-field > select { width: 100%; }
.f-field.f-check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; text-transform: none; font-size: 12.5px; font-weight: 500; color: var(--text); cursor: pointer; letter-spacing: 0; }
.filter-panel-body { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-panel-body .checkbox { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }

/* Metrics toolbar (period / locale / language) */
.kw-metrics-toolbar { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.kw-toolbar-group { display: flex; gap: 7px; align-items: center; }
.kw-toolbar-label { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.kw-toolbar-sep { color: var(--muted); }

/* Inline status chip with popup picker */
.status-chip-wrap { position: relative; display: inline-block; }
.status-chip {
  display: inline-flex; align-items: center; gap: 5px; border: none; font-family: inherit;
  font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2.5px 9px; border-radius: var(--r-pill); white-space: nowrap;
  color: var(--muted); background: var(--surface-3);
}
.status-chip.editable { cursor: pointer; }
.status-chip.editable::after { content: "▾"; font-size: 8px; opacity: 0.7; }
.status-chip.approved { color: var(--ok); background: var(--ok-weak); }
.status-chip.pending { color: var(--warning); background: var(--warn-weak); }
.status-chip.needs_research { color: var(--warning); background: var(--warn-weak); }
.status-chip.denied { color: var(--danger); background: var(--danger-weak); }
.status-chip.candidate { color: var(--accent); background: var(--accent-weak); }
.status-pop {
  position: absolute; top: calc(100% + 5px); left: 0; z-index: 240;
  list-style: none; margin: 0; padding: 5px; min-width: 130px;
  background: var(--surface-2); border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
}
.status-pop button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  font: inherit; font-size: 12px; color: var(--text); cursor: pointer;
  padding: 6px 9px; border-radius: var(--r-1);
}
.status-pop button:hover { background: var(--hover-1); }
.status-pop button.current { color: var(--accent); font-weight: 600; }

/* Coverage + competition chips */
.coverage {
  font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2.5px 9px; border-radius: var(--r-pill); white-space: nowrap;
  color: var(--muted); background: var(--surface-3);
}
.coverage.strong { color: var(--ok); background: var(--ok-weak); }
.coverage.weak { color: var(--warning); background: var(--warn-weak); }
.coverage.none { color: var(--danger); background: var(--danger-weak); }
.kw-tag.competition.low { color: var(--ok); background: var(--ok-weak); margin-left: 0; }
.kw-tag.competition.medium { color: var(--warning); background: var(--warn-weak); margin-left: 0; }
.kw-tag.competition.high { color: var(--danger); background: var(--danger-weak); margin-left: 0; }
.kw-tag.suppressed { color: var(--muted); background: var(--surface-3); text-decoration: line-through; }
.kw-tag.attribution { margin-left: 0; }
.kw-tag.attribution.website { color: var(--accent); background: var(--accent-weak); }
.kw-tag.attribution.other_known { color: var(--warning); background: var(--warn-weak); }
.kw-tag.attribution.unattributed { color: var(--muted); background: var(--surface-3); }
.status-pill.approved { color: var(--ok); background: var(--ok-weak); }
.kw-tag.clickable { cursor: pointer; }
.kw-tag.clickable:hover { filter: brightness(1.08); }
.ev-ci { font-size: 11px; }
td.ev-cell { white-space: nowrap; }

/* Row expander (SERP detail) */
.expander-btn {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 10px; padding: 2px 4px; transition: transform var(--dur-1) var(--ease);
  display: inline-block;
}
.expander-btn.open { transform: rotate(90deg); color: var(--accent); }
.kw-serp-detail {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  background: var(--surface-inset); border-radius: var(--r-2);
  padding: 12px 16px; margin: 2px 0 6px;
}
.kw-serp-detail h4 { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 7px; }
.kw-serp-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.kw-serp-list li { padding: 2.5px 0; }
.kw-cell { min-width: 210px; }
.table-scroll { overflow-x: auto; }
.table-scroll::-webkit-scrollbar { height: 8px; }

/* Bulk action bar */
.bulk-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-weak); border-radius: var(--r-2);
  padding: 8px 14px; margin-bottom: 10px; font-size: 12.5px;
}
.bulk-bar .spacer { flex: 1; }

/* Cluster detail stats grid */
.cluster-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 900px) { .cluster-stats { grid-template-columns: repeat(3, 1fr); } }
.cluster-stats .stat { background: var(--surface-3); border-radius: var(--r-2); padding: 9px 12px; }
.cluster-stats .stat-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.cluster-stats .stat-value { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Action dropdown menu */
.action-menu-wrap { position: relative; display: inline-block; }
.action-menu {
  position: absolute; top: calc(100% + 5px); right: 0; z-index: 240;
  min-width: 200px; padding: 5px;
  background: var(--surface-2); border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
}
.action-menu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  font: inherit; font-size: 12.5px; color: var(--text); cursor: pointer;
  padding: 7px 10px; border-radius: var(--r-1);
}
.action-menu button:hover { background: var(--hover-1); }

.empty-state { text-align: center; padding: 28px 20px; color: var(--muted); font-size: 13px; }
.empty-state-cta { color: var(--accent); font-weight: 550; cursor: pointer; }
.cluster-topic-owner { font-size: 12.5px; }
.muted-note { color: var(--muted); font-size: 12px; margin: -4px 0 14px; }

/* ====== Swipe mode (rapid keyword review) ===================================== */
.swipe-overlay {
  position: absolute; inset: 0; z-index: 260;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
  overflow: auto; padding: 30px 24px 48px;
}
.swipe-topbar {
  width: min(680px, 100%); display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 18px;
}
.swipe-back {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 550; color: var(--accent);
}
.swipe-back:hover { text-decoration: underline; }
.swipe-progress { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.swipe-back { white-space: nowrap; }
.swipe-card {
  width: min(680px, 100%);
  background: var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5); -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
  border-radius: var(--r-3); padding: 26px 28px;
  transition: transform 0.26s var(--ease), opacity 0.26s var(--ease);
  animation: swipe-in 0.24s var(--ease);
}
@keyframes swipe-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.swipe-card.leave-right { transform: translateX(64%) rotate(5deg); opacity: 0; }
.swipe-card.leave-left { transform: translateX(-64%) rotate(-5deg); opacity: 0; }
.swipe-card.leave-up { transform: translateY(-42%); opacity: 0; }
.swipe-keyword h1 { font-size: 29px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.swipe-pills { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.swipe-section { margin-top: 20px; }
.swipe-section > h3 {
  font-size: 10.5px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.swipe-chiprow { display: flex; gap: 8px; flex-wrap: wrap; }
.swipe-chip {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font: inherit; font-size: 12px; font-weight: 550; color: var(--text);
  background: var(--surface-3); border: none; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--panel-ring);
  border-radius: var(--r-pill); padding: 6px 13px;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.swipe-chip:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--accent-soft), var(--sh-1); }
.swipe-chip.on { color: var(--accent); background: var(--accent-weak); box-shadow: inset 0 0 0 1.5px var(--accent); }
.swipe-kbd {
  font-family: "Geist Mono", monospace; font-size: 9.5px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border-radius: 4px; padding: 1px 5px;
  box-shadow: inset 0 0 0 1px var(--panel-ring);
}
.swipe-chip.on .swipe-kbd { color: var(--accent); }
.swipe-actionbar { display: flex; gap: 10px; margin: 24px 0 4px; }
.swipe-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 10px; border-radius: var(--r-pill); border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 650; white-space: nowrap;
  background: var(--surface-3); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), filter var(--dur-1) var(--ease);
}
.swipe-btn:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2); }
.swipe-btn:active { transform: translateY(0); }
.swipe-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.swipe-btn-deny { color: var(--danger); background: var(--danger-weak); box-shadow: inset 0 0 0 1px var(--danger-soft), var(--sh-1); }
.swipe-btn-deny:hover { box-shadow: inset 0 0 0 1.5px var(--danger), var(--sh-2); }
.swipe-btn-approve { color: var(--ok); background: var(--ok-weak); box-shadow: inset 0 0 0 1px var(--ok-soft), var(--sh-1); }
.swipe-btn-approve:hover { box-shadow: inset 0 0 0 1.5px var(--ok), var(--sh-2); }
.swipe-btn .swipe-kbd { background: color-mix(in srgb, var(--bg) 22%, transparent); color: inherit; box-shadow: none; opacity: 0.85; }
.swipe-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 20px; }
@media (max-width: 760px) { .swipe-metrics { grid-template-columns: repeat(2, 1fr); } }
.swipe-metric { background: var(--surface-3); border-radius: var(--r-2); padding: 9px 12px; min-width: 0; }
.swipe-metric-label {
  font-size: 9.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; white-space: nowrap;
}
.swipe-metric-value {
  font-size: 15px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.swipe-metric-value.small { font-size: 12px; font-weight: 550; }
.swipe-empty { text-align: center; margin-top: 90px; }
.swipe-empty h1 { font-size: 32px; font-weight: 650; letter-spacing: -0.03em; margin-bottom: 10px; }
.swipe-empty p { margin-bottom: 22px; }
.swipe-empty .btn { min-width: 200px; }

/* ====== Content group (runs / approvals / page tests) ========================== */
.kw-tag.st { margin-left: 0; white-space: nowrap; }
.kw-tag.st.ok { color: var(--ok); background: var(--ok-weak); }
.kw-tag.st.warn { color: var(--warning); background: var(--warn-weak); }
.kw-tag.st.acc { color: var(--accent); background: var(--accent-weak); }
.kw-tag.st.bad { color: var(--danger); background: var(--danger-weak); }
.kw-tag.st.mut { color: var(--muted); background: var(--surface-3); }

/* Status tabs (page tests) */
.tab-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tab-chip {
  border: none; cursor: pointer; font-family: inherit; white-space: nowrap;
  font-size: 12px; font-weight: 550; color: var(--muted);
  background: var(--surface-2); border-radius: var(--r-pill); padding: 6px 14px;
  box-shadow: inset 0 0 0 1px var(--panel-ring);
  transition: box-shadow var(--dur-1) var(--ease), color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.tab-chip:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.tab-chip.on { color: var(--accent); background: var(--accent-weak); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* Run progress checklist */
.run-stages { list-style: none; margin: 0; padding: 0; }
.run-stages li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; font-size: 13px; border-bottom: 1px solid var(--border-subtle);
}
.run-stages li:last-child { border-bottom: none; }
.run-stage-dot {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
  color: var(--muted); background: var(--surface-3);
}
.run-stages li.done .run-stage-dot { color: #fff; background: var(--ok); }
.run-stages li.running .run-stage-dot { color: #fff; background: var(--accent); }
.run-stages li.failed .run-stage-dot { color: #fff; background: var(--danger); }
.run-stages li.pending { color: var(--muted); }
.run-stages li.running .run-stage-name { font-weight: 600; }
.run-stages li.failed .run-stage-name { color: var(--danger); font-weight: 600; }
.run-stage-note { margin-left: auto; font-size: 11.5px; color: var(--muted); }

/* Approvals ops strip context line */
.kpi-context.small { font-size: 11px; color: var(--muted); margin-top: 4px; }
.an-tile-value.warn { color: var(--warning); }
.an-tile-value.mid { font-size: 17px; line-height: 1.35; }

/* Toasts */
.toast-viewport {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
  border-radius: var(--r-pill); padding: 9px 16px;
  font-size: 12.5px; font-weight: 550;
  animation: toast-in 180ms var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.toast.success::before { background: var(--ok); }
.toast.error::before { background: var(--danger); }
.toast.info::before { background: var(--accent); }

/* Clickable table rows */
.seo-table.clickable tbody tr { cursor: pointer; }
.seo-table .sub-code { display: block; margin-top: 1px; }
.seo-table th.sortable { cursor: pointer; user-select: none; }
.seo-table th.sortable:hover { color: var(--text); }
.sort-arrow { color: var(--accent); font-size: 9px; margin-left: 3px; }
.seo-table tr.row-selected { background: var(--accent-weak); }
.page-url { font-size: 12px; }
.page-url.large { font-size: 14px; font-weight: 600; }

/* ====== Analytics page ======================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.an-tile {
  background: var(--surface-3); border-radius: var(--r-2); padding: 12px 14px;
  transition: box-shadow var(--dur-1) var(--ease);
}
.an-tile.selectable { cursor: pointer; }
.an-tile.selectable:hover { box-shadow: inset 0 0 0 1px var(--accent-soft); }
.an-tile.selected { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-weak); }
.an-tile.static { opacity: 0.92; }
.an-tile .kpi-name { margin-bottom: 4px; }
.an-tile-value { font-size: 24px; font-weight: 650; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-period-delta { font-size: 11px; margin-top: 4px; }
.kpi-period-delta .pos-delta-up, .kpi-period-delta .pos-delta-down { font-weight: 600; }
.kpi-warn { color: var(--warning); font-size: 11.5px; font-weight: 550; }

.trend-legend { display: flex; gap: 16px; margin-top: 8px; }
.tl-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; }
.tl-dash { width: 14px; height: 0; border-top: 2px dashed var(--muted); display: inline-block; }

/* Funnel: normalized bars */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-meta { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.funnel-name { font-size: 12.5px; font-weight: 550; }
.funnel-rate { font-size: 11px; font-variant-numeric: tabular-nums; }
.funnel-track { position: relative; height: 26px; border-radius: var(--r-1); background: var(--surface-3); overflow: hidden; }
.funnel-bar {
  height: 100%; border-radius: var(--r-1);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent));
}
.funnel-value {
  position: absolute; top: 50%; transform: translateY(-50%); left: 10px;
  font-size: 11.5px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--bg) 50%, transparent);
}

/* Audience */
.viz-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.an-dim { min-width: 0; }
.donut-wrap { display: flex; align-items: center; gap: 18px; padding: 6px 0 10px; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; }

/* AI + cluster tags */
.kw-tag.ai { color: var(--trescored); background: color-mix(in srgb, var(--trescored) 9%, transparent); }
.kw-tag.cluster-approved { color: var(--ok); background: var(--ok-weak); margin-left: 0; }
.kw-tag.cluster-candidate { color: var(--warning); background: var(--warn-weak); margin-left: 0; }
.member-list { display: flex; gap: 6px; flex-wrap: wrap; }
.kw-detail-title { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; }
.kw-detail-title a { font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.kw-copy-link { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: var(--r-1); align-self: center; }
.kw-copy-link:hover { color: var(--accent); }

/* ---- DatePicker (port of herald.css §15, modern surfaces) ----------------------------- */
.datepicker { position: relative; display: inline-block; }
.datepicker-field {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); color: var(--text);
  backdrop-filter: var(--blur-1); -webkit-backdrop-filter: var(--blur-1);
  border: none; box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-pill); padding: 7px 14px;
  font: inherit; font-size: 12.5px; font-weight: 550; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: box-shadow var(--dur-1) var(--ease);
}
.datepicker-field:hover { box-shadow: inset 0 0 0 1px var(--accent-soft), var(--sh-1); }
.datepicker-field.empty .datepicker-value { color: var(--muted); }
.datepicker-value { white-space: nowrap; }
.datepicker-icon { color: var(--muted); margin-left: auto; display: inline-flex; align-items: center; }
.datepicker-popover {
  position: absolute; top: calc(100% + 6px); right: 0; left: auto; z-index: 111;
  background: var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5); -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
  border-radius: var(--r-2); padding: 12px; min-width: 240px;
}
.datepicker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.datepicker-title { font-size: 13px; font-weight: 600; }
.datepicker-nav {
  background: var(--surface-3); color: var(--muted); border: none;
  border-radius: var(--r-pill); cursor: pointer; padding: 5px 9px;
  display: inline-flex; align-items: center;
}
.datepicker-nav:hover { color: var(--text); background: var(--hover-1); }
.datepicker-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; text-align: center; margin-bottom: 4px;
}
.datepicker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepicker-day {
  background: transparent; color: var(--text); border: none;
  border-radius: var(--r-pill); padding: 6px 0; font: inherit; font-size: 12px;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.datepicker-day:hover { background: var(--accent-weak); }
.datepicker-day.muted { color: var(--muted); opacity: 0.45; }
.datepicker-day.today { box-shadow: inset 0 0 0 1px var(--accent-soft); color: var(--accent); }
.datepicker-day.selected { background: var(--accent); color: #fff; font-weight: 650; }
.datepicker-day.selected:hover { filter: brightness(1.05); }
.datepicker-foot { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.datepicker-action {
  background: var(--surface-3); color: var(--muted); border: none; border-radius: var(--r-pill);
  padding: 5px 12px; font: inherit; font-size: var(--fs-xs); font-weight: 550; cursor: pointer;
}
.datepicker-action:hover { color: var(--text); background: var(--hover-1); }

/* ---- Theme toggle (port of herald.css §sun-and-moon, Argyle morph) -------------------- */
.theme-toggle {
  --icon-fill: var(--muted);
  --icon-fill-hover: var(--text);
  background: var(--surface-2); border: none;
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  backdrop-filter: var(--blur-1); -webkit-backdrop-filter: var(--blur-1);
  padding: 7px; inline-size: 34px; block-size: 34px; aspect-ratio: 1;
  border-radius: var(--r-pill); cursor: pointer; touch-action: manipulation;
  outline-offset: 4px; display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle > svg { inline-size: 100%; block-size: 100%; stroke-linecap: round; }
.sun-and-moon > :is(.moon, .sun, .sun-beams) { transform-origin: center center; }
.sun-and-moon > :is(.moon, .sun) { fill: var(--icon-fill); }
.theme-toggle:is(:hover, :focus-visible) > .sun-and-moon > :is(.moon, .sun) { fill: var(--icon-fill-hover); }
.sun-and-moon > .sun-beams { stroke: var(--icon-fill); stroke-width: 2px; }
.theme-toggle:is(:hover, :focus-visible) .sun-and-moon > .sun-beams { stroke: var(--icon-fill-hover); }
.shell:not(.light) .sun-and-moon > .sun { transform: scale(1.75); }
.shell:not(.light) .sun-and-moon > .sun-beams { opacity: 0; }
.shell:not(.light) .sun-and-moon > .moon > circle { transform: translateX(-7px); }
@supports (cx: 1px) {
  .shell:not(.light) .sun-and-moon > .moon > circle { transform: translateX(0); cx: 17px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sun-and-moon > .sun { transition: transform .5s cubic-bezier(.5, 1.25, .75, 1.25); }
  .sun-and-moon > .sun-beams {
    transition: transform .5s cubic-bezier(.5, 1.5, .75, 1.25), opacity .5s cubic-bezier(.25, 0, .3, 1);
  }
  .sun-and-moon .moon > circle { transition: transform .25s cubic-bezier(0, 0, 0, 1); }
  @supports (cx: 1px) {
    .sun-and-moon .moon > circle { transition: cx .25s cubic-bezier(0, 0, 0, 1); }
  }
  .shell:not(.light) .sun-and-moon > .sun {
    transform: scale(1.75); transition-timing-function: cubic-bezier(.25, 0, .3, 1); transition-duration: .25s;
  }
  .shell:not(.light) .sun-and-moon > .sun-beams { transform: rotateZ(-25deg); transition-duration: .15s; }
  .shell:not(.light) .sun-and-moon > .moon > circle { transition-delay: .25s; transition-duration: .5s; }
}

/* ---- Labs / games easter egg (port of lab/* + nav.rs cursor) ----------------- */
/* Wordmark-as-cursor: pulses while the konami menu is open. */
.dash-brand .word.lab-on {
  color: var(--accent); font-size: 11.5px; letter-spacing: 0.14em; white-space: nowrap;
  animation: lab-title-pulse 1.4s ease-in-out infinite;
}
@keyframes lab-title-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Game overlay — the mock's stand-in for the /lab/<key> route. No scrim, no
   blur, no fade: the panel pops over the dashboard and vanishes instantly. */
.lab-overlay {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.lab-panel {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--surface-2);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
  border-radius: var(--r-4); padding: 26px 30px;
}
.lab-panel-head { display: flex; align-items: baseline; gap: 16px; align-self: stretch; }
.lab-title {
  font-family: "Geist Mono", monospace; font-weight: 700; font-size: 16px;
  letter-spacing: 0.14em; color: var(--text);
}
.lab-key-hints { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lab-game-hud {
  display: flex; align-items: baseline; gap: 12px; align-self: stretch;
  font-family: "Geist Mono", monospace; font-variant-numeric: tabular-nums;
}
.lab-game-label { font-size: 10px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.lab-score-inline { font-size: 22px; font-weight: 700; color: var(--accent); margin-right: 10px; }
.lab-score-inline.muted { color: var(--muted); }
.lab-canvas { display: block; border-radius: var(--r-2); box-shadow: inset 0 0 0 1px var(--border); }
.lab-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface-inset); text-align: center; padding: 0 40px;
}
.lab-ph-title { font-family: "Geist Mono", monospace; font-weight: 700; font-size: 22px; letter-spacing: 0.18em; color: var(--muted); }
.lab-ph-sub { font-size: 12px; color: var(--muted); max-width: 300px; line-height: 1.5; }
.lab-game-hint { font-size: 11px; color: var(--muted); }

/* Discovery hint (mock-only) */
.lab-hint-toast {
  position: absolute; right: 22px; bottom: 18px; z-index: 90;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-pill); padding: 8px 12px;
  animation: lab-fade-in 400ms var(--ease);
}
@keyframes lab-fade-in { from { opacity: 0; } to { opacity: 1; } }
.lab-hint-psst { font-size: 11.5px; color: var(--muted); margin-right: 5px; font-style: italic; }
.lab-hint-toast kbd {
  font-family: "Geist Mono", monospace; font-size: 10px; color: var(--text);
  background: var(--surface-3); border-radius: 5px; padding: 2px 5px;
  box-shadow: inset 0 -1px 0 var(--border);
}
.lab-hint-x {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 2px 2px 6px;
}
.lab-hint-x:hover { color: var(--text); }

/* Carnival Mode (CLOWN) — gaudy token override, kept token-driven so the
   whole UI re-tints, mirroring carnival.rs. */
.herald-window.carnival {
  /* Light cotton-candy pink base. Carnival has no `.light` class, so without
     these it inherits the dark token set and the page goes near-black. Mirror
     the light surfaces/text so everything stays readable on pink. */
  --bg:            #FFDDEE;
  --text:          #3A1850;
  --muted:         #A23B72;
  --surface-2:     rgba(255, 255, 255, 0.72);
  --surface-3:     rgba(122, 31, 255, 0.05);
  --surface-inset: rgba(122, 31, 255, 0.04);
  --hover-1:       rgba(232, 24, 153, 0.08);
  --border:        rgba(122, 31, 255, 0.18);
  --border-subtle: rgba(122, 31, 255, 0.12);
  --border-strong: rgba(122, 31, 255, 0.30);
  --panel-ring:    rgba(122, 31, 255, 0.12);

  --accent: #E81899;
  --accent-weak: rgba(232, 24, 153, 0.10);
  --accent-soft: rgba(232, 24, 153, 0.34);
  --trescored: #7A1FFF;
  --ambient-1: rgba(232, 24, 153, 0.14);
  --ambient-2: rgba(122, 31, 255, 0.12);
  --data-1: #E81899;
}
.herald-window.carnival .dash-brand .mark { transform: rotate(-8deg); }

/* ====== Content config modals (prompt library + template editor) ============== */
/* Prompt library */
.prompt-list { display: flex; flex-direction: column; gap: 22px; }
.prompt-category { display: flex; flex-direction: column; gap: 12px; }
.prompt-category-title {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 0; padding-bottom: 2px;
}
.prompt-card {
  background: var(--surface-inset); border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.prompt-card-header { display: flex; align-items: center; gap: 10px; }
.prompt-key {
  font-family: "Geist Mono", monospace; font-size: 12px; font-weight: 700; color: var(--text);
  background: var(--surface-3); border-radius: var(--r-1); padding: 3px 8px;
}
.prompt-card-actions { margin-left: auto; display: flex; gap: 14px; }
.prompt-preview {
  margin: 0; font-family: "Geist Mono", monospace; font-size: 12px; line-height: 1.65;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border-radius: var(--r-1); padding: 11px 13px;
  box-shadow: inset 0 0 0 1px var(--border-subtle); max-height: 220px; overflow: auto;
}
.prompt-history { margin-top: 2px; }
.new-prompt-form { margin-bottom: 4px; }
.editor-source {
  font-family: "Geist Mono", monospace; font-size: 12px; line-height: 1.6;
  resize: vertical; min-height: 80px;
}

/* Template stage summary (read-only) */
.stage-summary { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.stage-summary li {
  counter-increment: stg; position: relative; padding: 9px 12px 9px 38px;
  background: var(--surface-2); border-radius: var(--r-1);
  box-shadow: inset 0 0 0 1px var(--border-subtle); font-size: 13px;
}
.stage-summary { counter-reset: stg; }
.stage-summary li::before {
  content: counter(stg); position: absolute; left: 11px; top: 9px;
  width: 18px; height: 18px; border-radius: 50%; font-size: 10.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); background: var(--accent-weak);
}

/* Stage editor table */
.stage-editor-table { min-width: 760px; }
.stage-editor-table th, .stage-editor-table td { vertical-align: top; }
.stage-editor-table .seo-filter { width: 100%; }
.stage-editor-table td:nth-child(3), .stage-editor-table th:nth-child(3) { min-width: 118px; }
.stage-editor-table td:nth-child(4), .stage-editor-table th:nth-child(4),
.stage-editor-table td:nth-child(5), .stage-editor-table th:nth-child(5) { min-width: 150px; }
.stage-def-cell { min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.stage-name-input { font-size: 12px; }
.stage-desc { line-height: 1.5; }
.stage-idx { font-weight: 650; color: var(--text); margin-right: 6px; }
.stage-move { display: inline-flex; gap: 3px; }
.stage-move .pg-btn { min-width: 22px; height: 22px; padding: 0; }
.stage-locked-row td { background: var(--surface-3); opacity: 0.85; }
.stage-reference {
  list-style: none; margin: 4px 0 12px; padding: 12px 14px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 10px 18px;
  background: var(--surface-inset); border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring);
}
.stage-reference li { font-size: 12px; }
.stage-reference li > div { line-height: 1.5; margin-top: 2px; }
.version-history-bar { display: flex; align-items: center; gap: 12px; margin: 6px 0 8px; }
.version-history-bar .small { color: var(--muted); }

/* ====== GEO page ============================================================== */
.geo-layout {
  display: grid; grid-template-columns: 200px 1fr; gap: 0;
  min-height: 320px;
}
.geo-topic-list {
  display: flex; flex-direction: column; gap: 1px;
  border-right: 1px solid var(--border-subtle);
  padding: 10px 0; min-width: 0;
}
.geo-topic-item {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 9px 14px; background: none; border: none; cursor: pointer;
  text-align: left; transition: background var(--dur-1) var(--ease);
  border-left: 2px solid transparent; min-width: 0; width: 100%;
}
.geo-topic-item:hover { background: var(--hover-1); }
.geo-topic-item.active {
  background: var(--accent-weak); border-left-color: var(--accent);
}
.geo-topic-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.geo-detail { padding: 16px 20px; }
.geo-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 6px; }
.geo-chart-card {
  background: var(--surface-inset); border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.geo-chart-stat { display: flex; align-items: baseline; gap: 10px; }
.geo-big-num { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.geo-chart-axis {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted); letter-spacing: 0.01em;
}



/* ====== Phase separation: pre-publish (indigo) vs post-publish (green) =========
   Tweaks-panel switchable ("Phase zones" toggle). Tinted backdrop zones only —
   no label text: sidebar groups, dashboard bands, and each routed page sit on a
   faint phase-colored surface. Pre-publish rides the existing indigo accent,
   post-publish the ok green, so both themes (and carnival) re-tint for free. */
.herald-window { --phase-pre: var(--accent); --phase-post: var(--ok); --phase-ops: var(--warning); }

/* Sidebar zones — each phase's nav groups gathered on one tinted surface.
   Dark mode needs a stronger mix to read against the deep bg; light stays subtle. */
.dash-nav .nav-zone { margin: 12px -6px 0; padding: 0 6px 8px; border-radius: 14px; --zmix: 10%; --zring: 22%; }
.herald-window.light .dash-nav .nav-zone { --zmix: 6%; --zring: 13%; }
.dash-nav .nav-zone .group-label { margin: 12px 0 5px; }
.dash-nav .nav-zone.pre {
  background: color-mix(in srgb, var(--phase-pre) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-pre) var(--zring), transparent);
}
.dash-nav .nav-zone.post {
  background: color-mix(in srgb, var(--phase-post) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-post) var(--zring), transparent);
}
.dash-nav .nav-zone.ops {
  background: color-mix(in srgb, var(--phase-ops) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-ops) var(--zring), transparent);
}
/* Active item's icon takes the phase hue instead of generic accent */
.dash-nav.phased a.ph-pre.active .ni { color: var(--phase-pre); }
.dash-nav.phased a.ph-post.active .ni { color: var(--phase-post); }
.dash-nav.phased a.ph-ops.active .ni { color: var(--phase-ops); }

/* Page backdrop zones — every routed page's content sits on its phase tint */
.page-zone, .phase-band { --zmix: 7%; --zring: 17%; }
.herald-window.light .page-zone, .herald-window.light .phase-band { --zmix: 4%; --zring: 10%; }
.page-zone { border-radius: 18px; padding: 16px 16px 18px; max-width: 1680px; margin-inline: auto; }
.page-zone.pre {
  background: color-mix(in srgb, var(--phase-pre) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-pre) var(--zring), transparent);
}
.page-zone.post {
  background: color-mix(in srgb, var(--phase-post) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-post) var(--zring), transparent);
}
.page-zone.ops {
  background: color-mix(in srgb, var(--phase-ops) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-ops) var(--zring), transparent);
}

/* Dashboard phase bands — same backdrop language as the page zones */
.phase-band { margin-bottom: 20px; border-radius: 18px; padding: 16px 16px 18px; }
.phase-band.pre {
  background: color-mix(in srgb, var(--phase-pre) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-pre) var(--zring), transparent);
}
.phase-band.post {
  background: color-mix(in srgb, var(--phase-post) var(--zmix), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--phase-post) var(--zring), transparent);
}
.pb-stack { display: grid; gap: 16px; }
.pb-stack > .kpi-strip, .pb-stack > .cols-2 { margin: 0; }
.pb-cols { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; align-items: start; }
.pb-col-label {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.6px; margin-bottom: 9px; font-weight: 600;
}


/* ---- pages.css (Pages screen additions) ---- */
/* ====== Pages screen (list + page-entity detail) ============================
   Loaded after modern.css; uses its tokens. */

/* ---- status pills ---- */
.status-pill.pg-published { color: var(--ok); background: var(--ok-weak); }
.status-pill.pg-draft { color: var(--warning); background: var(--warn-weak); }
.status-pill.pg-archived { color: var(--muted); background: var(--surface-3); }

/* ---- detail header ---- */
.pg-back-row { margin: 14px 0 10px; }
.pg-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.pg-head-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pg-head-id .page-url.large { font-size: 17px; }
.pg-head-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---- two-column zone: live view | provenance + connections ---- */
.pg-cols { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1180px) { .pg-cols { grid-template-columns: 1fr; } }

/* ---- live-view browser frame ---- */
.live-frame {
  border: 1px solid var(--border-subtle); border-radius: 10px; overflow: hidden;
  background: var(--surface-2);
}
.lf-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--surface-3); border-bottom: 1px solid var(--border-subtle);
}
.lf-dot { width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--text) 18%, transparent); }
.lf-url {
  flex: 1; margin-left: 8px; padding: 3px 12px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border-subtle);
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lf-open { color: var(--accent); font-size: 13px; text-decoration: none; padding: 0 4px; }
.lf-open:hover { text-decoration: underline; }
.lf-page { max-height: 600px; overflow: auto; }
.lf-doc { position: relative; padding: 0 0 2px; }

/* ---- page skeleton blocks (wireframe of the live page) ---- */
.lf-doc .sk-nav {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle); margin-bottom: 14px;
}
.sk-brand { width: 26px; height: 14px; border-radius: 3px; background: color-mix(in srgb, var(--text) 22%, transparent); }
.sk-pill { width: 44px; height: 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--text) 12%, transparent); }
.sk-pill.cta { margin-left: auto; width: 64px; height: 16px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sk-h1 { width: 62%; height: 18px; border-radius: 4px; margin: 6px 18px 10px; background: color-mix(in srgb, var(--text) 18%, transparent); }
.sk-meta { width: 30%; height: 8px; border-radius: 4px; margin: 0 18px 16px; background: color-mix(in srgb, var(--text) 9%, transparent); }
.sk-p { display: flex; flex-direction: column; gap: 7px; margin: 0 18px 18px; }
.sk-p span { display: block; height: 7px; border-radius: 4px; background: color-mix(in srgb, var(--text) 9%, transparent); }
.sk-toc {
  display: flex; flex-direction: column; gap: 8px; width: 46%;
  margin: 0 18px 18px; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border-subtle); background: color-mix(in srgb, var(--text) 3%, transparent);
}
.sk-toc span { display: block; height: 6px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 32%, transparent); }
.sk-table {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  margin: 0 18px 18px; padding: 8px; border-radius: 8px; border: 1px solid var(--border-subtle);
}
.sk-table span { display: block; height: 14px; border-radius: 3px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.sk-table span:nth-child(-n+4) { background: color-mix(in srgb, var(--text) 14%, transparent); }
.sk-img {
  height: 96px; margin: 0 18px 18px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border-subtle);
  background: repeating-linear-gradient(45deg, transparent, transparent 7px,
    color-mix(in srgb, var(--text) 5%, transparent) 7px, color-mix(in srgb, var(--text) 5%, transparent) 14px);
}
.sk-img.tall { height: 140px; }
.sk-img span { font-family: var(--font-mono, ui-monospace, monospace); font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.sk-cta { display: block; width: 168px; height: 30px; border-radius: var(--r-pill); margin: 0 18px 18px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.sk-form {
  display: flex; flex-direction: column; gap: 10px; margin: 0 18px 18px;
  padding: 16px; border-radius: 8px; border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.sk-field { display: block; height: 22px; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--surface-2); }
.sk-field.tall { height: 56px; }
.sk-faq { display: flex; flex-direction: column; gap: 10px; margin: 0 18px 18px; }
.sk-faq-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border-subtle); border-radius: 7px; }
.sk-faq-row i { width: 8px; height: 8px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 40%, transparent); }
.sk-faq-row b { height: 7px; border-radius: 4px; background: color-mix(in srgb, var(--text) 11%, transparent); }
.sk-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 18px 18px; }
.sk-gallery .sk-img.sq { height: 86px; margin: 0; }
.sk-specs { display: flex; flex-direction: column; gap: 9px; margin: 0 18px 18px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: 8px; }
.sk-spec-row { display: flex; align-items: center; gap: 14px; }
.sk-spec-row b { height: 7px; border-radius: 4px; background: color-mix(in srgb, var(--text) 15%, transparent); }
.sk-spec-row i { height: 7px; border-radius: 4px; background: color-mix(in srgb, var(--text) 7%, transparent); }
.sk-footer {
  display: flex; gap: 24px; padding: 18px; margin-top: 4px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.sk-footer span { display: block; width: 90px; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--text) 14%, transparent); }

/* ---- overlays ---- */
.lf-overlay { position: absolute; inset: 0; pointer-events: none; }
.hm-cell {
  position: absolute; border-radius: 50%; transform: scale(2);
  background: radial-gradient(circle,
    color-mix(in srgb, var(--trescored) 85%, transparent) 0%,
    color-mix(in srgb, var(--trescored) 40%, transparent) 48%,
    transparent 74%);
}
.sc-band { position: absolute; left: 0; width: 100%; border-top: 1px dashed color-mix(in srgb, var(--accent) 38%, transparent); }
.sc-band b {
  position: absolute; right: 8px; top: 4px;
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 10px; font-weight: 700;
  color: var(--accent); background: var(--surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill); padding: 1px 7px;
}
.hm-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.hm-scale {
  width: 90px; height: 8px; border-radius: var(--r-pill);
  background: linear-gradient(90deg, transparent, var(--trescored));
  border: 1px solid var(--border-subtle);
}

/* ---- provenance timeline ---- */
.prov-list { display: flex; flex-direction: column; }
.prov-row { position: relative; display: flex; align-items: baseline; gap: 12px; padding: 0 0 14px 22px; }
.prov-row::before {
  content: ""; position: absolute; left: 4.5px; top: 6px; bottom: -4px;
  width: 1px; background: var(--border-subtle);
}
.prov-row:last-child::before { display: none; }
.prov-dot {
  position: absolute; left: 0; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 3px var(--surface-2);
}
.prov-dot.accent { background: var(--accent); }
.prov-dot.ok { background: var(--ok); }
.prov-dot.red { background: var(--trescored); }
.prov-dot.warn { background: var(--warning); }
.prov-dot.mut { background: var(--muted); }
.prov-date {
  flex: 0 0 76px; font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.prov-label { font-size: 12.5px; line-height: 1.45; }
.prov-label code { font-size: 11px; }

/* ---- V2 nav active-state bridge ---------------------------------------------
   leptos_router's <A> marks the active link with aria-current="page" rather
   than an `.active` class, so the design system's `.dash-nav a.active` rules
   (modern.css) don't fire on their own. Alias aria-current to the same
   floating-pill treatment, including the per-phase icon tint. */
.dash-nav a[aria-current="page"] {
  color: var(--text); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  backdrop-filter: var(--blur-1); -webkit-backdrop-filter: var(--blur-1);
}
.dash-nav a[aria-current="page"] .ni { color: var(--accent); opacity: 1; }
.dash-nav.phased a.ph-pre[aria-current="page"] .ni { color: var(--phase-pre); }
.dash-nav.phased a.ph-post[aria-current="page"] .ni { color: var(--phase-post); }
.dash-nav.phased a.ph-ops[aria-current="page"] .ni { color: var(--phase-ops); }

/* ---- V2 PR 3 restyle bridge -------------------------------------------------
   The pre-V2 screens render content in flat `.kpi-section` blocks with bare
   `<h2>` page titles. The design system frames sections as frosted, levitating
   `.panel`s and sizes page titles as `.dash-head h2`. Bridge those here so the
   restyle-only screens (dashboard, analytics, seo, geo, competitors, sales)
   adopt the V2 look without per-screen markup churn. Pure restyle — no
   structural or behavior change. (Component classes — tables, tiles, tags,
   filters, funnel, donut, charts — are already covered by modern.css above.) */

/* Page titles: the screens render a bare <h2> as the page heading (sections
   use <h3>, modals use <h3>), so sizing <h2> here hits page titles only. */
.herald-window h2 {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.1;
  /* Page titles sit directly above the first content block (north-star card,
     filter bar, …) which carries no top margin — give the title breathing
     room so it doesn't crowd what follows (AC #16 dashboard, #18 keywords). */
  margin-bottom: 20px;
}

/* Flat content sections → frosted, levitating panels. */
.herald-window .kpi-section {
  background: var(--surface-2);
  backdrop-filter: var(--blur-1) saturate(1.5);
  -webkit-backdrop-filter: var(--blur-1) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  border-radius: var(--r-3);
  padding: 20px;
  margin-bottom: 22px;
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.herald-window .kpi-section:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2);
}
.herald-window .kpi-section > h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

/* GEO chart cards: geo.rs uses .geo-chart; give it the .geo-chart-card frame. */
.herald-window .geo-chart {
  background: var(--surface-inset);
  border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring);
  padding: 12px 14px;
}

/* ====== 22. RESPONSIVE HARDENING (appended last — wins the cascade) =========
   The shell is a fixed 224px rail + fluid content column (.herald-window, which
   never stacks). These rules keep that content column coherent as the effective
   width shrinks — window resize OR browser zoom both change the CSS-px width.
   Scope: desktop/zoom resilience only — no mobile drawer, tables keep their
   existing horizontal scroll. */

/* Multi-column content grids that otherwise have no collapse → single column
   once the content area gets tight. At a 1024px viewport the content column is
   only ~800px after the 224px rail, below which asymmetric splits crush. The
   .cols-2.even / specific selectors are listed explicitly to out-specify their
   base two-column rules. */
@media (max-width: 1024px) {
  .cols-2, .cols-2.even, .an-grid, .pb-cols, .triage-cols, .form-grid,
  .kw-meta, .metric-row, .geo-charts, .geo-layout, .stage-reference {
    grid-template-columns: 1fr;
  }
}

/* Keep the topbar's flex children able to shrink so they never force the page
   wider than the viewport at narrow/zoomed widths. */
.dash-topbar { min-width: 0; }
.freshness { min-width: 0; }
