/* ==========================================================================
   ASK OLIVE — DESIGN SYSTEM v1  (single source of truth)
   One token vocabulary. Style ONLY via var(--token). No hex below the token
   blocks except inside the two theme definitions.
   Themes: DARK is :root default (Richard-approved, 2026-07-22). Light applies
   via prefers-color-scheme unless data-theme="dark"; data-theme="light"
   always wins, both ways. localStorage['olive-theme'] persists the explicit
   choice (see the <head> IIFE + nav toggle script on every page).
   ========================================================================== */

/* ---------- 1. TOKENS — shared (theme-independent) ---------- */
:root {
  /* type */
  --font-sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-display: var(--lq-font-display, 'Inter Tight', 'Inter', -apple-system, sans-serif);
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --fs-xs: 0.75rem;    /* 12 — chips, table meta */
  --fs-sm: 0.8125rem;  /* 13 — dense UI, labels */
  --fs-base: 0.9375rem;/* 15 — body */
  --fs-md: 1.0625rem;  /* 17 — lead */
  --fs-lg: 1.25rem;    /* 20 — h4/card titles */
  --fs-xl: 1.5rem;     /* 24 — h3 */
  --fs-2xl: 1.875rem;  /* 30 — h2 / page titles */
  --fs-3xl: 2.5rem;    /* 40 — h1 */
  --fs-4xl: 3.25rem;   /* 52 — hero */
  --lh-tight: 1.15; --lh-snug: 1.35; --lh-body: 1.6;

  /* spacing (4px scale) */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-7: 1.75rem; --sp-8: 2rem; --sp-9: 2.25rem; --sp-10: 2.5rem;
  --sp-12: 3rem; --sp-16: 4rem; --sp-20: 5rem;

  /* radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-full: 999px;

  /* motion */
  --ease: cubic-bezier(.3,.7,.3,1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 350ms;

  /* layout */
  --page-max: 1200px;
  --nav-h: 56px;

  color-scheme: dark;
}

/* ---------- 2. TOKENS — DARK (default) ---------- */
/* Stage 3 (2026-09-17, docs/DESIGN_TOKENS_LIQUID_CANONICAL.md §4): the ground/
   text/line/brand identity now follows olive-liquid.css's Heartwood values, so
   the 64-page ask-olive-compat.css bridge stops pulling toward the old indigo
   palette. Semantic status colours (--leaf/--ok/--warn/--danger/--thread) are
   intentionally UNCHANGED in this pass — out of the doc's named scope. */
:root {
  --bg: var(--lq-ground, #0C0E1C); --bg-raised: var(--lq-ground-lift, #14172A); --bg-elevated: var(--lq-ground-lift-2, #1B1F36);
  --bg-inset: var(--lq-ground, #090B16); --bg-hover: var(--lq-ground-lift-2, #1A1E33);
  --ink: var(--lq-text-warm, #F0F2FC); --text: var(--lq-text-warm, #C9CEE6); --text-muted: var(--lq-text-warm-2, #9BA2C4); --text-faint: var(--lq-text-warm-2, #6E7494);
  --line: var(--lq-rule, #262B45); --line-strong: var(--lq-rule, #3A4062);
  --brand: var(--lq-brand-hi, #8B93F8); --brand-strong: var(--lq-brand, #4F46E5); --brand-hover: var(--lq-brand-hover, #6068F0);
  --brand-tint: var(--lq-rule-2, #1D2040); --on-brand: var(--lq-text-warm, #FFFFFF);
  --leaf: #A9C86C; --leaf-tint: #1A2114;
  --ok: #A9C86C; --ok-tint: #1A2114;
  --warn: #E8B44E; --warn-tint: #2A2210;
  --danger: #F2837B; --danger-strong: #C33A32; --danger-tint: #321714;
  --thread: linear-gradient(90deg, #8B93F8, #A9C86C);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--lq-heartwood-hi, var(--brand));
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 2px 10px rgba(0,0,0,.45);
  --shadow-3: 0 16px 40px rgba(0,0,0,.55);
  --scrim: rgba(26,31,23,.72);
}

/* ---------- 3. TOKENS — LIGHT (opt-in) ---------- */
/* DARK is the default regardless of OS (Richard-approved 2026-07-22). Light applies
   ONLY on the explicit toggle below — this media block is gated to data-theme="light"
   so a light-preference OS no longer auto-flips the theme.
   --bg-raised folded onto --lq-ground-lift-2 (csync #3842, 2026-09-18) — the fallback
   #FFFFFF is unchanged, so this is zero visual change, only single-source-of-truth
   routing (--lq-ground-lift-2 is the Heartwood Light token that already equals
   #FFFFFF; picked to match, not to change, the current render). Rest of this block
   is a separate, older indigo light palette not yet folded into Heartwood Light —
   out of #3842's named scope (--bg-raised/--nv-bg only), flagged for follow-up. */
@media (prefers-color-scheme: light) {
  :root[data-theme="light"] {
    color-scheme: light;
    --bg: #F6F7FB; --bg-raised: var(--lq-ground-lift-2, #FFFFFF); --bg-elevated: #FFFFFF;
    --bg-inset: #EEF0F7; --bg-hover: #F0F1F9;
    --ink: #171A2E; --text: #2B2F4A; --text-muted: #5B6180; --text-faint: #8A90AC;
    --line: #E4E6F0; --line-strong: #C9CDE0;
    --brand: #4F46E5; --brand-strong: #4640D8; --brand-hover: #3B35C4;
    --brand-tint: #EEEDFC; --on-brand: #FFFFFF;
    --leaf: #5D7A2A; --leaf-tint: #EFF3E4;
    --ok: #4E6B1E; --ok-tint: #EDF3DF;
    --warn: #8A5A00; --warn-tint: #FBF1DC;
    --danger: #B3261E; --danger-strong: #B3261E; --danger-tint: #FBEAE9;
    --thread: linear-gradient(90deg, #4F46E5, #7A9B3E);
    --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);
    --shadow-1: 0 1px 2px rgba(23,26,46,.06);
    --shadow-2: 0 2px 8px rgba(23,26,46,.08), 0 1px 2px rgba(23,26,46,.05);
    --shadow-3: 0 12px 32px rgba(23,26,46,.16), 0 2px 8px rgba(23,26,46,.08);
    --scrim: rgba(23,26,46,.45);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F6F7FB; --bg-raised: var(--lq-ground-lift-2, #FFFFFF); --bg-elevated: #FFFFFF;
  --bg-inset: #EEF0F7; --bg-hover: #F0F1F9;
  --ink: #171A2E; --text: #2B2F4A; --text-muted: #5B6180; --text-faint: #8A90AC;
  --line: #E4E6F0; --line-strong: #C9CDE0;
  --brand: #4F46E5; --brand-strong: #4640D8; --brand-hover: #3B35C4;
  --brand-tint: #EEEDFC; --on-brand: #FFFFFF;
  --leaf: #5D7A2A; --leaf-tint: #EFF3E4;
  --ok: #4E6B1E; --ok-tint: #EDF3DF;
  --warn: #8A5A00; --warn-tint: #FBF1DC;
  --danger: #B3261E; --danger-strong: #B3261E; --danger-tint: #FBEAE9;
  --thread: linear-gradient(90deg, #4F46E5, #7A9B3E);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);
  --shadow-1: 0 1px 2px rgba(23,26,46,.06);
  --shadow-2: 0 2px 8px rgba(23,26,46,.08), 0 1px 2px rgba(23,26,46,.05);
  --shadow-3: 0 12px 32px rgba(23,26,46,.16), 0 2px 8px rgba(23,26,46,.08);
  --scrim: rgba(23,26,46,.45);
}

/* ---------- 4. RESET + BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* csync #2847: this stylesheet had ZERO [hidden] rules. The UA default
   `[hidden]{display:none}` is a normal-origin rule with (0,1,0) specificity;
   any authored class here that sets display (flex/grid/block — .btn,
   .lens-switcher, .lib-grid, .panel, etc.) is also normal-origin author
   CSS, and author origin always beats UA origin regardless of specificity
   or source order. So el.hidden = true (or a bare `hidden` attribute in
   markup) on anything carrying such a class silently did nothing —
   confirmed live (headless-browser measured, before/after) on
   prompt-library.html's #scopeContext (.lib-scope-context{display:flex})
   and #libGrid (.lib-grid{display:grid}): hidden attribute present,
   computed display stayed "flex"/"grid", offsetParent non-null, real
   layout box. A few pages had already bolted on their own scoped or
   blanket [hidden] fix to compensate (account.html, canvas.css,
   olive-touchpoint.css, project-shell.css) — those still work fine
   alongside this rule, just redundant now. `!important` reinstates the
   one guarantee `hidden` is supposed to make; anything that needs to be
   hidden-but-still-laid-out should not use the `hidden` attribute at all
   (use a dedicated class instead). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-base)/var(--lh-body) var(--font-sans);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1,h2,h3,h4 { color: var(--ink); font-family: var(--font-display); line-height: var(--lh-tight); letter-spacing: -0.015em; margin: 0 0 var(--sp-3); font-weight: 640; }
h1 { font-size: var(--fs-3xl); } h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); } h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-4); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.875em; }
code { background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0.1em 0.35em; }
pre { background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4); overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; }
img, svg { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
::selection { background: var(--brand); color: var(--on-brand); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.skip-link { position: absolute; left: var(--sp-4); top: -48px; z-index: 200; background: var(--brand-strong); color: var(--on-brand); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm); transition: top var(--dur-2) var(--ease); }
.skip-link:focus { top: var(--sp-2); }

/* layout helpers */
.wrap { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--sp-6); }
.eyebrow { font: 600 var(--fs-xs)/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.thread-rule { height: 2px; border: 0; background: var(--thread); border-radius: 1px; margin: var(--sp-3) 0 var(--sp-5); width: 64px; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }

/* ---------- 5. TOP NAV ---------- */
.topnav { position: sticky; top: 0; z-index: 100; height: var(--nav-h); background: color-mix(in srgb, var(--bg-raised) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topnav-inner { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--sp-6); height: 100%; display: flex; align-items: center; gap: var(--sp-6); }
.brand { display: flex; align-items: center; gap: var(--sp-2); color: var(--ink); font: 640 var(--fs-md)/1 var(--font-display); letter-spacing: -0.01em; position: relative; }
.brand:hover { text-decoration: none; }
.brand .leaf { width: 22px; height: 22px; flex: none; }
.nav-links { display: flex; align-items: center; gap: var(--sp-1); margin: 0 0 0 auto; padding: 0; list-style: none; }
.nav-links a { display: block; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 520; }
.nav-links a:hover { color: var(--ink); background: var(--bg-hover); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--brand); background: var(--brand-tint); }
.nav-actions { display: flex; align-items: center; gap: var(--sp-2); }
.topnav .nav-burger { display: none; }

/* csync #2728 — #burger is the ONLY route to navigation on a phone; #themeBtn
   sits right next to it. Both render at 36x36 (.btn-icon), under the 44x44
   touch-target minimum. Rather than grow every .btn-icon on the site (huge
   blast radius — this class is shared by dozens of unrelated small buttons
   across every portal), expand just these two hit areas with an invisible
   ::before overlay, leaving the visible icon untouched. 44-36=8px total, so
   the overlay grows 4px each side — exactly the --sp-2 (8px) gap between the
   two buttons in .nav-actions, so their hit areas meet with no overlap. */
#burger, #themeBtn { position: relative; }
#burger::before, #themeBtn::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 44px; height: 44px;
  transform: translate(-50%, -50%);
}
/* .brand (logo/wordmark link) is flagged small on every page too (101.5x22) —
   same treatment, sized to its own box since it isn't a fixed-size icon. */
.brand::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 44px;
  min-width: 44px;
  transform: translate(-50%, -50%);
}

@media (max-width: 800px) {
  .nav-links { display: none; position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--bg-elevated); border-bottom: 1px solid var(--line); padding: var(--sp-2); box-shadow: var(--shadow-2); }
  .nav-links.open { display: flex; }
  .nav-links a { padding: var(--sp-3) var(--sp-4); }
  .topnav .nav-burger { display: inline-flex; }
}

/* ---------- 6. BUTTONS — the whole set. 4 variants x 3 sizes. ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font: 570 var(--fs-sm)/1 var(--font-sans); letter-spacing: 0.01em;
  padding: 0 var(--sp-4); height: 36px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
  text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--brand-strong); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--bg-raised); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn-danger { background: var(--danger-strong); color: var(--on-brand); }
.btn-danger:hover { filter: brightness(1.12); }
.btn-sm { height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn-lg { height: 44px; padding: 0 var(--sp-6); font-size: var(--fs-base); border-radius: var(--r-md); }
.btn-icon { width: 36px; padding: 0; } .btn-sm.btn-icon { width: 28px; } .btn-lg.btn-icon { width: 44px; }

/* ---------- 7. CARDS & PANELS — 3 shapes only ---------- */
.card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-6); box-shadow: var(--shadow-1); }
.card-interactive { display: block; color: inherit; transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.card-interactive:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card-interactive:focus-visible { box-shadow: var(--focus-ring); }
.panel { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--line); background: var(--bg-inset); }
.panel-head h3, .panel-head h4 { margin: 0; font-size: var(--fs-base); font-weight: 620; }
.panel-body { padding: var(--sp-5); }
.stat { padding: var(--sp-5); }
.stat .stat-value { font: 640 var(--fs-2xl)/1 var(--font-display); color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .stat-label { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-1); }

/* ---------- 8. BADGES / PILLS ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--sp-1); font: 600 var(--fs-xs)/1 var(--font-sans); padding: 4px 10px; border-radius: var(--r-full); border: 1px solid transparent; }
.badge-neutral { background: var(--bg-inset); color: var(--text-muted); border-color: var(--line); }
.badge-brand { background: var(--brand-tint); color: var(--brand); }
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.tier { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--r-sm); font: 700 var(--fs-xs)/1 var(--font-mono); background: var(--brand-tint); color: var(--brand); border: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- 9. CHAT ---------- */
.chat { display: flex; flex-direction: column; gap: var(--sp-5); }
.msg { max-width: 44rem; }
.msg-user { align-self: flex-end; background: var(--brand-tint); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg); padding: var(--sp-3) var(--sp-5); }
.msg-olive { align-self: flex-start; display: grid; grid-template-columns: 28px 1fr; gap: var(--sp-3); }
.olive-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--leaf-tint); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.olive-avatar svg { width: 15px; height: 15px; }
.msg-olive .bubble { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-sm) var(--r-lg) var(--r-lg) var(--r-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-1); }
.msg-olive .bubble > :last-child { margin-bottom: 0; }
.sources { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.source-chip { display: inline-flex; align-items: center; gap: var(--sp-2); font: 500 var(--fs-xs)/1 var(--font-mono); color: var(--text-muted); background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-full); padding: 4px 10px 4px 4px; }
.source-chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.typing { display: inline-flex; gap: 4px; padding: var(--sp-3) var(--sp-4); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: typing 1.2s infinite var(--ease); }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
/* clarify option cards */
.clarify { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.clarify-option { display: flex; align-items: center; gap: var(--sp-3); text-align: left; width: 100%; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); cursor: pointer; font: 500 var(--fs-sm)/var(--lh-snug) var(--font-sans); color: var(--text); transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease); }
.clarify-option:hover { border-color: var(--brand); background: var(--brand-tint); }
.clarify-option:focus-visible { box-shadow: var(--focus-ring); }
.clarify-option .clarify-key { flex: none; font: 600 var(--fs-xs)/1 var(--font-mono); color: var(--text-muted); background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 7px; }
.clarify-option strong { color: var(--ink); font-weight: 620; }
/* composer */
.composer { display: flex; gap: var(--sp-2); align-items: flex-end; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: var(--sp-2); box-shadow: var(--shadow-1); }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.composer textarea { flex: 1; border: 0; background: none; resize: none; font: 400 var(--fs-base)/var(--lh-snug) var(--font-sans); color: var(--text); padding: var(--sp-2) var(--sp-3); min-height: 24px; }
.composer textarea:focus { outline: none; box-shadow: none; }

/* ---------- 10. FORMS ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.field > label { font: 590 var(--fs-sm)/1 var(--font-sans); color: var(--ink); }
.hint { font-size: var(--fs-xs); color: var(--text-muted); margin: 0; }
.error-text { font-size: var(--fs-xs); color: var(--danger); margin: 0; font-weight: 550; }
.input, .select, .textarea { width: 100%; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm); color: var(--text); font: 400 var(--fs-sm)/1.4 var(--font-sans); padding: var(--sp-2) var(--sp-3); height: 36px; transition: border-color var(--dur-1) var(--ease); }
.textarea { height: auto; min-height: 88px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: var(--sp-8); }
.check { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-strong); }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); cursor: pointer; }
/* csync #2728 — role="switch" input (e.g. #acctBufferToggle) measured 36x20,
   under the 44x44 touch-target minimum. Grow the real box to 44x44 with
   padding (12px vertical, 4px horizontal) and clip the background to the
   content-box so the visible pill still reads as 36x20 — real box model,
   not a transform, so getBoundingClientRect on the input itself is >=44px
   both ways. Thumb offsets (top/left) shift to match the padded content box;
   the checked-state translateX is the existing slide animation, unrelated
   to sizing. */
.switch input { appearance: none; flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 12px 4px; border-radius: var(--r-full); background: var(--line-strong); background-clip: content-box; transition: background var(--dur-2) var(--ease); cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--bg-raised); top: 14px; left: 6px; transition: transform var(--dur-2) var(--ease); box-shadow: var(--shadow-1); }
.switch input:checked { background: var(--brand-strong); background-clip: content-box; }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- 11. TABLES ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-raised); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th { text-align: left; font: 600 var(--fs-xs)/1 var(--font-sans); letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); background: var(--bg-inset); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.tbl td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); color: var(--text); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--bg-hover); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--fs-xs); }

