/* ==========================================================================
   KEYWORD ANALYZER — design system
   --------------------------------------------------------------------------
   One system, three layers:
     1. Tokens      colour, type, space, radius, motion — defined once
     2. Primitives  button, input, chip, alert, menu, tab, panel
     3. Regions     gate, topbar, query bar, metrics, results

   Conventions
     · Light only. There is no dark palette: the tool is a reading surface
       and one well-tuned set of neutrals beats two mediocre ones.
     · The palette is black, white and grey. Hue appears in exactly one
       place — the live progress indicator — so that motion reads as the
       only thing on screen that is happening right now.
     · The four intent classes are separated by ink weight and fill, not by
       colour, which also makes them survive greyscale printing.
     · Radii are restrained: 3 / 5 / 8 / 10px. No pills.
     · Separation is by hairline first, shadow only where something floats.
   ========================================================================== */

/* ==========================================================================
   1. TOKENS
   ========================================================================== */

:root {
  /* -- Type -------------------------------------------------------------
     Geist is the display and UI face: a modern grotesk with a tall x-height
     and flat terminals that stays legible at 11px in table headers and
     still has presence at 68px. Geist Mono carries keywords and any string
     the user might copy, where character-level distinction matters. */
  --font-display: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-ui: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-display-xl: clamp(2.5rem, 1.4rem + 4.4vw, 4.25rem);
  --fs-display-l:  clamp(1.875rem, 1.25rem + 2.4vw, 2.75rem);
  --fs-h1:   1.375rem;
  --fs-h2:   1.0625rem;
  --fs-h3:   0.9375rem;
  --fs-body: 0.875rem;
  --fs-sm:   0.8125rem;
  --fs-xs:   0.75rem;
  --fs-micro: 0.6875rem;

  --lh-tight: 1.04;
  --lh-snug: 1.3;
  --lh-body: 1.55;
  --lh-loose: 1.7;

  --tr-display: -0.035em;
  --tr-tight: -0.018em;
  --tr-micro: 0.09em;

  /* -- Space (4px base) -------------------------------------------------- */
  --s-1: 2px;  --s-2: 4px;  --s-3: 6px;  --s-4: 8px;  --s-5: 12px;
  --s-6: 16px; --s-7: 20px; --s-8: 24px; --s-9: 32px; --s-10: 40px;
  --s-11: 56px; --s-12: 72px; --s-13: 96px;

  /* -- Radius ------------------------------------------------------------ */
  --r-xs: 3px; --r-sm: 5px; --r-md: 8px; --r-lg: 10px;

  /* -- Motion ------------------------------------------------------------ */
  --e-out: cubic-bezier(0.22, 1, 0.36, 1);
  --e-std: cubic-bezier(0.4, 0.14, 0.3, 1);
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 320ms;

  /* -- Surfaces ----------------------------------------------------------
     A cool, near-neutral grey ladder. The canvas is a step below white so
     that panels lift off it without needing a shadow. */
  --c-canvas:       #F4F4F5;
  --c-surface:      #FFFFFF;
  --c-surface-2:    #FAFAFB;
  --c-sunken:       #EDEDEF;
  --c-inset:        #F6F6F7;

  /* -- Ink ---------------------------------------------------------------
     Four steps only. 1 is for headings and data, 2 for body, 3 for labels,
     4 for the quietest metadata. */
  --c-ink-1: #101113;
  --c-ink-2: #34363B;
  --c-ink-3: #5C5F66;
  --c-ink-4: #6B6E75;
  /* All four clear 4.5:1 on both the canvas and white, so nothing in the
     interface is text that only mostly passes. */

  --c-line:        rgba(16, 17, 19, 0.10);
  --c-line-strong: rgba(16, 17, 19, 0.18);
  --c-line-solid:  #E3E3E6;

  /* -- Interaction -------------------------------------------------------
     The accent is ink. Primary actions are near-black on white, which in a
     monochrome system is the strongest signal available and keeps hue free
     for the one place that earns it. */
  --c-accent:      #101113;
  --c-accent-hi:   #000000;
  --c-accent-tint: #E8E8EA;
  --c-accent-line: rgba(16, 17, 19, 0.30);

  --c-on-solid: #FFFFFF;
  --c-solid:    #101113;
  --c-solid-hi: #000000;

  /* -- Live ---------------------------------------------------------------
     The single permitted hue, used only while work is in flight: the run
     progress bar and the collecting indicator. Nothing static is ever
     orange, so the colour means "this is moving" and nothing else. */
  --c-live:      #E8590C;
  --c-live-soft: rgba(232, 89, 12, 0.16);

  /* -- Status ------------------------------------------------------------
     Status is carried by ink weight, an icon and a fill — not by hue. */
  --c-ok:          #101113;  --c-ok-tint:     #F0F0F1;
  --c-warn:        #34363B;  --c-warn-tint:   #F4F4F5;
  --c-danger:      #101113;  --c-danger-tint: #F2F2F3;
  --c-danger-line: rgba(16, 17, 19, 0.26);

  /* -- Intent classes ----------------------------------------------------
     Four steps down the ink ladder, each with its own fill. Seed is the
     darkest because it is the query the user actually typed.

     Fill and ink are separate tokens on purpose: a stacked bar needs the
     four greys spread as far apart as possible to stay readable at 8px,
     while the same grey as 11px tag text on a tinted chip would fall under
     4.5:1. The -ink steps are the ones tuned against -bg. */
  --c-seed:       #101113; --c-seed-bg:       #E4E4E7; --c-seed-ink:       #101113;
  --c-alphabet:   #3F4247; --c-alphabet-bg:   #EAEAEC; --c-alphabet-ink:   #2F3237;
  --c-question:   #71747B; --c-question-bg:   #F0F0F2; --c-question-ink:   #4A4D53;
  --c-commercial: #A6A9AF; --c-commercial-bg: #F5F5F6; --c-commercial-ink: #5C5F66;

  --shadow-sm: 0 1px 2px rgba(16, 17, 19, 0.05);
  --shadow-md: 0 4px 12px -4px rgba(16, 17, 19, 0.10), 0 1px 2px rgba(16, 17, 19, 0.05);
  --shadow-pop: 0 12px 32px -12px rgba(16, 17, 19, 0.24), 0 2px 6px -2px rgba(16, 17, 19, 0.10);

  --focus: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-accent-line);
  --topbar-h: 58px;
  --maxw: 1200px;

  color-scheme: light;
}

