/* ============================================================================
   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) 68%, white 5%);
  --surface-3: color-mix(in srgb, var(--panel) 60%, white 9%);
  --surface-4: color-mix(in srgb, var(--panel) 90%, white 9%);
  --surface-inset: color-mix(in srgb, var(--bg) 50%, black 30%);
  --border-subtle: color-mix(in srgb, var(--border) 40%, transparent);
  --border-strong: color-mix(in srgb, var(--border) 80%, white 10%);
  --text-subtle: color-mix(in srgb, var(--muted) 58%, var(--bg));
  --tp-1: color-mix(in srgb, var(--surface-3) 15%, transparent);
  --blur-1: blur(8px);
  --blur-2: blur(15px);

  /* 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: "Fraunces", Georgia, "Times New Roman", serif;
  --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);
  /* h2 is Fraunces and needs room (muddy below ~24px); h3 raised to match. */
  --fs-h3: 24px;
  --fs-h2: 36px;
  --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-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
/* Only the big headings get the Fraunces display serif (it muddies below
   ~24px); h3-h6 stay on the sans body family. */
h1, h2 { font-family: var(--font-display); }
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-2);
  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); }
.banner-edit { display: flex; gap: 8px; align-items: center; max-width: 640px; }
.banner-edit input { flex: 1; }
.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: 500; 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; 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-2) 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); }
/* Run detail badge: ready_for_review reads green like approved (both later pick
   up the ok-weak background from the competitors-page block). */
.kw-tag.status-ready_for_review { color: var(--ok); border: 1px solid var(--ok-soft); background: var(--ok-weak); }
.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); }

/* Topic evidence readiness pill (same look as .coverage). */
.readiness { 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); }
.readiness.rich { color: var(--ok); border-color: var(--ok-soft); }
.readiness.adequate { color: var(--warning); border-color: var(--warn-soft); }
.readiness.thin { 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); }
}

/* Inline button spinner (components::spinner::Spinner) — pure CSS ring,
   currentColor so it matches every button variant's text color. */
.spinner {
  display: inline-block;
  width: 1em; height: 1em;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner + *, * + .spinner { margin-left: 0 } /* keep spacing simple; add a gap where used */
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.6s; } }

/* ===== 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;
  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;
  padding: 6px 13px; border-radius: var(--r-pill);
  background: var(--surface-2); 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); border-color: var(--accent) }
.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-title h2 { margin: 0; }
.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 > h2 { 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-checkbox { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

/* Definition grid for page metadata (label / value pairs). */
.kw-def-grid { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--sp-3); margin: var(--sp-2) 0; font-size: 12.5px; }
.kw-def-grid dt { color: var(--muted); }
.kw-def-grid dd { margin: 0; }

/* One row per publish target: name, status badge, link, and actions. */
.kw-publish-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); padding: 7px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-xs); }
.kw-publish-row:last-of-type { border-bottom: none; }
.kw-publish-name { min-width: 110px; }
.kw-publish-row .kw-actions { margin-left: auto; }
.kw-publish-row .kpi-warn { flex-basis: 100%; }

/* The page status chip is a primary signal on the content page — scale it up. */
.page-status-chip .status-chip { font-size: 13px; padding: 6px 14px; letter-spacing: 0.07em; }
.page-status-chip .status-chip.editable::after { font-size: 10px; }

.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 container is defined once, near the .status-chip rules below. */
.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); margin: var(--sp-2) 10px; 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; }

/* ---- Content page: Editorial Desk layout (AC-309 redesign) ---- */
/* Cover hero: the page as readers meet it. Scrim is intentionally dark
   in both themes so title/chips stay legible over any featured image. */
/* No overflow:hidden here — it would clip the status-chip popover that opens
   downward past the hero. Corner rounding lives on the bg/scrim layers below. */