/* ---------- 12. TABS ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: var(--sp-3) var(--sp-4); font: 560 var(--fs-sm)/1 var(--font-sans); color: var(--text-muted); cursor: pointer; white-space: nowrap; transition: color var(--dur-1) var(--ease); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tab:hover { color: var(--ink); background: var(--bg-hover); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- 13. TOASTS ---------- */
.toast-region { position: fixed; bottom: var(--sp-6); right: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); z-index: 300; max-width: min(360px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: flex-start; gap: var(--sp-3); background: var(--bg-elevated); border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-3); font-size: var(--fs-sm); animation: toast-in var(--dur-3) var(--ease); }
.toast-ok { border-left-color: var(--ok); } .toast-danger { border-left-color: var(--danger); } .toast-warn { border-left-color: var(--warn); }
.toast strong { color: var(--ink); display: block; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 14. MODAL ---------- */
.modal[open] { display: grid; place-items: center; position: fixed; inset: 0; z-index: 400; background: none; border: 0; padding: var(--sp-4); width: 100%; height: 100%; }
.modal::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.modal-card { width: min(480px, 100%); background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: var(--fs-md); }
.modal-body { padding: var(--sp-5); color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); background: var(--bg-inset); }

/* ---------- 15. LEFT RAIL ---------- */
.layout-rail { display: grid; grid-template-columns: 240px minmax(0,1fr); gap: var(--sp-10); align-items: start; }
.layout-rail > * { min-width: 0; }
.rail { position: sticky; top: calc(var(--nav-h) + var(--sp-6)); }
.rail-group { margin-bottom: var(--sp-6); }
.rail-group > .eyebrow { display: block; margin-bottom: var(--sp-2); padding-left: var(--sp-3); }
.rail a { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); border-left: 2px solid transparent; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 520; }
.rail a:hover { color: var(--ink); background: var(--bg-hover); text-decoration: none; }
.rail a[aria-current="page"], .rail a.active { color: var(--brand); background: var(--brand-tint); border-left-color: var(--brand); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
@media (max-width: 900px) { .layout-rail { grid-template-columns: 1fr; } .rail { position: static; } }

/* ---------- 16. PAGE HEADER + FOOTER ---------- */
.page-head { padding: var(--sp-10) 0 var(--sp-6); }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; list-style: none; margin: 0 0 var(--sp-3); padding: 0; font-size: var(--fs-sm); }
.crumbs li { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); }
.crumbs li + li::before { content: "/"; color: var(--text-faint); }
.crumbs a { color: var(--text-muted); } .crumbs a:hover { color: var(--brand); }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); }
.page-head h1 { font-size: var(--fs-2xl); margin: 0; }
.page-actions { display: flex; gap: var(--sp-2); }
.site-footer { border-top: 1px solid var(--line); margin-top: var(--sp-20); padding: var(--sp-8) 0; color: var(--text-muted); font-size: var(--fs-sm); }
.footer-inner { display: flex; flex-wrap: wrap; gap: var(--sp-4) var(--sp-8); align-items: center; justify-content: space-between; }