/* ==========================================================================
   2. RESET / BASE
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--c-canvas);
  color: var(--c-ink-1);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-feature-settings: "cv05" 1, "ss03" 1, "tnum" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--c-accent); color: #fff; }

.is-hidden { display: none !important; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-xs);
}

.skip-link {
  position: absolute; left: var(--s-6); top: -60px; z-index: 100;
  padding: var(--s-4) var(--s-6);
  background: var(--c-solid); color: var(--c-on-solid);
  border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 550;
  transition: top var(--t-base) var(--e-out);
}
.skip-link:focus { top: var(--s-6); text-decoration: none; }

/* One icon system. Every glyph is authored in a 20x20 box with a 1.5 stroke;
   the markup carries viewBox="0 0 20 20" (CSS cannot set it) and size comes
   from width/height here, so stroke weight stays optically even at any size. */
.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.icon use { pointer-events: none; }

/* ==========================================================================
   3. PRIMITIVES
   ========================================================================== */

/* -- Eyebrow --------------------------------------------------------------*/
.eyebrow {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase;
  color: var(--c-ink-3);
}
.eyebrow__dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--c-accent); flex: none;
}
/* The running dot is the other place hue is allowed: it and the progress bar
   are the only live things on screen. The halo keeps it findable at 5px. */
.eyebrow__dot--live {
  background: var(--c-live);
  animation: pulse 1.8s var(--e-std) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 var(--c-live-soft); }
  50%      { opacity: .55; transform: scale(.86); box-shadow: 0 0 0 4px transparent; }
}

/* -- Buttons --------------------------------------------------------------*/
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-3);
  height: 36px; padding: 0 var(--s-5);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 550;
  letter-spacing: -0.006em; white-space: nowrap;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--e-std),
              border-color var(--t-fast) var(--e-std),
              color var(--t-fast) var(--e-std),
              opacity var(--t-fast) var(--e-std),
              transform var(--t-fast) var(--e-std);
}
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn__icon { width: 15px; height: 15px; }
.btn__chev { width: 14px; height: 14px; opacity: .6; margin-left: calc(-1 * var(--s-1)); }

.btn--lg { height: 44px; padding: 0 var(--s-7); font-size: var(--fs-body); }
.btn--sm { height: 30px; padding: 0 var(--s-4); font-size: var(--fs-xs); gap: var(--s-2); }
.btn--sm .btn__icon { width: 14px; height: 14px; }
.btn--block { width: 100%; }

.btn--primary { background: var(--c-solid); color: var(--c-on-solid); }
.btn--primary:hover:not(:disabled) { background: var(--c-solid-hi); }
.btn--primary:active:not(:disabled) { transform: translateY(0.5px); }

.btn--secondary {
  background: var(--c-surface); color: var(--c-ink-1);
  border-color: var(--c-line-strong); box-shadow: var(--shadow-sm);
}
.btn--secondary:hover:not(:disabled) { background: var(--c-surface-2); border-color: var(--c-ink-4); }

.btn--ghost { background: transparent; color: var(--c-ink-2); }
.btn--ghost:hover:not(:disabled) { background: var(--c-sunken); color: var(--c-ink-1); }

.btn--danger { background: transparent; color: var(--c-danger); border-color: var(--c-danger-line); }
.btn--danger:hover:not(:disabled) { background: var(--c-danger-tint); }

.btn.is-done { color: var(--c-ink-1); }
.btn.is-busy { cursor: progress; }

/* -- Download group -------------------------------------------------------
      Downloads sit in the tab that owns the data rather than behind one
      "Export" menu, because the formats differ per tab and a hidden menu
      made the most-used action in the tool invisible. The default format is
      filled; the alternates are hairline, so the recommended path is
      obvious without the others being hard to find. --------------------- */
.dl { display: inline-flex; align-items: center; gap: var(--s-2); }
.dl__label {
  margin-right: var(--s-1);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase;
  color: var(--c-ink-4);
}
.dl__btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 30px; padding: 0 var(--s-5);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-sm);
  background: var(--c-surface); color: var(--c-ink-2);
  font: inherit; font-size: var(--fs-xs); font-weight: 560;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--t-fast) var(--e-std),
              border-color var(--t-fast) var(--e-std),
              color var(--t-fast) var(--e-std);
}
.dl__btn .icon { width: 14px; height: 14px; }
.dl__btn:hover:not(:disabled) { background: var(--c-inset); border-color: var(--c-ink-4); color: var(--c-ink-1); }
.dl__btn:active:not(:disabled) { transform: translateY(0.5px); }
.dl__btn:focus-visible { outline: none; box-shadow: var(--focus); }
.dl__btn:disabled { cursor: progress; opacity: .55; }
.dl__btn--primary {
  background: var(--c-solid); border-color: var(--c-solid); color: var(--c-on-solid);
}
.dl__btn--primary:hover:not(:disabled) { background: var(--c-solid-hi); border-color: var(--c-solid-hi); color: var(--c-on-solid); }
.dl__btn.is-done { background: var(--c-surface); border-color: var(--c-ink-1); color: var(--c-ink-1); }

/* Keeps copy-and-download together at the end of a toolbar, and lets the
   pair wrap as one unit on narrow screens. */
.toolbar__end { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
@media (max-width: 40rem) {
  .dl__label { display: none; }
  .toolbar__end { width: 100%; justify-content: space-between; }
}
/* On the narrowest phones the format buttons wrap rather than push the page
   sideways; three formats are worth two rows, a horizontal scrollbar is not. */
@media (max-width: 26rem) {
  .dl { flex-wrap: wrap; }
  .dl__btn { padding: 0 var(--s-4); }
}

/* -- Chip button ----------------------------------------------------------*/
.chip-btn {
  height: 28px; padding: 0 var(--s-5);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-xs);
  background: var(--c-surface); color: var(--c-ink-2);
  font-size: var(--fs-xs); font-weight: 480;
  transition: all var(--t-fast) var(--e-std);
}
.chip-btn:hover:not(:disabled) { border-color: var(--c-ink-4); color: var(--c-ink-1); background: var(--c-surface-2); }
.chip-btn:disabled { opacity: .45; cursor: not-allowed; }

/* -- Badges / tags --------------------------------------------------------*/
.badge {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 20px; padding: 0 var(--s-3);
  border-radius: var(--r-xs);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: 0.02em; text-transform: none;
}
.badge .icon { width: 12px; height: 12px; }
.badge--cached { background: var(--c-accent-tint); color: var(--c-accent); }