.page-hero { position: relative; border-radius: var(--r-4); min-height: 240px; display: flex; align-items: flex-end; box-shadow: var(--sh-2); margin-bottom: var(--sp-4); }
.page-hero .hero-bg { position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(120% 120% at 20% 0%, color-mix(in srgb, var(--accent) 45%, transparent), transparent 60%), linear-gradient(135deg, #2a3350, #141824 70%); background-size: cover; background-position: center; }
.page-hero .hero-scrim { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(0deg, rgba(6,8,14,0.92) 6%, rgba(6,8,14,0.35) 55%, rgba(6,8,14,0.55)); }
.page-hero .hero-inner { position: relative; padding: var(--sp-5) var(--sp-6); width: 100%; }
.page-hero .hero-eyebrow { color: rgba(255,255,255,0.78); font-size: 12px; letter-spacing: 0.02em; font-family: var(--font-mono); }
.page-hero .hero-eyebrow .muted { color: rgba(255,255,255,0.55); }
.page-hero h1 { color: #fff; font-size: clamp(24px, 3vw + 12px, 40px); margin: var(--sp-2) 0 var(--sp-3); max-width: 22ch; line-height: 1.08; }
.page-hero-chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.page-hero-chips .chip-kind { font-size: 11.5px; font-weight: 600; padding: 4px 11px; border-radius: var(--r-pill); background: rgba(255,255,255,0.16); color: #fff; }

/* Vitals strip: the page's glance-layer numbers. */
.page-vitals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border-subtle); border: 1px solid var(--border-subtle); border-radius: var(--r-3); overflow: hidden; margin-bottom: var(--sp-3); }
.page-vitals .vital { background: var(--surface-2); padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: 3px; }
.page-vitals .vital .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.page-vitals .vital .v { font-family: var(--font-display); font-size: 18px; font-variant-numeric: tabular-nums; }

/* Desk: side panels beside the article reading column. */
.page-desk { display: grid; grid-template-columns: 320px 1fr; gap: var(--sp-4); align-items: start; margin-top: var(--sp-3); }
.page-desk .desk-side { display: flex; flex-direction: column; gap: var(--sp-3); position: sticky; top: var(--sp-3); }
.page-desk .desk-card { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: var(--sp-4); box-shadow: var(--sh-1); }
.page-desk .desk-card .kw-meta-label { margin-bottom: var(--sp-3); }
.page-desk .desk-main { min-width: 0; }

/* Search-snippet style header above the article body. */
.seo-head { display: flex; flex-direction: column; gap: 4px; padding: var(--sp-3) var(--sp-4); background: var(--surface-inset); border: 1px solid var(--border-subtle); border-radius: var(--r-2); }
.seo-head .t { color: #6ea8ff; font-size: 15px; }
.seo-head .u { color: var(--ok); font-size: 12px; font-family: var(--font-mono); }
.seo-head .d { color: var(--muted); font-size: 12.5px; }

@media (max-width: 900px) {
  .page-desk { grid-template-columns: 1fr; }
  .page-desk .desk-side { position: static; order: 2; }
  .page-desk .desk-main { order: 1; }
  .page-vitals { grid-template-columns: repeat(2, 1fr); }
}

/* 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); }

/* Oregon Trail — the one DOM (non-canvas) lab game. */
.oregon { width: 100%; max-width: 560px; }
.oregon-panel { display: flex; flex-direction: column; gap: var(--sp-3); width: 100%; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-3); padding: var(--sp-5) var(--sp-6); box-shadow: var(--sh-1); }
.oregon-title { margin: 0; font-size: 20px; letter-spacing: 0.04em; text-align: center; }
.oregon-intro { text-align: center; }
.oregon-jobs { display: flex; flex-direction: column; gap: var(--sp-2); }
.oregon-jobs .btn-primary { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.oregon-job-label { font-weight: 700; }
.oregon-job-hint { text-align: center; }
.oregon-names { display: flex; flex-direction: column; gap: var(--sp-2); }
.oregon-name-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.oregon-name-input { flex: 1 1 90px; min-width: 0; padding: 6px 8px; background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); color: var(--text); font-size: 13px; }
.oregon-month { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.oregon-wallet { display: flex; align-items: baseline; gap: var(--sp-2); }
.oregon-money { font-family: var(--font-mono); font-weight: 700; font-size: 20px; color: var(--accent); font-variant-numeric: tabular-nums; }
.oregon-store { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.oregon-buy { display: flex; justify-content: space-between; gap: var(--sp-2); }
.oregon-menu { display: flex; flex-direction: column; gap: var(--sp-2); }
.oregon-status { display: flex; flex-direction: column; gap: var(--sp-2); font-variant-numeric: tabular-nums; }
.oregon-status-head, .oregon-progress, .oregon-party, .oregon-hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
.oregon-date { font-weight: 700; }
.oregon-sick { margin: 0; }
.oregon-supplies { display: flex; flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-2) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 13px; }
.oregon-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.oregon-message { text-align: center; }
.oregon-message-text { white-space: pre-line; line-height: 1.5; margin: 0; }
.oregon-hunt { text-align: center; }
.oregon-hunt-stage { display: flex; align-items: center; justify-content: center; min-height: 88px; border: 1px dashed var(--border); border-radius: var(--r-2); background: var(--surface-inset); font-size: 15px; }
.oregon-hunt-stage.aim { border-style: solid; border-color: var(--accent); }
.oregon-target { font-size: 24px; font-weight: 800; color: var(--accent); }

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

/* =========================================================================
   Run-summary header + vertical stage timeline (run detail page).
   Ported from the design mock; styled entirely through the base tokens so
   the .light theme inverts automatically. Replaces the old chip stepper +
   "Stages" accordion.
   ========================================================================= */

/* ---- run-summary header ---- */
.run-summary { display: flex; flex-direction: column; gap: 15px; margin-bottom: 8px; }
.run-summary-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.run-summary-head { min-width: 0; }
.run-summary-top .kw-actions { margin-top: 0; }
.run-subtitle { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.run-subtitle .dotsep { opacity: 0.45; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.run-summary .stat {
  background: var(--surface-1); border: 1px solid var(--border-subtle);
  border-radius: var(--r-3); padding: 11px 13px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.run-summary .stat-k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.run-summary .stat-v { font-size: 19px; font-weight: 640; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.run-summary .stat-unit { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.run-summary .stat-sub { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.run-summary .stat-bar { margin-top: 6px; height: 4px; border-radius: 999px; background: var(--surface-inset); overflow: hidden; }
.run-summary .stat-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ok), var(--accent)); width: 0; transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }

.stages-h { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 24px 0 12px; padding-top: 18px; border-top: 1px solid var(--border-subtle); }

/* ---- per-state tint variables (consumed by bead / tag / line) ---- */
.stage-timeline .st-row.s-done     { --c: var(--ok);     --cw: var(--ok-weak);     --cs: var(--ok-soft); }
.stage-timeline .st-row.s-failed   { --c: var(--danger); --cw: var(--danger-weak); --cs: var(--danger-soft); }
.stage-timeline .st-row.s-active   { --c: var(--accent); --cw: var(--accent-weak); --cs: var(--accent-soft); }
.stage-timeline .st-row.s-pending,
.stage-timeline .st-row.s-upcoming { --c: var(--muted);  --cw: transparent;        --cs: var(--border); }

/* Per-section live commit-graph for the draft stage: one branch per outline
   part off an indigo spine (done + the writer are indigo — green is reserved
   for completed top-level stages), with a comet on the leading edge writer→next.
   State drives --c/--cs like the stage rows. */
.stage-timeline .st-branch.s-done     { --c: var(--accent); --cs: var(--accent-weak); }
.stage-timeline .st-branch.s-active   { --c: var(--accent); --cs: var(--accent-weak); }
.stage-timeline .st-branch.s-failed   { --c: var(--danger); --cs: var(--danger-soft); }
.stage-timeline .st-branch.s-upcoming { --c: var(--muted);  --cs: color-mix(in srgb, var(--muted) 18%, transparent); }

/* While the commit-graph is shown, the single-box io-grid is suppressed. */
/* Higher specificity than `.st-io-grid { display: grid }` (defined later) so
   the hide wins: when the section tree is up, drop the stage-level prompt +
   output boxes and keep only the per-section output boxes. */
.st-io-grid.st-io-hidden { display: none; }
.st-tree-wrap { margin-top: 2px; }
.st-tree-head { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 2px 0 9px 2px; }
.st-branch { display: grid; grid-template-columns: 26px 1fr; column-gap: 11px; align-items: start; }
.st-branch-rail { position: relative; align-self: stretch; }
.st-branch-trunk { position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.st-tree .st-branch:first-child .st-branch-trunk { top: 12px; }
.st-tree .st-branch:last-child .st-branch-trunk { bottom: calc(100% - 18px); }
/* the indigo spine: done sections full indigo; the writer goes grey below its
   bead (heading to the queued next); queued stays border-grey. */
.st-branch.s-done .st-branch-trunk   { background: var(--accent); }
.st-branch.s-active .st-branch-trunk { background: linear-gradient(180deg, var(--accent) 0 12px, var(--border) 13px); }
.st-branch-curve { position: absolute; left: 8px; top: 5px; width: 11px; height: 10px; border-left: 2px solid var(--c); border-bottom: 2px solid var(--c); border-bottom-left-radius: 8px; }
.st-branch-bead { position: absolute; left: 15px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2.5px var(--cs), 0 0 0 2px var(--panel); z-index: 2; }
.st-branch.s-active .st-branch-bead { animation: st-sec-breathe 1.9s ease-in-out infinite; }
@keyframes st-sec-breathe { 0%, 100% { box-shadow: 0 0 0 2.5px var(--accent-weak), 0 0 0 2px var(--panel); } 50% { box-shadow: 0 0 0 3.5px var(--accent-weak), 0 0 10px 1px var(--accent-soft), 0 0 0 2px var(--panel); } }
/* comet rides the writer's trunk into the next branch; anchored bead→below so it
   self-sizes to however long the streamed text runs. */
.st-branch-comet { display: none; }
.st-branch.s-active .st-branch-comet { display: block; position: absolute; left: 8px; width: 2px; top: 11px; bottom: -9px; overflow: hidden; pointer-events: none; z-index: 1; }
.st-branch.s-active .st-branch-comet::after { content: ""; position: absolute; left: -1px; right: -1px; top: 0; height: 30%; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 55%, white) 55%, var(--accent) 78%, transparent); animation: st-sec-comet 1.5s cubic-bezier(.5, 0, .6, 1) infinite; will-change: transform; }
@keyframes st-sec-comet { from { transform: translateY(-110%); } to { transform: translateY(360%); } }

.st-branch-body { min-width: 0; padding-bottom: 12px; }
.st-branch-line1 { display: flex; align-items: baseline; gap: 9px; }
.st-branch-title { font-weight: 600; font-size: 12.5px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-branch-lede { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.st-branch-peek { font-size: 11px; color: color-mix(in srgb, var(--muted) 78%, transparent); margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-branch-peek.st-branch-fail { color: var(--danger); }
.st-branch-out { max-height: 150px; margin-top: 7px; }
.st-status { font-size: 9px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 7px; border-radius: 999px; color: var(--c); background: var(--cs); white-space: nowrap; flex: none; margin-left: auto; }
@media (prefers-reduced-motion: reduce) {
  .st-branch.s-active .st-branch-bead, .st-branch.s-active .st-branch-comet::after { animation: none !important; }
  .st-branch.s-active .st-branch-comet::after { top: 64%; opacity: .9; }
}

/* ---- the rail ---- */
.stage-timeline { display: flex; flex-direction: column; }
.st-row { display: grid; grid-template-columns: 30px 1fr; gap: 12px; position: relative; }
.st-row.s-upcoming { opacity: 0.5; }
.st-gutter { display: flex; flex-direction: column; align-items: center; position: relative; }
.st-line {
  position: absolute; top: 0; bottom: 0; width: 2px; left: 50%; transform: translateX(-50%);
  background-color: var(--border); transition: background-color 0.45s ease; overflow: hidden;
}
.st-row:first-child .st-line { top: 14px; }
.st-row:last-child .st-line { bottom: auto; height: 14px; }
.st-line.done { background-color: var(--ok); }
/* Active segment: a dim energized track plus a green→accent streak that
   shoots from the running bead down to the next stage, clipped between them. */
.st-line.active { background-color: color-mix(in srgb, var(--accent) 18%, var(--border)); }
.st-line.active::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 42%;
  background: linear-gradient(180deg, transparent, var(--ok) 35%, var(--accent) 68%, transparent);
  animation: st-comet 1.2s linear infinite; will-change: transform;
}
.st-bead {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; z-index: 1; margin-top: 2px;
  background: linear-gradient(var(--cw), var(--cw)), var(--panel); border: 2px solid var(--c); color: var(--c);
  transition: border-color 0.4s ease, color 0.4s ease, box-shadow 0.35s ease;
}
.st-glyph { font-weight: 800; font-size: 11px; line-height: 1; display: inline-flex; transition: opacity 0.25s ease; }
.st-row.s-active .st-bead { box-shadow: 0 0 0 5px var(--accent-weak); animation: st-ring 1.5s ease-out infinite; }
.st-row.s-active .st-glyph { animation: st-glyph-pulse 1.2s ease-in-out infinite; }

.st-body { padding-bottom: 14px; min-width: 0; }
.st-head {
  display: flex; align-items: center; gap: 9px; cursor: pointer; background: none; border: 0;
  font: inherit; color: var(--text); padding: 3px 0; width: 100%; text-align: left;
}
.st-head:hover .st-name { color: var(--accent); }
.st-head-static { cursor: default; }
.st-head-static:hover .st-name { color: var(--text); }
.st-name { font-size: 14px; font-weight: 600; }
.st-twist { color: var(--muted); font-size: 9px; transition: transform 0.2s; }
.st-head[aria-expanded="true"] .st-twist { transform: rotate(90deg); }
.st-metaline { color: var(--muted); font-size: 11px; margin-left: auto; font-variant-numeric: tabular-nums; }
/* Re-run badge ("#2") on a stage head — appears only when a stage looped. */
.st-attempt { font-size: 10px; padding: 1px 6px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); border-radius: 8px; }

/* ---- expandable detail pop (animated grid-rows trick) ---- */
.st-pop { overflow: hidden; display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.st-pop.open { grid-template-rows: 1fr; margin-top: 6px; }
.st-pop-inner { min-height: 0; }
.st-detail { display: grid; gap: 13px; padding-bottom: 4px; }
.st-meta-row { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.st-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-meta b { color: var(--text); font-weight: 600; }
.st-tag { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 1.5px 8px; border-radius: var(--r-pill); color: var(--c); border: 1px solid var(--cs); }
.st-blurb { font-style: italic; color: var(--muted); font-size: 12.5px; margin: 0; line-height: 1.5; }
.st-retry {
  appearance: none; margin-left: auto; border: 1px solid var(--border); background: var(--surface-1); color: var(--muted);
  font: inherit; font-size: 11.5px; padding: 4px 11px; border-radius: var(--r-2); cursor: pointer; transition: 0.15s;
}
.st-retry:hover:not(:disabled) { border-color: var(--accent-soft); color: var(--accent); }

/* ---- Review verdict board (review stage detail panel) ----
   Summary banner (verdict + stats + severity spectrum) over one card per
   judge; the deterministic-checks pseudo-judge card is dashed + mono so it
   reads as machine output, not a model verdict. */
.kw-tag.sev-high { color: var(--danger); border: 1px solid var(--danger-soft); margin-left: 0; }
.kw-tag.sev-medium { color: var(--warning); border: 1px solid var(--warn-soft); margin-left: 0; }
.kw-tag.sev-low { color: var(--muted); border: 1px solid var(--border); margin-left: 0; }
.kw-tag.review-pass { color: var(--ok); border: 1px solid var(--ok-soft); }
.kw-tag.review-fail { color: var(--danger); border: 1px solid var(--danger-soft); }
.kw-tag.rv-det-tag { color: var(--muted); border: 1px dashed var(--border-strong); font-family: var(--font-mono); text-transform: none; letter-spacing: 0; margin-left: 0; }

.rv-board { display: grid; gap: 11px; }
.rv-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px;
  border: 1px solid var(--border); border-radius: var(--r-2);
  background: var(--surface-inset); padding: 12px 15px;
}
.rv-verdict { display: flex; align-items: center; gap: 10px; }
.rv-verdict-glyph {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; flex: none;
  color: var(--danger); border: 2px solid var(--danger); background: var(--danger-weak);
}
.rv-verdict-glyph.pass { color: var(--ok); border-color: var(--ok); background: var(--ok-weak); }
.rv-verdict-text { line-height: 1.25; }
.rv-verdict-text b { font-size: 13.5px; font-weight: 650; display: block; }
.rv-verdict-text span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rv-stats { display: flex; gap: 20px; margin-left: auto; }
.rv-stat { text-align: right; }
.rv-stat b { display: block; font-size: 17px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.15; }
.rv-stat span { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.rv-sevbar { flex-basis: 100%; height: 5px; border-radius: 999px; overflow: hidden; display: flex; background: var(--surface-3); }
.rv-sevbar i { display: block; height: 100%; }
.rv-sevbar .h, .rv-sevbar-key .h { background: var(--danger); }
.rv-sevbar .m, .rv-sevbar-key .m { background: var(--warning); }
.rv-sevbar .l, .rv-sevbar-key .l { background: var(--muted); opacity: 0.55; }
.rv-sevbar-key { flex-basis: 100%; margin-top: -6px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rv-sevbar-key i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 4px; }
.rv-sevbar-key i:not(:first-child) { margin-left: 8px; }

.rv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 640px) { .rv-grid { grid-template-columns: 1fr; } }
.rv-card {
  border: 1px solid var(--border); border-radius: var(--r-2);
  background: var(--surface-1); overflow: hidden; display: flex; flex-direction: column;
}
.rv-card.fail { border-color: color-mix(in srgb, var(--danger) 34%, var(--border)); }
.rv-card.det { border-style: dashed; background: transparent; }
.rv-card-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  border-bottom: 1px solid var(--border-subtle); background: var(--surface-2);
}
.rv-card.det .rv-card-head { background: transparent; }
.rv-card-model { font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-card.det .rv-card-model { font-family: var(--font-mono); font-weight: 500; color: var(--muted); }
.rv-card-head .kw-tag:last-child { margin-left: auto; }
.rv-card-body { padding: 9px 11px 11px; display: grid; gap: 8px; align-content: start; flex: 1; }
.rv-finding { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; font-size: 12px; line-height: 1.5; }
.rv-finding .kw-tag { align-self: start; margin-top: 1px; }
.rv-cat { color: var(--muted); font-size: 11px; }
.rv-fix { grid-column: 2; color: var(--muted); font-size: 11.5px; }
.rv-fix::before { content: "→ "; color: var(--accent); }
.rv-none { color: var(--muted); font-size: 11.5px; font-style: italic; margin: 0; }
.rv-card-foot { padding: 6px 11px; border-top: 1px solid var(--border-subtle); font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.rv-prompt > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; user-select: none;
}
.rv-prompt > summary::-webkit-details-marker { display: none; }
.rv-prompt > summary::before { content: "▸"; font-size: 9px; transition: transform 0.2s; }
.rv-prompt[open] > summary::before { transform: rotate(90deg); }
.rv-prompt > summary:hover { color: var(--accent); }
.rv-prompt > summary .st-copy { position: static; margin-left: auto; box-shadow: none; backdrop-filter: none; }
.rv-prompt .st-pre { margin-top: 7px; }

/* ---- I/O boxes ---- */
.st-io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 620px) { .st-io-grid { grid-template-columns: 1fr; } }
.st-io-head { display: flex; align-items: center; gap: 8px; margin: 0 0 5px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.st-pre-wrap { position: relative; }
.st-copy {
  position: absolute; top: 7px; right: 10px; z-index: 2; appearance: none;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 88%, transparent); color: var(--muted);
  padding: 4px; border-radius: var(--r-1); cursor: pointer; display: inline-grid; place-items: center;
  backdrop-filter: blur(3px); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.st-io-head .st-copy { position: static; margin-left: auto; box-shadow: none; backdrop-filter: none; }
.st-copy:hover { border-color: var(--accent-soft); color: var(--accent); }
.st-copy.copied { color: var(--ok); border-color: var(--ok-soft); }
.st-pre {
  background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); padding: 10px 11px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; margin: 0;
  overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.st-pre-img { display: grid; place-items: center; }
.st-pre-img img { max-height: 180px; border-radius: var(--r-1); }
.st-pre::-webkit-scrollbar { width: 11px; height: 11px; }
.st-pre::-webkit-scrollbar-track { background: transparent; }
.st-pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
.st-pre::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
.st-json { font-size: 12px; }
.st-json summary { cursor: pointer; color: var(--muted); font-size: 11px; margin-bottom: 6px; }

/* Blinking cursor while a stage streams its output. */
.st-caret { display: inline-block; width: 7px; height: 1.05em; margin-left: 1px; vertical-align: -2px; background: var(--accent); border-radius: 1px; animation: st-blink 1s steps(1) infinite; }

@keyframes st-comet { from { transform: translateY(-105%); } to { transform: translateY(245%); } }
@keyframes st-ring { 0% { box-shadow: 0 0 0 0 var(--accent-soft); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes st-glyph-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.32; } }
@keyframes st-blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .st-line.active::after, .st-row.s-active .st-bead, .st-row.s-active .st-glyph, .st-caret { animation: none !important; }
  .st-pop { transition: none; }
}

/* 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");
}
/* Fraunces — editorial display serif for the wordmark. Self-hosted (latin
   subset, variable: weight 400-700 + optical-size 9-144), no runtime external
   request. See --font-display and .dash-brand .word. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/Fraunces.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/Fraunces-Italic.woff2") format("woff2");
}
/* DotGothic16 — dot-matrix face for the top-bar ticker (LED-sign look).
   Self-hosted latin subset. */
@font-face {
  font-family: "DotGothic16";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/DotGothic16.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;
}
/* ---- Faint background waves ------------------------------------------------
   A z-index:-1 layer: paints above the shell's base gradient but below all
   content, so the frost aprons and frosted panels have slow motion to blur —
   that's what sells the glass. Two huge, heavily-blurred radial swells drift
   and breathe on long, offset loops; their overlap shifting reads as a slow
   wave of light. Transform/opacity only (GPU), low opacity, stilled for
   reduced-motion.

   The blobs are 200vmax and centred (translate ~-50%), so the box always
   straddles far past every viewport edge — no box edge or blur cut can ever
   enter view, at any phase of the drift. No layer rotation/clip (that was what
   swept a sharp edge into frame). */
/* Soft fade-in for swapped page content so SPA navigation reads as a settle,
   not a refresh. The shell (sidebar/top-bar/waves) stays mounted; only the
   route view inside .page-shell remounts, so this animation replays per nav.
   `both` holds the from-state during the initial frame to avoid a flash. */
.page-shell > * { animation: page-fade 220ms var(--ease, ease) both; }
@keyframes page-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .page-shell > * { animation: none; }
}

.hw-waves { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
/* One tint layer per phase, stacked. Each paints the two drifting blobs in its
   own colour; only the active zone's layer is shown. A zone change cross-fades
   by transitioning *opacity* (old layer out, new layer in) — bulletproof where
   interpolating a gradient's colour stop is not. Driven by a zone-* class on
   the shell root (set in lib.rs). */
.hw-layer {
  position: absolute; inset: 0; opacity: 0;
  transition: opacity 1600ms var(--ease, ease);
}
.hw-base { opacity: 1; --z1: var(--ambient-1); --z2: var(--accent-soft); }
.hw-pre  { --z1: color-mix(in srgb, var(--phase-pre)  24%, transparent); --z2: color-mix(in srgb, var(--phase-pre)  34%, transparent); }
.hw-post { --z1: color-mix(in srgb, var(--phase-post) 24%, transparent); --z2: color-mix(in srgb, var(--phase-post) 34%, transparent); }
.hw-ops  { --z1: color-mix(in srgb, var(--phase-ops)  24%, transparent); --z2: color-mix(in srgb, var(--phase-ops)  34%, transparent); }
.hw-layer::before, .hw-layer::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 200vmax; height: 200vmax; border-radius: 50%;
  filter: blur(80px); opacity: 0.5; will-change: transform;
}
.hw-layer::before {
  background: radial-gradient(closest-side, var(--z1), transparent 70%);
  animation: hw-swell-a 30s ease-in-out infinite alternate;
}
.hw-layer::after {
  background: radial-gradient(closest-side, var(--z2), transparent 72%);
  animation: hw-swell-b 36s ease-in-out infinite alternate;
}
/* Active zone fades in; the neutral base fades out under it. */
.herald-window.zone-pre  .hw-pre,
.herald-window.zone-post .hw-post,
.herald-window.zone-ops  .hw-ops  { opacity: 1; }
.herald-window.zone-pre  .hw-base,
.herald-window.zone-post .hw-base,
.herald-window.zone-ops  .hw-base { opacity: 0; }
/* Translate stays within ~±8% of -50%, so the centre drifts a good ~30vmax
   while every edge keeps a huge off-screen margin. */
@keyframes hw-swell-a {
  from { transform: translate3d(-58%, -56%, 0) scale(1); }
  to   { transform: translate3d(-44%, -46%, 0) scale(1.1); }
}
@keyframes hw-swell-b {
  from { transform: translate3d(-44%, -45%, 0) scale(1.08); }
  to   { transform: translate3d(-57%, -57%, 0) scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .hw-layer::before, .hw-layer::after { animation: none; }
  .hw-layer { transition: none; }
}

.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. */
/* isolation:isolate makes this a stacking context so the z-index:-1 .hw-waves
   layer paints above the shell's (opaque) background but below all content. */
.herald-window { position: relative; isolation: isolate; }
.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 .word {
  font-family: var(--font-display);
  /* High optical size = more contrast & character (the masthead look). */
  font-variation-settings: "opsz" 144;
  font-style: italic;
  font-weight: 700; font-size: 50px; letter-spacing: 0; line-height: 1;
  color: var(--text);
}
.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; }
/* Small ghost button that swaps the left slot between status chips and the
   announcement marquee. Muted by default; tints to accent when the marquee is
   showing (.on). */
.tb-view-toggle {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border-radius: 8px;
  color: var(--muted); background: transparent; cursor: pointer;
  transition: color var(--dur-1, 140ms) var(--ease, ease),
              background var(--dur-1, 140ms) var(--ease, ease);
}
.tb-view-toggle:hover { color: var(--text); background: var(--accent-weak); }
.tb-view-toggle.on { color: var(--accent); background: var(--accent-weak); }

/* Top-bar ticker. Fills the bar (only renders when toggled on); edges fade via
   a mask so text dissolves in/out instead of hard-clipping. The track is padded
   to start at the right edge (padding-left:100%) and translates fully off the
   left, looping — a classic announcement crawl. It always animates: the
   keyframes + a default duration live here, so motion never depends on JS;
   banner.rs only refines the duration for a constant pixel speed. */
.tb-marquee {
  flex: 1 1 auto; min-width: 0; overflow: hidden;
  font-family: "DotGothic16", ui-monospace, monospace;
  /* 16px = the font's native grid, so the dots land on whole pixels and stay
     crisp (off-grid sizes fuzz a bitmap-style face). No glow — the bloom read
     as blur. */
  font-size: 16px; color: var(--accent); line-height: 1.4;
  letter-spacing: 0.04em;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}
.tb-marquee-track {
  display: inline-block; white-space: nowrap;
  /* padding-left:100% parks the text exactly at the right edge at translateX:0,
     so the pass always enters from the component edge — no JS measurement in
     that path. */
  padding-left: 100%;
  will-change: transform;
  /* One pass: enter from the right edge, run off the left, and hold there
     (`both`). The component then remounts with the next (random) message, which
     restarts this animation. JS sets the constant-speed duration; the fallback
     keeps it moving if JS never runs. */
  animation: tb-marquee-loop var(--marquee-loop-dur, 20s) linear 1 both;
}

/* Lab game-picker variant: static (you navigate it with the keyboard), centred,
   no scroll — the same LED look as the ticker. */
.tb-marquee.tb-lab { display: flex; align-items: center; justify-content: center; }
.tb-marquee.tb-lab .tb-lab-text { animation: tb-lab-pulse 1.1s ease-in-out infinite; }
@keyframes tb-lab-pulse { 50% { opacity: 0.55; } }
/* Pause on hover/focus so it can be read. */
.tb-marquee:hover .tb-marquee-track,
.tb-marquee:focus-within .tb-marquee-track {
  animation-play-state: paused;
}
@keyframes tb-marquee-loop {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* Reduced motion: hold it still, anchored at the left so it's readable (drop
   the off-screen pad); the marquee swaps messages on a timer instead of
   scrolling. Full text is in the DOM for screen readers and in the title. */
@media (prefers-reduced-motion: reduce) {
  .tb-marquee-track { animation: none; padding-left: 0; }
}
.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; }
/* Give edge cells the same 20px breathing room as the flush-panel head, so an
   edge-to-edge table (e.g. the keyword panel) doesn't squish against the sides.
   Scoped to flush panels — interior column padding is left to the table class. */
.panel.flush .seo-table td:first-child, .panel.flush .seo-table th:first-child { padding-left: 20px; }
.panel.flush .seo-table td:last-child, .panel.flush .seo-table th:last-child { padding-right: 20px; }
.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; }
/* House delta token: ▲/▼ % figure, tone by direction. Shared by the KPI strip
   and the analytics trend header so their arrows read the same weight/colour. */
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.ok { color: var(--ok); }
.delta.danger { color: var(--danger); }
.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;
}

/* ---- 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-head .delta { font-size: 13px; }  /* legible beside the 28px value */
.tc-cap { margin-left: auto; }
.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; }
/* Shared uppercase section label; matches .metric .ml so the two read as one.
   14px bottom margin lines the channel list up with the metric-row rhythm. */
.col-label { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 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 {
  display: flex; align-items: stretch; gap: 16px;
  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-body { flex: 1 1 auto; min-width: 0; }
/* Right column: target label on top, action buttons pinned to the card bottom. */
.appr-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; text-align: right; }
.appr-target { max-width: 150px; line-height: 1.35; }
.appr-side .appr-actions { margin-top: auto; }
.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-title-link { color: inherit; text-decoration: none; }
.appr-title-link:hover .appr-title { color: var(--accent); text-decoration: underline; }

/* /content/actions/{id} — the recommended-action walkthrough's pipeline
   stepper: past stages dim, the current one carries the accent. */
.action-walk { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; max-width: 72ch; }
.action-walk li { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: var(--r-2); }
.action-walk li .walk-step { font-weight: 600; font-size: 13px; }
.action-walk li.done { border-left-color: var(--ok); opacity: 0.65; }
.action-walk li.current { border-left-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.action-walk li.current .walk-step { color: var(--accent); }
.appr-diag { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin-bottom: 12px; }
.appr-meta { display: flex; gap: 16px 18px; flex-wrap: wrap; margin: 10px 0 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; margin-bottom: 1px; }
.appr-stat .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.appr-stat .v.ev { color: var(--ok); }
/* Measured-outcome strip: shown only once the winning application is scored. */
.appr-outcome { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.appr-outcome-tag { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 9.5px; font-weight: 600; }
.appr-lift { font-weight: 650; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.appr-lift.ok { color: var(--ok); }
.appr-lift.danger { color: var(--danger); }
.appr-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.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,
.geo-params select, .geo-params input:not([type="checkbox"]) {
  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, .geo-params 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,
.geo-params select:hover, .geo-params input:not([type="checkbox"]):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,
.geo-params select:focus, .geo-params input:not([type="checkbox"]):focus {
  outline: none; box-shadow: inset 0 0 0 1.5px var(--accent-soft), var(--sh-1);
}
/* geo_scores run-params: topic on its own row, provider + model side by side,
   each label spaced off its control so they don't read as jammed. */
.geo-params { display: flex; flex-direction: column; gap: var(--sp-3); }
.geo-params .form-field { display: flex; flex-direction: column; gap: var(--sp-1); font-size: 12px; color: var(--muted); }
.geo-params .form-field select, .geo-params .form-field input { width: 100%; box-sizing: border-box; }
.geo-params-row { display: flex; gap: var(--sp-3); }
.geo-params-row .form-field { flex: 1; min-width: 0; }
.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; }

/* Watchlist picker: the "+ New" row and its inline create input live inside
   the .status-pop panel itself. */
.watchlist-new-row { color: var(--accent); }
.watchlist-new-pop {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
}
.watchlist-new-pop input { min-width: 9rem; flex: 1; }

/* 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 {
  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-4); 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); }

/* ===== Content-centre pipeline spine ===== */
/* Scoped header (own class so the shared .dash-head stays untouched). */
.cc-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin: 14px 0 22px; }
.cc-head .eyebrow { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.cc-head h2 { font-family: var(--font-display); font-weight: 560; font-size: clamp(26px, 3.6vw, 34px); line-height: 1.05; letter-spacing: -0.03em; }
.cc-head .sub { color: var(--muted); font-size: 14px; margin-top: 7px; max-width: 62ch; }
.cc-head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.cc-stat { display: flex; gap: 22px; text-align: right; }
.cc-stat .hsv { font-family: var(--font-display); font-size: 22px; font-weight: 540; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cc-stat .hsl { font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-subtle); font-weight: 600; margin-top: 1px; }
.cc-head-tools { display: flex; gap: 9px; align-items: center; }

.spine-wrap {
  background: var(--surface-2); border: 1px solid var(--panel-ring);
  border-radius: var(--r-3); padding: 18px 10px 16px; margin-bottom: 18px;
  box-shadow: var(--sh-1); position: relative; overflow: hidden;
}
.spine-legend {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 0 14px 14px; margin: 0 4px; border-bottom: 1px solid var(--border-subtle);
  font-size: 11.5px; color: var(--text-subtle);
}
.spine-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.spine-legend .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.spine-legend .sw-ok { background: var(--ok); }
.spine-legend .sw-run { background: var(--accent); }
.spine-legend .sw-warn { background: var(--warning); }
.spine-legend .grow { flex: 1; }

.spine {
  display: flex; align-items: stretch; gap: 9px; overflow-x: auto;
  padding: 18px 10px 16px;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.spine::-webkit-scrollbar { height: 9px; }
.spine::-webkit-scrollbar-track { background: var(--surface-inset); border-radius: var(--r-pill); margin: 0 12px; }
.spine::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: content-box; }
.spine::-webkit-scrollbar-thumb:hover { background: var(--accent-soft); background-clip: content-box; }
.spine-stage {
  flex: 1 0 170px; position: relative; display: flex; flex-direction: column; text-align: left;
  background: var(--tp-1); backdrop-filter: var(--blur-1); -webkit-backdrop-filter: var(--blur-1);
  border: 1px solid var(--panel-ring); border-radius: var(--r-2);
  padding: 15px 16px; color: var(--text); cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.spine-stage:hover { border-color: var(--border-strong); }
.spine-stage.on {
  background: linear-gradient(180deg, var(--accent-weak), var(--tp-1) 86%);
  border-color: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-soft);
}
.spine-stage.on::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px;
  height: 3px; border-radius: 3px; background: var(--accent);
}
.spine-stage .spine-kick { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-subtle); font-weight: 700; }
.spine-stage .spine-name {
  font-family: var(--font-sans); font-size: 18px; letter-spacing: -0.02em; margin-top: 5px; font-weight: 560; line-height: 1;
}
.spine-stage.on .spine-name { color: var(--accent); }
.spine-stage .spine-route { font-family: var(--font-mono); font-size: 10px; color: var(--text-subtle); margin-top: 3px; }
.spine-stage .spine-count {
  font-family: var(--font-sans); font-size: 30px; letter-spacing: -0.03em; line-height: 1;
  margin-top: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.spine-stage .spine-count small { font-size: 12px; color: var(--muted); font-family: var(--font-sans); letter-spacing: 0; margin-left: 4px; }
.spine-stage .spine-foot { margin-top: 11px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap; }
.cc-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cc-pill.p-run { color: var(--accent); background: var(--accent-weak); }
.cc-pill.p-ok { color: var(--ok); background: var(--ok-weak); }
.cc-pill.p-warn { color: var(--warning); background: var(--warn-weak); }
.cc-pill.p-mut { color: var(--muted); background: var(--surface-inset); }
.cc-pill.p-mut::before { opacity: 0.55; }
.cc-health { height: 5px; border-radius: 3px; background: var(--surface-inset); overflow: hidden; margin-top: 11px; }
.cc-health i { display: block; height: 100%; width: 100%; border-radius: 3px; }
.cc-health i.h-ok { background: var(--ok); }
.cc-health i.h-warn { background: var(--warning); }
.cc-health i.h-stalled { background: var(--danger); }

/* Inputs feeding the line */
.spine-inputs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 18px 2px; margin: 8px 4px 0; border-top: 1px dashed var(--border-subtle); }
.spine-libs-label { font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-subtle); font-weight: 700; margin-right: 2px; }
.cc-lib {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--panel-ring); border-radius: var(--r-1);
  padding: 7px 12px; color: var(--text); box-shadow: var(--sh-1);
  transition: border-color var(--dur-1) var(--ease);
}
.cc-lib:hover { border-color: var(--accent-soft); }
.cc-lib .ln { font-size: 12px; font-weight: 600; }
.cc-lib .lx { font-size: 10.5px; color: var(--muted); }

/* Proposal queue: whole row opens the detail (approve lives there, not here). */
.seo-row-link { cursor: pointer; }
.seo-row-link:hover { background: var(--hover-1); }
.review-link { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* Proposal detail: drafted-content diff vs the live page. */
.diff-summary { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.diffbox { background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-2); overflow: hidden; font-family: var(--font-mono); font-size: 12px; }
.diffbox .drow { display: flex; gap: 10px; padding: 3px 12px; }
.diffbox .drow .mk { width: 10px; flex: 0 0 auto; color: var(--muted); }
.diffbox .drow .tx { color: var(--muted); word-break: break-word; }
.diffbox .drow.add { background: var(--ok-weak); }
.diffbox .drow.add .mk { color: var(--ok); }
.diffbox .drow.add .tx { color: var(--text); }
.diffbox .drow.del { background: var(--danger-weak); }
.diffbox .drow.del .mk { color: var(--danger); }
.drafted-preview { margin-top: 12px; }
.drafted-preview > summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.drafted-body { margin-top: 10px; max-height: 420px; overflow-y: auto; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-2); }

/* New-run drop-down (replaces the modal) — drops from the New run button. */
.newrun-dd { background: var(--surface-2); border: 1px solid var(--accent-soft); border-radius: var(--r-3); box-shadow: var(--sh-2); padding: var(--sp-4); margin: 0 0 16px; }

/* ===== Content-library managers (images / prompts / templates) ===== */
.mgr-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.mgr-tools .btn-primary { margin-left: auto; }
.mgr { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .mgr { grid-template-columns: 1fr 340px; } .mgr.wide { grid-template-columns: 1fr minmax(360px, 1fr); } }
.mgr-main { min-width: 0; }
.mgr-side { position: sticky; top: 12px; }
.mgr-editor, .mgr-placeholder { background: var(--surface-2); border: 1px solid var(--panel-ring); border-radius: var(--r-3); padding: 14px 16px; box-shadow: var(--sh-1); }
.mgr-placeholder { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 16px; }

/* Image grid */
.imgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 13px; }
.imgtile { text-align: left; background: transparent; border: none; padding: 0; color: var(--text); cursor: pointer; position: relative; }
.imgtile .thumb-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-2); border: 2px solid transparent; box-shadow: var(--sh-1); display: block; background: var(--surface-inset); }
.imgtile.on .thumb-img { border-color: var(--accent); }
.imgtile .icap { font-size: 12px; margin-top: 7px; color: var(--text); font-weight: 500; line-height: 1.35; }
.imgtile .imeta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.imgtile.retired .thumb-img { filter: grayscale(0.75) brightness(0.82); }
.imgtile.retired .icap { color: var(--muted); }
.stbadge { position: absolute; top: 7px; left: 7px; z-index: 1; font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--bg) 72%, transparent); color: #fff; }