/* ============================================================
   Chat answer tables (markdownToHtml renderMdTables output)
   + [A1]-citation sources legend under assistant messages
   ============================================================ */
.md-table-wrap { overflow-x: auto; margin: var(--sp-3) 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.md-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: var(--lh-snug); }
.md-table th, .md-table td { padding: var(--sp-2) var(--sp-3); text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.md-table th { background: var(--bg-elevated); color: var(--ink); font-weight: 600; white-space: nowrap; }
.md-table tbody tr:last-child td { border-bottom: none; }
.md-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-raised) 55%, transparent); }
.md-table code { white-space: nowrap; }

.sources-details { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); }
.sources-details summary { cursor: pointer; user-select: none; color: var(--text-muted); }
.sources-details summary:hover { color: var(--text); }
.sources-details .sources-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.sources-details .sources-list li { padding: var(--sp-1) 0; border-bottom: 1px solid var(--line); }
.sources-details .sources-list li:last-child { border-bottom: none; }
.source-ref { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--leaf); background: var(--leaf-tint); border-radius: 4px; padding: 0 4px; }
.source-loc { color: var(--text-faint); font-family: var(--font-mono); font-size: var(--fs-xs); }

/* Per-code-block download toolbar — markup emitted by /js/shared/chat-core.js
   wrapCodeBlock(). Toolbar sits flush on top of the <pre>, one rounded unit. */