.tag {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 var(--s-3);
  border-radius: var(--r-xs);
  font-family: var(--font-ui);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.tag--seed       { background: var(--c-seed-bg);       color: var(--c-seed-ink); }
.tag--alphabet   { background: var(--c-alphabet-bg);   color: var(--c-alphabet-ink); }
.tag--question   { background: var(--c-question-bg);   color: var(--c-question-ink); }
.tag--commercial { background: var(--c-commercial-bg); color: var(--c-commercial-ink); }

/* -- Form field -----------------------------------------------------------*/
.field { margin-bottom: var(--s-5); }
.label {
  display: block; margin-bottom: var(--s-3);
  font-size: var(--fs-xs); font-weight: 530;
  letter-spacing: -0.004em; color: var(--c-ink-2);
}
.input {
  width: 100%; height: 42px; padding: 0 var(--s-5);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-sm);
  font-size: var(--fs-body); color: var(--c-ink-1);
  transition: border-color var(--t-fast) var(--e-std), box-shadow var(--t-fast) var(--e-std);
}
.input::placeholder { color: var(--c-ink-4); }
.input:hover { border-color: var(--c-ink-4); }
.input:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-tint); }
.input[aria-invalid="true"] { border-color: var(--c-danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--c-danger-tint); }
.input:disabled { background: var(--c-sunken); color: var(--c-ink-4); cursor: not-allowed; }

/* A field with a control sitting inside it (the password reveal). The input
   keeps its own box; the affix is placed over its trailing padding. */
.field__wrap { position: relative; display: flex; align-items: center; }
.input--has-affix { padding-right: 42px; }
.field__affix {
  position: absolute; right: 5px;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-xs);
  color: var(--c-ink-4);
  transition: color var(--t-fast) var(--e-std), background var(--t-fast) var(--e-std);
}
.field__affix:hover { color: var(--c-ink-2); background: var(--c-inset); }
.field__affix .icon { width: 17px; height: 17px; }

.form-error {
  display: flex; align-items: flex-start; gap: var(--s-3);
  margin-bottom: var(--s-5);
  font-size: var(--fs-sm); color: var(--c-danger);
}
.form-error .icon { width: 15px; height: 15px; margin-top: 2px; }
.form-error--loose { margin: calc(-1 * var(--s-3)) 0 var(--s-6); }

/* -- Search input ---------------------------------------------------------*/
.search { position: relative; flex: 1 1 200px; min-width: 0; max-width: 320px; }
.search__icon {
  position: absolute; left: var(--s-4); top: 50%; transform: translateY(-50%);
  color: var(--c-ink-4); pointer-events: none; width: 15px; height: 15px;
}
.search__input {
  width: 100%; height: 34px;
  padding: 0 var(--s-4) 0 var(--s-9);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--c-ink-1);
  transition: border-color var(--t-fast) var(--e-std), box-shadow var(--t-fast) var(--e-std);
}
.search__input::placeholder { color: var(--c-ink-4); }
.search__input:hover { border-color: var(--c-ink-4); }
.search__input:focus {
  outline: none; background: var(--c-surface);
  border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-tint);
}

/* -- Segmented control ----------------------------------------------------*/
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--c-inset);
  border-radius: var(--r-sm);
}
.segmented__btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 30px; padding: 0 var(--s-4);
  border-radius: var(--r-xs);
  font-size: var(--fs-xs); font-weight: 520;
  color: var(--c-ink-3);
  transition: all var(--t-fast) var(--e-std);
}
.segmented__btn .icon { width: 14px; height: 14px; }
.segmented__btn:hover { color: var(--c-ink-1); }
.segmented__btn[aria-pressed="true"] {
  background: var(--c-surface); color: var(--c-ink-1);
  box-shadow: var(--shadow-sm); font-weight: 560;
}

/* -- Menu (dropdown) ------------------------------------------------------*/
.menu { position: relative; }
.menu__panel {
  position: absolute; top: calc(100% + var(--s-3)); left: 0; z-index: 60;
  min-width: 208px; padding: var(--s-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  animation: menu-in var(--t-base) var(--e-out);
}
.menu__panel--right { left: auto; right: 0; }
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.menu__head {
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--c-line);
  margin-bottom: var(--s-2);
}
.menu__label {
  display: block; font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase; color: var(--c-ink-3);
}
.menu__value { display: block; margin-top: var(--s-1); font-size: var(--fs-sm); font-weight: 550; }
.menu__item {
  display: flex; align-items: center; gap: var(--s-4);
  width: 100%; padding: var(--s-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 480; color: var(--c-ink-2);
  text-align: left;
  transition: background var(--t-fast) var(--e-std), color var(--t-fast) var(--e-std);
}
.menu__item:hover { background: var(--c-inset); color: var(--c-ink-1); }
.menu__item .icon { color: var(--c-ink-4); }
.menu__item:hover .icon { color: var(--c-ink-2); }
.menu__hint {
  margin-left: var(--s-3); font-family: var(--font-mono);
  font-size: var(--fs-micro); color: var(--c-ink-3);
}

/* -- Alert ----------------------------------------------------------------*/
.alert {
  display: flex; align-items: flex-start; gap: var(--s-5);
  padding: var(--s-6);
  border: 1px solid; border-radius: var(--r-md);
}
.alert__icon { width: 18px; height: 18px; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-size: var(--fs-h3); font-weight: 600; letter-spacing: var(--tr-tight); }
.alert__text { margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--c-ink-2); }
.alert--danger  { background: var(--c-danger-tint); border-color: var(--c-danger-line); }
.alert--danger  .alert__icon, .alert--danger .alert__title { color: var(--c-danger); }
.alert--warning { background: var(--c-warn-tint); border-color: rgba(138, 90, 22, .22); }
.alert--warning .alert__icon, .alert--warning .alert__title { color: var(--c-warn); }

.lib-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-6);
  background: var(--c-warn-tint); color: var(--c-warn);
  border-bottom: 1px solid rgba(138, 90, 22, .22);
  font-size: var(--fs-sm); text-align: center;
}

/* -- Progress -------------------------------------------------------------*/
.progress {
  position: relative; height: 4px;
  background: var(--c-sunken); border-radius: 2px; overflow: hidden;
}
.progress--thin { height: 3px; flex: 1; }
/* The one place hue is allowed. Progress is the only thing on screen that
   is actively happening, so it is the only thing that gets colour. */