/* Prompt two-pane */
.plist { display: flex; flex-direction: column; }
.pgrp-l { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-subtle); font-weight: 700; padding: 12px 8px 6px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-2); cursor: pointer; border: 1px solid transparent; }
.prow:hover { background: var(--hover-1); }
.prow.on { background: var(--accent-weak); border-color: var(--accent-soft); }
.prow .pk { font-family: var(--font-mono); font-size: 12px; color: var(--text); flex: 1; }
.prow .pv { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-subtle); }
.vrail { margin-top: 16px; }
.vrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border-subtle); font-size: 12px; }
.vrow .vv { font-family: var(--font-mono); color: var(--text); min-width: 32px; }
.vrow .vd { color: var(--muted); flex: 1; font-size: 11px; }
.vrow .vcur { font-size: 10px; color: var(--ok); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* Template list + stage-chain editor */
.tlist { display: flex; flex-direction: column; gap: 2px; }
.trow { display: flex; align-items: center; gap: 10px; padding: 11px 10px; border-radius: var(--r-2); cursor: pointer; border: 1px solid transparent; }
.trow:hover { background: var(--hover-1); }
.trow.on { background: var(--accent-weak); border-color: var(--accent-soft); }
.trow .tnm { font-weight: 600; font-size: 12.5px; flex: 1; display: flex; align-items: center; gap: 7px; }
.trow .tsub { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); }
.chain { display: flex; flex-direction: column; margin-top: 4px; }
.cstage { display: flex; align-items: center; gap: 10px; padding: 9px 4px; }
.cstage + .cstage { border-top: 1px solid var(--border-subtle); }
.cnode { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); box-shadow: 0 0 0 3px var(--surface-2); }
.cstage.gen .cnode { background: var(--accent); }
.cstage.sys .cnode { background: var(--warning); }
.cbody { flex: 1; min-width: 0; }
.cname { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.cname .lk { font-size: 10px; color: var(--text-subtle); font-weight: 500; }
.cmeta { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); margin-top: 2px; }
.cstage.locked { opacity: 0.6; }