.code-block-wrap { margin: var(--sp-4) 0; }
.code-block-wrap pre { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.code-block-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 3px 10px;
    background: var(--bg-inset);
    border: 1px solid var(--line); border-bottom: 0;
    border-radius: var(--r-md) var(--r-md) 0 0;
    font-family: var(--font-mono); font-size: var(--fs-xs);
}
.code-block-lang { color: var(--text-faint); letter-spacing: 0.06em; }
.code-block-dl {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: 1px solid var(--line); border-radius: 4px;
    color: inherit; font-family: var(--font-mono); font-size: var(--fs-xs);
    padding: 2px 8px; cursor: pointer;
}
.code-block-dl:hover { border-color: var(--leaf); color: var(--leaf); }

/* ==========================================================================
   ANSWER RULES — confidence band, fact vs inference, source disagreement
   (csync #2649, N4)

   The server contract (server/rag/olive_v5/contracts.py + pipeline.py) emits
   `confidence_band` as one of exactly three words — high | medium |
   needs_review — plus a `conflicts` list and per-sentence fact/inference
   `claims`, under `v5` on the chat payload.

   NEVER render the raw `confidence` float as a percentage. It takes four
   discrete values derived from which evidence tier was cited; a "%" reads to a
   user as a probability of correctness, which was never computed. The reason
   this rule needs stating in the stylesheet: /js/shared/chat-core.js's
   buildRagAnswerHtml still prints "Confidence: 87%" via `.confidence-indicator`
   on the older surfaces, and that is what these classes exist to replace.

   STATUS: markup for these classes is not emitted yet. The renderers
   (public/js/shared/chat-core.js, public/olive-chat.html) are outside this
   ticket's file scope, so the band/conflict/inference UI is a follow-on that
   styles against the vocabulary pinned here rather than inventing its own.
   ========================================================================== */