.progress__fill {
  display: block; height: 100%; width: 0%;
  background: var(--c-live); border-radius: 2px;
  transition: width var(--t-slow) var(--e-out);
}
.progress__fill--indeterminate {
  width: 36% !important;
  animation: slide 1.5s var(--e-std) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

/* -- Disclosure -----------------------------------------------------------*/
.disclose { margin-top: var(--s-5); }
.disclose__summary {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--fs-sm); font-weight: 520; color: var(--c-ink-2);
  cursor: pointer; list-style: none; width: fit-content;
}
.disclose__summary::-webkit-details-marker { display: none; }
.disclose__summary:hover { color: var(--c-ink-1); }
.disclose__chev { width: 14px; height: 14px; transition: transform var(--t-base) var(--e-out); }
.disclose[open] .disclose__chev { transform: rotate(90deg); }
.disclose__list {
  margin-top: var(--s-4); padding-left: var(--s-7);
  display: grid; gap: var(--s-2);
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--c-ink-3);
}

/* -- Note -----------------------------------------------------------------*/
.note {
  padding: var(--s-4) var(--s-6);
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--c-ink-2);
}

/* -- Brand lockup ---------------------------------------------------------*/
.lockup { display: inline-flex; align-items: center; gap: var(--s-4); }
.lockup__mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: none;
  background: var(--c-solid); color: var(--c-on-solid);
  border-radius: var(--r-sm);
}
.lockup__mark svg { width: 22px; height: 22px; }
.lockup__word {
  font-family: var(--font-display);
  font-size: 1.0625rem; font-weight: 600;
  letter-spacing: -0.025em; color: var(--c-ink-1);
  white-space: nowrap;
}
.lockup--sm .lockup__mark { width: 26px; height: 26px; }
.lockup--sm .lockup__mark svg { width: 19px; height: 19px; }
.lockup--invert .lockup__mark { background: rgba(255, 255, 255, .1); color: #fff; }
.lockup--invert .lockup__word { color: #fff; }

/* ==========================================================================
   4. GATE (sign-in)
   ========================================================================== */

.gate { min-height: 100vh; min-height: 100dvh; display: grid; }

.gate__brand {
  display: none;
  position: relative; overflow: hidden;
  padding: var(--s-11) var(--s-10);
  background: #101115; color: #fff;
}

.gate__brand-mark { position: absolute; top: var(--s-11); left: var(--s-10); z-index: 1; }
.gate__brand-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; justify-content: center;
  height: 100%; max-width: 31rem;
}
.gate__display {
  font-family: var(--font-display);
  font-size: var(--fs-display-l); font-weight: 500;
  line-height: 1.06; letter-spacing: var(--tr-display);
  color: #fff;
}
.gate__lede {
  margin-top: var(--s-6); max-width: 26rem;
  font-size: var(--fs-body); line-height: var(--lh-loose);
  color: rgba(255, 255, 255, .58);
}
.gate__facts {
  display: flex; gap: var(--s-9);
  margin-top: var(--s-9); padding-top: var(--s-7);
  border-top: 1px solid rgba(255, 255, 255, .12);
}
.fact__n {
  display: block; font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 550; letter-spacing: -0.03em; color: #fff;
}
.fact__l {
  display: block; margin-top: var(--s-1);
  font-size: var(--fs-micro); letter-spacing: var(--tr-micro);
  text-transform: uppercase; color: rgba(255, 255, 255, .42);
}

.gate__panel {
  display: grid; place-items: center;
  padding: var(--s-9) var(--s-6);
  background: var(--c-canvas);
}
.gate__form-wrap { width: 100%; max-width: 23rem; }
.gate__mobile-lockup { margin-bottom: var(--s-9); }
.gate__title {
  margin-top: var(--s-5);
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 550;
  letter-spacing: var(--tr-display); line-height: 1.1;
}
.gate__sub { margin: var(--s-3) 0 var(--s-9); font-size: var(--fs-sm); color: var(--c-ink-3); }
.gate__foot {
  display: flex; align-items: center; gap: var(--s-3);
  margin-top: var(--s-8); padding-top: var(--s-6);
  border-top: 1px solid var(--c-line);
  font-size: var(--fs-xs); color: var(--c-ink-3);
}
.gate__foot .icon { width: 14px; height: 14px; }

@media (min-width: 62rem) {
  .gate { grid-template-columns: 1.05fr 1fr; }
  .gate__brand { display: block; }
  .gate__mobile-lockup { display: none; }
  .gate__panel { padding: var(--s-10); }
}

/* -- Demo-mode banner -----------------------------------------------------
      Mock data must never be mistakable for a real run. The striped edge is
      the one place a non-neutral treatment earns its keep: it has to be
      impossible to overlook, including in a screenshot sent to someone who
      was not there when it was taken. --------------------------------- */
.demo-banner {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-7);
  background: var(--c-ink-1); color: var(--c-on-solid);
  font-size: var(--fs-sm);
  border-bottom: 3px solid var(--c-live);
}
.demo-banner .icon { width: 17px; height: 17px; flex: none; color: var(--c-live); }
.demo-banner strong { font-weight: 600; }
.demo-banner code {
  font-family: var(--font-mono); font-size: var(--fs-micro);
  padding: 1px var(--s-2); border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.14);
}
/* The topbar sits below the banner rather than under it. */
body.is-mock .topbar { top: auto; }

/* ==========================================================================
   5. APP SHELL
   ========================================================================== */

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: var(--c-canvas);
  border-bottom: 1px solid var(--c-line);
}
.topbar__inner {
  max-width: var(--maxw); height: 100%; margin: 0 auto;
  padding: 0 var(--s-8);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-6);
}
.topbar__right { display: flex; align-items: center; gap: var(--s-5); }

.quota { display: flex; align-items: center; gap: var(--s-4); }
.quota__meter {
  width: 52px; height: 4px; border-radius: 2px;
  background: var(--c-line-strong); overflow: hidden;
}
.quota__fill {
  display: block; height: 100%; width: 100%;
  background: var(--c-ok); border-radius: 2px;
  transition: width var(--t-slow) var(--e-out), background var(--t-base) var(--e-std);
}
.quota__fill.is-low  { background: var(--c-warn); }
.quota__fill.is-none { background: var(--c-danger); }
.quota__text { font-size: var(--fs-xs); color: var(--c-ink-3); white-space: nowrap; }
.quota__text b { font-weight: 600; color: var(--c-ink-1); font-variant-numeric: tabular-nums; }