/* 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. */
/* 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;
}

/* Calendar occasion themes (calendar.rs). Layered over .light/.dark, so only
   override the tokens you want to re-tint — example: Yule. Copy this block for
   new occasions; the class name must match the row's `theme` in calendar.rs. */
.herald-window.holiday-xmas {
  --accent: #C8102E;
  --accent-weak: rgba(200, 16, 46, 0.10);
  --accent-soft: rgba(200, 16, 46, 0.34);
  --data-1: #1A7A3C;
}

/* ====== 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; }
/* Drag-and-drop reorder feedback: grab cursor on the handle, the dragged row
   dims, and the hovered drop target shows an insertion line along its top edge
   so it's obvious where the row will land. */
.stage-grip { cursor: grab; }
.stage-editable-row.dragging { opacity: 0.45; }
.stage-editable-row.drag-over td { box-shadow: inset 0 2px 0 0 var(--accent); }
.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); }

/* ====== KPI grid cards: frosted glass floating on the app ======================
   --shell resolves to the active page's hue (indigo pre / green post / amber ops),
   so the left-edge hover highlight and the active card both light up in the same
   colour as the page shell. Scoped to .kpi-grid so the lean .kpi-strip tiles
   (marketing dash) are untouched; higher specificity wins over the global
   .kpi-tile strip rules. */
.herald-window           { --shell: var(--accent); }
.herald-window.zone-pre  { --shell: var(--phase-pre); }
.herald-window.zone-post { --shell: var(--phase-post); }
.herald-window.zone-ops  { --shell: var(--phase-ops); }

.kpi-grid .kpi-tile {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  backdrop-filter: var(--blur-2);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 20px;
  border: 1px solid var(--border);
  /* White-glass slab: outer drop shadow floats it, inset highlights give the
     thin rounded-edge sheen; ::before/::after light the top + left rims. */
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 var(--border),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 6px 0 rgba(255, 255, 255, 0.1);
  padding: var(--sp-4);
}
.kpi-grid .kpi-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--shell) 2%, rgba(255, 255, 255, 0.05)), transparent);
}
.kpi-grid .kpi-tile::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), transparent, rgba(255, 255, 255, 0.3));
}
/* Selectable (non-static) tiles tint their fill toward --shell — half strength,
   white border kept (no indigo border) so only static tiles ever change border. */
.kpi-grid .kpi-tile.selectable:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: color-mix(in srgb, var(--shell) 3%, rgba(255, 255, 255, 0.18));
}
.kpi-grid .kpi-tile.selectable.selected {
  border-color: rgba(255, 255, 255, 0.2);
  background: color-mix(in srgb, var(--shell) 7%, rgba(255, 255, 255, 0.18));
}

/* 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); }

/* ---- paginated-table first-load skeleton (shared, see paginated_table.rs) ----
   Shimmer bars inside real <td>s under the real header, so a loading table
   shows its chrome immediately and rows swap in when the first page lands. */
.skl-row td { padding-block: 13px; }
.skl-bar {
  display: block; height: 12px; border-radius: 6px;
  width: 72%;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--text) 7%, transparent) 25%,
    color-mix(in srgb, var(--text) 15%, transparent) 37%,
    color-mix(in srgb, var(--text) 7%, transparent) 63%);
  background-size: 400% 100%;
  animation: skl-shimmer 1.4s ease-in-out infinite;
}
/* A little width variety per column so it doesn't look like a barcode. */
.skl-row td:first-child .skl-bar { width: 40%; }
.skl-row td:nth-child(3n) .skl-bar { width: 56%; }
.skl-row td:nth-child(4n) .skl-bar { width: 84%; }
@keyframes skl-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skl-bar { animation: none; } }
.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; }

/* ===== Colombian Independence Day (Jul 20) — .indep-co, see calendar.rs ===== */

/* Flag colors clipped to the glyphs: yellow fills the top half, blue then red
   the quarters below — the tricolor bands of the bandera. Scoped to the
   wordmark + headings so body copy stays readable. */
.indep-co .dash-brand .word,
.indep-co h1, .indep-co .sk-h1 {
  background: linear-gradient(180deg,
    #FCD116 0%, #FCD116 50%,
    #003893 50%, #003893 75%,
    #CE1126 75%, #CE1126 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Occasion avatar accessory. The topbar rolls .co-fit-0..3 once per page load
   (topbar.rs); each variant is a data-URI SVG on ::before. Inert off-occasion —
   only .indep-co gives the pseudo any content. */
.indep-co .tb-avatar { overflow: visible; width: 48px; height: 48px; }
/* Photo cutouts (assets/co/): variants 0/2/3 replace the avatar circle
   entirely — the celeb face fills the circle, initials hidden via transparent
   color. Variant 1 keeps the normal avatar and perches the sombrero vueltiao
   on top. */
.indep-co .co-fit-0,
.indep-co .co-fit-2,
.indep-co .co-fit-3,
.indep-co .co-fit-4,
.indep-co .co-fit-5,
.indep-co .co-fit-6 { color: transparent; }
.indep-co .co-fit-0 { background: url("/assets/co/valderrama.png") center/cover no-repeat; }
.indep-co .co-fit-2 { background: url("/assets/co/shakira.png") center/cover no-repeat; }
.indep-co .co-fit-3 { background: url("/assets/co/betty.png") center 30%/cover no-repeat; }
.indep-co .co-fit-4 { background: url("/assets/co/karolg.png") center/cover no-repeat; }
.indep-co .co-fit-5 { background: url("/assets/co/jbalvin.png") center/cover no-repeat; }
.indep-co .co-fit-6 { background: url("/assets/co/james.png") center/cover no-repeat; }
/* Sombrero vueltiao cursor. Hotspot at the crown's tip (16 2); `auto`
   fallback keeps text/pointer cursors usable if the image fails to load.
   ponytail: one cursor everywhere (also over links/text) — per-control
   cursors if anyone misses the I-beam. */
.indep-co, .indep-co * {
  cursor: url("/assets/co/sombrero-cursor.png") 16 2, auto;
}

.indep-co .co-fit-1::before {
  content: "";
  position: absolute;
  left: 50%; top: -17px;
  width: 48px; height: 28px;
  transform: translateX(-50%);
  pointer-events: none;
  background: url("/assets/co/sombrero.png") center/contain no-repeat;
}

/* Coffee-brew minigame (install_click_beans + BrewState, calendar.rs).
   Clicks toss beans that arc and settle at the bottom of the screen; at 100
   piled beans a "¿Colar café?" button appears; brewing sucks every bean to
   screen center and pops a flash that resolves to "☕ × cups". */
.co-bean {
  position: fixed;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  pointer-events: none;
  z-index: 40; /* same layer as the butterflies: under modals */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg transform='rotate(25 10 10)'%3E%3Cellipse cx='10' cy='10' rx='6' ry='9' fill='%236F4E37'/%3E%3Cpath d='M10 2.5 C 7 7, 13 13, 10 17.5' stroke='%233E2A1E' stroke-width='1.6' fill='none'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
  animation: co-bean-pop 0.8s forwards; /* duration overridden per bean (JS) */
}
/* Ballistic toss with two bounces. Per-keyframe cubic-beziers fake the
   physics: decelerate to the apex, accelerate into the floor, then two
   damped bounces (--bounce, then 30% of it) while the horizontal drift
   carries through. ponytail: pure CSS — a rAF engine only if beans ever
   need to collide with each other. */
@keyframes co-bean-pop {
  0% {
    transform: translate(0, 0) rotate(0);
    animation-timing-function: cubic-bezier(0.25, 0.8, 0.5, 1);
  }
  26% {
    transform: translate(calc(var(--dx) * 0.38), var(--up)) rotate(calc(var(--rot) * 0.35));
    animation-timing-function: cubic-bezier(0.45, 0, 0.85, 0.4);
  }
  60% {
    transform: translate(calc(var(--dx) * 0.78), var(--down)) rotate(calc(var(--rot) * 0.8));
    animation-timing-function: cubic-bezier(0.2, 0.85, 0.55, 1);
  }
  74% {
    transform: translate(calc(var(--dx) * 0.89), calc(var(--down) - var(--bounce, 18px))) rotate(calc(var(--rot) * 0.92));
    animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.45);
  }
  86% {
    transform: translate(calc(var(--dx) * 0.95), var(--down)) rotate(var(--rot));
    animation-timing-function: cubic-bezier(0.25, 0.85, 0.6, 1);
  }
  93% {
    transform: translate(calc(var(--dx) * 0.98), calc(var(--down) - var(--bounce, 18px) * 0.3)) rotate(var(--rot));
    animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.5);
  }
  100% { transform: translate(var(--dx), var(--down)) rotate(var(--rot)); }
}
/* Brewing: each bean is re-based at its resting spot by JS, then swarms to
   screen center (--gx/--gy) and shrinks away into the flash. */
.co-bean.grind {
  animation: co-bean-suck 0.45s ease-in forwards;
}
@keyframes co-bean-suck {
  to { transform: translate(var(--gx), var(--gy)) rotate(360deg) scale(0.2); opacity: 0.6; }
}
.co-brew-btn {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 41; /* above the bean pile */
}
/* The flash is a point anchored at --fx/--fy (the brew target: topbar cup
   after the first brew, screen center before); burst + "cup × n" center on
   that point via the translate baked into their keyframes. */
.co-brew-flash {
  position: fixed;
  left: var(--fx, 50vw); top: var(--fy, 50vh);
  pointer-events: none;
  z-index: 41;
}
.co-flash-burst {
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #FCD116 55%, transparent 72%);
  animation: co-flash-pop 0.5s ease-out forwards;
}
@keyframes co-flash-pop {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  70%  { transform: translate(-50%, -50%) scale(14); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(18); opacity: 0; }
}
.co-flash-cups {
  position: absolute; left: 0; top: 0;
  display: flex; align-items: center; gap: 10px;
  font-size: 40px; font-weight: 700; white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  animation: co-cups-in 1.4s ease-out forwards;
}
@keyframes co-cups-in {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
  30%  { transform: translate(-50%, -50%) scale(1); }
  80%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
/* Topbar cup counter + cafeteros dropdown (details/summary, same skeleton
   as .tb-usermenu), and the minimised game's bean-aware brew action. */
.co-cup { flex: none; }
.tb-brew-btn {
  flex: none; font-size: 12px; padding: 4px 10px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tb-coffee > summary {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px; font-variant-numeric: tabular-nums;
  padding: 4px 8px; border-radius: var(--r-1); white-space: nowrap;
}
/* Opens La Tienda (the docked shop panel) from the cafeteros dropdown. */
.tb-tienda-open {
  display: block; width: calc(100% - 16px); margin: 4px 8px 8px;
  font-size: 12px; letter-spacing: 0.08em; padding: 6px 10px;
}

/* Bean HUD (bottom-left): count + income rate + frenzy badge. */
.co-hud {
  position: fixed; left: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: var(--r-2);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1);
  font-size: 13px; font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 41;
}
.co-hud-rate { color: var(--muted); }
/* El Ritmo: the tap-combo meter — fills red→gold, flashes at the top. */
.co-hud-combo {
  position: relative; overflow: hidden;
  width: 74px; height: 16px; border-radius: 8px;
  background: color-mix(in srgb, var(--muted) 22%, transparent);
  box-shadow: inset 0 0 0 1px var(--panel-ring);
  flex: none;
}
.co-hud-combo-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(to right, #c8102e, #FCD116);
  transition: width 0.12s linear;
}
.co-hud-combo-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}
.co-hud-combo.hot { animation: co-combo-hot 0.35s ease-in-out infinite alternate; }
@keyframes co-combo-hot {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}
.co-hud-frenzy {
  font-weight: 700; color: #b8860b;
  animation: co-frenzy-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes co-frenzy-pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.25); }
}

/* Floating "+N" at the click point: drifts up and fades (JS removes it). */
.co-plus {
  position: fixed;
  transform: translateX(-50%);
  font-size: 13px; font-weight: 700; color: #7a5c00;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 42;
  animation: co-plus-up 0.9s ease-out forwards;
}
@keyframes co-plus-up {
  0%   { transform: translateX(-50%) translateY(0); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-42px); opacity: 0; }
}