.answer-confidence {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    font: 600 var(--fs-xs)/1 var(--font-sans);
    padding: 4px 10px; border-radius: var(--r-full);
    border: 1px solid transparent;
}
.answer-confidence .dot { width: 7px; height: 7px; }
.answer-confidence-high { background: var(--ok-tint); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.answer-confidence-medium { background: var(--warn-tint); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
/* Deliberately NOT --danger: "needs review" is a prompt to check, not an error.
   Red would read as "this answer is wrong", which is a different claim. */
.answer-confidence-needs_review { background: var(--bg-inset); color: var(--text-muted); border-color: var(--line-strong); }
.answer-confidence-reason { font-weight: 450; color: var(--text-muted); }

/* Source disagreement. Both sides are always shown — the server reports the
   split and never adjudicates it, so the UI must not present one as the
   answer either. */
.evidence-conflict {
    margin-top: var(--sp-4);
    background: var(--warn-tint);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-sm); color: var(--text);
}
.evidence-conflict-head { display: flex; align-items: center; gap: var(--sp-2); font: 620 var(--fs-sm)/1 var(--font-sans); color: var(--warn); margin-bottom: var(--sp-2); }
.evidence-conflict-pair { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.evidence-conflict-side { display: flex; gap: var(--sp-2); align-items: flex-start; line-height: var(--lh-snug); }
.evidence-conflict-side .tier { flex: none; }
.evidence-conflict-side q { color: var(--text-muted); font-style: normal; }

/* Fact vs inference. A cited sentence is left completely alone — the default
   reading experience must not change for the well-grounded case. Only the
   inference carries a mark, and it is a left rule plus muted text rather than
   a highlight, so an answer that is largely reasoning does not turn into a
   wall of colour. */
.claim-inference {
    border-left: 2px solid var(--line-strong);
    padding-left: var(--sp-3);
    color: var(--text-muted);
}
.claim-inference::after {
    content: "inference";
    display: inline-block; margin-left: var(--sp-2);
    font: 600 var(--fs-xs)/1 var(--font-mono); letter-spacing: 0.04em;
    color: var(--text-faint); text-transform: uppercase;
    vertical-align: 1px;
}
.claim-fact { /* no decoration by design — see note above */ }