.account {
  display: flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-2) 0 var(--s-2);
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--e-std);
}
.account:hover { background: var(--c-sunken); }
.account[aria-expanded="true"] { background: var(--c-sunken); }
.account__avatar {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--c-solid); color: var(--c-on-solid);
  border-radius: var(--r-xs);
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
}
.account__chev { width: 14px; height: 14px; color: var(--c-ink-4); transition: transform var(--t-base) var(--e-out); }
.account[aria-expanded="true"] .account__chev { transform: rotate(180deg); }

.workspace {
  flex: 1; width: 100%; max-width: var(--maxw);
  margin: 0 auto; padding: var(--s-10) var(--s-8) var(--s-12);
  display: flex; flex-direction: column;
}

.footer {
  display: flex; align-items: center; justify-content: center; gap: var(--s-4);
  flex-wrap: wrap;
  max-width: var(--maxw); margin: 0 auto; width: 100%;
  padding: var(--s-7) var(--s-8);
  border-top: 1px solid var(--c-line);
  font-size: var(--fs-xs); color: var(--c-ink-3);
}
.footer__sep { opacity: .5; }

/* ==========================================================================
   6. QUERY BAR
   Reinterpreted from the reference's segmented filter strip: hairline
   dividers, a micro-label above each value, action fused to the end.
   ========================================================================== */

.query {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color var(--t-base) var(--e-std), box-shadow var(--t-base) var(--e-std);
}
.query:focus-within { border-color: var(--c-ink-4); }

.query__seg { padding: var(--s-5) var(--s-7); min-width: 0; border-right: 1px solid var(--c-line); }
.query__seg--main { padding-right: var(--s-5); }
.query__seg--meta { display: flex; flex-direction: column; justify-content: center; min-width: 104px; }

.query__label {
  display: block; margin-bottom: var(--s-2);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase; color: var(--c-ink-3);
}
.query__value {
  font-family: var(--font-mono); font-size: var(--fs-sm);
  color: var(--c-ink-2); font-variant-numeric: tabular-nums;
}
/* -- Market selector -----------------------------------------------------
      A listbox of our own rather than a native <select>: the browser's option
      popup is drawn by the OS, so its square corners and system typography
      cannot be brought in line with the rest of the surface. The panel is
      fixed-positioned and placed from script, because the query bar clips its
      own overflow to keep the segment corners rounded. ------------------ */
.query__seg--market { display: flex; flex-direction: column; justify-content: center; }
.query__select-row { display: flex; align-items: center; gap: var(--s-3); }
.market { min-width: 0; }
.market__btn {
  display: flex; align-items: center; gap: var(--s-3);
  height: 26px; max-width: 13rem; padding: 0 var(--s-2) 0 0;
  font-family: var(--font-ui);
  font-size: var(--fs-sm); font-weight: 520;
  color: var(--c-ink-1);
  text-align: left;
}
.market__btn:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
.market__btn:disabled { color: var(--c-ink-4); cursor: not-allowed; }
.market__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market__panel {
  position: fixed; z-index: 70;
  padding: var(--s-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  animation: menu-in var(--t-base) var(--e-out);
}
.market__option {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 480; color: var(--c-ink-2);
  text-align: left; white-space: nowrap;
  transition: background var(--t-fast) var(--e-std), color var(--t-fast) var(--e-std);
}
.market__option:hover { background: var(--c-inset); color: var(--c-ink-1); }
.market__option[aria-selected="true"] { color: var(--c-ink-1); font-weight: 560; }
.market__tick { width: 15px; height: 15px; margin-left: auto; color: var(--c-ink-1); }
.market__option[aria-selected="false"] .market__tick { visibility: hidden; }
.query__chev { width: 14px; height: 14px; color: var(--c-ink-4); flex: none; transition: transform var(--t-base) var(--e-out); }
.market__btn[aria-expanded="true"] .query__chev { transform: rotate(180deg); }
.query__seg--market:hover .query__chev { color: var(--c-ink-2); }

/* What the chosen market actually changes, stated rather than implied — the
   difference between markets is invisible until a run comes back. */
.query__hint {
  margin-top: var(--s-4);
  font-size: var(--fs-xs); color: var(--c-ink-3);
}
.query__hint code {
  font-family: var(--font-mono); font-size: var(--fs-micro);
  padding: 1px var(--s-2);
  background: var(--c-inset); border-radius: var(--r-xs);
  color: var(--c-ink-2);
}

.query__input-row { display: flex; align-items: center; gap: var(--s-4); }
.query__icon { color: var(--c-ink-4); width: 17px; height: 17px; }
.query__input {
  flex: 1; min-width: 0; height: 26px;
  border: 0; background: none; padding: 0;
  font-family: var(--font-display);
  font-size: 1.125rem; font-weight: 500; letter-spacing: var(--tr-tight);
  color: var(--c-ink-1);
}
.query__input::placeholder { color: var(--c-ink-4); font-weight: 400; }
.query__input:focus { outline: none; }
.query__input:focus-visible { box-shadow: none; }
.query__input:disabled { color: var(--c-ink-4); cursor: not-allowed; }

.query__action { padding: var(--s-5); display: flex; align-items: center; }
.query__action .btn { min-width: 168px; }

@media (max-width: 72rem) {
  /* Market gets the full width beside the topic before the metadata wraps:
     it is an input, and the two metadata cells are not. */
  .query { grid-template-columns: 1fr 1fr 1fr; }
  .query__seg--main { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--c-line); }
  .query__seg--market { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--c-line); }
  .market, .market__btn { max-width: none; width: 100%; }
  .query__action { grid-column: 1 / -1; border-top: 1px solid var(--c-line); }
  .query__action .btn { min-width: 0; }
}
@media (max-width: 40rem) {
  .query { grid-template-columns: 1fr 1fr; }
  .query__seg--meta:last-of-type { border-right: 0; }
}

/* ==========================================================================
   7. RUN / STATUS
   ========================================================================== */

.status-region { margin-top: var(--s-7); display: grid; gap: var(--s-5); }

.run-panel {
  padding: var(--s-7);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.run-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-5); }