/* Golden bean: drifts across the screen with a bobbing glow; clickable
   (the one interactive .co-* element — everything else is decoration). */
.co-golden {
  position: fixed;
  width: 26px; height: 26px;
  cursor: pointer;
  z-index: 45;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg transform='rotate(25 10 10)'%3E%3Cellipse cx='10' cy='10' rx='6' ry='9' fill='%23E7B416'/%3E%3Cpath d='M10 2.5 C 7 7, 13 13, 10 17.5' stroke='%23A87900' stroke-width='1.6' fill='none'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(252, 209, 22, 0.9));
  animation: co-golden-fly 11s linear forwards, co-golden-bob 0.9s ease-in-out infinite alternate;
}
@keyframes co-golden-fly {
  from { translate: 0 0; }
  to   { translate: var(--gdx) 0; }
}
@keyframes co-golden-bob {
  from { margin-top: -8px; }
  to   { margin-top: 8px; }
}
.tb-coffee > summary:hover { background: var(--hover-1); }
.tb-coffee-menu { min-width: 220px; }
.tb-coffee-title {
  font-size: 11px; letter-spacing: 0.08em; color: var(--muted);
  padding: 4px 8px 6px; border-bottom: 1px solid var(--panel-ring);
}
.tb-coffee-list {
  list-style: none; margin: 0; padding: 4px 0 0;
  display: flex; flex-direction: column; gap: 2px;
}
.tb-coffee-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 4px 8px; font-size: 13px;
}
.tb-coffee-score {
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---- La Tienda (P1): docked shop panel, calendar::Tienda ---- */
.co-tienda {
  position: fixed; right: 16px; top: 64px;
  width: 330px; max-height: calc(100vh - 92px);
  display: flex; flex-direction: column;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-2);
  border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-2, 0 12px 40px rgba(0, 0, 0, 0.35));
  z-index: 46; /* above the golden bean, below modals */
  font-size: 13px;
}
.co-tienda-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-ring);
  position: sticky; top: 0; background: inherit; z-index: 1;
}
.co-tienda-title { font-size: 12px; letter-spacing: 0.14em; font-weight: 700; }
.co-tienda-cups {
  display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.co-tienda-close { font-size: 18px; line-height: 1; padding: 0 4px; }
.co-tienda-rate {
  padding: 7px 14px; color: var(--muted); font-size: 12px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--panel-ring);
}
.co-tienda-sacos-pct { color: #b8860b; font-weight: 600; }
.co-tienda-rows { display: flex; flex-direction: column; }
.co-trow {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 9px;
  border-bottom: 1px solid var(--panel-ring);
}
.co-trow-icon { flex: none; width: 26px; display: flex; justify-content: center; }
.co-trow-glyph { font-size: 18px; }
.co-trow-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.co-trow-name { font-weight: 600; white-space: nowrap; }
.co-trow-owned { color: var(--muted); font-size: 12px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.co-trow-meta { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.co-trow-lack { color: #c0392b; }
.co-trow-buy {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 5px 9px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.co-trow-done { flex: none; color: #2e7d32; font-weight: 600; font-size: 12px; }
/* Thin affordability bar along the row's bottom edge: fills as cups accrue
   toward this row's price — the ×1.15 curve made visible. */
.co-trow-afford {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: #b8860b; opacity: 0.7;
  transition: width 0.4s ease;
  pointer-events: none;
}
.co-tienda-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--panel-ring);
}
.co-mult { font-size: 12px; padding: 3px 10px; }
.co-mult.on { outline: 2px solid #b8860b; }
.co-tienda-note { margin-left: auto; color: var(--muted); font-size: 11px; }
.co-cosecha {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px 14px;
}
.co-cosecha-title { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); }
.co-cosecha-line { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.co-cosecha-sell { font-size: 12.5px; }

/* Mejoras de finca: the tier's ×2 upgrade row, indented under its producer. */
.co-trow-up { padding-left: 30px; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.co-trow-up.locked { opacity: 0.55; }
.co-mute { margin-left: 2px; }
/* Logros: the badge wall at the tienda's foot. */
.co-logros { padding: 0 14px 14px; border-top: 1px solid var(--panel-ring); }
.co-logros-toggle {
  font-size: 11px; letter-spacing: 0.14em; padding: 10px 0 6px;
  font-variant-numeric: tabular-nums;
}
.co-logros-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.co-badge {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px 5px; border-radius: var(--r-1);
  box-shadow: inset 0 0 0 1px var(--panel-ring);
  text-align: center;
}
.co-badge-glyph { font-size: 18px; line-height: 1; }
.co-badge-name { font-size: 9px; color: var(--muted); line-height: 1.2; }
.co-badge.locked { opacity: 0.35; filter: grayscale(1); }

/* La chiva: the bonus bus driving the skyline; each click knocks a sack off. */
.co-chiva {
  position: fixed; bottom: 4px; left: -130px;
  cursor: pointer;
  z-index: 45; /* clickable, same layer as the golden bean */
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  animation: co-chiva-drive 16s linear forwards, co-chiva-rumble 0.28s linear infinite alternate;
}
@keyframes co-chiva-drive {
  to { translate: calc(100vw + 260px) 0; }
}
@keyframes co-chiva-rumble {
  from { margin-bottom: 0; }
  to   { margin-bottom: 2px; }
}

/* ---- Finca skyline (P2): pixel producers along the bottom edge ---- */
.co-skyline {
  position: fixed; left: 0; right: 0; bottom: 0; height: 0;
  pointer-events: none;
  z-index: 39; /* just under the bean pile */
}
.co-sprite {
  position: absolute; bottom: 2px;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

/* ---- Event FX (P4/P6), calendar::CoffeeFx ---- */
/* Golden-frenzy vignette: the ×7 window is felt at the screen edges. */
.co-frenzy-glow {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 44;
  box-shadow: inset 0 0 90px 12px rgba(252, 209, 22, 0.35);
  animation: co-glow-pulse 0.9s ease-in-out infinite alternate;
}
@keyframes co-glow-pulse {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}
/* El aguacero: a sheet of slanted rain scrolling down the screen. */
.co-aguacero {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 44;
  background:
    repeating-linear-gradient(75deg,
      transparent 0 7px,
      rgba(150, 195, 255, 0.28) 7px 8px,
      transparent 8px 15px);
  animation: co-rain-fall 0.5s linear infinite;
}
@keyframes co-rain-fall {
  from { background-position: 0 0; }
  to   { background-position: -26px 100px; }
}
/* La roya: a pulsing rust blotch squatting on the harvest; each click
   shrinks it via --roya-scale until it's gone. */
.co-roya {
  position: fixed;
  width: 64px; height: 64px;
  margin: -32px 0 0 -32px;
  border: none; border-radius: 50%;
  cursor: pointer;
  z-index: 45;
  color: #fff; font-size: 18px; font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  background: radial-gradient(circle at 40% 35%,
    #d97e2f 0%, #a4551c 45%, #6e3a12 75%, rgba(110, 58, 18, 0) 100%);
  filter: drop-shadow(0 0 8px rgba(164, 85, 28, 0.8));
  transform: scale(var(--roya-scale, 1));
  animation: co-roya-throb 0.7s ease-in-out infinite alternate;
}
@keyframes co-roya-throb {
  from { transform: scale(var(--roya-scale, 1)); }
  to   { transform: scale(calc(var(--roya-scale, 1) * 1.12)); }
}
/* Milestone confetti (P6): flag-colored flecks tossed from the top. */
.co-confetti {
  position: fixed; top: -12px;
  width: 8px; height: 12px;
  pointer-events: none;
  z-index: 46;
  animation: co-confetti-fall 1.4s ease-in forwards;
}
@keyframes co-confetti-fall {
  to {
    transform: translate(var(--cfx, 0), 105vh) rotate(var(--cfr, 540deg));
    opacity: 0.85;
  }
}
/* Brew landed: the topbar cup counter hops (P6). */
.tb-coffee > summary.co-hop { animation: co-cup-hop 0.4s ease-out; }
@keyframes co-cup-hop {
  30% { transform: translateY(-5px) scale(1.12); }
  60% { transform: translateY(1px) scale(0.98); }
}
/* HUD badges: sacos multiplier, aguacero, roya. */
.co-hud-sacos { color: #b8860b; font-weight: 600; }
.co-hud-rain { color: #5b8dd6; font-weight: 600; }
.co-hud-roya { color: #c0392b; font-weight: 700; }

/* Mariposas amarillas: a small, non-interactive cursor flourish. The component
   emits six at a time and throttles bursts; CSS handles the short flight. */
.co-butterflies {
  position: fixed; inset: 0;
  pointer-events: none; overflow: hidden;
  z-index: 40;
}
.co-bfly {
  position: absolute; display: block;
  animation-name: co-fly;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  will-change: transform, opacity;
}
.co-bfly img {
  width: 100%; height: 100%; display: block;
  transform-origin: 50% 50%;
  animation: co-flap var(--flap, 0.3s) ease-in-out infinite;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}
/* One-shot drift away from the pointer, then fade in place. */
@keyframes co-fly {
  0%   { transform: translate(0, 0) rotate(0) scale(.7); opacity: 0; }
  14%  { opacity: .9; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
/* scaleX wobble = wings flapping. */
@keyframes co-flap {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(0.35); }
}
@media (prefers-reduced-motion: reduce) {
  .co-bfly { display: none; }
}

/* ---- Café Colombia: full clicker playfield ------------------------------
   A quiet, flat frame keeps the 12×12 pocillo and producer sprites in charge.
   Crisp borders and restrained coffee/leaf surfaces replace scenic gradients. */
.co-game {
  --co-espresso: #1e1511;
  --co-roast: #3a241a;
  --co-cream: #dcc796;
  --co-paper: #ead9ad;
  --co-leaf: #24493a;
  --co-leaf-dark: #173128;
  --co-yellow: #f0cb45;
  --co-blue: #1757a6;
  --co-red: #c4382f;
  --co-line: #594033;
  position: fixed;
  inset: 0 0 0 224px;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding-top: 58px;
  color: #fff6de;
  overflow: hidden;
  background: var(--co-espresso);
  font-family: "Geist", system-ui, sans-serif;
  letter-spacing: 0;
}
.co-game-tricolor {
  position: absolute;
  top: 58px; left: 0; right: 0;
  height: 5px;
  z-index: 4;
  background: linear-gradient(90deg,
    var(--co-yellow) 0 50%, var(--co-blue) 50% 75%, var(--co-red) 75%);
}
.co-game-header {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 12px clamp(18px, 2.2vw, 34px) 10px;
  background: var(--co-espresso);
  border-bottom: 3px solid #100b09;
  position: relative;
  z-index: 3;
}
.co-game-brand {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.co-game-kicker,
.co-panel-heading span,
.co-store-section-label {
  font-family: "GeistMono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.16em;
}
.co-game-kicker { color: var(--co-yellow); white-space: nowrap; }
.co-game-brand strong {
  margin-top: 5px;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(23px, 2.2vw, 34px);
  font-weight: 720;
  font-style: italic;
  letter-spacing: -0.035em;
  white-space: nowrap;
}
.co-game-head-stats {
  display: flex;
  align-items: stretch;
  justify-content: center;
  border: 2px solid var(--co-line);
  background: #281b16;
}
.co-game-head-stats > span {
  min-width: 94px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  column-gap: 6px;
  padding: 7px 13px;
  border-left: 2px solid var(--co-line);
  font-variant-numeric: tabular-nums;
}
.co-game-head-stats > span:first-child { border-left: 0; }
.co-game-head-stats b { font-family: "GeistMono", monospace; font-size: 15px; color: #fff; }
.co-game-head-stats small {
  grid-column: 1 / -1;
  color: #cdbd9d;
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}
.co-game-cup-total { display: grid !important; grid-template-columns: auto auto !important; }
.co-game-cup-total .co-cup { grid-row: 1; }
.co-game-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.co-game-actions button {
  color: #fff6de;
  background: #2a1c17;
  border: 2px solid var(--co-line);
  box-shadow: none;
}
.co-game-actions button:hover { color: #fff; background: #39251d; }
.co-game-icon-btn { width: 34px; height: 34px; padding: 0; }
.co-game-minimise { padding: 7px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }

.co-game-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(270px, 0.88fr) minmax(290px, 1fr) minmax(350px, 1.08fr);
  overflow: hidden;
}
.co-click-panel,
.co-production-panel,
.co-market-panel { min-width: 0; min-height: 0; }
.co-click-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px clamp(16px, 2vw, 28px) 16px;
  overflow: hidden auto;
  color: #fff7e5;
  background: var(--co-leaf);
  border-right: 3px solid var(--co-leaf-dark);
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.co-panel-heading {
  width: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}
.co-panel-heading span { color: #fff; }
.co-panel-heading small { color: rgba(255, 255, 255, 0.64); font-size: 10px; }
.co-harvest-total {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
  line-height: 1;
}
.co-harvest-total strong {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(42px, 4.5vw, 68px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
}
.co-harvest-total span {
  margin-top: 5px;
  font-family: "GeistMono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #dce7ca;
}
.co-harvest-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.co-harvest-meta i { width: 3px; height: 3px; border-radius: 50%; background: var(--co-yellow); }
.co-main-button {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: min(220px, 64%);
  aspect-ratio: 1;
  margin: 14px 0 2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 90ms cubic-bezier(.2,.8,.2,1), filter 120ms ease;
}
.co-main-button:hover { background: transparent; transform: translate(-2px, -2px); filter: brightness(1.06); }
.co-main-button:active { transform: translate(5px, 5px); }
.co-main-button:focus-visible { outline: 4px solid var(--co-yellow); outline-offset: 5px; }
.co-main-button .co-cup {
  width: 100%; height: 100%; display: block;
  filter: drop-shadow(9px 9px 0 rgba(12, 28, 22, .7));
  image-rendering: pixelated;
}
.co-steam {
  position: absolute;
  left: 48%; top: 7%;
  width: 6px; height: 22px;
  background: rgba(236, 232, 216, .68);
  box-shadow: 8px -12px 0 rgba(236, 232, 216, .48);
  opacity: 0;
  animation: co-steam-rise 2.7s ease-in-out infinite;
}
.co-steam-two { left: 57%; top: 13%; animation-delay: 1.2s; transform: scale(.75); }
@keyframes co-steam-rise {
  0% { opacity: 0; translate: 0 12px; scale: .8; }
  30% { opacity: .7; }
  100% { opacity: 0; translate: 11px -34px; scale: 1.2; }
}
.co-click-help { position: relative; z-index: 1; font-family: "GeistMono", monospace; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: #e8dec2; }
.co-rhythm {
  position: relative;
  z-index: 1;
  width: min(330px, 100%);
  margin-top: 12px;
}
.co-rhythm-label { display: flex; justify-content: space-between; font-family: "GeistMono", monospace; font-size: 9px; letter-spacing: .13em; }
.co-rhythm-label b { color: var(--co-yellow); }
.co-rhythm-track { height: 8px; margin-top: 5px; background: rgba(10, 26, 20, .55); border: 1px solid rgba(255,255,255,.22); overflow: hidden; }
.co-rhythm-track span { display: block; height: 100%; background: var(--co-yellow); transition: width .12s linear; }
.co-brew-action {
  position: relative;
  z-index: 1;
  width: min(330px, 100%);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 12px;
  color: #23130c;
  background: var(--co-yellow);
  border: 1px solid #ffe983;
  border-radius: 0;
  box-shadow: 0 5px 0 #8b651b;
  font-weight: 760;
}
.co-brew-action:hover { background: #ffe06a; transform: translateY(-1px); }
.co-brew-action:active { transform: translateY(4px); box-shadow: 0 1px 0 #8b651b; }
.co-brew-action:disabled { color: rgba(255,255,255,.55); background: rgba(12,34,25,.55); border-color: rgba(255,255,255,.18); box-shadow: none; }
.co-brew-rule { position: relative; z-index: 1; margin-top: 7px; font-family: "GeistMono", monospace; font-size: 9px; color: rgba(255,255,255,.6); }
.co-event-row { position: relative; z-index: 1; min-height: 22px; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 8px; }
.co-event-row span { padding: 3px 7px; font-size: 9px; font-weight: 700; background: rgba(16, 28, 21, .7); border: 1px solid currentColor; }
.co-event-row .gold { color: var(--co-yellow); }
.co-event-row .rain { color: #a9d5ff; }
.co-event-row .rust { color: #ff9e65; }
.co-production-panel {
  display: flex;
  flex-direction: column;
  color: #2c1a10;
  background: var(--co-cream);
  border-right: 3px solid #806747;
}
.co-production-panel .co-panel-heading { padding: 17px 18px 10px; border-color: rgba(71, 40, 22, .24); }
.co-production-panel .co-panel-heading span { color: #3c2417; }
.co-production-panel .co-panel-heading small { color: #70513a; }
.co-production-summary { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 18px; background: #bfa76f; border-bottom: 2px solid #806747; }
.co-production-summary span { font-family: "GeistMono", monospace; font-size: 9px; letter-spacing: .12em; }
.co-production-summary strong { font-family: "Fraunces", serif; font-size: 16px; }
.co-production-scenes { flex: 1; min-height: 0; overflow-y: auto; scrollbar-color: #9f7948 transparent; }
.co-production-scene {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 8px 12px;
  padding: 16px 16px 14px;
  border-bottom: 2px solid #a48b5c;
  background: var(--co-paper);
  filter: saturate(.68);
}
.co-production-scene:nth-child(even) { background: #d6c18e; }
.co-production-scene.live { filter: none; }
.co-production-scene::after {
  content: "SIN COMPRAR";
  position: absolute;
  right: 16px; bottom: 12px;
  font-family: "GeistMono", monospace;
  font-size: 8px;
  letter-spacing: .13em;
  color: rgba(70,45,28,.42);
}
.co-production-scene.live::after { content: "PRODUCIENDO"; color: #245c43; }
.co-scene-copy { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.co-scene-icon { width: 54px; height: 54px; flex: none; display: grid; place-items: center; background: #edddae; border: 2px solid #94764e; box-shadow: 3px 3px 0 #92764f; }
.co-scene-copy > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.co-scene-copy b { font-family: "Fraunces", serif; font-size: 17px; }
.co-scene-copy small { color: #6c4b34; font-size: 10px; }
.co-scene-owned { position: relative; z-index: 1; align-self: center; font-family: "Fraunces", serif; font-size: 34px; color: rgba(48,29,17,.55); font-variant-numeric: tabular-nums; }
.co-production-scene.live .co-scene-owned { color: #2d5f43; }
.co-scene-units { position: relative; z-index: 1; grid-column: 1 / -1; min-height: 20px; display: flex; gap: 3px; padding-left: 64px; }
.co-scene-units span { animation: co-worker-bob 1.6s ease-in-out infinite alternate; }
.co-scene-units span:nth-child(2n) { animation-delay: .45s; }
@keyframes co-worker-bob { to { transform: translateY(-3px); } }

.co-market-panel {
  position: relative;
  overflow-y: auto;
  color: #f7ead0;
  background: #211511;
  scrollbar-color: #73513b #170c09;
}
.co-market-sticky { position: sticky; top: 0; z-index: 5; background: #1d130f; border-bottom: 2px solid var(--co-line); }
.co-market-panel .co-panel-heading { padding: 17px 16px 10px; border-color: rgba(255,238,202,.18); }
.co-market-wallet { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: #100805; border-bottom: 1px solid rgba(255,238,202,.16); }
.co-market-wallet > span { display: inline-flex; align-items: center; gap: 7px; font-family: "GeistMono", monospace; font-size: 16px; color: var(--co-yellow); font-variant-numeric: tabular-nums; }
.co-buy-mults { display: flex; gap: 4px; }
.co-buy-mults button {
  min-width: 37px;
  padding: 4px 6px;
  color: #cbb99b;
  background: transparent;
  border: 1px solid #654535;
  border-radius: 0;
  box-shadow: none;
  font-family: "GeistMono", monospace;
  font-size: 10px;
}
.co-buy-mults button.on { color: #1c100a; background: var(--co-yellow); border-color: var(--co-yellow); }
.co-upgrade-shelf,
.co-store-buildings,
.co-prestige-card,
.co-game-logros { border-bottom: 1px solid rgba(255,238,202,.16); }
.co-store-section-label { display: block; padding: 10px 14px 6px; color: #d7b56a; }
.co-upgrade-card {
  width: calc(100% - 20px);
  min-height: 62px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 0 10px 7px;
  padding: 8px 10px;
  color: #f7ead0;
  text-align: left;
  background: #35221a;
  border: 1px solid #6f4a33;
  border-radius: 0;
  box-shadow: 3px 3px 0 #100805;
}
.co-upgrade-card:hover:not(:disabled) { border-color: var(--co-yellow); background: #422a20; transform: translate(-1px, -1px); }
.co-upgrade-card:disabled { opacity: .46; }
.co-upgrade-card.owned { opacity: .68; border-color: #3f755a; }
.co-upgrade-card.gift { border-color: var(--co-yellow); }
.co-upgrade-glyph,
.co-upgrade-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--co-yellow); background: #1c0e09; font-family: "Fraunces", serif; font-size: 22px; }
.co-upgrade-card > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.co-upgrade-card b { font-family: "Fraunces", serif; font-size: 14px; }
.co-upgrade-card small { color: #bba98d; font-size: 9px; }
.co-upgrade-card em { color: var(--co-yellow); font-family: "GeistMono", monospace; font-size: 9px; font-style: normal; white-space: nowrap; }

/* Existing economy rows become the store's large, legible building cards. */
.co-game .co-trow {
  min-height: 70px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 9px;
  padding: 9px 12px;
  color: #f7ead0;
  border-bottom: 1px solid rgba(255,238,202,.12);
  background: #281914;
}
.co-game .co-trow:hover { background: #34221b; }
.co-game .co-trow-icon { width: 46px; height: 46px; display: grid; place-items: center; background: #f0d59e; border: 2px solid #81583d; box-shadow: 3px 3px 0 #110805; }
.co-game .co-trow-info { gap: 3px; }
.co-game .co-trow-name { color: #fff4da; font-family: "Fraunces", serif; font-size: 15px; }
.co-game .co-trow-owned { color: var(--co-yellow); font-family: "GeistMono", monospace; }
.co-game .co-trow-meta { color: #bba98d; font-size: 9px; white-space: normal; line-height: 1.3; }
.co-game .co-trow-lack { color: #e98f83; }
.co-game .co-trow-buy {
  min-width: 74px;
  justify-content: center;
  color: #21120b;
  background: var(--co-yellow);
  border: 1px solid #ffe071;
  border-radius: 0;
  box-shadow: 0 3px 0 #8d6314;
  font-family: "GeistMono", monospace;
  font-size: 9px;
}
.co-game .co-trow-buy:hover:not(:disabled) { background: #ffe169; transform: translateY(-1px); }
.co-game .co-trow-buy:disabled { color: #8f7d68; background: #322119; border-color: #503729; box-shadow: none; }
.co-game .co-trow-afford { height: 3px; background: var(--co-yellow); opacity: 1; }
.co-game .co-trow-up { min-height: 52px; padding-left: 32px; background: #160b08; }
.co-game .co-trow-up .co-trow-icon { width: 34px; height: 34px; background: #2a1710; color: var(--co-yellow); }
.co-game .co-trow-up.locked { opacity: .42; }
.co-prestige-card { padding: 2px 12px 14px; background: #24140e; }
.co-prestige-card > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px 10px; }
.co-prestige-card > div > span:first-child { display: flex; flex-direction: column; }
.co-prestige-card b { font-family: "Fraunces", serif; font-size: 15px; }
.co-prestige-card small { color: #bba98d; font-size: 9px; }
.co-prestige-mark { font-size: 20px; }
.co-prestige-card > button { width: 100%; border-radius: 0; background: #9d2b27; border-color: #d65147; }
.co-prestige-card > button:disabled { background: #39221a; border-color: #51362a; color: #978573; }
.co-game-logros { padding: 0 12px 16px; }
.co-game .co-logros-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 11px 0 7px;
  color: #d7b56a;
  background: transparent;
  border: 0;
  box-shadow: none;
  text-align: left;
  font-family: "GeistMono", monospace;
  font-size: 10px;
  letter-spacing: .12em;
}
.co-game .co-logros-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.co-game .co-badge { color: #f7ead0; background: #2a1710; border-radius: 0; box-shadow: inset 0 0 0 1px #553928; }
.co-game .co-badge-name { color: #c9b69a; }

/* Click feedback floats away from the cup and disappears; nothing collects at
   the viewport edge anymore. */
.co-bean {
  z-index: 82;
  animation: co-bean-spark .9s cubic-bezier(.18,.72,.2,1) forwards;
}
@keyframes co-bean-spark {
  0% { transform: translate(-50%, -50%) scale(.35) rotate(0); opacity: 0; }
  14% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--bean-scale, 1)) rotate(var(--rot)); opacity: 0; }
}
.co-plus { z-index: 83; color: var(--co-yellow, #f5ce3e); font-family: "Fraunces", serif; font-size: 19px; text-shadow: 0 2px 4px rgba(25,10,5,.85); }
.co-brew-flash { z-index: 84; }
.indep-co .co-butterflies { z-index: 52; }
.co-frenzy-glow, .co-aguacero { z-index: 72; }
.co-golden, .co-chiva, .co-roya { z-index: 76; }
.co-confetti { z-index: 80; }
.co-game-cup-total.co-hop { animation: co-cup-hop .4s ease-out; }

@media (max-width: 1180px) {
  .co-game-grid { grid-template-columns: minmax(250px, .82fr) minmax(270px, .9fr) minmax(330px, 1fr); }
  .co-game-header { gap: 12px; }
  .co-game-head-stats > span { min-width: 78px; padding-inline: 8px; }
}
@media (max-width: 1050px) {
  .co-game { overflow-y: auto; }
  .co-game-grid { min-height: auto; grid-template-columns: 1fr 1fr; overflow: visible; }
  .co-click-panel, .co-market-panel { min-height: calc(100dvh - 140px); }
  .co-production-panel { grid-column: 1 / -1; min-height: 560px; border-left: 0; border-right: 0; border-top: 3px solid #806747; }
  .co-production-scenes { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
}
@media (max-width: 820px) {
  .co-game { inset: 0; z-index: 70; padding-top: 0; display: block; }
  .co-game-tricolor { top: 0; }
  .co-game-header { position: sticky; top: 0; z-index: 8; grid-template-columns: 1fr auto; padding-top: 12px; }
  .co-game-head-stats { grid-column: 1 / -1; grid-row: 2; }
  .co-game-actions { grid-column: 2; grid-row: 1; }
  .co-game-grid { display: block; }
  .co-click-panel, .co-market-panel, .co-production-panel { min-height: 0; max-height: none; overflow: visible; }
  .co-click-panel { min-height: 760px; }
  .co-market-panel { padding-bottom: 40px; }
  .co-production-scenes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .co-steam, .co-scene-units span, .co-bean { animation: none; }
  .co-main-button { transition: none; }
}

/* Effectiveness scorecard (Herald V1 MVP test) */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: var(--sp-3); }

/* Phase timeline: a horizontal stepper (done / current / upcoming). */
.phase-progress { display: flex; overflow-x: auto; padding: 10px 4px 6px; }
.phase-step { flex: 1 0 0; min-width: 96px; text-align: center; position: relative; }
.phase-step::before { content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: var(--border-subtle); z-index: 0; }
.phase-step:first-child::before { display: none; }
.phase-step.done::before, .phase-step.current::before { background: var(--accent); }
.phase-dot { position: relative; z-index: 1; width: 12px; height: 12px; border-radius: 50%; margin: 4px auto 8px; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--border-subtle); }
.phase-step.done .phase-dot { background: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.phase-step.current .phase-dot { width: 16px; height: 16px; margin: 2px auto 8px; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-weak), inset 0 0 0 2px var(--accent); }
.phase-name { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.3; padding: 0 4px; }
.phase-step.done .phase-name, .phase-step.current .phase-name { color: var(--text); }
.phase-date { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.phase-step.current .phase-date { color: var(--accent); }
.grade-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.grade-list > div { display: flex; gap: 10px; align-items: baseline; line-height: 1.5; }
.grade-list .status-chip { flex: none; width: 62px; text-align: center; }
.delta-ahead { color: var(--ok); font-weight: 600; font-variant-numeric: tabular-nums; }
.delta-behind { color: var(--danger); font-weight: 600; font-variant-numeric: tabular-nums; }
.delta-flat { color: var(--muted); }

/* "n/6 topics winning" hero */
.winning-hero { display: flex; align-items: center; gap: 20px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--panel-ring), var(--sh-1); border-radius: var(--r-3); padding: var(--sp-4) var(--sp-5); margin: 10px 0 4px; }
.winning-figure { display: flex; align-items: baseline; gap: 2px; line-height: 1; flex: none; }
.winning-num { font-size: 46px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.winning-den { font-size: 24px; font-weight: 600; color: var(--muted); }
.winning-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.winning-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text); }
.winning-pips { display: flex; gap: 6px; }
.winning-pip { width: 22px; height: 8px; border-radius: 4px; background: var(--border-subtle); }
.winning-pip.on { background: var(--ok); }
.launch-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.launch-picker label { margin: 0; }
.launch-picker input[type="date"] { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-subtle); border-radius: var(--r-2); padding: 6px 10px; font: inherit; font-variant-numeric: tabular-nums; }
.launch-picker input[type="date"]:focus { outline: none; border-color: var(--accent); }

/* Range/band bar (components/range_band.rs): track spans [min, max]; shaded
   segment = the 80% band, tick = par, accent edge = success line (band's
   upper edge), dot = today's actual. All tokens, so both themes come free. */
.range-band { min-width: 140px; }
.rb-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-subtle); }
.rb-band { position: absolute; top: 0; height: 100%; border-radius: 5px; background: var(--accent-fill); }
.rb-par { position: absolute; top: -2px; width: 2px; height: 14px; margin-left: -1px; background: var(--muted); }
.rb-success { position: absolute; top: -3px; width: 3px; height: 16px; margin-left: -1.5px; border-radius: 1px; background: var(--accent); }
.rb-actual { position: absolute; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 2px var(--panel); }
.seo-table .rb-cell { width: 38%; min-width: 160px; }

/* ====================================================================== */
/* Competitors — situation room                                           */
/* Threat board + overlap heatmap + inline detail + suggestion table.     */
/* Strict colour budget: ink values, red (--trescored) = they lead,       */
/* green (--ok) = we lead, indigo (--accent) = interaction/selection.     */
/* Every rule is scoped under .competitors-room; both themes come free    */
/* from the shared token system (no hardcoded hexes except cell text).    */
/* ====================================================================== */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.competitors-room { --heat-sat: 22; }

/* section header rule */
.competitors-room .sect-h {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: 0 0 var(--sp-3); min-height: 30px;
}
.competitors-room .sect-h h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 600; margin: 0;
}
.competitors-room .sect-h .rule { flex: 1; height: 1px; background: var(--border); }
.competitors-room .sect-h .aside { font-size: 11px; color: var(--text-subtle); }

/* small buttons + variants (base <button> is auto-styled; these size it
   and give anchors the same chrome) */
.competitors-room .btn-sm,
.competitors-room a.btn-sm {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); padding: 5px 11px; border-radius: var(--r-1);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.competitors-room .btn-sm:hover,
.competitors-room a.btn-sm:hover { border-color: var(--border-strong); }
.competitors-room .btn-ok {
  background: transparent;
  border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok);
}
.competitors-room .btn-ok:hover { background: var(--ok-weak); }
.competitors-room .btn-ghost {
  background: transparent; border-color: var(--border); color: var(--muted);
}
.competitors-room .btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.competitors-room .backbtn { display: inline-flex; align-items: center; gap: 6px; }

/* status chips (scoped so the global .chip elsewhere is untouched) */
.competitors-room .chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px;
  font-weight: 600; padding: 2px 9px; border-radius: var(--r-pill);
  text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid transparent;
}
.competitors-room .chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.competitors-room .chip.active { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 34%, transparent); }
.competitors-room .chip.watching { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.competitors-room .chip.archived { color: var(--text-subtle); border-color: var(--border-strong); }

/* coverage strip */
.competitors-room .coverage {
  display: flex; align-items: center; gap: var(--sp-4);
  margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.competitors-room .cov-markets { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.competitors-room .cov-m {
  display: flex; align-items: center; gap: 7px; font-size: 12px;
  padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface-2);
}
.competitors-room .cov-m .mk { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-subtle); }
/* cov-m is a toggle button: reset the native button chrome, dim when off. */
.competitors-room .cov-m {
  font: inherit; color: var(--text); cursor: pointer;
  transition: opacity var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.competitors-room .cov-m:hover { border-color: var(--border-strong); }
.competitors-room .cov-m.on { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.competitors-room .cov-m.off { opacity: 0.45; }
/* locale we collect but have no data for yet: present but inert */
.competitors-room .cov-m.empty { opacity: 0.5; cursor: default; border-style: dashed; color: var(--text-subtle); }
.competitors-room .cov-m.empty:hover { border-color: var(--border); }
.competitors-room .empty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.competitors-room .cov-actions { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.competitors-room .fresh-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }
.competitors-room .stale-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px var(--warn-weak); }

.competitors-room .situation-kpis { margin-bottom: var(--sp-5); }

/* two-column layout */
.competitors-room .situation-layout {
  display: grid; grid-template-columns: 1.02fr 1.3fr; gap: var(--sp-5); align-items: start;
}
.competitors-room .situation-layout.detail-mode { grid-template-columns: minmax(280px, 330px) 1fr; }
@media (max-width: 900px) {
  .competitors-room .situation-layout,
  .competitors-room .situation-layout.detail-mode { grid-template-columns: 1fr; }
}
.competitors-room .right-col { min-width: 0; }

/* threat board */
.competitors-room .board {
  display: flex; flex-direction: column; gap: 7px;
  overflow-y: auto; overflow-x: hidden; padding-right: 4px;
}
.competitors-room .board::-webkit-scrollbar { width: 8px; }
.competitors-room .board::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.competitors-room .board::-webkit-scrollbar-track { background: transparent; }
.competitors-room .threat-row {
  display: grid; grid-template-columns: 18px 1fr 84px; gap: var(--sp-3); align-items: center;
  padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--r-2);
  background: var(--surface-2); cursor: pointer; transition: border-color var(--dur-1) var(--ease); flex: 0 0 auto;
}
.competitors-room .threat-row:hover { border-color: var(--border-strong); }
.competitors-room .threat-row.sel { border-color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.competitors-room .threat-row.dimmed { opacity: 0.5; }
.competitors-room .rank-n { font-family: var(--font-mono); font-size: 12px; color: var(--text-subtle); font-weight: 600; text-align: center; }
.competitors-room .tr-main { min-width: 0; }
.competitors-room .tr-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.competitors-room .tr-name { font-weight: 600; font-size: 14px; }
.competitors-room .tr-dom { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); }
.competitors-room .tr-tag { font-size: 9px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; border-radius: var(--r-pill); padding: 1px 6px; }
.competitors-room .tr-tag.matrix { color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); }
.competitors-room .tr-stats {
  display: flex; gap: 5px; margin-top: 8px; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; align-items: center; flex-wrap: wrap;
}
.competitors-room .tr-stats b { color: var(--text); font-weight: 600; }
.competitors-room .tr-stats .sep { color: var(--border-strong); }
.competitors-room .tr-stats .neg b { color: var(--danger); }
.competitors-room .situation-layout.detail-mode .tr-stats { display: none; }
.competitors-room .situation-layout.detail-mode .threat-row { padding: 11px 14px; }
.competitors-room .threatmeter { text-align: right; }
.competitors-room .tm-val { font-family: var(--font-mono); font-size: 17px; font-weight: 600; line-height: 1; }
.competitors-room .tm-bar { height: 4px; border-radius: 3px; background: var(--border); margin-top: 7px; overflow: hidden; }
.competitors-room .tm-fill { height: 100%; border-radius: 3px; }
.competitors-room .tm-lab { font-size: 9px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-subtle); margin-top: 5px; }

/* picker chips */
.competitors-room .pickbars { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.competitors-room .pickbar {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--r-2); background: var(--surface-2);
}
.competitors-room .pickbar .tlabel { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-subtle); font-weight: 600; min-width: 78px; }
.competitors-room .tchip {
  font: inherit; font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer;
  display: inline-flex; gap: 6px; align-items: center; transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.competitors-room .tchip:hover { border-color: var(--border-strong); color: var(--text); }
.competitors-room .tchip[aria-pressed="true"] {
  background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent);
}
.competitors-room .tchip[aria-pressed="true"]::before { content: "✓"; font-size: 9.5px; opacity: 0.9; }
.competitors-room .pickbar .tcount { margin-left: auto; font-size: 11px; color: var(--text-subtle); font-family: var(--font-mono); white-space: nowrap; }

/* topic multi-select popover */
.competitors-room .ms { position: relative; display: inline-flex; }
.competitors-room .ms-trigger {
  font: inherit; font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer;
  display: inline-flex; gap: 7px; align-items: center; white-space: nowrap;
  transition: border-color var(--dur-1) var(--ease);
}
.competitors-room .ms-trigger:hover { border-color: var(--border-strong); }
.competitors-room .ms-trigger[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.competitors-room .ms-caret { font-size: 9px; color: var(--text-subtle); }
.competitors-room .ms-backdrop { position: fixed; inset: 0; z-index: 40; }
.competitors-room .ms-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 41; width: 260px; max-width: 80vw;
  border: 1px solid var(--border-strong); border-radius: var(--r-2); background: var(--panel);
  box-shadow: var(--shadow-2, 0 8px 24px rgb(0 0 0 / 0.18)); padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.competitors-room .ms-search {
  font: inherit; font-size: 12px; padding: 6px 9px; border-radius: var(--r-2);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.competitors-room .ms-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; gap: 1px; }
.competitors-room .ms-opt {
  font: inherit; font-size: 12px; text-align: left; cursor: pointer; color: var(--text);
  display: flex; align-items: center; gap: 8px; padding: 6px 7px; border: 0; border-radius: var(--r-2); background: transparent;
}
.competitors-room .ms-opt:hover { background: var(--surface-2); }
.competitors-room .ms-box {
  width: 14px; height: 14px; flex: none; border-radius: 4px; border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
}
.competitors-room .ms-opt[aria-pressed="true"] .ms-box {
  background: var(--accent); border-color: var(--accent);
}
.competitors-room .ms-opt[aria-pressed="true"] .ms-box::after { content: "✓"; font-size: 10px; color: var(--panel); line-height: 1; }
.competitors-room .ms-opt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.competitors-room .ms-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.competitors-room .ms-chip {
  font-size: 11px; font-weight: 600; padding: 3px 4px 3px 10px; border-radius: var(--r-pill);
  background: var(--accent-weak); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent); display: inline-flex; align-items: center; gap: 4px;
}
.competitors-room .ms-chip-x {
  font: inherit; font-size: 13px; line-height: 1; cursor: pointer; border: 0; background: transparent;
  color: var(--accent); padding: 0 3px; border-radius: 50%; opacity: 0.75;
}
.competitors-room .ms-chip-x:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* heatmap */
.competitors-room .heat { border: 1px solid var(--border); border-radius: var(--r-2); overflow: hidden; background: var(--surface-2); }
.competitors-room .heat-scroll { overflow-x: auto; }
.competitors-room .heat table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.competitors-room .heat th {
  font-weight: 600; color: var(--text-subtle); text-align: center; padding: 11px 6px 12px; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; vertical-align: bottom;
}
.competitors-room .heat th.rowh, .competitors-room .heat td.rowh {
  text-align: left; position: sticky; left: 0; background: var(--surface-2); z-index: 1;
  padding-left: 16px; white-space: nowrap; font-size: 12.5px; color: var(--text); font-weight: 600;
}
.competitors-room .heat td.rowh { cursor: pointer; }
.competitors-room .heat td.rowh:hover { color: var(--accent); }
.competitors-room .heat td { padding: 0 5px; text-align: center; }
.competitors-room .heat tr td:last-child, .competitors-room .heat tr th:last-child { padding-right: 14px; }
.competitors-room .heat .cell {
  margin: 3px 0; height: 38px; border-radius: 6px; display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 12px; cursor: pointer; position: relative;
  transition: transform var(--dur-1) var(--ease); outline: 1px solid transparent; outline-offset: -1px;
}
.competitors-room .heat .cell:hover { outline-color: var(--text); transform: translateY(-1px); }
.competitors-room .heat .cell:hover::after {
  content: "↳ inspect"; position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-sans); font-size: 8.5px; font-weight: 600; color: var(--text-subtle); white-space: nowrap; letter-spacing: 0.03em;
}
.competitors-room .legend {
  display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-subtle);
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.competitors-room .legend .scale { display: flex; height: 8px; width: 110px; border-radius: 5px; overflow: hidden; }
.competitors-room .legend .scale i { flex: 1; }
.competitors-room .legend .legend-note { margin-left: auto; }

/* inline detail */
.competitors-room .detail { border: 1px solid var(--border); border-radius: var(--r-2); background: var(--surface-2); padding: 22px 24px; min-width: 0; }
.competitors-room .d-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3);
  padding-bottom: var(--sp-4); margin-bottom: 18px; border-bottom: 1px solid var(--border);
}
.competitors-room .d-title { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.competitors-room .d-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 7px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.competitors-room .d-sub .sep { color: var(--border-strong); }
.competitors-room .d-sub .d-home { color: var(--accent); text-decoration: none; }
.competitors-room .d-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.competitors-room .d-metrics {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r-2); overflow: hidden; margin-bottom: var(--sp-4);
}
@media (max-width: 560px) { .competitors-room .d-metrics { grid-template-columns: repeat(2, 1fr); } }
.competitors-room .d-metric { background: var(--surface-2); padding: 12px 14px; }
.competitors-room .d-metric .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-subtle); font-weight: 600; }
.competitors-room .d-metric .v { font-family: var(--font-mono); font-size: 18px; font-weight: 600; margin-top: 5px; }

/* rank-distribution segmented bar + sparkline */
.competitors-room .posn { margin-bottom: var(--sp-4); }
.competitors-room .posn .ph { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; gap: 12px; flex-wrap: wrap; }
.competitors-room .posn .ph .lab { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-subtle); font-weight: 600; }
.competitors-room .posn .ph .tot { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.competitors-room .posn .ph .tot .spark { display: inline-block; vertical-align: middle; }
.competitors-room .posn .segbar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--border); gap: 1px; }
.competitors-room .posn .seg { display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; font-weight: 600; min-width: 26px; }
.competitors-room .posn .seg.s1 { background: var(--trescored); color: #fff; }
.competitors-room .posn .seg.s2 { background: var(--warning); color: #231a06; }
.competitors-room .posn .seg.s3 { background: color-mix(in srgb, var(--warning) 40%, var(--surface-2)); color: var(--text); }
.competitors-room .posn .seglabels { display: flex; gap: 16px; margin-top: 9px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.competitors-room .posn .seglabels i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* detail meta grid */
.competitors-room .d-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 26px; margin-bottom: var(--sp-4); }
@media (max-width: 560px) { .competitors-room .d-meta { grid-template-columns: 1fr; } }
.competitors-room .d-meta .mrow { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.competitors-room .d-meta .mk { color: var(--muted); }
.competitors-room .d-meta .mv { font-family: var(--font-mono); font-weight: 600; text-align: right; }
.competitors-room .d-meta .mv.link { color: var(--accent); font-weight: 500; text-decoration: none; }

/* topic-scope filter banner */
.competitors-room .topicfilter {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--sp-3);
  padding: 10px 14px; border-radius: var(--r-2);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-weak); font-size: 12.5px;
}
.competitors-room .topicfilter .tf-lab { color: var(--muted); }
.competitors-room .topicfilter b { color: var(--accent); }
.competitors-room .topicfilter .tf-count { font-family: var(--font-mono); color: var(--muted); font-size: 11.5px; }
.competitors-room .topicfilter .tf-clear {
  margin-left: auto; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); background: transparent;
  color: var(--accent); font: inherit; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-pill); cursor: pointer;
}
.competitors-room .topicfilter .tf-clear:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* detail kind tabs + gap ledger */
.competitors-room .l-tabs { display: flex; gap: 2px; margin-bottom: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.competitors-room .l-tab {
  font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 13px; cursor: pointer;
  border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.competitors-room .l-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.competitors-room .l-tab .ct { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-subtle); margin-left: 5px; }
.competitors-room .l-tab.on .ct { color: var(--accent); }
.competitors-room .ledgertbl { margin-top: var(--sp-3); }

/* suggested competitors */
.competitors-room .suggest { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.competitors-room .sugg-tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-2); }
.competitors-room table.sugg-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 720px; }
.competitors-room table.sugg-table th {
  text-align: left; padding: 10px 12px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-subtle); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2);
}
.competitors-room table.sugg-table th.r, .competitors-room table.sugg-table td.r { text-align: right; }
.competitors-room table.sugg-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.competitors-room table.sugg-table tr:last-child td { border-bottom: 0; }
.competitors-room table.sugg-table tbody tr:hover { background: var(--surface-2); }
.competitors-room .sugg-host { font-weight: 600; font-size: 13px; text-decoration: none; color: var(--text); }
.competitors-room .sugg-host code { font-family: var(--font-mono); }
.competitors-room .signal { display: inline-flex; align-items: center; gap: 8px; }
.competitors-room .signal .sv { font-family: var(--font-mono); font-weight: 600; font-size: 13px; }
.competitors-room .signal .sbar { width: 52px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.competitors-room .signal .sbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.competitors-room .spread { display: flex; height: 16px; width: 98px; border-radius: 3px; overflow: hidden; background: var(--border); gap: 1px; }
.competitors-room .spread i { display: block; }
.competitors-room .spread .p1 { background: var(--trescored); }
.competitors-room .spread .p2 { background: var(--warning); }
.competitors-room .spread .p3 { background: color-mix(in srgb, var(--warning) 40%, var(--surface-2)); }
.competitors-room .sugg-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.competitors-room .sugg-empty { padding: 26px; text-align: center; color: var(--text-subtle); font-size: 13px; border: 1px dashed var(--border-strong); border-radius: var(--r-2); }
.competitors-room .num { font-variant-numeric: tabular-nums; }

/* =========================================================================
   Content-template stage editor — full-width "operator table" + inspector.
   Scoped under .te / .te-* so it never collides with .seo-table / .mgr.
   Left status stripe encodes stage kind: generate=accent, tunable=warning,
   pinned=border-strong. See crates/webapp/src/pages/content_templates.rs.
   ========================================================================= */
.ct-hidden { display: none; }

.te { }
.te-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 0 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.te-crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.te-crumb .link-button { color: var(--muted); font-size: 13px; }
.te-crumb .link-button:hover { color: var(--text); }
.te-sep { color: var(--text-subtle); }
.te-cur { color: var(--text); font-weight: 600; }
.te-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.te-badge.default { color: var(--accent); background: var(--accent-weak); }
.te-badge.active  { color: var(--ok); background: var(--ok-weak); }
.te-badge.draft   { color: var(--warning); background: var(--warn-weak); }

.te-tabs {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-2); padding: 3px; gap: 2px;
}
.te-tabs button {
  border: none; background: transparent; color: var(--muted); font-size: 12px;
  padding: 5px 14px; border-radius: var(--r-1); font-weight: 550; box-shadow: none;
}
.te-tabs button:hover:not(:disabled) { color: var(--text); background: transparent; border: none; }
.te-tabs button.on { background: var(--accent); color: var(--text); font-weight: 600; }
.te-tabs button.on:hover:not(:disabled) { background: var(--accent); color: var(--text); }

.te-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.te-body { }
.te-meta { max-width: 640px; }

.te-legend {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  margin: 0 0 12px; font-size: 12px; color: var(--muted);
}
.te-lg { display: inline-flex; align-items: center; gap: 7px; }
.te-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.sw-gen { background: var(--accent); }
.sw-tune { background: var(--warning); }
.sw-lock { background: var(--border-strong); }

/* split: table + docked inspector */
.te-split {
  display: grid; grid-template-columns: 1fr 320px; gap: 0;
  border: 1px solid var(--border); border-radius: var(--r-3); overflow: hidden;
  background: var(--panel);
}
@media (max-width: 820px) {
  .te-split { grid-template-columns: 1fr; }
  .te-side { border-left: none !important; border-top: 1px solid var(--border); }
}
.te-main { min-width: 0; overflow-x: auto; }

.te-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.te-tbl th {
  text-align: left; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-subtle); font-weight: 700; padding: 9px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.te-tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.te-tbl th.te-num, .te-tbl td.te-num { text-align: right; width: 1%; white-space: nowrap; }
.te-tbl tbody tr.te-row { cursor: pointer; }
.te-tbl tbody tr.te-row:hover td { background: var(--hover-2); }
.te-tbl tbody tr.sel td { background: var(--accent-weak); }
.te-tbl tbody tr.locked { cursor: default; color: var(--muted); }
.te-tbl tbody tr.locked:hover td { background: transparent; }

/* left stripe cell */
.te-tbl th.te-stripe, .te-tbl td.te-stripe { width: 3px; padding: 0 !important; }
.te-stripe-bar, .te-stripe .st-lock {
  display: block; width: 3px; height: 40px; border-radius: 3px;
}
.st-gen { background: var(--accent); }
.st-tune { background: var(--warning); }
.st-lock { background: var(--border-strong); }

.te-idx { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-subtle); font-weight: 600; }
.te-cell { display: inline-flex; align-items: center; gap: 6px; }
.te-grip { color: var(--text-subtle); cursor: grab; font-size: 13px; user-select: none; }
.te-grip:active { cursor: grabbing; }
.te-lk { color: var(--text-subtle); display: inline-flex; flex: 0 0 auto; }
.te-snm { font-weight: 600; }
.te-skey { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); }
.te-mono { font-family: var(--font-mono); font-size: 12px; }
.te-prompt { color: var(--accent); }

/* drag affordances */
.te-tbl.dragging, .te-tbl.dragging * { user-select: none; }
.te-tbl tr.dragging td { opacity: 0.38; }
.te-tbl tr.drop-into td { box-shadow: inset 0 -2px 0 0 var(--accent); }

/* inspector */
.te-side { border-left: 1px solid var(--border); background: var(--surface-1); padding: 16px; }
.te-side-empty { padding: 24px 4px; text-align: center; }
.te-ins-head { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; }
.te-ins-name { font-size: 15px; font-weight: 600; }
.te-ins-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 14px; font-family: var(--font-mono); }
.te-type-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-1); white-space: nowrap;
}
.tb-gen { color: var(--accent); background: var(--accent-weak); }
.tb-tune { color: var(--warning); background: var(--warn-weak); }
.te-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.te-flabel { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-subtle); font-weight: 700; }
.te-field input, .te-field select, .te-field textarea { width: 100%; }
.te-remove { width: 100%; margin-top: 4px; }

/* ---- Evidence Manager (topic page, evidence-management plan §3) ---- */
.topic-evidence .ev-mgr-header { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.topic-evidence .ev-mgr-header h2 { margin: 0; }
.ev-mgr-spacer { flex: 1; }
.ev-mock-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--warning); border: 1px dashed var(--warn-soft); border-radius: var(--r-pill); padding: 1px 8px; }
.ev-research-banner { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; border: 1px solid var(--warn-soft); background: var(--warn-weak); border-radius: var(--r-2); padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-3); }
.ev-research-title { font-weight: 700; color: var(--warning); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.ev-research-queries { display: flex; gap: var(--sp-2); flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.ev-research-queries li { font-family: var(--mono, monospace); font-size: 12px; border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 10px; background: var(--surface-2); }
.ev-pending { border: 1px solid var(--warn-soft); border-radius: var(--r-2); padding: var(--sp-3); margin-bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.ev-pending-head { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.ev-pending-title { font-weight: 700; color: var(--warning); }
.ev-card { display: flex; align-items: flex-start; gap: var(--sp-3); border: 1px solid var(--border-subtle); border-radius: var(--r-2); padding: var(--sp-2) var(--sp-3); background: var(--surface-2); }
.ev-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.ev-card-top { display: flex; align-items: baseline; gap: var(--sp-2); }
.ev-claim { line-height: 1.35; }
.ev-kind-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 8px; flex: none; }
.ev-stale-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; color: var(--danger); border: 1px solid var(--danger-soft); border-radius: var(--r-pill); padding: 1px 8px; flex: none; }
.ev-meta { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.ev-meta .ev-num { font-weight: 700; color: var(--text); }
.ev-origin, .ev-binding { border: 1px solid var(--border-subtle); border-radius: var(--r-pill); padding: 0 8px; font-size: 11px; }
.ev-card-actions { display: flex; gap: var(--sp-2); align-items: center; align-self: center; flex: none; }
.ev-verbatim blockquote { margin: var(--sp-1) 0 0; padding: var(--sp-1) var(--sp-3); border-left: 2px solid var(--border-strong); color: var(--muted); font-style: italic; font-size: 12.5px; }
.ev-verbatim summary { cursor: pointer; }
.ev-group-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-subtle); font-weight: 700; margin-bottom: var(--sp-1); }
.ev-form { border: 1px solid var(--border-subtle); border-radius: var(--r-2); background: var(--surface-2); padding: var(--sp-3); margin-bottom: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.ev-form-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end; }
.ev-form-field { display: flex; flex-direction: column; gap: 4px; }
.ev-form-field.grow { flex: 1; min-width: 180px; }
.ev-form-field textarea { width: 100%; resize: vertical; }
.ev-form-actions { display: flex; gap: var(--sp-2); }
.ev-detail-modal { max-width: 680px; }
.ev-modal-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.ev-claim.large { font-size: 15px; line-height: 1.45; margin: 0 0 var(--sp-2); }
.ev-modal-quote { margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-3); border-left: 2px solid var(--border-strong); color: var(--muted); font-style: italic; font-size: 13px; }
.ev-detail-modal .ev-meta { margin-bottom: var(--sp-3); }

/* ---- Evidence registry (/evidence, WS-02.3) ---- */
.evidence-registry .editor-tabs { margin-top: var(--sp-2); }
.ev-superseded-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: var(--r-pill); padding: 0 6px; margin-right: 4px; }
.ev-row-actions { white-space: nowrap; }
.ev-row-actions button { margin-right: var(--sp-1); }
/* Status chips reuse .kw-tag sizing with a per-status tint. */
.ev-status-pending { color: var(--warning); border-color: var(--warn-soft); }
.ev-status-approved { color: var(--success, #3fb950); }
.ev-status-stale { color: var(--warning); }
.ev-status-rejected, .ev-status-archived { color: var(--muted); }
/* Governance detail modal */
.ev-gov-modal { max-width: 820px; }
.ev-gov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-3); }
.ev-gov-sec { display: flex; flex-direction: column; gap: 4px; }
.ev-fact { display: flex; gap: var(--sp-2); font-size: 12.5px; align-items: baseline; }
.ev-fact-label { flex: none; width: 92px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-subtle); font-weight: 700; }
.ev-fact-value { min-width: 0; overflow-wrap: anywhere; }
.ev-gov-sub { border-top: 1px solid var(--border-subtle); padding-top: var(--sp-2); margin-bottom: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-start; }
.ev-peer-row { display: flex; gap: var(--sp-2); align-items: baseline; flex-wrap: wrap; }
.ev-peer-row.ev-resolved { opacity: 0.6; }
.ev-peer-row .link-button { text-align: left; }
.ev-peer-add { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-self: stretch; }
.ev-peer-add input.grow { flex: 1; min-width: 160px; }
.ev-gov-actions { flex-wrap: wrap; margin-bottom: var(--sp-2); }
.ev-research-queue h3 { margin-bottom: 2px; }
.ev-research-queue .ev-research-queries { flex-direction: column; gap: 2px; }

/* ---- WS-03 claim provenance (pages/claims.rs) ---- */
/* Verification + claim review states as status-chip variants. verified=green,
   qualified=amber (true but narrowed), unsupported/revoked=red, stale=amber,
   unverified/rejected/retired=muted. */
.status-chip.verified { color: var(--ok); background: var(--ok-weak); }
.status-chip.qualified, .status-chip.stale { color: var(--warning); background: var(--warn-weak); }
.status-chip.unsupported, .status-chip.revoked { color: var(--danger); background: var(--danger-weak); }
.status-chip.unverified, .status-chip.rejected, .status-chip.retired { color: var(--muted); background: var(--surface-3); }
/* Edge relationship + deterministic check chips. */
.kw-tag.rel-supports, .kw-tag.check-pass { color: var(--ok); background: var(--ok-weak); margin-left: 0; }
.kw-tag.rel-contradicts, .kw-tag.check-fail { color: var(--danger); background: var(--danger-weak); margin-left: 0; }
.kw-tag.rel-limits, .kw-tag.rel-supersedes { color: var(--warning); background: var(--warn-weak); margin-left: 0; }
.kw-tag.claim-type { color: var(--accent); background: var(--accent-weak); margin-left: 0; }
.ev-status-revoked { color: var(--danger); }
/* Edge / occurrence cards stack; chips row wraps. */
.claim-edge, .claim-occurrence { margin-bottom: var(--sp-3); }
.claim-edge .page-hero-chips, .claim-occurrence .page-hero-chips { flex-wrap: wrap; row-gap: var(--sp-1); }
.claim-affected-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-1); font-size: 12.5px; }