.run-panel__elapsed {
  font-family: var(--font-mono); font-size: var(--fs-sm);
  color: var(--c-ink-3); font-variant-numeric: tabular-nums;
}
.run-panel__stage {
  margin: var(--s-5) 0 var(--s-5);
  font-family: var(--font-display);
  font-size: var(--fs-h2); font-weight: 500; letter-spacing: var(--tr-tight);
}
.run-panel__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-5);
  margin-top: var(--s-5);
}
.run-panel__hint { font-size: var(--fs-xs); color: var(--c-ink-3); }

.countdown { display: flex; align-items: center; gap: var(--s-4); margin-top: var(--s-5); }
.countdown__value {
  font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 500;
  color: var(--c-danger); font-variant-numeric: tabular-nums;
}
.alert--danger .progress { background: rgba(162, 44, 28, .16); }
.alert--danger .progress__fill { background: var(--c-danger); }

/* ==========================================================================
   8. EMPTY STATE
   ========================================================================== */

.empty {
  flex: 1;
  display: grid; grid-template-columns: 1fr; gap: var(--s-10);
  align-items: start; align-content: start;
  margin-top: var(--s-9);
  padding: var(--s-11) 0 var(--s-12);
  border-top: 1px solid var(--c-line);
}
.empty__display {
  margin-top: var(--s-6);
  font-family: var(--font-display);
  font-size: var(--fs-display-l); font-weight: 500;
  line-height: var(--lh-tight); letter-spacing: var(--tr-display);
}
.empty__lede {
  margin-top: var(--s-6); max-width: 34rem;
  font-size: var(--fs-body); line-height: var(--lh-loose); color: var(--c-ink-3);
}
.empty__chips { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-8); }
.empty__chips-label {
  margin-right: var(--s-2);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase; color: var(--c-ink-3);
}
.empty__viz { display: none; margin: 0; }

/* -- Specimen -------------------------------------------------------------
      The empty state has to answer one question — what will I get? — so it
      shows the answer rather than decorating around it: a miniature of the
      real intent breakdown, using the same ink steps and the same mono face
      the results use. It doubles as the class legend. ------------------- */
.spec {
  background: var(--c-surface);
  border: 1px solid var(--c-line-solid);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.spec__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-5);
  padding: var(--s-6) var(--s-7);
  border-bottom: 1px solid var(--c-line);
}
.spec__title {
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase;
  color: var(--c-ink-3);
}
.spec__note {
  font-family: var(--font-mono);
  font-size: var(--fs-micro); color: var(--c-ink-4);
}
.spec__rows { list-style: none; margin: 0; padding: var(--s-3) 0; }
.spec__row {
  display: grid; grid-template-columns: 6.5rem minmax(0, 1fr);
  align-items: center; gap: var(--s-5);
  padding: var(--s-4) var(--s-7);
}
.spec__class {
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase;
  color: var(--c-ink-2);
}
.spec__bar {
  height: 6px; border-radius: 2px;
  background: var(--c-sunken);
  overflow: hidden;
}
.spec__fill {
  display: block; height: 100%;
  border-radius: 2px;
  animation: spec-grow 900ms var(--e-out) both;
}
.spec__fill--seed       { background: var(--c-seed); }
.spec__fill--alphabet   { background: var(--c-alphabet); }
.spec__fill--question   { background: var(--c-question); }
.spec__fill--commercial { background: var(--c-commercial); }
@keyframes spec-grow { from { transform: scaleX(0); transform-origin: left; } to { transform: none; } }

.spec__ex {
  grid-column: 2;
  margin-top: var(--s-2);
  font-family: var(--font-mono); font-size: var(--fs-micro);
  color: var(--c-ink-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.spec__foot {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-7);
  border-top: 1px solid var(--c-line);
  background: var(--c-surface-2);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase;
  color: var(--c-ink-3);
}
.spec__foot .icon { width: 14px; height: 14px; color: var(--c-ink-4); }

@media (min-width: 60rem) {
  .empty { grid-template-columns: 1fr 0.92fr; gap: var(--s-11); align-items: center; align-content: start; }
  .empty__viz { display: block; }
}

/* ==========================================================================
   9. RESULTS
   ========================================================================== */

.results { margin-top: var(--s-10); animation: rise var(--t-slow) var(--e-out); }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.results__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-8); flex-wrap: wrap;
  padding-bottom: var(--s-8);
  border-bottom: 1px solid var(--c-line);
}
.results__title { min-width: 0; }
.results__actions { flex: none; padding-top: var(--s-2); }
.results__display {
  margin-top: var(--s-5);
  font-family: var(--font-display);
  font-size: var(--fs-display-l); font-weight: 500;
  line-height: var(--lh-tight); letter-spacing: var(--tr-display);
  overflow-wrap: break-word;
}
.results__meta {
  display: flex; align-items: center; gap: var(--s-3);
  margin-top: var(--s-5);
  font-size: var(--fs-xs); color: var(--c-ink-3);
}
.results__meta .icon { width: 13px; height: 13px; }
.results__actions { display: flex; gap: var(--s-4); }

/* -- Metrics --------------------------------------------------------------*/
.metrics {
  display: grid; grid-template-columns: repeat(2, 1fr);
  margin-top: var(--s-8);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  overflow: hidden;
}
.metric {
  padding: var(--s-7);
  border-right: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
}
.metric:nth-child(2n) { border-right: 0; }
.metric:nth-last-child(-n+2) { border-bottom: 0; }
.metric__label {
  display: block;
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase; color: var(--c-ink-3);
}
.metric__value {
  display: block; margin-top: var(--s-4);
  font-family: var(--font-display);
  font-size: 1.75rem; font-weight: 550;
  letter-spacing: -0.03em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric__sub { display: block; margin-top: var(--s-3); font-size: var(--fs-xs); color: var(--c-ink-3); }
.metric__bar { height: 3px; margin-top: var(--s-5); background: var(--c-sunken); border-radius: 2px; overflow: hidden; }
.metric__bar-fill {
  display: block; height: 100%; width: 0;
  background: var(--c-ok); border-radius: 2px;
  transition: width var(--t-slow) var(--e-out);
}
.metric__bar-fill.is-partial { background: var(--c-warn); }

@media (min-width: 52rem) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metric { border-bottom: 0; }
  .metric:nth-child(2n) { border-right: 1px solid var(--c-line); }
  .metric:last-child { border-right: 0; }
}

/* -- Intent mix -----------------------------------------------------------*/
.mix {
  margin-top: var(--s-6); padding: var(--s-7);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
}
.mix__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-6); flex-wrap: wrap; }
.mix__title { font-size: var(--fs-h3); font-weight: 600; letter-spacing: var(--tr-tight); }
.mix__note { font-size: var(--fs-xs); color: var(--c-ink-3); }
.mix__bar {
  display: flex; gap: 2px;
  height: 8px; margin-top: var(--s-6);
  border-radius: var(--r-xs); overflow: hidden;
}
.mix__slice { height: 100%; transition: opacity var(--t-fast) var(--e-std); min-width: 2px; }
.mix__slice--seed       { background: var(--c-seed); }
.mix__slice--alphabet   { background: var(--c-alphabet); }
.mix__slice--question   { background: var(--c-question); }
.mix__slice--commercial { background: var(--c-commercial); }
.mix__legend {
  display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-8);
  margin-top: var(--s-6);
}
.mix__legend li { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-xs); }
.mix__swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.mix__name { color: var(--c-ink-2); text-transform: capitalize; }
.mix__pct {
  font-family: var(--font-mono); color: var(--c-ink-3);
  font-variant-numeric: tabular-nums;
}

/* -- Tabs -----------------------------------------------------------------*/
.tabs {
  display: flex; gap: var(--s-7);
  margin-top: var(--s-10);
  border-bottom: 1px solid var(--c-line);
}
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) 0 var(--s-5);
  font-size: var(--fs-sm); font-weight: 520; color: var(--c-ink-3);
  transition: color var(--t-fast) var(--e-std);
}
.tab .icon { width: 15px; height: 15px; }
.tab::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1.5px; background: var(--c-ink-1);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--t-base) var(--e-out);
}
.tab:hover { color: var(--c-ink-1); }
.tab[aria-selected="true"] { color: var(--c-ink-1); font-weight: 600; }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab__count {
  padding: 1px var(--s-3);
  background: var(--c-inset); border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--c-ink-3);
  font-variant-numeric: tabular-nums;
}

/* -- Panels ---------------------------------------------------------------*/
.panel { padding-top: var(--s-8); }
.panel__toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-5); margin-bottom: var(--s-7);
}
.panel__toolbar--wrap { flex-wrap: wrap; }
.panel__caption { font-size: var(--fs-xs); color: var(--c-ink-3); }
@media (max-width: 30rem) { .attrib__label { display: none; } }
.panel__summary {
  margin-bottom: var(--s-5);
  font-size: var(--fs-xs); color: var(--c-ink-3);
  font-variant-numeric: tabular-nums;
}

/* -- Attribution ----------------------------------------------------------
      Which model wrote the report, stated next to the report itself. The dot
      reuses an existing intent hue per provider so no new colour enters the
      palette. --------------------------------------------------------------*/
.attrib { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-xs); min-width: 0; }
.attrib__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-ink-4); flex: none; }
.attrib__dot--anthropic { background: var(--c-commercial); }
.attrib__dot--openai    { background: var(--c-question); }
.attrib__dot--gemini    { background: var(--c-seed); }
.attrib__label { color: var(--c-ink-3); }
.attrib__provider { font-weight: 600; color: var(--c-ink-1); }
.attrib__model {
  padding: 1px var(--s-3);
  background: var(--c-inset); border: 1px solid var(--c-line); border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--c-ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* -- Per-provider failure list -------------------------------------------*/
.failures {
  display: grid; gap: var(--s-4);
  margin-top: var(--s-6); padding-top: var(--s-5);
  border-top: 1px solid var(--c-danger-line);
}
.failure { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; font-size: var(--fs-sm); }
.failure__dot { width: 6px; height: 6px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.failure__name { font-weight: 600; color: var(--c-ink-1); }
.failure__model {
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--c-ink-3);
}
.failure__reason { color: var(--c-ink-2); }
.failure__reason::before { content: "— "; color: var(--c-ink-4); }

/* -- Grouped keywords -----------------------------------------------------*/
.groups {
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  overflow: hidden;
}
.group { border-bottom: 1px solid var(--c-line); }
.group:last-child { border-bottom: 0; }
.group__summary {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-5) var(--s-7);
  cursor: pointer; list-style: none;
  transition: background var(--t-fast) var(--e-std);
}
.group__summary::-webkit-details-marker { display: none; }
.group__summary:hover { background: var(--c-surface-2); }
.group__chev { width: 14px; height: 14px; color: var(--c-ink-4); transition: transform var(--t-base) var(--e-out); flex: none; }
.group[open] > .group__summary .group__chev { transform: rotate(90deg); }
.group[open] > .group__summary { background: var(--c-surface-2); }
.group__query {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--c-ink-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.group__count {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--c-ink-3);
  font-variant-numeric: tabular-nums; flex: none;
}
.group__body {
  padding: var(--s-2) var(--s-7) var(--s-6) calc(var(--s-7) + var(--s-7));
  display: grid; gap: 1px;
}
.group__kw {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-xs);
  font-size: var(--fs-sm); color: var(--c-ink-2);
  transition: background var(--t-fast) var(--e-std), color var(--t-fast) var(--e-std);
}
.group__kw:hover { background: var(--c-inset); color: var(--c-ink-1); }

/* -- Flat keywords --------------------------------------------------------*/
.flat {
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  overflow: hidden;
}
.flat__row {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: var(--s-5);
  padding: var(--s-5) var(--s-7);
  border-bottom: 1px solid var(--c-line);
  transition: background var(--t-fast) var(--e-std);
}
.flat__row:last-child { border-bottom: 0; }
.flat__row:hover { background: var(--c-surface-2); }
.flat__kw { font-size: var(--fs-body); color: var(--c-ink-1); min-width: 0; overflow-wrap: break-word; }
.flat__src {
  margin-top: var(--s-2);
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--c-ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flat__tags { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }

/* -- Inline empty (filter yields nothing) --------------------------------*/
.void {
  padding: var(--s-11) var(--s-7);
  text-align: center;
}
.void__icon { width: 22px; height: 22px; color: var(--c-ink-4); margin-bottom: var(--s-5); }
.void__title { font-size: var(--fs-h3); font-weight: 600; letter-spacing: var(--tr-tight); }
.void__text { margin-top: var(--s-3); font-size: var(--fs-sm); color: var(--c-ink-3); }

/* ==========================================================================
   10. PROSE (AI report)
   ========================================================================== */

.prose {
  max-width: 68ch;
  font-size: 0.9375rem; line-height: var(--lh-loose); color: var(--c-ink-2);
}
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2 {
  margin: var(--s-10) 0 var(--s-5);
  padding-top: var(--s-7);
  border-top: 1px solid var(--c-line);
  font-family: var(--font-display);
  font-size: var(--fs-h1); font-weight: 550;
  letter-spacing: var(--tr-display); line-height: var(--lh-snug);
  color: var(--c-ink-1);
}
.prose > h1:first-child, .prose > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 {
  margin: var(--s-8) 0 var(--s-4);
  font-size: var(--fs-h2); font-weight: 600;
  letter-spacing: var(--tr-tight); color: var(--c-ink-1);
}
.prose h4 { margin: var(--s-7) 0 var(--s-3); font-size: var(--fs-h3); font-weight: 600; color: var(--c-ink-1); }
.prose p { margin: var(--s-5) 0; }
.prose ul, .prose ol { margin: var(--s-5) 0; padding-left: var(--s-7); display: grid; gap: var(--s-3); }
.prose ul { list-style: none; }
.prose ul > li { position: relative; }
.prose ul > li::before {
  content: ""; position: absolute; left: calc(-1 * var(--s-6)); top: 0.62em;
  width: 4px; height: 4px; border-radius: 50%; background: var(--c-ink-4);
}
.prose ol { list-style: decimal; }
.prose ol > li::marker { color: var(--c-ink-4); font-variant-numeric: tabular-nums; }
.prose li > ul, .prose li > ol { margin: var(--s-3) 0 0; }
.prose strong { font-weight: 600; color: var(--c-ink-1); }
.prose em { font-style: italic; }
.prose code {
  padding: 2px var(--s-3);
  background: var(--c-inset); border: 1px solid var(--c-line);
  border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: 0.85em; color: var(--c-ink-1);
}
.prose pre {
  margin: var(--s-6) 0; padding: var(--s-6);
  background: var(--c-inset); border: 1px solid var(--c-line);
  border-radius: var(--r-sm); overflow-x: auto;
}
.prose pre code { padding: 0; background: none; border: 0; font-size: var(--fs-xs); }
.prose blockquote {
  margin: var(--s-6) 0; padding-left: var(--s-6);
  border-left: 2px solid var(--c-line-strong); color: var(--c-ink-3);
}
.prose hr { margin: var(--s-9) 0; border: 0; border-top: 1px solid var(--c-line); }
.prose__scroll {
  margin: var(--s-6) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.prose__scroll:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }
.prose__scroll > table { margin: 0; min-width: 24rem; }
.prose table {
  width: 100%; margin: var(--s-6) 0;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.prose th, .prose td { white-space: nowrap; }
.prose td:last-child, .prose th:last-child { white-space: normal; }
.prose th, .prose td { padding: var(--s-4) var(--s-5); text-align: left; border-bottom: 1px solid var(--c-line); }
.prose th {
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase; color: var(--c-ink-3);
}
.prose td { color: var(--c-ink-2); }
.prose tr:last-child td { border-bottom: 0; }

/* -- Report layout: prose measure stays readable, the freed column carries
      a sticky section index rather than sitting empty ------------------- */
.report { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-10); }

.tocnav { display: none; }
.tocnav__label {
  margin-bottom: var(--s-5);
  font-size: var(--fs-micro); font-weight: 560;
  letter-spacing: var(--tr-micro); text-transform: uppercase; color: var(--c-ink-3);
}
.tocnav__list { display: grid; gap: 1px; border-left: 1px solid var(--c-line); }
.tocnav__link {
  display: block; width: 100%; text-align: left;
  padding: var(--s-3) var(--s-5);
  margin-left: -1px; border-left: 1.5px solid transparent;
  font-size: var(--fs-xs); line-height: 1.45; color: var(--c-ink-3);
  transition: color var(--t-fast) var(--e-std), border-color var(--t-fast) var(--e-std);
}
.tocnav__link:hover { color: var(--c-ink-1); }
.tocnav__link.is-current { color: var(--c-ink-1); border-left-color: var(--c-ink-1); font-weight: 550; }
.tocnav__link--sub { padding-left: var(--s-8); }

@media (min-width: 66rem) {
  .report { grid-template-columns: minmax(0, 1fr) 13rem; gap: var(--s-11); }
  .tocnav { display: block; position: sticky; top: calc(var(--topbar-h) + var(--s-8)); align-self: start; }
}

/* Plain-text fallback when the Markdown renderer is unavailable */
.prose.is-plain {
  white-space: pre-wrap;
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: var(--lh-body);
}

/* ==========================================================================
   11. RESPONSIVE
   ========================================================================== */

@media (max-width: 48rem) {
  .workspace { padding: var(--s-8) var(--s-6) var(--s-11); }
  .topbar__inner { padding: 0 var(--s-6); }
  .footer { padding: var(--s-7) var(--s-6); }
  .quota__meter, .quota__text { display: none; }
  .results__head { align-items: flex-start; }
  .tabs { gap: var(--s-6); overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .panel__toolbar { flex-direction: column; align-items: stretch; }
  .panel__toolbar--wrap {
    display: grid; grid-template-columns: 1fr auto;
    align-items: center; gap: var(--s-4);
  }
  .search { flex: none; width: 100%; max-width: none; grid-column: 1 / -1; }
  .segmented { width: 100%; }
  .segmented__btn { flex: 1; justify-content: center; }
  .group__body { padding-left: var(--s-7); }
  .flat__row { grid-template-columns: 1fr; }
  .flat__tags { justify-content: flex-start; }
  .run-panel__foot { flex-direction: column; align-items: stretch; gap: var(--s-5); }
  .alert { flex-wrap: wrap; }
  .alert > .btn { width: 100%; }
}

@media (max-width: 30rem) {
  .metric { padding: var(--s-6); }
  .metric__value { font-size: 1.5rem; }
  .gate__panel { padding: var(--s-8) var(--s-5); }
}

/* ==========================================================================
   12. MOTION PREFERENCES
   ========================================================================== */

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

@media print {
  .topbar, .query, .status-region, .results__actions, .tabs, .panel__toolbar, .footer, .empty { display: none !important; }
  .panel.is-hidden { display: block !important; }
  body { background: #fff; }
}
