/* /static/css/fonts.css */
/*
 * fonts.css — self-hosted fonts (no request leaves the app, so the look survives offline and nothing waits on a third party).
 * Atkinson Hyperlegible Next: UI and body text (letterforms drawn to stay distinguishable at small sizes). Bricolage Grotesque: display type, a variable font with a width axis (75-100%) used condensed for signage-like headings. JetBrains Mono: code and the tool-call log.
 * Licences: SIL OFL 1.1, copies in static/fonts/.
 * Styles for: @font-face only
 */
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/atkinson-400.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: italic; font-weight: 400; font-display: swap; src: url(/static/fonts/atkinson-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/atkinson-600.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/atkinson-700.woff2) format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; src: url(/static/fonts/bricolage-grotesque-wdth.woff2) format("woff2-variations"), url(/static/fonts/bricolage-grotesque-wdth.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/jetbrains-mono-400.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/jetbrains-mono-500.woff2) format("woff2"); }

/* /static/css/tokens.css */
/*
 * tokens.css — design tokens (colour, type, space, radius, depth, motion). Change the look here, nowhere else.
 * Styles for: :root variables, light and dark.
 * Breakpoint: all
 *
 * How colour works (2026-11 redesign, see docs/DECISIONS.md "Interface redesign"):
 *   - Semantic tokens first (--bg, --surface, --text, --border, --accent ...). Components use these.
 *   - The older names (--white, --paper, --ink, --line, --cobalt ...) are kept as aliases of the semantic tokens, so every existing rule
 *     follows the theme. "--white" means "the card surface", not literally white; use --on-accent for text on a filled accent.
 *   - Neutrals carry a trace of the brand hue (oklch hue 265) so greys read as part of the product rather than as a browser default.
 *   - Dark mode: elevation is shown by lighter surfaces, not by shadows (shadows barely read on dark). The accent is lifted in lightness
 *     so text in it keeps >= 4.5:1 on the dark surfaces.
 *   - Theme is chosen by <html data-theme="light|dark">, set before first paint by the inline script in index.html (core/appearance.js
 *     owns the logic). With no data-theme the system preference decides.
 */
:root {
  /* One knob for the size of the whole interface. 1 = 16px per rem; the default 1.25 = 20px.
     Settings > Appearance offers 1 / 1.125 / 1.25 / 1.375 (core/appearance.js SCALES). */
  --ui-scale: 1.25;
  color-scheme: light;

  /* --- SEMANTIC COLOUR: light --- */
  --bg: #fcfcfd;                 /* the conversation canvas */
  --bg-sunken: #f5f6f9;          /* sidebar, footers, wells */
  --surface: #ffffff;            /* cards, composer, inputs */
  --surface-raised: #ffffff;     /* menus, popovers, modals (same as surface in light; shadow does the lifting) */
  --hover: #eef0f5;              /* hover fill for rows and quiet buttons */
  --hover-strong: #e5e8ef;
  --text: #121a33;               /* deep ink-blue: the colour of a drawing, not a screen's default black */
  --text-2: #424b63;
  --text-3: #646d82;             /* 4.8:1 on --bg-sunken, so the sidebar's labels pass WCAG AA (was #6a7389, 4.39:1) */
  --text-4: #9298a8;             /* placeholders and disabled only (decorative, not for meaning) */
  --border: #e4e7ee;
  --border-strong: #cfd4df;
  --hairline: rgba(18, 26, 51, 0.07);

  --accent: #2948f4;             /* the logo's blue */
  --accent-hover: #1d3ae0;
  --accent-ink: #1f38c9;         /* accent used as text (4.5:1+ on white and on --accent-soft) */
  --accent-soft: #eef1ff;
  --accent-tint: #dde3ff;
  --accent-ring: rgba(41, 72, 244, 0.32);
  --on-accent: #ffffff;
  --hub: #ffb000;                /* the logo's amber hub */

  --gold: #b8860b;               /* paid features: the lock and plan name next to a locked option (core/plan.js gates) */
  --gold-soft: #fdf3d7;
  --gold-border: #ecd189;
  --warn: #b26b00;
  --warn-soft: #fff5db;
  --warn-ink: #6b4800;
  --warn-border: #f0d48a;
  --danger: #c92a2a;
  --danger-soft: #fdeeee;
  --danger-border: #f3c2c2;
  /* Status green: Okabe-Ito "bluish green" family (hue ~164 deg), validated for colour-blind readers. --ok is 5.4:1 on white. */
  --ok: #00795a;
  --ok-soft: #e3f6ef;
  --live: #008562;
  --live-dot: #8af5c8;

  --scrim: rgba(12, 17, 33, 0.42);
  --glass: rgba(252, 252, 253, 0.78);   /* sticky bars over scrolling content */
  --dot: #cdd3df;                        /* canvas grid dots */

  /* --- TYPE --- */
  --font-sans: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;   /* headings and the wordmark */
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --text-2xs: 0.6875rem;   /* 11 */
  --text-xs: 0.75rem;      /* 12 */
  --text-sm: 0.8125rem;    /* 13 */
  --text-base: 0.875rem;   /* 14: interface text */
  --text-read: 0.96875rem; /* 15.5: conversation text, read in paragraphs */
  --text-md: 1.0625rem;    /* 17 */
  --text-lg: 1.375rem;     /* 22 */
  --text-xl: 1.75rem;      /* 28 */
  --text-hero: clamp(2rem, 1.35rem + 2.2vw, 3rem);
  --track-tight: -0.022em; /* display sizes */
  --track-snug: -0.011em;  /* sub-headings */

  /* --- SPACE (4px grid) --- */
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.25rem; --s6: 1.5rem; --s8: 2rem; --s10: 2.5rem; --s12: 3rem; --s16: 4rem;

  /* --- RADIUS: concentric (an inner radius = outer radius minus its padding) --- */
  --r-xs: 0.25rem; --r-sm: 0.375rem; --r-md: 0.5rem; --r-lg: 0.75rem; --r-xl: 1rem; --r-2xl: 1.25rem; --r-full: 999px;

  /* --- DEPTH: layered shadows (a tight contact shadow + a soft ambient one), tinted with the ink hue, never pure black --- */
  --shadow-1: 0 1px 2px rgba(18, 26, 51, 0.05);
  --shadow-2: 0 1px 2px rgba(18, 26, 51, 0.04), 0 4px 12px -2px rgba(18, 26, 51, 0.07), 0 0 0 1px rgba(18, 26, 51, 0.05);
  --shadow-3: 0 2px 4px rgba(18, 26, 51, 0.04), 0 12px 32px -6px rgba(18, 26, 51, 0.16), 0 0 0 1px rgba(18, 26, 51, 0.06);
  --shadow-4: 0 4px 8px rgba(18, 26, 51, 0.05), 0 24px 64px -12px rgba(18, 26, 51, 0.28), 0 0 0 1px rgba(18, 26, 51, 0.06);
  --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.7);   /* the lit top edge of a raised surface */

  /* --- MOTION: three durations, two curves. Exits are faster than entrances. --- */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);            /* decelerate: things arriving */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);          /* expressive decelerate (popovers, cards) */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);              /* things leaving */
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);    /* a small overshoot for presses and toggles */
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms;

  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);   /* gap + accent ring: visible on any surface */

  /* --- LAYOUT --- */
  --sb-w: 17.5rem;
  --col: 48rem;        /* conversation column: text, cards and composer share one edge */
  --col-wide: 58rem;   /* visuals may run wider than the text */
  --topbar-h: 3.25rem;
  --touch: 2.75rem;

  /* --- LEGACY ALIASES (older rules use these; keep them pointing at the semantic tokens) --- */
  --white: var(--surface);
  --paper: var(--bg-sunken);
  --paper-2: var(--hover);
  --vellum: var(--hover-strong);
  --vellum-dot: var(--dot);
  --ink: var(--text);
  --ink-2: var(--text-2);
  --ink-3: var(--text-3);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --cobalt: var(--accent);
  --cobalt-deep: var(--accent-ink);
  --cobalt-soft: var(--accent-soft);
  --cobalt-tint: var(--accent-tint);
  --amber: var(--hub);
  --amber-tint: var(--warn-soft);
  --danger-tint: var(--danger-soft);
}

/* --- DARK: the same roles, re-mapped. Written twice (system preference, and an explicit choice) because a media query cannot be combined
   with an attribute selector in one rule. Keep the two blocks identical. --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f121a; --bg-sunken: #0b0d14; --surface: #161a24; --surface-raised: #1c2130; --hover: #1f2432; --hover-strong: #272d3d;
    --text: #eceef4; --text-2: #b9bfcd; --text-3: #8b92a5; --text-4: #636a7d;
    --border: #252b39; --border-strong: #343b4d; --hairline: rgba(255, 255, 255, 0.06);
    --accent: #4a66ff; --accent-hover: #5b75ff; --accent-ink: #9fb0ff; --accent-soft: rgba(74, 102, 255, 0.14); --accent-tint: rgba(74, 102, 255, 0.26);
    --accent-ring: rgba(110, 133, 255, 0.45); --on-accent: #ffffff; --hub: #ffb81f;
    --warn: #f5b437; --warn-soft: rgba(245, 180, 55, 0.12); --warn-ink: #f6c766; --warn-border: rgba(245, 180, 55, 0.32);
    --gold: #f2c75c; --gold-soft: rgba(242, 199, 92, 0.13); --gold-border: rgba(242, 199, 92, 0.34);
    --danger: #ff6b6b; --danger-soft: rgba(255, 107, 107, 0.12); --danger-border: rgba(255, 107, 107, 0.32);
    --ok: #3ccf9c; --ok-soft: rgba(60, 207, 156, 0.13); --live: #0b8a63;
    --scrim: rgba(3, 5, 10, 0.62); --glass: rgba(15, 18, 26, 0.72); --dot: #2a3142;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px -2px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-3: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 40px -8px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
    --shadow-4: 0 4px 10px rgba(0, 0, 0, 0.4), 0 28px 72px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
    --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f121a; --bg-sunken: #0b0d14; --surface: #161a24; --surface-raised: #1c2130; --hover: #1f2432; --hover-strong: #272d3d;
  --text: #eceef4; --text-2: #b9bfcd; --text-3: #8b92a5; --text-4: #636a7d;
  --border: #252b39; --border-strong: #343b4d; --hairline: rgba(255, 255, 255, 0.06);
  --accent: #4a66ff; --accent-hover: #5b75ff; --accent-ink: #9fb0ff; --accent-soft: rgba(74, 102, 255, 0.14); --accent-tint: rgba(74, 102, 255, 0.26);
  --accent-ring: rgba(110, 133, 255, 0.45); --on-accent: #ffffff; --hub: #ffb81f;
  --warn: #f5b437; --warn-soft: rgba(245, 180, 55, 0.12); --warn-ink: #f6c766; --warn-border: rgba(245, 180, 55, 0.32);
  --gold: #f2c75c; --gold-soft: rgba(242, 199, 92, 0.13); --gold-border: rgba(242, 199, 92, 0.34);
  --danger: #ff6b6b; --danger-soft: rgba(255, 107, 107, 0.12); --danger-border: rgba(255, 107, 107, 0.32);
  --ok: #3ccf9c; --ok-soft: rgba(60, 207, 156, 0.13); --live: #0b8a63;
  --scrim: rgba(3, 5, 10, 0.62); --glass: rgba(15, 18, 26, 0.72); --dot: #2a3142;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px -2px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-3: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 40px -8px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
  --shadow-4: 0 4px 10px rgba(0, 0, 0, 0.4), 0 28px 72px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* /static/css/base.css */
/*
 * base.css — reset, typography, page frame (sidebar | main), scrollbars
 * Styles for: html/body, .app, .main, .topbar, .thread-wrap, .dock
 * Breakpoint: all (mobile-first; layout switches in desktop.css)
 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; height: 100%; font-size: calc(100% * var(--ui-scale, 1) * var(--device-scale, 1)); background: var(--bg); }   /* every rem in the app scales from here; --device-scale: phones (mobile.css, short.css) */
body {
  font-family: var(--font-sans); font-size: var(--text-base); line-height: 1.5; color: var(--text);
  background: var(--bg); height: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; font-synthesis-weight: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
ul, ol { list-style: none; }
a { color: var(--accent-ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[hidden] { display: none !important; }
::selection { background: var(--accent-tint); color: inherit; }
::placeholder { color: var(--text-4); opacity: 1; }
body.no-scroll { overflow: hidden; }

.app { display: flex; height: 100dvh; opacity: 0; transition: opacity 360ms var(--ease); }
body.ready .app { opacity: 1; }

.main { position: relative; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--bg); }
.thread-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; scrollbar-gutter: stable; }
.thread { max-width: var(--col); margin: 0 auto; padding: var(--s6) var(--s4) var(--s10); }
/* The composer floats over the end of the thread: content fades out under it instead of being cut by a hard edge. */
.dock { flex: none; position: relative; padding: 0 var(--s4) max(var(--s3), env(safe-area-inset-bottom)); background: var(--bg); }
.dock::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--s8); background: linear-gradient(to top, var(--bg), transparent); pointer-events: none; }
.dock-inner { max-width: var(--col); margin: 0 auto; }

/* --- TOP BAR: quiet. The conversation is the content; the bar is a frame. --- */
.topbar { flex: none; display: flex; align-items: center; gap: var(--s2); height: var(--topbar-h); padding: 0 var(--s3) 0 var(--s4); border-bottom: 1px solid var(--hairline); background: var(--bg); z-index: 5; }
.crumbs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.top-actions { display: flex; align-items: center; gap: 2px; margin-left: var(--s1); }
.top-actions .icon-btn { width: 2rem; height: 2rem; border-radius: var(--r-md); color: var(--text-3); }
.top-actions .icon-btn:hover { background: var(--hover); color: var(--text); }
.top-sep { width: 1px; height: 1.25rem; background: var(--border); margin: 0 var(--s1); }

.scroll::-webkit-scrollbar, .sb-scroll::-webkit-scrollbar { width: 0.625rem; }
.scroll::-webkit-scrollbar-thumb, .sb-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0.625rem; border: 0.1875rem solid transparent; background-clip: content-box; }
.scroll::-webkit-scrollbar-thumb:hover, .sb-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; border: 0.1875rem solid transparent; }
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }

/* Drop anywhere: a calm full-window target that names what will happen. */
.drop-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; animation: appear var(--dur-2) ease both; }
.drop-overlay > div { display: grid; gap: var(--s2); justify-items: center; padding: var(--s10) var(--s12); border: 2px dashed var(--accent); border-radius: var(--r-2xl); background: var(--surface); box-shadow: var(--shadow-4); text-align: center; color: var(--text); animation: drop-in var(--dur-3) var(--ease-out) both; }
.drop-overlay strong { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 650; letter-spacing: var(--track-snug); }
.drop-overlay span { font-size: var(--text-sm); color: var(--text-3); }
.drop-overlay .drop-icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--accent-ink); margin-bottom: var(--s1); }
@keyframes drop-in { from { opacity: 0; transform: scale(0.96); } }

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

/* /static/css/components/primitives.css */
/*
 * primitives.css — buttons, chips, inputs, menus, modals, video progress, toasts, swatches, brand loader, status chip
 * Styles for: shared UI atoms used by every feature
 * Breakpoint: all
 * Press feedback: every button sinks slightly on :active (transform only, so it costs nothing); hovers change colour, never size.
 */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 2.25rem; padding: 0 0.875rem; border: 1px solid transparent; border-radius: var(--r-md); font-weight: 600; font-size: var(--text-sm); line-height: 1; letter-spacing: 0.005em; white-space: nowrap; transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease, box-shadow var(--dur-1) ease, transform var(--dur-1) var(--ease); }
.btn:active:not(:disabled) { transform: translateY(0.5px) scale(0.985); }
.btn:disabled { opacity: 0.5; }
/* Primary: one filled accent per view. A lit top edge and a tight shadow make it read as pressable without a gradient. */
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(18, 26, 51, 0.18), 0 0 0 1px color-mix(in srgb, var(--accent) 80%, black); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-quiet { background: var(--surface); color: var(--text-2); border-color: var(--border); box-shadow: var(--shadow-1); }
.btn-quiet:hover:not(:disabled) { background: var(--hover); color: var(--text); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-quiet.danger { color: var(--danger); }
.btn-small { min-height: 1.875rem; padding: 0 0.625rem; font-size: var(--text-xs); border-radius: var(--r-sm); }
.btn-large { min-height: 2.75rem; padding: 0 1.25rem; font-size: var(--text-base); border-radius: var(--r-lg); }
.icon-btn { display: inline-grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: var(--r-md); color: var(--text-3); transition: background-color var(--dur-1) ease, color var(--dur-1) ease, transform var(--dur-1) var(--ease); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.sm { width: 1.625rem; height: 1.625rem; border-radius: var(--r-sm); }
.icon-btn[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.icon-btn.primary { background: var(--accent); color: var(--on-accent); border-radius: var(--r-full); }
.icon-btn.primary:hover { background: var(--accent-hover); }
.icon { flex: none; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; padding: 0 0.3125rem; font-family: var(--font-sans); font-size: var(--text-2xs); font-weight: 600; line-height: 1; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--surface); color: var(--text-3); }
.chip { display: inline-flex; align-items: center; gap: 0.375rem; min-height: 2rem; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--text-2); font-size: var(--text-sm); box-shadow: var(--shadow-1); transition: border-color var(--dur-1), color var(--dur-1), background-color var(--dur-1), transform var(--dur-1) var(--ease); }
.chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--hover); }
.chip:active { transform: scale(0.98); }
.tag { font-size: var(--text-xs); font-weight: 500; color: var(--text-3); padding: 2px 0.5rem; border-radius: var(--r-full); background: var(--hover); }
.muted { color: var(--text-3); font-size: var(--text-sm); }
.hint { font-size: var(--text-xs); color: var(--text-3); }
.sw { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: 0.1875rem; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--text-xs); color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 0.375rem; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"], textarea.edit-area, .modal textarea, .modal input[type="text"] { width: 100%; min-height: 2.25rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); box-shadow: inset 0 1px 1px var(--hairline); transition: border-color var(--dur-1), box-shadow var(--dur-1); }
input[type="text"]:hover, input[type="search"]:hover, input[type="email"]:hover, input[type="password"]:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
textarea { resize: vertical; line-height: 1.5; }
select { height: 2rem; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); font-size: var(--text-xs); }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }

/* Status: a quiet dot and a word. Demo mode is information, not a warning, so it is neutral with an amber dot. */
.status-chip { display: inline-flex; align-items: center; gap: 0.4375rem; height: 1.75rem; box-sizing: border-box; padding: 0 0.625rem; font-size: var(--text-xs); font-weight: 600; border-radius: var(--r-full); background: transparent; color: var(--text-3); border: 1px solid var(--border); white-space: nowrap; cursor: default; }
.status-dot { position: relative; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--text-4); flex: none; }
.status-chip[data-mode="live"] { color: var(--text-2); }
.status-chip[data-mode="live"] .status-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-chip[data-mode="live"] .status-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--ok); opacity: 0; animation: status-ping 2.4s ease-out 3; }   /* pings three times on arrival, then rests */
.status-chip[data-mode="offline"] { color: var(--text-3); border-style: dashed; }
.status-chip[data-mode="offline"] .status-dot { background: var(--text-4); }
.status-chip[data-mode="demo"] { color: var(--text-2); }
.status-chip[data-mode="demo"] .status-dot { background: var(--hub); box-shadow: 0 0 0 3px var(--warn-soft); }
@keyframes status-ping { 0% { transform: scale(1); opacity: 0.5; } 70%, 100% { transform: scale(2.6); opacity: 0; } }

/* --- MENU --- */
.menu { position: fixed; z-index: 400; min-width: 13rem; max-width: 18rem; padding: 0.3125rem; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); animation: pop var(--dur-2) var(--ease-out); transform-origin: top; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }
.menu-item { display: flex; align-items: center; gap: 0.625rem; width: 100%; min-height: 2rem; padding: 0.375rem 0.5rem; border-radius: var(--r-sm); font-size: var(--text-sm); text-align: left; color: var(--text); }
.menu-item .icon { color: var(--text-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); box-shadow: none; }
.menu-item:hover .icon { color: var(--text-2); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item:disabled { color: var(--text-3); }
.menu-item kbd { margin-left: auto; }
.menu-label { flex: 1 1 auto; min-width: 0; }
/* A locked option: the plan that includes it sits at the right end of the row, with a gold lock. The row still opens the plans. */
.menu-item.is-locked > .icon { color: var(--text-4); }
.menu-plan { flex: none; display: inline-flex; align-items: center; gap: 0.25rem; margin-left: auto; padding: 0.0625rem 0.4375rem 0.0625rem 0.3125rem; border: 1px solid var(--gold-border); border-radius: var(--r-full); background: var(--gold-soft); color: var(--gold); font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.02em; }
.menu-plan .icon { color: var(--gold) !important; }
.menu-gap { width: 1rem; }
.menu-div { border: 0; border-top: 1px solid var(--border); margin: 0.25rem -0.3125rem; }
.menu-swatches, .swatch-row { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 0.625rem; }
.swatch-row { padding: 0; }
.swatch { width: 1.375rem; height: 1.375rem; border-radius: 50%; background: var(--c); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); display: grid; place-items: center; color: var(--text-3); transition: transform var(--dur-1) var(--ease-spring); }
.swatch:hover { transform: scale(1.12); }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }

/* --- MODAL --- */
.overlay { position: fixed; inset: 0; z-index: 300; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: max(var(--s4), env(safe-area-inset-top)) max(var(--s4), env(safe-area-inset-right)) max(var(--s4), env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-left)); background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade var(--dur-2) ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(32.5rem, 100%); max-height: min(86dvh, 47.5rem); display: flex; flex-direction: column; background: var(--surface-raised); border-radius: var(--r-xl); box-shadow: var(--shadow-4); animation: rise var(--dur-3) var(--ease-out); }
.modal.wide { width: min(42.5rem, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(0.5rem) scale(0.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s4) var(--s3) var(--s5); }
.modal-head h2 { font-family: var(--font-display); font-size: var(--text-md); font-weight: 650; letter-spacing: var(--track-snug); }
.modal-body { padding: var(--s2) var(--s5) var(--s5); overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); background: var(--bg-sunken); border-radius: 0 0 var(--r-xl) var(--r-xl); }
@media (max-width: 30rem) { .modal-foot > .btn { flex: 1 1 auto; justify-content: center; } }   /* phones: footer buttons share the row, then wrap, never run off it */
.modal-text { color: var(--text-2); }
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }   /* minmax: a wide control wraps or scrolls, never widens the dialog */
.form label, .form .field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.375rem; font-size: var(--text-sm); font-weight: 600; }
.form small, .form .label small { font-weight: 400; color: var(--text-3); display: block; }
.form section { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s1); padding-bottom: var(--s5); border-bottom: 1px solid var(--border); }
.form section:last-child { border: 0; padding: 0; }
.form h3 { font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
/* Option rows (radio and checkbox). The control is drawn here so the only accent on a row is the control itself; keyboard focus tints the row instead of ringing the box. */
.radio { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: var(--s3); margin: 0 calc(-1 * var(--s3)); padding: 0.5rem var(--s3); border-radius: var(--r-md); font-weight: 400 !important; cursor: pointer; transition: background-color var(--dur-1); }
.radio:hover, .radio:has(input:focus-visible) { background: var(--hover); }
.radio input { appearance: none; -webkit-appearance: none; flex: none; display: grid; place-content: center; width: 1.125rem; height: 1.125rem; min-height: 0; margin: 0.125rem 0 0; padding: 0; border: 1.5px solid var(--border-strong); border-radius: 50%; background: var(--surface); cursor: pointer; transition: background-color var(--dur-1), border-color var(--dur-1); }
.radio input::before { content: ""; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: #fff; transform: scale(0); transition: transform var(--dur-2) var(--ease-spring); }
.radio input[type="checkbox"] { border-radius: 0.3125rem; }
.radio input[type="checkbox"]::before { width: 0.625rem; height: 0.625rem; border-radius: 0; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.radio input:checked { background: var(--accent); border-color: var(--accent); }
.radio input:checked::before { transform: scale(1); }
.radio input:hover:not(:checked) { border-color: var(--text-3); }
.radio input:focus, .radio input:focus-visible { outline: none; box-shadow: none; }
.radio input:focus:not(:checked) { border-color: var(--border-strong); }
.radio small { margin-top: 0.125rem; line-height: 1.45; }
.modal:focus, .modal:focus-visible { outline: none; box-shadow: var(--shadow-4); }
.radio b { display: block; font-weight: 600; }
.file-list li, .prompt-list li { display: flex; align-items: center; gap: var(--s3); padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.file-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list small, .prompt-list small { color: var(--text-3); display: block; }
.prompt-list li > div { flex: 1; min-width: 0; }
.prompt-list li { padding: 0.625rem 0; }
.prompt-list b { display: block; font-weight: 600; }
.prompt-add { display: grid; gap: var(--s2); padding: var(--s3); background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r-lg); }
.prompt-add .btn { justify-self: end; min-width: 5rem; }
.form section > .muted { margin-top: calc(-1 * var(--s1)); }
.prompt-list small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--text-3); justify-content: center; padding: var(--s5) 0 !important; }
.pick-list { display: grid; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: var(--s2); padding: 0.5rem 0.625rem 0.5rem calc(0.625rem + var(--depth, 0) * 1.125rem); border-radius: var(--r-sm); text-align: left; font-size: var(--text-sm); }
.pick-row span { flex: 1; }
.pick-row:hover:not(:disabled) { background: var(--hover); }
.pick-row:disabled { opacity: 0.4; }
.shortcuts { display: grid; grid-template-columns: max-content 1fr; gap: 0.625rem var(--s5); font-size: var(--text-sm); align-items: center; }
.shortcuts dt { display: flex; gap: 0.25rem; }
.shortcuts dd { color: var(--text-2); }

/* Appearance picker (Settings): three small previews of the interface, the chosen one ringed. */
.theme-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.theme-opt { display: grid; gap: var(--s2); padding: 0.375rem 0.375rem var(--s2); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); font-size: var(--text-sm); font-weight: 600; color: var(--text-2); text-align: center; transition: border-color var(--dur-1), box-shadow var(--dur-1), color var(--dur-1); }
.theme-opt:hover { border-color: var(--border-strong); color: var(--text); }
.theme-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--text); }
.theme-swatch { position: relative; height: 3.75rem; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--hairline); }
.theme-swatch i { position: absolute; display: block; border-radius: 0.1875rem; }
.theme-swatch .ts-side { left: 0; top: 0; bottom: 0; width: 28%; border-radius: 0; }
.theme-swatch .ts-line { left: 36%; height: 0.375rem; }
.theme-swatch .ts-box { left: 36%; right: 8%; bottom: 0.5rem; height: 1rem; border-radius: 0.3125rem; }
.ts-light { background: #fcfcfd; } .ts-light .ts-side { background: #f0f2f6; } .ts-light .ts-line { background: #d7dbe5; } .ts-light .ts-box { background: #fff; box-shadow: 0 0 0 1px #dfe3eb; }
.ts-dark { background: #0f121a; } .ts-dark .ts-side { background: #0b0d14; } .ts-dark .ts-line { background: #2a3142; } .ts-dark .ts-box { background: #1c2130; box-shadow: 0 0 0 1px #2a3142; }
.ts-system { background: linear-gradient(135deg, #fcfcfd 50%, #0f121a 50%); }
.ts-system .ts-side { background: linear-gradient(135deg, #f0f2f6 50%, #0b0d14 50%); }
.ts-system .ts-line { background: #8a91a3; } .ts-system .ts-box { background: linear-gradient(90deg, #fff 50%, #1c2130 50%); box-shadow: 0 0 0 1px #8a91a3; }
.theme-swatch .ts-dot { position: absolute; right: 12%; bottom: 0.75rem; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #2948f4; }
.seg-pick { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 100%; gap: 2px; padding: 2px; border-radius: var(--r-md); background: var(--hover); border: 1px solid var(--border); }
.seg-pick button { min-height: 1.875rem; padding: 0 0.75rem; border-radius: var(--r-sm); font-size: var(--text-xs); font-weight: 600; color: var(--text-3); white-space: nowrap; transition: background-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1); }
.seg-pick button:hover { color: var(--text); }
.seg-pick button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--border); }
/* a narrow dialog (phones): the choices wrap into rows of equal cells instead of pushing the dialog wider than the screen */
@media (max-width: 40rem) { .seg-pick { display: grid; grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(min(100%, 6.25rem), 1fr)); width: 100%; } .theme-pick { gap: var(--s2); } }

/* --- TOAST --- */
/* walkthrough video download (visuals/export-video.js): real frame progress */
.video-export { display: grid; gap: 0.625rem; min-width: min(22rem, 80vw); }
.video-progress { width: 100%; height: 0.375rem; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--hover); }
.video-progress::-webkit-progress-bar { background: var(--hover); border-radius: 999px; }
.video-progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width var(--dur-2) linear; }
.video-progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.toasts { position: fixed; z-index: 500; left: 50%; bottom: 7rem; transform: translateX(-50%); display: grid; gap: var(--s2); justify-items: center; pointer-events: none; }
/* Toasts are always dark in light mode and raised-light-on-dark in dark mode: they must stand apart from whatever is under them. */
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s4); min-height: 2.5rem; padding: 0.5rem 0.5rem 0.5rem 1rem; border-radius: var(--r-lg); background: #161b2c; color: #f1f3f8; font-size: var(--text-sm); box-shadow: var(--shadow-4); animation: toast-in var(--dur-3) var(--ease-out); }
.toast:not(:has(.toast-action)) { padding-right: 1rem; }
:root[data-theme="dark"] .toast { background: #2a3043; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #2a3043; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.75rem) scale(0.96); } }
.toast-action { padding: 0.3125rem 0.625rem; border-radius: var(--r-sm); color: #b9c6ff; font-weight: 650; }
.toast-action:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* --- BRAND LOADER: the logo breathes. It shrinks while its tentacles pull in, then swells while they spread, then eases back to rest. ---
 * Every keyframe set starts and ends at the rest pose (the static logo) and every segment eases in and out (a literal sine-in-out curve: var() is not honoured inside keyframe timing functions), so the loop is smooth and a stop at a cycle end has zero speed (see settleLoader in core/ui.js).
 * Only transform and opacity are animated. Spokes squash along their own axis (scaleY about the hub) and each node slides the same distance, so they stay joined. */
.vloader { flex: none; overflow: visible; --v-dur: 2200ms; }
.vloader-spoke { stroke: var(--accent); }
.vloader-node { fill: var(--accent); }
.vloader-hub { fill: var(--hub); }
.vloader-halo { fill: var(--hub); opacity: 0; }
.vloader-body, .vloader-spoke, .vloader-halo { transform-box: view-box; transform-origin: 200px 200px; }
.vloader-body { animation: v-body var(--v-dur) infinite both; }
.vloader-spoke { animation: v-arm var(--v-dur) infinite both; }
.vloader-node { animation: v-tip var(--v-dur) infinite both; }
.vloader-halo { animation: v-halo var(--v-dur) infinite both; }
.vloader.is-still .vloader-body, .vloader.is-still .vloader-spoke, .vloader.is-still .vloader-node, .vloader.is-still .vloader-halo { animation: none; }
/* 0% rest -> 38% small, tentacles pulled in -> 72% big, tentacles spread -> 100% rest. Node travel = 66 x (1 - spoke scale). */
@keyframes v-body {
  0%   { transform: scale(1) rotate(0deg); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  38%  { transform: scale(0.72) rotate(-7deg); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  72%  { transform: scale(1.07) rotate(6deg); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes v-arm {
  0%   { transform: scaleY(1); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  38%  { transform: scaleY(0.5); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  72%  { transform: scaleY(1.2); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  100% { transform: scaleY(1); }
}
@keyframes v-tip {
  0%   { transform: translateY(0); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  38%  { transform: translateY(33px); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  72%  { transform: translateY(-13.2px); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  100% { transform: translateY(0); }
}
@keyframes v-halo {
  0%   { opacity: 0; transform: scale(0.7); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  72%  { opacity: 0.26; transform: scale(1.25); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  100% { opacity: 0; transform: scale(0.7); }
}
.file-chip { display: inline-flex; align-items: center; gap: 0.375rem; max-width: 100%; height: 1.875rem; padding: 0 0.25rem 0 0.375rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); font-size: var(--text-xs); color: var(--text-2); animation: pop var(--dur-2) var(--ease-out); }
.file-chip > .icon:first-child { color: var(--accent-ink); }
.file-chip .fname { max-width: 11.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.file-chip small { color: var(--text-3); }
.file-chip small.warn { color: var(--warn-ink); }
.file-chip.error { border-color: var(--danger-border); background: var(--danger-soft); }
.file-chip .x { display: grid; place-items: center; width: 1.375rem; height: 1.375rem; border-radius: var(--r-sm); color: var(--text-3); }
.file-chip .x:hover { background: var(--hover); color: var(--text); }
.form section > h3 { margin-bottom: var(--s2); }

/* Client handover dialog (features/app/handover.js) and the call to action under an imported workflow */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (max-width: 40rem) { .field-row { grid-template-columns: 1fr; } }
.handover-cta { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); padding: var(--s4); border: 1px solid var(--accent-tint); border-radius: var(--r-xl); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); box-shadow: var(--shadow-1); }
.handover-ico { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--r-lg); background: var(--surface); color: var(--accent-ink); border: 1px solid var(--accent-tint); box-shadow: var(--shadow-1); }
.handover-text { flex: 1 1 16rem; min-width: 0; display: grid; gap: 0.125rem; }
.handover-text b { font-family: var(--font-display); font-size: var(--text-md); font-weight: 650; letter-spacing: var(--track-snug); color: var(--text); }
.handover-cta small { color: var(--text-3); font-size: var(--text-sm); line-height: 1.45; }
.handover-cta .btn { flex: none; }

/* --- COMMAND PALETTE (Ctrl/Cmd+K): top-anchored, one big search field, grouped results, key hints in the footer --- */
.overlay:has(> .palette-modal) { place-items: start center; padding-top: min(14vh, 8rem); }
.palette-modal { width: min(38rem, 100%); overflow: hidden; }
.palette-modal .modal-head { display: none; }
.palette-modal .modal-body { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.palette { display: flex; flex-direction: column; min-height: 0; max-height: min(70dvh, 32rem); }
.pal-search { position: relative; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.pal-search .icon { position: absolute; left: 1.125rem; color: var(--text-3); pointer-events: none; }
.palette-input, .palette-input:hover, .palette-input:focus { height: 3.5rem; padding: 0 1.25rem 0 3rem !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; font-size: var(--text-md) !important; }
.palette-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0.375rem; display: grid; align-content: start; gap: 1px; }
.pal-group { padding: 0.625rem 0.625rem 0.25rem; font-size: var(--text-2xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.palette-list button { display: flex; align-items: center; gap: 0.75rem; width: 100%; min-height: 2.5rem; padding: 0 0.625rem; border-radius: var(--r-md); text-align: left; font-size: var(--text-base); color: var(--text-2); }
.palette-list button.active { background: var(--hover); color: var(--text); }
.pal-ico { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--r-sm); background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-3); flex: none; }
.palette-list button.active .pal-ico { color: var(--accent-ink); border-color: var(--accent-tint); background: var(--accent-soft); }
.pal-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-list small { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); color: var(--text-3); }
.pal-empty { padding: var(--s8) var(--s4); text-align: center; color: var(--text-3); font-size: var(--text-sm); }
.pal-foot { display: flex; gap: var(--s4); padding: 0.5rem 0.875rem; border-top: 1px solid var(--border); background: var(--bg-sunken); font-size: var(--text-xs); color: var(--text-3); }
.pal-foot kbd { margin-right: 0.1875rem; }

/* /static/css/components/sidebar.css */
/*
 * sidebar.css — left sidebar: brand, actions, search, folder tree (coloured, indented groups), chat rows with dates, bulk bar, settings footer
 * Styles for: .sidebar and everything inside it
 * Breakpoint: all (docked vs drawer is decided in mobile.css / desktop.css)
 * Navigation is dimmed so the conversation dominates: sunken background, secondary text colour, one raised row for "you are here".
 * Selection checkboxes appear in place of a chat's icon on hover, focus, or as soon as anything is selected (no layout shift).
 */
.sidebar { display: flex; flex-direction: column; background: var(--bg-sunken); border-right: 1px solid var(--hairline); min-height: 0; }
.sb-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 var(--s2) 0 var(--s4); }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text); border-radius: var(--r-sm); }
.brand img { display: block; width: 1.5rem; height: 1.5rem; transition: transform var(--dur-3) var(--ease-spring); }
.brand:hover img { transform: rotate(45deg); }   /* the wheel turns one spoke: a tiny sign of life, then rests */
.wordmark { font-family: var(--font-display); font-size: 1.1875rem; font-weight: 700; font-stretch: 85%; letter-spacing: -0.01em; line-height: 1; }
.wordmark b { color: var(--accent); font-weight: 700; margin-left: 1px; }
.sb-actions { display: flex; gap: var(--s2); padding: var(--s1) var(--s3) var(--s2); }
.new-chat { flex: 1; justify-content: flex-start; min-height: 2.25rem; padding-left: 0.625rem; }
.new-chat > .icon { color: var(--accent-ink); }
.new-chat kbd { margin-left: auto; }
.sb-search { position: relative; padding: 0 var(--s3) var(--s2); }
.sb-search .icon { position: absolute; left: 1.375rem; top: 50%; margin-top: calc(var(--s1) * -1); transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.sb-search input { padding-left: 2rem; height: 2.125rem; min-height: 0; background: transparent; border-color: transparent; box-shadow: none; font-size: var(--text-sm); }
.sb-search input:hover { background: var(--hover); border-color: transparent; }
.sb-search input:focus { background: var(--surface); border-color: var(--accent); }
.sb-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 var(--s2) var(--s3); }
.sb-tree { display: block; }
.sb-scroll.drop-root-active { background: var(--accent-soft); }
.sb-label { display: flex; align-items: center; justify-content: space-between; min-height: 1.75rem; padding: var(--s4) var(--s2) var(--s1) 0.625rem; font-size: var(--text-2xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.sb-label .icon-btn { margin-right: -0.125rem; }
.sb-sub { padding: var(--s3) var(--s2) 2px 0.625rem; font-size: var(--text-2xs); font-weight: 600; color: var(--text-4); }
.sb-empty { padding: var(--s5) var(--s3); color: var(--text-3); font-size: var(--text-sm); }
.sb-cta { display: flex; gap: var(--s2); align-items: center; width: 100%; padding: var(--s2) 0.625rem; margin-top: 2px; border-radius: var(--r-md); color: var(--text-3); font-size: var(--text-xs); text-align: left; line-height: 1.4; }
.sb-cta:hover { color: var(--text); background: var(--hover); }

.row { position: relative; display: flex; align-items: center; gap: 0.5rem; min-height: 2rem; padding: 0 0.25rem 0 0.5rem; border-radius: var(--r-md); color: var(--text-2); font-size: var(--text-sm); cursor: pointer; user-select: none; }
.row:hover { background: var(--hover); color: var(--text); }
.row.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--border); }   /* you are here: the one raised row */
.row.selected { background: var(--accent-soft); color: var(--text); }
.row.dragging { opacity: 0.45; }
.row.drop { background: var(--accent-tint); outline: 2px dashed var(--accent); outline-offset: -2px; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .rename { flex: 1; min-width: 0; height: 1.625rem; min-height: 0; padding: 0 0.5rem; font-size: var(--text-sm); }
/* Row buttons (+, more) replace the date / count while the row is hovered or focused; touch screens always show them (mobile.css). */
.row .row-act { display: none; }
.row:hover .row-act, .row:focus-within .row-act, .row:focus .row-act { display: inline-grid; }
.row:hover .when, .row:focus-within .when { display: none; }
.row .count { font-size: var(--text-2xs); color: var(--text-4); min-width: 1ch; font-variant-numeric: tabular-nums; }
.row:hover .count:not(:empty) { display: none; }
.row .chev { display: grid; transition: transform var(--dur-2) var(--ease); color: var(--text-4); }
.row .chev.open { transform: rotate(90deg); }
/* Folders carry their colour on the icon and a thin rule down the left of everything inside; the row itself stays neutral. */
.row.folder { margin-top: 1px; font-weight: 600; color: var(--text); }
.row .folder-ic { display: grid; color: var(--fc, #74818f); }
.row .folder-ic svg { fill: color-mix(in srgb, var(--fc, #74818f) 24%, transparent); }
.children { margin: 0 0 0.25rem 1.0625rem; padding-left: 0.375rem; border-left: 1.5px solid color-mix(in srgb, var(--fc, #74818f) 45%, transparent); }
.children.drop { background: color-mix(in srgb, var(--fc, #74818f) 8%, transparent); outline: 2px dashed var(--fc, var(--accent)); outline-offset: -2px; border-radius: var(--r-md); }
.row .chat-ic { display: grid; place-items: center; width: 1rem; color: var(--text-4); }
.row.active .chat-ic { color: var(--accent-ink); }
.row .when { flex: none; padding-right: 0.25rem; font-size: var(--text-2xs); font-weight: 400; color: var(--text-4); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.active .when { color: var(--text-3); }
/* The checkbox sits on top of the chat icon: hidden until the row is hovered or focused, or anything is selected. */
.row.chat .check-wrap { position: absolute; left: 0.5rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 1rem; height: 1.75rem; margin: 0; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity var(--dur-1); }
.row.chat:hover .check-wrap, .row.chat:focus-within .check-wrap, .sidebar:has(.row.selected) .row.chat .check-wrap { opacity: 1; pointer-events: auto; }
.row.chat:hover .chat-ic, .row.chat:focus-within .chat-ic, .sidebar:has(.row.selected) .row.chat .chat-ic { opacity: 0; }
.check-wrap { display: grid; place-items: center; flex: none; width: 1.375rem; height: 1.875rem; margin-left: -4px; cursor: pointer; }
.row .has-ctx { width: 0.375rem; height: 0.375rem; border-radius: 50%; background: var(--hub); flex: none; }
.row.hint { color: var(--text-4); font-size: var(--text-xs); cursor: default; min-height: 1.75rem; }
.row.hint:hover { background: none; }
.row .check { width: 0.875rem; height: 0.875rem; cursor: pointer; }

.result { display: grid; gap: 2px; width: 100%; padding: 0.5rem 0.625rem; border-radius: var(--r-md); text-align: left; }
.result:hover { background: var(--hover); }
.result b { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.result small { color: var(--text-3); font-size: var(--text-2xs); }
.result span { color: var(--text-2); font-size: var(--text-xs); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: var(--warn-soft); color: inherit; border-radius: 0.1875rem; padding: 0 1px; box-shadow: inset 0 -1px 0 var(--warn-border); }

.sb-foot { flex: none; display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2) var(--s2) max(var(--s2), env(safe-area-inset-bottom)); border-top: 1px solid var(--hairline); }
.sb-foot-row { display: flex; align-items: center; gap: 2px; }
a.foot-btn { text-decoration: none; }
.sb-legal { display: flex; flex-wrap: wrap; gap: 0.125rem 0.75rem; padding: 0.125rem 0.5rem 0.25rem; font-size: var(--text-2xs); }
.sb-legal a { color: var(--text-3); text-decoration: none; }
.sb-legal a:hover, .sb-legal a:focus-visible { color: var(--text); text-decoration: underline; }
.foot-btn { display: inline-flex; align-items: center; justify-content: flex-start; gap: 0.5rem; min-height: 2rem; padding: 0 0.5rem; border-radius: var(--r-md); color: var(--text-2); font-size: var(--text-sm); font-weight: 500; position: relative; }
.foot-btn .icon { color: var(--text-3); }
.foot-btn:hover { background: var(--hover); color: var(--text); }
.foot-btn:hover .icon { color: var(--text-2); }
.foot-btn.theme-btn { margin-left: auto; padding: 0; width: 2rem; justify-content: center; }
.bulk { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; width: 100%; padding: var(--s2); border: 1px solid var(--accent-tint); border-radius: var(--r-lg); background: var(--accent-soft); font-size: var(--text-xs); color: var(--text-2); animation: pop var(--dur-2) var(--ease-out); }
.bulk .btn-small { min-height: 1.75rem; padding: 0 var(--s2); gap: 0.25rem; }
.bulk-count { flex: 1 0 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 0.125rem 0.25rem; font-weight: 650; color: var(--accent-ink); }
.link-btn { color: var(--accent-ink); font-size: var(--text-xs); font-weight: 500; text-decoration: underline; text-underline-offset: 0.18em; }
.scrim { display: none; }

/* /static/css/components/chat.css */
/*
 * chat.css — top bar crumbs, messages, work log, composer, empty chat (welcome), suggestions
 * Styles for: the conversation column
 * Breakpoint: all
 * Hierarchy: the person's words sit in a quiet raised bubble on the right; VamimiAI's replies are unboxed text at reading size, so the
 * visuals they carry are what stands out. One accent fill per view (Send).
 */
.crumb, .crumb-title { display: inline-flex; align-items: center; gap: 0.375rem; max-width: 100%; height: 2rem; padding: 0 0.5rem; border-radius: var(--r-md); font-size: var(--text-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb:hover, .crumb-title:hover { background: var(--hover); color: var(--text); }
.crumb-title { font-weight: 600; color: var(--text); flex: 0 1 auto; min-width: 0; display: block; line-height: 2rem; }
.crumb-title.muted { color: var(--text-3); font-weight: 500; }
/* Rename box: the ring is drawn inside the border (inset) because .crumbs clips overflow. */
input.crumb-input, input.crumb-input:focus, input.crumb-input:focus-visible { height: 2rem; min-height: 0; max-width: 26rem; padding: 0 0.5rem; border: 1px solid var(--accent); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--accent); font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.sep { color: var(--text-4); }

/* --- MESSAGES --- */
.msg { display: flex; gap: var(--s3); margin-bottom: var(--s8); animation: msg-in var(--dur-3) var(--ease-out) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(0.375rem); } }
.msg-main { position: relative; flex: 1; min-width: 0; display: grid; gap: var(--s3); align-content: start; }
.msg.user { justify-content: flex-end; margin-bottom: var(--s6); }
.msg.user .msg-main { flex: 0 1 auto; max-width: min(85%, 36rem); justify-items: end; gap: var(--s1); }
.bubble { padding: 0.625rem 0.9375rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-xl) var(--r-xl) var(--r-sm) var(--r-xl); box-shadow: var(--shadow-1); font-size: var(--text-read); line-height: 1.55; overflow-wrap: anywhere; }
.bubble p { white-space: pre-wrap; }
.msg-files { display: flex; flex-wrap: wrap; gap: 0.375rem; justify-content: flex-end; }
.avatar { flex: none; width: 1.75rem; height: 1.75rem; color: var(--accent); margin-top: 2px; }
/* One height for the reasoning row (live pill and the finished "Worked for" pill). The logo beside it copies it, so both share a centre line. */
:root { --work-h: 2rem; --work-r: var(--r-md); }
.msg:has(> .msg-main > .msg-head > .work) > .avatar, .msg > .live-avatar { width: var(--work-h); height: var(--work-h); margin-top: 0; }
.avatar svg, .avatar img { width: 100%; height: 100%; display: block; overflow: visible; }
/* A reply that just replaced the live loader: the avatar stays put (the loader has already come to rest in exactly that pose); only the content fades in. */
.msg.is-fresh { animation: none; }
.msg.is-fresh > .msg-main { animation: msg-in var(--dur-3) var(--ease-out) both; }
.msg-text { font-size: var(--text-read); line-height: 1.7; color: var(--text); overflow-wrap: anywhere; max-width: 42rem; }
.msg-text p + p, .msg-text ul + p, .msg-text p + ul, .msg-text ol + p, .msg-text p + ol { margin-top: var(--s3); }
.msg-text ul, .msg-text ol { padding-left: 1.25rem; }
.msg-text ul { list-style: disc; } .msg-text ol { list-style: decimal; }
.msg-text li + li { margin-top: 0.25rem; }
.msg-text li::marker { color: var(--text-4); }
.msg-text strong, .msg-text b { font-weight: 650; color: var(--text); }
.msg-text h1, .msg-text h2, .msg-text h3 { font-family: var(--font-display); font-weight: 650; letter-spacing: var(--track-snug); line-height: 1.25; margin: var(--s5) 0 var(--s2); }
.msg-text h1 { font-size: var(--text-lg); } .msg-text h2 { font-size: 1.1875rem; } .msg-text h3 { font-size: var(--text-md); }
.msg-text code { font-family: var(--font-mono); font-size: 0.84em; background: var(--hover); border: 1px solid var(--border); padding: 0.0625rem 0.3125rem; border-radius: var(--r-xs); }
.msg-text pre { margin: var(--s3) 0; padding: var(--s3) var(--s4); background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r-lg); overflow-x: auto; font-size: var(--text-sm); }
.msg-text pre code { background: none; border: 0; padding: 0; }
.msg-text a { color: var(--accent-ink); }
.msg-text.err { color: var(--danger); }
.msg.error .msg-main { gap: var(--s2); }
.msg.error .msg-text.err { padding: var(--s3) var(--s4); border: 1px solid var(--danger-border); border-radius: var(--r-lg); background: var(--danger-soft); font-size: var(--text-base); }
.msg-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity var(--dur-2) ease; min-height: 1.75rem; margin-left: -0.375rem; font-size: var(--text-xs); color: var(--text-3); }
.msg-actions .icon-btn { width: 1.75rem; height: 1.75rem; }
.msg.user .msg-actions { justify-content: flex-end; margin: 0 -0.375rem 0 0; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg-actions.always, .msg.is-fresh .msg-actions { opacity: 1; }
.msg-actions time, .msg-actions .meta { margin: 0 var(--s2); color: var(--text-4); font-variant-numeric: tabular-nums; }
/* Pin: a round button beside the first row of every message. Hidden until hover/focus, always shown once pinned and on touch screens. */
.pin-btn { position: relative; z-index: 2; flex: none; display: grid; place-items: center; width: 1.875rem; height: 1.875rem; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); color: var(--text-3); opacity: 0; transition: opacity var(--dur-1), background-color var(--dur-1), color var(--dur-1), border-color var(--dur-1); }
.pin-btn:hover { background: var(--hover); color: var(--text); }
.pin-btn[aria-pressed="true"] { opacity: 1; background: var(--accent-soft); border-color: var(--accent-tint); color: var(--accent-ink); }
.pin-btn[aria-pressed="true"] svg { fill: currentColor; }
/* Assistant: the first row and the pin share one flex row, so the row ends where the pin starts and nothing is covered. */
.msg-head { display: flex; align-items: flex-start; gap: var(--s2); min-width: 0; }
.msg-head > :first-child { flex: 1 1 auto; min-width: 0; }
.msg-head > .pin-btn { margin-top: calc((var(--work-h) - 1.875rem) / 2); }
/* You: the pin sits just left of the bubble, centred on it. */
.msg.user .bubble { position: relative; }
.msg.user .pin-btn { position: absolute; top: 50%; right: calc(100% + 0.5rem); transform: translateY(-50%); }
.msg:hover .pin-btn, .msg:focus-within .pin-btn, .pin-btn:focus-visible { opacity: 1; }
.msg-main:has(.edit-area) .pin-btn { display: none; }
@media (hover: none) { .pin-btn { opacity: 1; } }
.msg-warn { font-size: var(--text-xs); color: var(--warn-ink); background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: var(--r-md); padding: 0.4375rem 0.75rem; }
.msg-warn summary { display: flex; gap: 0.375rem; align-items: center; cursor: pointer; font-weight: 600; }
.msg-warn ul { margin: 0.375rem 0 2px 1rem; list-style: disc; }
.day-sep { display: flex; align-items: center; gap: var(--s3); font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); margin: var(--s8) 0 var(--s6); }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.edit-area { width: 100%; min-width: min(35rem, 70vw); }
.edit-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s2); }
.bubble:has(.edit-area) { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r-lg); box-shadow: 0 0 0 3px var(--accent-ring); width: 100%; }
/* Follow-ups the reply suggests: quiet pills, the first thing to reach for when the reply ends. */
.suggestions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.suggestions .chip { min-height: 1.875rem; font-size: var(--text-sm); animation: msg-in var(--dur-3) var(--ease-out) both; animation-delay: calc(120ms + var(--i, 0) * 60ms); }
.suggestions .chip .icon { color: var(--accent-ink); }
.to-bottom { position: absolute; left: 50%; bottom: 0.75rem; transform: translateX(-50%) rotate(90deg); width: 2.125rem; height: 2.125rem; border-radius: 50%; background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-3); color: var(--text-2); display: grid; place-items: center; z-index: 4; }
.to-bottom:hover { color: var(--text); }

/* --- WORK LOG: a single quiet line while working, a collapsed record afterwards. Every line is a real server event. --- */
.work { border: 1px solid var(--border); border-radius: var(--work-r); background: var(--surface); font-size: var(--text-sm); overflow: hidden; box-shadow: var(--shadow-1); }
.work.done { display: inline-block; width: fit-content; max-width: 100%; min-width: min(16rem, 100%); background: transparent; box-shadow: none; transition: background-color var(--dur-1), border-color var(--dur-1); }
.work.done:hover { border-color: var(--border-strong); }
.work.done[open] { display: block; width: auto; background: var(--surface); box-shadow: var(--shadow-1); }
/* The live row reserves the same gutter as the finished reply's pin button, so the pill and log keep the same width when the record replaces them. */
.live-work > .msg-main { gap: 0; padding-right: calc(1.875rem + var(--s2)); }
.live-avatar .vloader { display: block; width: 100% !important; height: 100% !important; }
.live-head { position: relative; display: flex; align-items: center; gap: var(--s2); width: 100%; box-sizing: border-box; height: var(--work-h); padding: 0 0.5rem 0 0.75rem; border: 1px solid var(--border); border-radius: var(--work-r); background: var(--surface); box-shadow: var(--shadow-1); color: var(--text-2); font-size: var(--text-sm); font-weight: 500; text-align: left; overflow: hidden; transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease; }
/* A light sweeps across the live pill: motion that says "working" without inventing progress. Off in lite mode and reduced motion. */
.live-head::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--accent) 9%, transparent) 50%, transparent 70%); transform: translateX(-100%); animation: sweep 2.2s var(--ease) infinite; pointer-events: none; }
@keyframes sweep { to { transform: translateX(100%); } }
.live-head:hover { border-color: var(--border-strong); color: var(--text); }
.live-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: appear var(--dur-2) ease both; }
.live-meta { flex: none; color: var(--text-3); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.live-head > .icon { flex: none; color: var(--text-4); transition: transform var(--dur-2) var(--ease); }
.live-head[aria-expanded="true"] > .icon { transform: rotate(90deg); }
.live-head[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; }
.live-panel { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--work-r) var(--work-r); background: var(--surface); font-size: var(--text-sm); overflow: hidden; box-shadow: var(--shadow-1); }
.live-stats { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); background: var(--bg-sunken); font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.live-stats b { color: var(--text); font-weight: 650; }
.live-log { display: grid; gap: 0.375rem; max-height: min(17.5rem, 40dvh); overflow: auto; overscroll-behavior: contain; padding: 0.625rem 0.75rem; }
.live-log li { display: flex; align-items: flex-start; gap: 0.5rem; font-size: var(--text-xs); line-height: 1.45; color: var(--text-2); animation: msg-in var(--dur-2) var(--ease-out) both; }
.log-mark { flex: none; display: grid; place-items: center; width: 1rem; height: 1rem; margin-top: 1px; border-radius: 50%; }
.log-mark.is-done { background: var(--ok-soft); color: var(--ok); }
/* A running stage reads as work in progress, not as waiting: three bars that rise and fall in turn (like a level meter), the label in full
   colour with its own seconds counter, and a thin bar that keeps moving under it. Off in lite mode and reduced motion (motion.css). */
.log-mark.is-live { display: flex; align-items: flex-end; justify-content: center; gap: 0.125rem; border-radius: var(--r-xs); background: var(--accent-soft); padding: 0.1875rem 0.125rem; }
.log-mark.is-live i { display: block; width: 0.1875rem; height: 100%; border-radius: 1px; background: var(--accent); transform-origin: bottom; animation: log-level 900ms var(--ease) infinite; }
.log-mark.is-live i:nth-child(2) { animation-delay: -300ms; }
.log-mark.is-live i:nth-child(3) { animation-delay: -600ms; }
@keyframes log-level { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
@keyframes log-spin { to { transform: rotate(360deg); } }   /* still used by the admin panel's small spinner */
.log-stage.is-live { color: var(--text); font-weight: 600; }
.log-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.5rem; }
.log-time { color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.log-stage.is-live .log-time { color: var(--accent-ink); }
.log-track { position: relative; display: block; height: 0.125rem; margin-top: 0.3125rem; width: 12rem; max-width: 100%; border-radius: var(--r-full); background: var(--accent-soft); overflow: hidden; }
.log-track i { position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: inherit; background: var(--accent); animation: log-track 1.4s var(--ease) infinite; }
@keyframes log-track { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.log-body { min-width: 0; overflow-wrap: anywhere; }
.log-detail { display: block; color: var(--text-3); font-size: var(--text-xs); }
.log-call { padding-left: 1.5rem; color: var(--text-3); }
.log-call code { flex: none; font-family: var(--font-mono); font-size: 0.6875rem; padding: 0 0.3125rem; border-radius: var(--r-xs); background: var(--accent-soft); color: var(--accent-ink); }
.log-call span { min-width: 0; overflow-wrap: anywhere; }
.log-earlier { padding-left: 1.5rem; color: var(--text-3); font-style: italic; }
.live-reply { margin-top: var(--s3); }
.live-reply[hidden] { display: none; }
.live-note { padding: 0.375rem 0.75rem 0.5rem; border-top: 1px solid var(--border); font-size: var(--text-2xs); color: var(--text-4); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.work-phases { display: grid; gap: 0.3125rem; margin-top: var(--s3); color: var(--text-2); }
.phase { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-xs); }
.phase-mark { width: 1rem; height: 1rem; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--border-strong); color: var(--ok); flex: none; }
.phase.done .phase-mark { background: var(--ok-soft); border-color: transparent; }
.work.done summary { display: flex; align-items: center; gap: 0.5rem; box-sizing: border-box; height: calc(var(--work-h) - 2px); padding: 0 0.625rem; cursor: pointer; color: var(--text-3); list-style: none; font-size: var(--text-xs); font-weight: 500; }
.work.done summary:hover { color: var(--text-2); }
.work.done summary::-webkit-details-marker { display: none; }
.work.done summary .icon:first-child { color: var(--ok); }
.work.done summary > .icon:last-child { margin-left: auto; transition: transform var(--dur-2) var(--ease); color: var(--text-4); }
.work.done[open] summary > .icon:last-child { transform: rotate(90deg); }
.work.done > .work-phases, .work.done > .work-calls { padding: 0 0.75rem 0.625rem; margin-top: 0; }
.work-calls { display: grid; gap: 2px; max-height: 13.75rem; overflow: auto; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-3); counter-reset: s; }
.work-calls li { display: flex; gap: 0.5rem; white-space: nowrap; overflow: hidden; }
.work-calls b { color: var(--accent-ink); font-weight: 500; }
.work-calls span { overflow: hidden; text-overflow: ellipsis; }

/* --- COMPOSER: one raised surface. Text on top, tools below; the box lifts and rings in accent when it has focus. --- */
.composer { position: relative; }
.composer-box { position: relative; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-2xl); box-shadow: var(--shadow-2), var(--inset-top); transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) ease; }
.composer-box:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text-3)); }
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--shadow-3), 0 0 0 3px var(--accent-ring); }
.composer-input { display: block; width: 100%; min-height: 3.25rem; max-height: 13.75rem; padding: 0.9375rem 1.125rem 0.375rem; border: 0 !important; background: none; resize: none; box-shadow: none !important; font-size: var(--text-read); line-height: 1.55; color: var(--text); }
.composer-input:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; gap: var(--s2); padding: 0.25rem 0.5rem 0.5rem; }
.bar-tune { display: none; }   /* phones only (mobile.css) */
.bar-attach { width: 2.125rem; height: 2.125rem; border-radius: var(--r-full); color: var(--text-3); }
.spacer { flex: 1; }
.counter { font-size: var(--text-2xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.send-btn { display: grid; place-items: center; width: 2.125rem; height: 2.125rem; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(18, 26, 51, 0.2); transition: background-color var(--dur-1), transform var(--dur-1) var(--ease-spring), opacity var(--dur-1), box-shadow var(--dur-1); }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled { background: var(--hover-strong); color: var(--text-4); box-shadow: none; }
.send-btn.is-stop { background: var(--text); color: var(--bg); }
.attach-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s2); }
.ctx-chip { display: inline-flex; align-items: center; gap: 0.375rem; max-width: 16.25rem; height: 1.625rem; padding: 0 0.625rem; border: 1px solid var(--border); border-radius: var(--r-full); font-size: var(--text-xs); color: var(--text-2); background: var(--bg-sunken); overflow: hidden; white-space: nowrap; }
.ctx-chip .icon { color: var(--accent-ink); }
.ctx-chip small { color: var(--text-3); }
.ctx-chip:hover { border-color: var(--border-strong); color: var(--text); }
.composer-note { margin-top: 0.5rem; text-align: center; font-size: var(--text-2xs); color: var(--text-4); }
.composer-keys { white-space: nowrap; }
.composer-note kbd { height: 1.0625rem; min-width: 1.0625rem; padding: 0 0.25rem; font-size: 0.625rem; margin: 0 1px; color: var(--text-3); }
.slash { position: absolute; left: 0.5rem; right: 0.5rem; bottom: calc(100% + 0.5rem); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 0.3125rem; max-height: 16.25rem; overflow: auto; z-index: 6; animation: pop var(--dur-2) var(--ease-out); }
.slash-head { font-size: var(--text-2xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); padding: 0.375rem 0.5rem; }
.slash button { display: grid; width: 100%; text-align: left; padding: 0.5rem 0.625rem; border-radius: var(--r-sm); gap: 2px; }
.slash button.active, .slash button:hover { background: var(--hover); }
.slash button span { font-size: var(--text-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- WELCOME: one question, the import as the main action, starters as quiet cards. One staggered entrance, then still. --- */
.welcome { container-type: inline-size; display: grid; gap: var(--s6); max-width: 42rem; margin: 0 auto; padding: clamp(var(--s4), 7vh, var(--s16)) 0 var(--s6); }
.welcome > * { animation: w-in 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes w-in { from { opacity: 0; transform: translateY(0.625rem); } }
.w-head { display: grid; gap: var(--s3); justify-items: start; }
.w-eyebrow { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--text-sm); font-weight: 600; color: var(--text-3); }
.w-eyebrow img { display: block; }
.w-head h1 { font-family: var(--font-display); font-weight: 700; font-stretch: 88%; color: var(--text); font-size: var(--text-hero); line-height: 1.02; letter-spacing: var(--track-tight); }
.w-lede { color: var(--text-2); font-size: var(--text-md); line-height: 1.55; max-width: 38rem; }

/* The import target: the biggest thing on screen, because the first import is where the product earns its keep. */
.w-import { position: relative; display: grid; gap: var(--s4); padding: var(--s5); border: 1px solid var(--border); border-radius: var(--r-2xl); background: var(--surface); box-shadow: var(--shadow-2), var(--inset-top); overflow: hidden; isolation: isolate; }
.w-import::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 90% at 0% 0%, var(--accent-soft), transparent 55%); opacity: 0.9; }
.w-import-main { display: flex; align-items: center; gap: var(--s4); }
.w-import-icon { flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: var(--r-lg); background: var(--surface); color: var(--accent-ink); border: 1px solid var(--accent-tint); box-shadow: var(--shadow-1); }
.w-import-text { flex: 1; min-width: 0; display: grid; gap: 0.125rem; }
.w-import-text strong { font-family: var(--font-display); font-size: var(--text-md); font-weight: 650; letter-spacing: var(--track-snug); color: var(--text); }
.w-import-text span { font-size: var(--text-sm); color: var(--text-3); }
.w-import .btn-primary { flex: none; }
.w-gives { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); padding-top: var(--s4); border-top: 1px dashed var(--border-strong); }
.w-gives li { display: inline-flex; align-items: center; gap: 0.4375rem; font-size: var(--text-sm); font-weight: 500; color: var(--text-2); }
.w-gives .icon { color: var(--accent-ink); }
.w-examples { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--text-sm); color: var(--text-3); }
.w-examples > span { margin-right: var(--s1); }
.w-example { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.875rem; padding: 0 0.625rem; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--text-2); font-size: var(--text-xs); font-weight: 500; transition: border-color var(--dur-1), color var(--dur-1), background-color var(--dur-1), transform var(--dur-1) var(--ease); }
.w-example b { font-weight: 700; color: var(--text); }
.w-example .icon { color: var(--text-4); transition: transform var(--dur-2) var(--ease), color var(--dur-1); }
.w-example:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.w-example:hover .icon { color: var(--accent-ink); transform: translateX(2px); }
.w-example:active { transform: scale(0.97); }

.w-ideas { display: grid; gap: var(--s3); }
.w-label { font-size: var(--text-2xs); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.w-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.w-cards > li { animation: w-in 480ms var(--ease-out) both; animation-delay: calc(200ms + var(--j, 0) * 40ms); }
.w-card { display: flex; align-items: flex-start; gap: var(--s3); width: 100%; height: 100%; padding: 0.75rem 0.875rem; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); text-align: left; font-size: var(--text-sm); line-height: 1.45; color: var(--text-2); transition: border-color var(--dur-1), background-color var(--dur-1), box-shadow var(--dur-2), transform var(--dur-2) var(--ease); }
.w-card:hover { border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.w-card:active { transform: translateY(0) scale(0.99); }
.w-card-icon { flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--r-md); background: var(--hover); color: var(--text-3); transition: background-color var(--dur-1), color var(--dur-1); }
.w-card:hover .w-card-icon { background: var(--accent-soft); color: var(--accent-ink); }
.w-card-text { padding-top: 0.25rem; }
.slot { color: var(--accent-ink); font-weight: 600; text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: 0.2em; }
.w-demo { display: flex; align-items: center; gap: 0.5rem; justify-self: start; font-size: var(--text-xs); color: var(--text-3); }
.w-demo .status-dot { background: var(--hub); box-shadow: 0 0 0 3px var(--warn-soft); }
@container (max-width: 34rem) {
  .w-cards { grid-template-columns: 1fr; }
  .w-import-main { flex-wrap: wrap; }
  .w-import .btn-primary { width: 100%; }
  .w-lede { font-size: var(--text-base); }
}

.demo-note { justify-self: center; display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.625rem; text-align: left; max-width: 100%; border: 1px solid var(--warn-border); background: var(--warn-soft); color: var(--warn-ink); font-size: var(--text-xs); border-radius: var(--r-md); }
.eyebrow { font-size: var(--text-xs); color: var(--text-3); font-weight: 700; }

/* /static/css/components/tune.css */
/*
 * tune.css: the Tune controls.
 * Styles for: .tune-core (the bar between Attach and Send: Format, Detail and Creativity cells + the Options button), .tune-pop (the Options popup above the
 * composer and the Customize chat popover under the top bar; bottom sheets on phones), .sld (slider), .combo (type-anywhere field), .seg, .tg-switch,
 * .chip-set, .tune-select, .tune-hintline, .meta.tuned.
 * Meaning is never carried by colour alone: selected chips show a check mark, and a switch that is on moves its knob right and shows a check in it.
 */

/* --- TOP BAR: Customize chat --- */
.topbar { position: relative; }
.tune-top { flex: none; display: flex; align-items: center; }
.tune-chat, .tune-opt { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; border: 1px solid transparent; border-radius: var(--r-md); background: transparent; color: var(--text-2); font-size: var(--text-sm); font-weight: 500; white-space: nowrap; transition: border-color var(--dur-1), background-color var(--dur-1), color var(--dur-1); }
.tune-chat { height: 2rem; padding: 0 0.625rem; }
.tune-chat .icon { color: var(--text-3); }
.tune-chat:hover, .tune-opt:hover { background: var(--hover); color: var(--text); }
.tune-chat.is-open, .tune-opt.is-open { background: var(--accent-soft); color: var(--accent-ink); }
.tune-chat.is-open .icon, .tune-opt.is-open .icon { color: var(--accent-ink); }

/* --- THE BAR: quiet controls between Attach and Send. No boxes: a hover fill and a hairline divider are enough. --- */
.composer-bar { align-items: center; }
.bar-end { flex: none; display: flex; align-items: center; gap: var(--s2); }
.tune-core { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 2px; padding: 0 0.125rem; }
.tune-core .tcell { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 0.5rem; min-height: 2.125rem; padding: 0 0.625rem; border: 0; border-radius: var(--r-md); background: transparent; transition: background-color var(--dur-1); }
.tune-core .tcell + .tcell::before, .tune-core .tcell + .tune-opt::before { content: ""; position: absolute; left: -1px; top: 25%; bottom: 25%; width: 1px; background: var(--border); }
.tune-core .tcell.tf-slider { flex: 1.5 1 0; }
.tune-core .tcell.tf-select { flex: 0.9 1 0; }
.tcell:hover:not(.is-na) { background: var(--hover); }
.tcell.is-na { opacity: 0.45; }
.tcell .tf-cap { flex: none; font-size: var(--text-xs); color: var(--text-3); }
.tcell .tune-select { flex: 1; min-width: 0; width: auto; max-width: none; height: 1.75rem; min-height: 1.75rem; padding: 0; border: 0; background: transparent; font-size: var(--text-xs); font-weight: 600; color: var(--text); cursor: pointer; }
.tune-opt { position: relative; flex: 0.8 1 0; min-width: 0; min-height: 2.125rem; padding: 0 0.625rem; justify-content: flex-start; font-size: var(--text-xs); }
.tune-opt .icon:first-child { color: var(--text-3); }
.tune-opt span { flex: 1; text-align: left; }
.tune-opt .chev { flex: none; color: var(--text-4); transform: rotate(180deg); transition: transform var(--dur-2) var(--ease); }
.tune-opt.is-open .chev { transform: none; }

/* --- SLIDER: named steps on a native range input --- */
.sld { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.sld-cap { flex: none; font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
.sld-cap b { color: var(--text); font-weight: 600; }
.sld-input { -webkit-appearance: none; appearance: none; flex: 1 1 auto; width: auto; min-width: 2.25rem; height: 1.125rem; margin: 0; background: transparent; cursor: pointer; }
.sld-input::-webkit-slider-runnable-track { height: 0.1875rem; border-radius: 0.25rem; background: linear-gradient(to right, var(--accent) var(--p, 33%), var(--border-strong) var(--p, 33%)); }
.sld-input::-webkit-slider-thumb { -webkit-appearance: none; width: 0.875rem; height: 0.875rem; margin-top: -0.34375rem; border-radius: 50%; background: var(--surface); border: 0; box-shadow: 0 0 0 1.5px var(--accent), 0 1px 3px rgba(18, 26, 51, 0.25); transition: transform var(--dur-1) var(--ease-spring); }
.sld-input:hover::-webkit-slider-thumb, .sld-input:focus-visible::-webkit-slider-thumb { transform: scale(1.18); }
.sld-input:focus-visible { box-shadow: none; }
.sld-input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-ring); }
.sld-input::-moz-range-track { height: 0.1875rem; border-radius: 0.25rem; background: var(--border-strong); }
.sld-input::-moz-range-progress { height: 0.1875rem; border-radius: 0.25rem; background: var(--accent); }
.sld-input::-moz-range-thumb { width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--accent); }
.sld-input:disabled { cursor: not-allowed; opacity: 0.5; }

/* --- POPUPS --- */
.tune-pop { z-index: 30; display: flex; flex-direction: column; gap: 0.625rem; padding: 0.875rem 1rem; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-4); animation: pop var(--dur-2) var(--ease-out); }
.tune-pop[hidden] { display: none; }
.tune-options { position: absolute; right: 0; bottom: calc(100% + 0.625rem); width: min(44rem, 100%); max-height: min(78dvh, 42rem); overflow-y: auto; overscroll-behavior: contain; padding-bottom: 0; }
.tune-chatpop { position: absolute; top: calc(100% + 0.375rem); right: var(--s4); width: min(21.25rem, calc(100vw - 1.5rem)); }
.pop-head { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-display); font-size: var(--text-base); font-weight: 650; letter-spacing: var(--track-snug); color: var(--text); }
.pop-head .pop-close { margin-left: auto; }
.pop-count { padding: 0.0625rem 0.4375rem; border-radius: 999px; background: var(--cobalt-soft); color: var(--cobalt-deep); font-size: 0.6875rem; font-weight: 600; }
.pop-count[hidden] { display: none; }
.pop-close { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 0.5rem; color: var(--ink-3); }
.pop-close:hover { background: var(--paper-2); color: var(--ink); }
.pop-sub { margin: 0 0 0.25rem; font-size: 0.75rem; color: var(--ink-3); }
.pop-body { display: flex; flex-direction: column; gap: 0.75rem; }
/* Options: two columns of labelled groups. Every field is a caption above a full-width control, so all controls start on one edge. */
.pop-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; align-items: start; }
.pop-col { display: flex; flex-direction: column; gap: 0.875rem; min-width: 0; }
.pop-sec { display: flex; flex-direction: column; gap: 0.625rem; min-width: 0; }
.pop-sec h4 { margin: 0; padding-bottom: 0.25rem; border-bottom: 1px solid var(--line); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.tune-options .tf-segmented, .tune-options .tf-chips { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0.25rem; }
.tune-options .pop-sec { gap: 0.5rem; }
.tune-options .seg { display: grid; width: 100%; }
.pop-foot { position: sticky; bottom: 0; display: flex; align-items: flex-start; gap: 0.75rem; margin: 0 -1rem; padding: 0.5rem 1rem 0.75rem; border-top: 1px solid var(--border); background: var(--surface-raised); }
.pop-foot .tune-hintline { flex: 1; margin: 0; padding: 0.25rem 0 0; }
.pop-reset { flex: none; }
.pop-reset:disabled { opacity: 0.45; cursor: default; }
.tune-chatpop .pop-foot { margin-bottom: -0.875rem; }

/* --- FIELDS inside popups: a caption and its control on one line --- */
.tf { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.375rem 0.625rem; min-width: 0; }
.tf-cap { flex: none; font-size: 0.75rem; color: var(--ink-2); white-space: nowrap; }
.tf.is-na { opacity: 0.45; }
.tf-chips { flex-direction: column; align-items: flex-start; justify-content: flex-start; }
.tune-input { width: 11.875rem; max-width: 100%; height: 1.875rem; padding: 0 0.5625rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--white); font-size: 0.7812rem; color: var(--ink); }
.combo { display: inline-flex; max-width: 100%; }
.tune-select { height: 1.75rem; min-height: 1.75rem; padding: 0 0.375rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--white); font-size: 0.75rem; color: var(--ink); max-width: 9.375rem; }
.tune-hintline { min-height: 1.125rem; margin: 2px 0 0; font-size: 0.7188rem; line-height: 1.4; color: var(--ink-2); }
.tune-hintline.is-idle { color: var(--ink-3); }
.ctx-slot { display: contents; }
.ctx-slot .ctx-chip { margin: 0 0 0.25rem 0.875rem; }

/* --- CONTROLS --- */
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1px; padding: 2px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.seg-btn { min-height: 1.625rem; padding: 0 0.5rem; border-radius: 0.375rem; font-size: 0.75rem; color: var(--ink-2); white-space: nowrap; transition: background-color 140ms, color 140ms; }
.seg-btn:hover:not(:disabled):not(.on) { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.seg-btn.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--border); }
.seg-btn:disabled, .tg-switch:disabled, .chip-btn:disabled, .tune-select:disabled, .tune-input:disabled { cursor: not-allowed; }

/* A switch row: name and one line of what it does on the left, the switch on the right. */
.tf-switch { flex-wrap: nowrap; align-items: center; gap: 0.75rem; }
.tf-switch .tf-cap { display: flex; flex-direction: column; flex: 1; min-width: 0; white-space: normal; font-size: 0.75rem; color: var(--ink); cursor: pointer; }
.tf-switch .tf-cap small { font-size: 0.6875rem; color: var(--ink-3); line-height: 1.35; }
.tg-switch { position: relative; flex: none; width: 2.125rem; height: 1.25rem; border-radius: 999px; background: var(--line-strong); transition: background-color 140ms; }
.tg-switch i { position: absolute; top: 0.125rem; left: 0.125rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(18, 26, 51, 0.3); transition: transform var(--dur-2) var(--ease-spring); }
.tg-switch[aria-checked="true"] { background: var(--accent); }
.tg-switch[aria-checked="true"] i { transform: translateX(0.875rem); display: grid; place-items: center; }
.tg-switch[aria-checked="true"] i::after { content: ""; width: 0.1875rem; height: 0.375rem; margin-top: -1px; border: solid var(--cobalt); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.tg-switch:disabled { cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .tg-switch, .tg-switch i { transition: none; } }

.chip-set { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; }
.chip-btn { height: 1.625rem; padding: 0 0.5625rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); font-size: 0.75rem; color: var(--ink-2); background: var(--white); white-space: nowrap; transition: border-color 140ms, background-color 140ms; }
.chip-btn:hover:not(:disabled) { border-color: var(--cobalt); }
.chip-btn.on { background: var(--cobalt-soft); border-color: var(--cobalt); color: var(--cobalt-deep); font-weight: 600; }
.chip-btn.on::before { content: "\2713\00a0"; }

.meta.tuned { display: inline-flex; align-items: center; gap: 0.25rem; max-width: min(90ch, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- PHONES: Attach and Send on top, the four bar cells in a 2x2 grid; popups become bottom sheets; Customize chat shows only its icon --- */
@media (max-width: 767.98px) {
  .composer-bar { flex-wrap: wrap; }
  .bar-attach { order: 1; } .bar-end { order: 2; margin-left: auto; }
  /* Phones: the controls become one swipeable strip of compact pills, so the composer stays two rows tall. The edge fade says "more". */
  .tune-core { order: 3; flex: 1 1 100%; display: flex; gap: 0.375rem; padding: 0.125rem 0.25rem 0.25rem; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .tune-core::-webkit-scrollbar { display: none; }
  .tune-core .tcell + .tcell::before, .tune-core .tcell + .tune-opt::before { display: none; }
  .tune-pop { position: fixed; left: 0.5rem; right: 0.5rem; top: auto; bottom: 0.5rem; width: auto; max-height: 78dvh; overflow-y: auto; z-index: 60; }
  .pop-cols { grid-template-columns: 1fr; }
  .tune-chat { width: 2.125rem; padding: 0; } .tune-chat span { display: none; }
  .tune-core .tcell, .tune-core .tcell.tf-slider, .tune-core .tcell.tf-select, .tune-opt { flex: 0 0 auto; scroll-snap-align: start; min-height: 2.25rem; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r-full); }
  .tune-core .tcell.tf-slider { min-width: 13rem; }
  .tune-core .tcell.tf-select { min-width: 8.5rem; }
  .tune-opt { min-width: 7rem; }
  .sld-input { height: 1.5rem; min-width: 4rem; }
  .seg-btn { min-height: 2rem; padding: 0 0.5625rem; }
  .tune-select, .tune-input { height: 2.125rem; min-height: 2.125rem; }
  .tg-switch { width: 2.5rem; height: 1.5rem; } .tg-switch i { width: 1.25rem; height: 1.25rem; } .tg-switch[aria-checked="true"] i { transform: translateX(1rem); }
  .pop-col + .pop-col { margin-top: 1rem; }
  .chip-btn { height: 2rem; }
}

/* --- NARROW COMPOSER (tablets, small laptops with the sidebar docked, phones held sideways): the bar's own width decides, not the window's.
   The Format select keeps room for its value, the cells tighten, and below 38rem the captions that repeat the control's name step aside
   (each control keeps its aria-label). Phones under 48rem use the swipeable strip above instead. --- */
.composer-bar { container: tunebar / inline-size; }
@media (min-width: 768px) {
  @container tunebar (max-width: 46rem) {
    .tune-core .tcell { padding: 0 0.5rem; gap: 0.375rem; }
    .tune-core .tcell.tf-select { flex: none; }
    .tcell .tune-select { flex: none; width: auto; min-width: 4.75rem; field-sizing: content; }
    .tune-opt { flex: none; }
    .tune-opt .chev { display: none; }
  }
  @container tunebar (max-width: 38rem) {
    .tune-core .tcell.tf-select .tf-cap { display: none; }
    .tune-opt span { display: none; }
    .tune-opt { padding: 0 0.5rem; }
  }
}

/* /static/css/components/blocks.css */
/*
 * blocks.css — visual cards inside messages: card shell, diagram view, walkthrough bar, sequence, chart, table, timeline, stats
 * Styles for: .block and everything a block renders
 * Breakpoint: all
 */
.block { border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-2); animation: msg-in var(--dur-3) var(--ease-out) both; }
.msg-blocks { display: grid; gap: var(--s4); }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 3rem; padding: 0.5rem 0.625rem 0.5rem var(--s4); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.block-head h3 { font-family: var(--font-display); font-size: 1rem; font-weight: 650; font-stretch: 92%; letter-spacing: var(--track-snug); line-height: 1.2; color: var(--text); }
/* Toolbar: quiet until you reach for it, so the drawing is what you see first. */
.block-actions .btn-quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-3); font-weight: 500; }
.block-actions .icon-btn { color: var(--text-3); }
.block-actions .btn-quiet:hover:not(:disabled) { background: var(--hover); border-color: transparent; color: var(--text); }
.block-title { display: grid; min-width: 0; }
.block-title.block-title-row { display: flex; align-items: center; gap: var(--s2); }
.block-title .sub { font-size: var(--text-xs); color: var(--ink-3); }
.block-actions { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.block-actions-sep { width: 1px; height: 1.25rem; margin: 0 var(--s2); background: var(--line); }
.block-body { padding: var(--s4); }
.block-body.flush { padding: 0; position: relative; }
.block-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: 0.5rem 0.625rem 0.5rem var(--s4); border-top: 1px solid var(--border); background: var(--bg-sunken); font-size: var(--text-xs); color: var(--text-3); }
.chip-changes { font-size: var(--text-xs); font-weight: 600; color: var(--warn-ink); background: var(--warn-soft); padding: 2px 0.625rem; border-radius: var(--r-full); }

/* --- DIAGRAM VIEW: a stage (canvas + zoom controls), then, during a walkthrough, the caption panel and the controls, all in flow --- */
.dv { position: relative; display: flex; flex-direction: column; --dv-h: 22.5rem; }
.dv-stage { position: relative; height: var(--dv-h); }
.dv-wrap { position: relative; height: 100%; overflow: hidden; background-color: var(--dv-bg, var(--vellum)); background-image: radial-gradient(var(--dv-dot, var(--vellum-dot)) 1px, transparent 1.3px); background-size: 1.375rem 1.375rem; touch-action: pan-y pinch-zoom; outline: none; }
.dv-wrap:focus-visible { box-shadow: inset 0 0 0 2px var(--cobalt); }
.dv-wrap.is-zoomed, .dv-studio .dv-wrap { cursor: grab; touch-action: none; }
.dv-wrap[data-grid="lines"] { background-image: linear-gradient(var(--dv-dot) 1px, transparent 1px), linear-gradient(90deg, var(--dv-dot) 1px, transparent 1px); background-size: 1.5rem 1.5rem; }
.dv-wrap[data-grid="none"] { background-image: none; }
.dv-wrap.is-panning { cursor: grabbing; }
.dv-wrap svg.diagram { position: absolute; inset: 0; width: 100%; height: 100%; }
.dv-studio { height: 100%; }
.dv-studio .dv-stage { flex: 1; min-height: 0; height: auto; }

/* zoom controls, always on the canvas (visuals/viewport.js) */
.vp-controls { position: absolute; right: 0.625rem; bottom: 0.625rem; z-index: 3; display: flex; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface-raised) 92%, transparent); box-shadow: var(--shadow-2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.vp-btn { display: grid; place-items: center; width: 1.875rem; height: 1.875rem; border-radius: var(--r-md); color: var(--text-2); transition: background-color var(--dur-1), color var(--dur-1); }
.vp-btn:hover { background: var(--paper-2); color: var(--ink); }
.vp-level { min-width: 3.25rem; height: 2rem; padding: 0 0.25rem; border-radius: 0.375rem; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-2); }
.vp-level:hover { background: var(--paper-2); color: var(--ink); }

/* the guided tour: a caption panel that always shows in full, then the controls */
.dv-caption { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.625rem var(--s4) 0.5rem; background: var(--white); border-top: 1px solid var(--line); }
.dv-caption[hidden] { display: none; }
.dv-cap-title { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 700; color: var(--ink); line-height: 1.3; }
.dv-cap-sub { font-size: var(--text-sm); color: var(--ink-2); min-height: 1.2em; }
.dv-walkbar { padding: 0.375rem var(--s3) 0.5rem; background: var(--white); }
.dv-walkbar[hidden] { display: none; }
.dv-walk-row { display: flex; align-items: center; gap: var(--s2); }
.dv-time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-2); min-width: 9ch; }
.dv-scrub { flex: 1; min-width: 4rem; accent-color: var(--cobalt); height: 1.375rem; }
.dv-follow[hidden] { display: none; }
.dv.is-walking .vp-controls { bottom: 0.625rem; }
.dv-hint { position: absolute; left: 50%; bottom: 0.625rem; transform: translateX(-50%); padding: 0.3125rem 0.75rem; border-radius: var(--r-sm); background: color-mix(in srgb, #121a33 88%, transparent); color: #fff; font-size: var(--text-xs); backdrop-filter: blur(0.25rem); box-shadow: var(--shadow-2); }
.dv-hint:hover { background: #121a33; }

/* --- SEQUENCE --- */
.seq-wrap { overflow-x: auto; padding: var(--s2) 0; text-align: center; }
svg.seq { max-width: none; font-family: var(--font-sans); }
.seq-life { stroke: var(--line-strong); stroke-dasharray: 4 5; }
.seq-actor rect { fill: var(--accent-soft); stroke: var(--accent-tint); }
.seq-actor text { font-size: 0.8125rem; font-weight: 600; fill: var(--cobalt-deep); text-anchor: middle; dominant-baseline: central; }
.seq-line { stroke: var(--ink-2); stroke-width: 1.6; fill: none; }
.seq-line.k-reply { stroke-dasharray: 6 5; stroke: var(--ink-3); }
.seq-head { fill: var(--ink-2); } .seq-head-open { fill: none; stroke: var(--ink-2); stroke-width: 1.6; }
.seq-label { font-size: 0.7812rem; fill: var(--ink); text-anchor: middle; }
.seq-note { fill: var(--warn-soft); stroke: var(--warn-border); }
.seq-note-text { font-size: 0.75rem; fill: var(--warn-ink); text-anchor: middle; dominant-baseline: central; }
svg.seq.is-intro .seq-row { animation: msg-in 380ms var(--ease) both; animation-delay: calc(var(--i) * 80ms); }

/* --- CHART --- */
.chart { position: relative; display: grid; gap: var(--s3); justify-items: center; }
.chart-svg { width: 100%; max-width: 47.5rem; height: auto; }
.chart .grid { stroke: var(--line); } .chart .axis { font-size: 0.6875rem; fill: var(--ink-3); }
.chart .line { stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.chart .area { opacity: 0.14; } .chart .slice { stroke: var(--surface); stroke-width: 2; }
.chart .bar, .chart .slice, .chart .dot { transition: opacity 120ms; } .chart .bar:hover, .chart .slice:hover { opacity: 0.82; }
.donut-total { font-size: 1.625rem; font-weight: 600; fill: var(--ink); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--text-xs); color: var(--ink-2); justify-content: center; }
.chart-legend li { display: inline-flex; align-items: center; gap: 0.375rem; } .chart-legend b { font-weight: 600; }
.chart-tip { position: absolute; z-index: 3; pointer-events: none; padding: 0.25rem 0.5625rem; border-radius: var(--r-sm); background: #161b2c; color: #f1f3f8; font-size: var(--text-xs); white-space: nowrap; box-shadow: var(--shadow-3); }
.chart.is-intro .bar { transform-box: fill-box; transform-origin: bottom; animation: grow 650ms var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
.chart.is-intro .line { animation: draw-line 1s var(--ease) both; }
.chart.is-intro .slice { animation: fade-slice 600ms var(--ease) both; animation-delay: calc(var(--i) * 90ms); }
@keyframes grow { from { transform: scaleY(0); } } @keyframes draw-line { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } } @keyframes fade-slice { from { opacity: 0; } }

/* --- TABLE --- */
.tbl-wrap { margin: calc(var(--s4) * -1); }
.tbl-scroll { overflow-x: auto; max-height: 28.75rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl th { position: sticky; top: 0; background: var(--bg-sunken); text-align: left; padding: 0; border-bottom: 1px solid var(--line-strong); z-index: 1; }
.tbl th button { width: 100%; padding: 0.625rem var(--s4); text-align: inherit; font-weight: 600; color: var(--ink-2); font-size: var(--text-xs); text-transform: none; }
.tbl th button:hover { color: var(--ink); background: var(--vellum); }
.tbl th[aria-sort="ascending"] button::after { content: " \2191"; color: var(--cobalt); } .tbl th[aria-sort="descending"] button::after { content: " \2193"; color: var(--cobalt); }
.tbl td { padding: 0.625rem var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); } .tbl tbody tr:hover { background: var(--accent-soft); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-foot { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: space-between; align-items: center; padding: 0.5rem var(--s4); font-size: var(--text-xs); color: var(--ink-3); border-top: 1px solid var(--line); }
/* phones: columns keep a readable width and the table scrolls sideways inside its card, instead of one word per line */
@media (max-width: 47.99rem) { .tbl td { min-width: 8.5rem; padding: 0.5rem 0.75rem; } .tbl td:first-child { min-width: 6.5rem; } .tbl td.long { min-width: 15rem; } .tbl th button { padding: 0.5rem 0.75rem; } }

/* --- TIMELINE --- */
.tl { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 6rem 1.125rem 1fr; gap: var(--s3); position: relative; padding-bottom: var(--s5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: calc(6rem + var(--s3) + 0.5rem); top: 1.125rem; bottom: -4px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-date { text-align: right; font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); padding-top: 0.1875rem; }
.tl-dot { width: 1rem; height: 1rem; margin-top: 0.1875rem; border-radius: 50%; background: var(--white); border: 0.1875rem solid var(--cobalt); z-index: 1; }
.tl-item.k-milestone .tl-dot { background: var(--cobalt); } .tl-item.k-risk .tl-dot { border-color: var(--danger); background: var(--danger-tint); }
.tl-body strong { font-size: var(--text-sm); } .tl-body p { font-size: var(--text-xs); color: var(--ink-3); }
.tl.is-intro .tl-item { animation: msg-in 420ms var(--ease) both; animation-delay: calc(var(--i) * 90ms); }

/* --- STATS --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.375rem, 1fr)); gap: var(--s3); }
.stat { display: grid; gap: 2px; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-sunken); }
.stat-label { font-size: var(--text-xs); color: var(--ink-3); font-weight: 500; }
.stat-value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 650; letter-spacing: var(--track-tight); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); } .stat-delta.t-up { color: var(--cobalt-deep); }
.stat-note { font-size: var(--text-xs); color: var(--ink-3); }
.stats.is-intro .stat { animation: msg-in 420ms var(--ease) both; animation-delay: calc(var(--i) * 80ms); }

/* --- LINKED SUB-DIAGRAMS (only rendered when the Settings switch is on; see visuals/subdiagram-ui.js) --- */
.subtrail { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; padding: 0.375rem var(--s4); border-bottom: 1px solid var(--line); background: var(--cobalt-soft); font-size: var(--text-xs); color: var(--ink-2); }
.subtrail .icon { color: var(--cobalt); flex: none; }
.subtrail-link { color: var(--cobalt-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; padding: 0.125rem 0.25rem; border-radius: var(--r-sm); }
.subtrail-link:hover { background: var(--cobalt-tint); }
.subtrail-sep { color: var(--ink-3); }
.subtrail-here { font-weight: 600; color: var(--ink); }
.subbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); padding: 0.5rem var(--s4); border-top: 1px solid var(--line); background: var(--cobalt-soft); }
.subbar-label { display: inline-flex; align-items: center; gap: 0.375rem; margin-right: auto; min-width: 0; font-size: var(--text-sm); color: var(--ink-2); }
.subbar-label b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.subchips { display: flex; align-items: center; flex-wrap: wrap; gap: 0.375rem; }
.subchips-label { font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); }
.subchip { display: inline-flex; align-items: center; gap: 0.25rem; font-size: var(--text-xs); font-weight: 600; color: var(--cobalt-deep); background: var(--cobalt-soft); border: 1px solid var(--cobalt-tint); padding: 2px 0.625rem; border-radius: var(--r-full); }
.subchip:hover { background: var(--cobalt-tint); }
.studio-inspector > .subbar { border-top: 0; border-bottom: 1px solid var(--line); }
.studio-title .subtrail { padding: 0; border: 0; background: none; }

/* --- AUDIT LEVELS in tables (visuals/table.js): a mark and the word, so meaning never rests on colour alone --- */
.lvl { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.375rem; padding: 0 0.5rem 0 0.25rem; border-radius: var(--r-full); font-size: var(--text-xs); font-weight: 650; white-space: nowrap; background: var(--hover); color: var(--text-2); }
.lvl-mark { display: grid; place-items: center; width: 0.9375rem; height: 0.9375rem; border-radius: 50%; font-style: normal; font-size: 0.625rem; font-weight: 800; line-height: 1; background: var(--text-4); color: var(--surface); }
.lvl-4, .lvl-3 { background: var(--danger-soft); color: var(--danger); }
.lvl-4 .lvl-mark, .lvl-3 .lvl-mark { background: var(--danger); }
.lvl-2 { background: var(--warn-soft); color: var(--warn-ink); }
.lvl-2 .lvl-mark { background: var(--warn); }

/* /static/css/components/studio.css */
/*
 * studio.css — full-screen diagram viewer: toolbar, stage, minimap, inspector
 * Styles for: .studio and its children
 * Breakpoint: all (inspector collapses below the stage on small screens in mobile.css)
 */
.studio { position: fixed; inset: 0; z-index: 250; display: flex; flex-direction: column; background: var(--bg); animation: studio-in var(--dur-3) var(--ease-out); }
@keyframes studio-in { from { opacity: 0; transform: scale(0.99); } }
.studio-bar { display: flex; align-items: center; gap: var(--s3); min-height: var(--topbar-h); padding: 0.375rem var(--s3); border-bottom: 1px solid var(--border); background: var(--bg); flex-wrap: wrap; }
.studio-title { flex: 1 1 10rem; min-width: 0; }
.studio-title h2 { font-family: var(--font-display); font-size: var(--text-md); font-weight: 650; letter-spacing: var(--track-snug); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-find { position: relative; display: flex; align-items: center; min-width: 11.875rem; }
.studio-find .icon { position: absolute; left: 0.625rem; color: var(--ink-3); }
.studio-search { padding-left: 2rem !important; height: 2.25rem; padding-right: 4.375rem !important; }
.studio-matches { position: absolute; right: 0.625rem; font-size: var(--text-xs); color: var(--ink-3); }
.studio-actions { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.studio-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.studio-stage { position: relative; flex: 1; min-height: 0; background: var(--vellum); }
.studio-stage .dv { height: 100%; }
.studio-inspector { display: flex; flex-direction: column; max-height: 42%; border-top: 1px solid var(--border); background: var(--bg-sunken); }
.studio-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s4); display: grid; gap: var(--s3); align-content: start; }
.studio-inspector .tabs { display: flex; gap: var(--s4); padding: 0 var(--s4); border-bottom: 1px solid var(--line); flex: none; }
.tab { min-height: 2.625rem; font-size: var(--text-sm); font-weight: 500; color: var(--ink-3); position: relative; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.tab:hover { color: var(--text); }
.studio-body h4 { font-size: var(--text-base); } .studio-body h5 { font-size: var(--text-xs); font-weight: 700; color: var(--ink-3); margin-top: var(--s2); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.375rem var(--s4); font-size: var(--text-sm); } .facts dt { color: var(--ink-3); }
.row-list { display: grid; gap: 2px; }
.row-btn { display: flex; justify-content: space-between; gap: var(--s3); width: 100%; padding: 0.4375rem 0.625rem; border-radius: var(--r-sm); text-align: left; font-size: var(--text-sm); }
.row-btn:hover { background: var(--paper-2); } .row-btn small { color: var(--ink-3); }
.studio .call { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--s2); width: 100%; text-align: left; padding: 0.375rem var(--s2); border-left: 0.1875rem solid transparent; border-radius: var(--r-sm); }
.studio button.call:hover { background: var(--paper-2); }
.studio .call .idx { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-3); text-align: right; }
.studio .call .name { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; margin-right: 0.5rem; }
.studio .call .args { font-size: var(--text-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.studio .call .why { display: block; font-size: var(--text-xs); color: var(--danger); }
.studio .call.is-animation .name { color: var(--cobalt-deep); } .studio .call.is-error { background: var(--danger-tint); }
.studio .call.is-active { background: var(--cobalt-tint); border-left-color: var(--cobalt); }
.json-editor { min-height: 15rem; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; white-space: pre; overflow: auto; }
.studio-legend { position: absolute; left: 0.75rem; bottom: 0.75rem; padding: 0.5rem 0.75rem; background: color-mix(in srgb, var(--surface-raised) 92%, transparent); border: 1px solid var(--border); backdrop-filter: blur(6px); border-radius: var(--r-md); box-shadow: var(--shadow-1); max-width: 60%; z-index: 2; }
.minimap { position: absolute; right: 0.75rem; bottom: 0.75rem; z-index: 2; background: color-mix(in srgb, var(--surface-raised) 92%, transparent); border: 1px solid var(--border); backdrop-filter: blur(6px); border-radius: var(--r-md); box-shadow: var(--shadow-2); overflow: hidden; cursor: pointer; touch-action: none; }
.minimap i { position: absolute; border-radius: 2px; opacity: 0.8; }
.minimap-view { position: absolute; border: 2px solid var(--cobalt); background: rgba(41, 72, 244, 0.08); border-radius: 0.1875rem; pointer-events: none; }
.dv-studio .dv-walkbar, .dv-studio .dv-caption { z-index: 3; }

/* Linked sub-diagrams */
.studio-crumbs:empty { display: none; }
.studio-subchips:empty { display: none; }
.studio-subchips { padding: 0.5rem var(--s4); border-bottom: 1px solid var(--line); }

/* /static/css/components/editor.css */
/*
 * editor.css: the manual diagram editor (features/editor). Styles for: the overlay drawn inside the diagram SVG (selection, handles, guides,
 * marquee, connector rubber band), connector hit areas, the floating toolbar, the inline text box and the Edit tab of the inspector.
 * Selection never relies on colour alone: it also uses outlines, handles and a dashed group box.
 */
.dv-wrap.is-editing { cursor: default; }
.is-armed .dv-wrap { cursor: crosshair; }
.edit-layer, .edit-layer * { pointer-events: none; }
.edit-layer .edit-handle, .edit-layer .edit-conn, .edit-layer .edit-conn * { pointer-events: all; }
.edit-sel { fill: none; stroke: var(--cobalt); }
.edit-group { fill: rgba(41, 72, 244, 0.05); stroke: var(--cobalt); }
.edit-handle { fill: var(--surface); stroke: var(--cobalt); }
.edit-conn { cursor: crosshair; }
.edit-conn circle { fill: var(--surface); stroke: var(--cobalt); }
.edit-conn path { fill: none; stroke: var(--cobalt); stroke-linecap: round; }
.edit-conn:hover circle { fill: var(--cobalt-soft); }
.edit-rubber { fill: none; stroke: var(--cobalt); stroke-dasharray: 6 4; }
.edit-guide { stroke: #e0306e; }
.edit-marquee { fill: rgba(41, 72, 244, 0.08); stroke: var(--cobalt); }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.edge.is-edit-sel .edge-base, .edge.is-edit-sel .edge-lit { stroke: var(--cobalt) !important; stroke-width: 3.2; opacity: 1; }
.node.is-drop .body { stroke: var(--cobalt); stroke-width: 3.5; }
.is-editing .node { cursor: move; }

.edit-bar { position: absolute; top: 0.625rem; left: 0; right: 0; margin-inline: auto; width: max-content; z-index: 6; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.25rem; max-width: calc(100% - 1.25rem); padding: 0.25rem; background: var(--white); border: 1px solid var(--line-strong); border-radius: 0.75rem; box-shadow: var(--shadow-2); }
.edit-bar .sep { width: 1px; align-self: stretch; margin: 2px 0.25rem; background: var(--line); }
.edit-bar button { min-height: 2rem; padding: 0 0.625rem; border-radius: 0.5rem; font-size: 0.7812rem; color: var(--ink-2); white-space: nowrap; }
.edit-bar button:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.edit-bar button:disabled { opacity: 0.4; cursor: not-allowed; }
.edit-bar button.is-armed { background: var(--cobalt-soft); color: var(--cobalt-deep); font-weight: 600; }
.edit-bar .layout-note { font-size: 0.75rem; color: var(--ink-3); padding: 0 0.375rem; }
.edit-inline { position: absolute; z-index: 9; resize: none; overflow: hidden; padding: 0.375rem 0.5rem; border: 2px solid var(--cobalt); border-radius: 0.5rem; background: var(--white); color: var(--ink); font: 0.875rem/1.125rem inherit; text-align: center; box-shadow: var(--shadow-2); }

.ep-sec { display: flex; flex-direction: column; gap: 0.5rem; margin: 0 0 0.875rem; }
.ep-sec h5 { margin: 0; font-size: 0.75rem; font-weight: 600; color: var(--ink-2); }
.ep-field { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; font-size: 0.75rem; color: var(--ink-2); }
.ep-field > span { flex: none; min-width: 2.75rem; }
.ep-text { flex: 1; min-width: 0; padding: 0.375rem 0.5rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--white); font-size: 0.8125rem; color: var(--ink); resize: vertical; }
textarea.ep-text { width: 100%; }
.ep-select { max-width: 10rem; }
.ep-grid { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.ep-swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ep-swatch { width: 1.625rem; height: 1.625rem; border-radius: 50%; border: 2px solid var(--white); box-shadow: 0 0 0 1px var(--line-strong); }
.ep-swatch.on { box-shadow: 0 0 0 2px var(--cobalt); }
.ep-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.875rem; }
.ep-num { width: 4.5rem; padding: 0.3125rem 0.375rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); font-size: 0.7812rem; color: var(--ink); background: var(--white); }
.ep-danger { color: var(--danger); }
.ep-tips { margin: 0; padding-left: 1.125rem; font-size: 0.75rem; line-height: 1.5; color: var(--ink-3); }
.ep-seg { max-width: 100%; }

@media (max-width: 767.98px) {
  .edit-bar { top: 0.375rem; left: 0.375rem; right: 0.375rem; margin: 0; width: auto; max-width: none; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .edit-bar::-webkit-scrollbar { display: none; }
  .edit-bar button { flex: none; min-height: 2.375rem; }
  .edge-hit { stroke-width: 22; }
}

/* --- Editor for sequence, chart, table, timeline and KPI visuals (features/editor/visual-editor.js) --- */
.modal.ve-modal { width: min(70rem, 96vw); max-height: min(92dvh, 53.75rem); }
.ve { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.ve-preview { position: sticky; top: 0; min-width: 0; overflow: auto; max-height: 68dvh; border: 1px solid var(--line); border-radius: var(--r-lg); }
.ve-preview .block { margin: 0; border: 0; }
.ve-form { display: flex; flex-direction: column; gap: 0.625rem; min-width: 0; }
.ve-h { margin: 0.5rem 0 0; font-size: 0.75rem; font-weight: 600; color: var(--ink-2); }
.ve-field { display: flex; align-items: center; gap: 0.625rem; font-size: 0.75rem; color: var(--ink-2); }
.ve-field > span { flex: none; min-width: 3.25rem; }
.ve-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.875rem; }
.ve-check { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.7812rem; color: var(--ink-2); }
.ve-list { display: flex; flex-direction: column; gap: 0.375rem; align-items: flex-start; }
.ve-row { display: flex; align-items: center; gap: 0.375rem; width: 100%; }
.ve-in { flex: 1 1 0; min-width: 0; padding: 0.375rem 0.5rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--white); color: var(--ink); font-size: 0.8125rem; }
.ve-sel { flex: none; max-width: 7.375rem; }
.ve-dash { display: inline-grid; place-items: center; height: 1.75rem; padding: 0 0.625rem; border: 1px dashed var(--line-strong); border-radius: var(--r-md); font-size: 0.75rem; color: var(--ink-3); }
.ve-ctl { display: inline-flex; flex: none; gap: 2px; }
.ve-btn { min-height: 1.75rem; min-width: 1.75rem; padding: 0 0.5625rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--white); color: var(--ink-2); font-size: 0.7812rem; }
.ve-btn:hover:not(:disabled) { border-color: var(--cobalt); color: var(--ink); }
.ve-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ve-danger { color: var(--danger); }
.ve-grid { display: grid; gap: 0.375rem; align-items: center; overflow-x: auto; padding-bottom: 0.25rem; }
.ve-colhead { font-size: 0.7188rem; font-weight: 600; color: var(--ink-2); }
.ve-colhead-in { display: flex; align-items: center; gap: 0.25rem; }
.ve-note { margin: 0; font-size: 0.75rem; color: var(--ink-3); }
@media (max-width: 860px) { .ve { grid-template-columns: 1fr; } .ve-preview { position: static; max-height: 36dvh; } .ve-row { flex-wrap: wrap; } .ve-sel { max-width: none; } }

/* /static/css/components/onboarding.css */
/*
 * onboarding.css — first-run modal (.onb*) and the Style panel (.stylepop*)
 * Styles for: the onboarding dialog with its tilted example cards; the diagram Style popover
 * Breakpoint: cards stack and stop tilting below 45rem
 */
:root { --serif: var(--font-display); }   /* name kept; it is now the display grotesque, not a serif */

/* --- ONBOARDING (first-run modal) --- */
.onb-overlay { padding: var(--s3); background: var(--scrim); }
.onb { position: relative; width: min(71.25rem, 100%); max-height: min(95dvh, 53.75rem); overflow-x: hidden; overflow-y: auto; border-radius: var(--r-xl);
  background: var(--paper);
  box-shadow: var(--shadow-4); animation: onb-in 380ms var(--ease) both; }
@keyframes onb-in { from { opacity: 0; transform: translateY(1.125rem) scale(0.985); } }
@keyframes onb-step { from { opacity: 0; transform: translateY(0.625rem); } }
.onb-step { animation: onb-step 340ms var(--ease) both; }
.onb-progress { position: absolute; top: 1.5rem; left: 2.75rem; z-index: 2; display: flex; gap: 0.375rem; }
.onb-progress i { width: 1.625rem; height: 0.25rem; border-radius: 0.25rem; background: var(--border-strong); transition: background 240ms; }
.onb-progress i.is-on { background: var(--cobalt); }
.onb-close { position: absolute; top: 0.875rem; right: 0.875rem; z-index: 3; }
.onb h2 { font-family: var(--serif); font-weight: 700; font-stretch: 84%; letter-spacing: -0.01em; line-height: 1; text-wrap: balance; }
.onb h2 em { font-style: normal; }
.onb-lead { color: var(--ink-2); font-size: var(--text-md); line-height: 1.55; text-wrap: pretty; }

/* step 1 */
.onb-hero { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: clamp(1.5rem, 4vw, 3.25rem); align-items: center; padding: 3.625rem 2.75rem 1.625rem; }
.onb-copy { display: grid; gap: 1.25rem; justify-items: start; }
.onb-badge { padding: 0.3125rem 0.875rem; border: 1px solid var(--accent-tint); border-radius: var(--r-full); background: var(--accent-soft); color: var(--cobalt-deep); font-size: var(--text-sm); font-weight: 500; }
.onb-1 h2 { font-size: clamp(2.5rem, 1.2rem + 3.4vw, 4.1rem); }
.onb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem 1rem; }
.onb-cta { display: inline-flex; align-items: center; gap: 0.625rem; padding: 0.9375rem 1.5rem; border-radius: var(--r-md); background: var(--accent); color: var(--on-accent); font-size: var(--text-md); font-weight: 600;
  box-shadow: 0 0.75rem 1.625rem -0.5rem color-mix(in srgb, var(--accent) 55%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18); transition: transform 160ms var(--ease), box-shadow 160ms; }
.onb-cta:hover { transform: translateY(-2px); background: var(--accent-hover); box-shadow: 0 1rem 2rem -0.5rem color-mix(in srgb, var(--accent) 65%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.onb-cta .icon { transition: transform 160ms var(--ease); }
.onb-cta:hover .icon { transform: translateX(0.25rem); }
.onb-skip { padding: 0.625rem 0.375rem; color: var(--ink-3); font-size: var(--text-sm); }
.onb-skip:hover { color: var(--ink); text-decoration: underline; }
.onb-assure { display: flex; flex-wrap: wrap; gap: 0.5rem 1.125rem; font-size: var(--text-sm); color: var(--ink-2); }
.onb-assure li { display: inline-flex; align-items: center; gap: 0.375rem; }
.onb-assure .icon { color: var(--ok); }
.onb-proof { display: grid; gap: 2px; padding-left: 0.75rem; border-left: 0.1875rem solid var(--amber); font-size: var(--text-sm); color: var(--ink-2); }
.onb-proof small { color: var(--ink-3); }
.onb-also { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem 0.875rem; margin: 0 2.75rem; padding: 1.125rem 0 1.625rem; border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--ink-3); }
.onb-also ul { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.onb-also li { padding: 0.3125rem 0.75rem; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--text-2); }
.onb.no-demo .onb-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding-top: 4.5rem; }
.onb.no-demo .onb-copy { justify-items: center; }

/* the live demo */
.onb-demo { min-width: 0; }
.od-window { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; border-radius: 1.125rem; background: var(--surface); box-shadow: var(--shadow-4); transform: rotate(0.6deg); transition: transform 300ms var(--ease); }
.od-window:hover { transform: rotate(0deg); }
.od-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; padding: 0.5625rem 0.875rem; border-bottom: 1px solid var(--line); font-size: var(--text-xs); }
.od-brand { display: inline-flex; align-items: center; gap: 0.4375rem; font-weight: 600; }
.od-looks { display: inline-flex; align-items: center; gap: 0.5625rem; }
.od-looks-l { color: var(--ink-3); }
.od-look { width: 1.375rem; height: 1.375rem; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--border-strong); transition: transform 140ms var(--ease), box-shadow 140ms; }
.od-look:hover { transform: scale(1.14); }
.od-look.is-on { box-shadow: 0 0 0 2px var(--cobalt); }
.od-canvas { position: relative; height: clamp(20.625rem, 52dvh, 31.25rem); background-color: var(--dv-bg, #edf0f4); background-image: radial-gradient(var(--dv-dot, #c9d1db) 1px, transparent 1.3px); background-size: 1.25rem 1.25rem; transition: background-color 320ms; }
.od-canvas[data-grid="lines"] { background-image: linear-gradient(var(--dv-dot) 1px, transparent 1px), linear-gradient(90deg, var(--dv-dot) 1px, transparent 1px); background-size: 1.375rem 1.375rem; }
.od-canvas[data-grid="none"] { background-image: none; }
.od-stage { position: absolute; inset: 0.625rem; }
.od-stage svg { width: 100%; height: 100%; }
.od-loader { position: absolute; inset: 0; display: grid; place-items: center; }
.od-loader[hidden] { display: none; }
.od-composer { display: flex; align-items: center; gap: 0.625rem; margin: 0.625rem 0.75rem 0.75rem; padding: 0.5rem 0.5rem 0.5rem 0.875rem; border: 1px solid var(--line-strong); border-radius: 0.875rem; background: var(--surface); box-shadow: 0 1px 0.1875rem rgba(23, 33, 44, 0.06); }
.od-input { flex: 1; min-width: 0; min-height: 2.5rem; display: flex; flex-wrap: wrap; align-content: center; align-items: center; font-size: var(--text-sm); line-height: 1.4; }
.od-ph { color: var(--ink-3); }
.od-typed { color: var(--ink); }
.od-caret { display: inline-block; width: 1.5px; height: 0.9375rem; margin-left: 1px; background: var(--cobalt); animation: onb-blink 1s steps(1) infinite; }
@keyframes onb-blink { 50% { opacity: 0; } }
.od-send { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: 50%; background: var(--cobalt); color: #fff; transition: transform 140ms var(--ease); }
.od-send.is-pressed { transform: scale(0.84); }
.od-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.875rem; }
.od-steps { display: flex; flex-wrap: nowrap; gap: 0.5rem 0.875rem; white-space: nowrap; font-size: var(--text-xs); color: var(--ink-3); }
.od-steps li { display: inline-flex; align-items: center; gap: 0.4375rem; transition: color 240ms; }
.od-n { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--hover-strong); font-weight: 600; transition: background 240ms, box-shadow 240ms, color 240ms; }
.od-steps li.is-active { color: var(--ink); font-weight: 600; }
.od-steps li.is-active .od-n { background: var(--cobalt); color: #fff; box-shadow: 0 0 0 0.25rem var(--accent-ring); }
.od-steps li.is-done { color: var(--ink-2); }
.od-steps li.is-done .od-n { background: var(--ok); color: #fff; }
.od-replay { white-space: nowrap; padding: 0.25rem 0.5625rem; border-radius: 0.5rem; color: var(--cobalt-deep); font-size: var(--text-xs); font-weight: 600; }
.od-replay:hover { background: var(--cobalt-soft); }
.od-replay[hidden] { display: none; }

/* step 2 */
.onb-pick { display: grid; justify-items: center; gap: 1rem; padding: 4.875rem 2.75rem 2.375rem; text-align: center; }
.onb-2 h2 { font-size: clamp(2.2rem, 1.2rem + 2.6vw, 3.3rem); outline: none; }
.onb-lead { max-width: 54ch; }
.onb-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 0.875rem; width: min(52.5rem, 100%); margin-top: 0.625rem; text-align: left; }
.onb-choices li { display: flex; }
.onb-choice { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; width: 100%; padding: 1.125rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); box-shadow: 0 1px 2px rgba(23, 33, 44, 0.05); text-align: left;
  transition: transform 170ms var(--ease), border-color 170ms, box-shadow 170ms; }
.onb-choice:hover { transform: translateY(-2px); border-color: var(--cobalt); box-shadow: var(--shadow-3); }
.onb-ico { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 0.8125rem; }
.onb-choice[data-tint="amber"] .onb-ico { background: var(--warn-soft); color: var(--warn-ink); }
.onb-choice[data-tint="blue"] .onb-ico { background: var(--accent-soft); color: var(--accent-ink); }
.onb-choice[data-tint="teal"] .onb-ico { background: var(--ok-soft); color: var(--ok); }
.onb-choice[data-tint="violet"] .onb-ico { background: color-mix(in srgb, #7c5cff 14%, transparent); color: color-mix(in srgb, #7c5cff 70%, var(--text)); }
.onb-ct { display: grid; gap: 0.25rem; min-width: 0; }
.onb-ct b { font-size: var(--text-base); font-weight: 600; }
.onb-ct span { font-size: var(--text-sm); line-height: 1.45; color: var(--ink-3); }
.onb-ct .slot { padding: 0 0.25rem; border-radius: 0.3125rem; background: var(--cobalt-soft); color: var(--cobalt-deep); }
.onb-go { color: var(--ink-3); transition: transform 170ms var(--ease), color 170ms; }
.onb-choice:hover .onb-go { transform: translateX(0.25rem); color: var(--cobalt); }
.onb-pick-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(52.5rem, 100%); margin-top: 0.375rem; font-size: var(--text-sm); color: var(--ink-3); }
.onb-back, .onb-own { color: var(--ink-2); font-weight: 500; padding: 0.375rem 0.25rem; }
.onb-back:hover, .onb-own:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 920px) {
  .onb-hero { grid-template-columns: 1fr; padding: 4rem 1.5rem 1.25rem; gap: 1.75rem; }
  .onb-progress { left: 1.5rem; }
  .onb-also { margin: 0 1.5rem; }
  .onb-pick { padding: 4.5rem 1.5rem 1.75rem; }
  .od-canvas { height: clamp(16.25rem, 42dvh, 23.75rem); }
}
@media (max-width: 640px) {
  .onb-choices { grid-template-columns: 1fr; }
  .onb-pick-foot { flex-wrap: wrap; justify-content: center; }
  .onb-pick-foot span { order: 3; width: 100%; text-align: center; }
  .od-looks-l { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .onb, .onb-step, .od-caret { animation: none; }
  .od-window, .onb-cta, .onb-choice { transition: none; }
}

/* --- DIAGRAM STYLE PANEL --- */
.stylepop-wrap { min-width: 0; max-width: none; width: min(22rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1.5rem); overflow-y: auto; padding: 0; }
.stylepop { display: grid; }
.sp-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: 0.75rem 0.875rem 0.5rem; }
.sp-head strong { font-size: var(--text-base); }
.sp-head span { font-size: var(--text-xs); color: var(--ink-3); }
.sp-section { display: grid; gap: 0.5rem; padding: 0.5rem 0.875rem 0.75rem; border-top: 1px solid var(--line); }
.sp-section h3 { font-size: var(--text-xs); font-weight: 700; color: var(--ink-2); }
.sp-row { display: grid; gap: 0.5rem; }
.sp-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.sp-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.sp-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.sp-opt { display: grid; justify-items: center; gap: 0.25rem; padding: 0.5rem 0.25rem 0.4375rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--white); color: var(--ink-2); transition: border-color 120ms, box-shadow 120ms, background 120ms; }
.sp-opt:hover { border-color: var(--line-strong); background: var(--paper); }
.sp-opt.is-on { border-color: var(--cobalt); box-shadow: 0 0 0 1px var(--cobalt); color: var(--ink); }
.sp-prev { display: grid; place-items: center; min-height: 1.875rem; }
.sp-prev svg { display: block; max-width: 100%; height: auto; }
.sp-theme .sp-prev { min-height: 2.875rem; }
.sp-theme .sp-prev svg { border-radius: 0.3125rem; }
.sp-name { font-size: var(--text-xs); font-weight: 600; }
.sp-hint { font-size: 0.66rem; color: var(--ink-3); margin-top: -3px; }
.sp-foot { display: flex; justify-content: flex-end; padding: 0.5rem 0.625rem 0.625rem; border-top: 1px solid var(--line); }

/* /static/css/components/account.css */
/*
 * account.css — sign-in screen, account button in the sidebar, sync dot, maintenance notice, feedback buttons, announcement modal
 * Styles for: .gate, .account-btn, .sync-dot, .notice-bar, .fb, .ann-*, .privacy-list (features/app/account.js)
 * Breakpoint: all
 */

/* --- SIGN-IN SCREEN: the app stays visible, blurred, behind one calm card --- */
.gate { position: fixed; inset: 0; z-index: 600; display: grid; place-items: center; padding: var(--s4); background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(10px) saturate(1.1); -webkit-backdrop-filter: blur(10px) saturate(1.1); animation: fade var(--dur-3) ease both; }
.gate-card { display: grid; justify-items: center; gap: var(--s3); width: min(25rem, 100%); padding: var(--s8) var(--s6) var(--s6); border: 1px solid var(--border); border-radius: var(--r-2xl); background: var(--surface-raised); box-shadow: var(--shadow-4); text-align: center; animation: rise var(--dur-3) var(--ease-out) both; }
.gate-mark { width: 2.5rem; height: 2.5rem; margin-bottom: var(--s1); }
.gate-card h1 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; font-stretch: 90%; letter-spacing: var(--track-tight); line-height: 1.1; }
.gate-lede { color: var(--text-2); font-size: var(--text-base); line-height: 1.55; }
.gate-error { width: 100%; padding: var(--s2) var(--s3); border: 1px solid var(--danger-border); border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: var(--text-sm); }
/* Google's sign-in button guidelines: white surface, the four-colour G, "Continue with Google" */
.gate-google { display: inline-flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; height: 2.75rem; margin-top: var(--s2); border: 1px solid #dadce0; border-radius: var(--r-lg); background: #fff; color: #1f1f1f; font-family: Roboto, var(--font-sans); font-size: var(--text-base); font-weight: 600; box-shadow: var(--shadow-1); transition: background-color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1) var(--ease); }
.gate-google:hover { background: #f8faff; box-shadow: var(--shadow-2); }
.gate-google:active { transform: scale(0.985); }
.gate-google:disabled { opacity: 0.7; cursor: progress; }
.gate-g { display: grid; place-items: center; width: 1.125rem; height: 1.125rem; }
.gate-g svg { width: 100%; height: 100%; }
.gate-busy { font-size: var(--text-xs); color: var(--text-3); }
.gate-fine { margin-top: var(--s2); font-size: var(--text-xs); line-height: 1.5; color: var(--text-3); text-wrap: pretty; }
.gate-ico { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: var(--r-lg); background: var(--hover); color: var(--text-2); }
.gate-ico-banned { background: var(--danger-soft); color: var(--danger); }
.gate-ico-waitlist { background: var(--accent-soft); color: var(--accent-ink); }

/* --- ACCOUNT BUTTON (sidebar footer) --- */
.account-btn { display: flex; align-items: center; gap: 0.625rem; width: 100%; min-height: 2.75rem; padding: 0.375rem 0.5rem; border-radius: var(--r-lg); text-align: left; transition: background-color var(--dur-1); }
.account-btn:hover { background: var(--hover); }
.account-avatar { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; object-fit: cover; background: var(--hover-strong); box-shadow: 0 0 0 1px var(--hairline); }
.account-initial { display: grid; place-items: center; font-size: var(--text-xs); font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); }
.account-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.account-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.account-text small { font-size: var(--text-2xs); color: var(--text-3); }
.account-signin { width: 100%; }
/* sync state: still means saved; a slow pulse means saving; hollow means waiting for the connection */
.sync-dot { flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ok); }
.sync-dot[data-state="saving"] { background: var(--accent); animation: sync-pulse 1.2s ease-in-out infinite; }
.sync-dot[data-state="offline"] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-4); }
.sync-dot[data-state="error"] { background: var(--warn); }
@keyframes sync-pulse { 50% { opacity: 0.35; } }

/* --- MAINTENANCE NOTICE --- */
.notice-bar { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.4375rem var(--s4); border-bottom: 1px solid var(--warn-border); background: var(--warn-soft); color: var(--warn-ink); font-size: var(--text-sm); font-weight: 500; text-align: center; }

/* --- FEEDBACK ON REPLIES --- */
.fb { display: inline-flex; gap: 1px; }
.fb-btn[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.fb-btn[aria-pressed="true"] svg { fill: color-mix(in srgb, currentColor 22%, transparent); }

/* --- ANNOUNCEMENT --- */
.ann-overlay { z-index: 450; }
.ann-card { width: min(34rem, 100%); max-height: min(90dvh, 44rem); overflow: auto; border-radius: var(--r-2xl); background: var(--surface-raised); box-shadow: var(--shadow-4); animation: rise var(--dur-3) var(--ease-out); }
.ann-card:focus { outline: none; }
.ann { display: grid; }
.ann-media { background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.ann-media img { display: block; width: 100%; max-height: 18rem; object-fit: cover; }
.ann-body { display: grid; gap: var(--s3); padding: var(--s6); }
.ann-kicker { justify-self: start; padding: 0.125rem 0.5rem; border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.ann-body h2 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; font-stretch: 90%; letter-spacing: var(--track-tight); line-height: 1.12; }
.ann-text { display: grid; gap: var(--s2); color: var(--text-2); font-size: var(--text-read); line-height: 1.6; white-space: pre-wrap; }
.ann-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s2); }
.ann-actions a.btn { text-decoration: none; }
.ann-never { margin-left: auto; font-weight: 500; color: var(--text-3); }

.privacy-list { display: grid; gap: var(--s2); padding-left: 1.1rem; list-style: disc; color: var(--text-2); font-size: var(--text-sm); line-height: 1.55; }
.privacy-list b { color: var(--text); }

/* E-mail and password under the Google button (features/app/account.js passwordForm) */
.gate-or { display: flex; align-items: center; gap: var(--s3); width: 100%; color: var(--text-3); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.gate-form { display: grid; gap: var(--s2); width: 100%; text-align: left; }
.gate-form input { height: 2.75rem; border-radius: var(--r-lg); font-size: var(--text-base); }   /* base look: primitives.css */
.gate-form input[hidden] { display: none; }
.gate-submit { width: 100%; height: 2.75rem; justify-content: center; }
.gate-msg { min-height: 0; font-size: var(--text-sm); line-height: 1.45; color: var(--text-2); }
.gate-msg:empty { display: none; }
.gate-msg.bad { color: var(--danger); }
.gate-links { display: flex; justify-content: space-between; gap: var(--s3); }
.gate-link { padding: var(--s1) 0; border: 0; background: none; color: var(--accent-ink); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.gate-link:hover { text-decoration: underline; }
.gate-link[hidden] { display: none; }

/* /static/css/components/plans.css */
/*
 * Styles for: the plans dialog (.plans, .plan-*), locked options (.locked-row), the handover branding controls (.handover-brand,
 * .handover-logo*, .handover-kits) and the dismissible sign-up screen (.gate-soft, .gate-later). JS: features/app/plans.js, handover.js, account.js.
 * Colours come from the semantic tokens only (AGENTS.md), so light and dark both work.
 */
.plans { display: grid; gap: var(--s4); }
.plans-lead { font-size: var(--text-md); font-weight: 600; color: var(--text); }
.plans-note { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--text-sm); }
.plans-note svg { flex: none; margin-top: 0.125rem; }
/* Billing period: a big centred two-way switch. The thumb slides under the chosen side; each side is a full-size target. */
.plan-period { position: relative; display: grid; grid-template-columns: 1fr 1fr; justify-self: center; width: min(26rem, 100%); padding: 0.3125rem; border: 1px solid var(--border-strong); border-radius: var(--r-full); background: var(--bg-sunken); box-shadow: inset 0 1px 2px color-mix(in srgb, var(--text) 6%, transparent); }
.plan-period-thumb { position: absolute; inset: 0.3125rem auto 0.3125rem 0.3125rem; width: calc(50% - 0.3125rem); border-radius: var(--r-full); background: var(--accent); box-shadow: var(--shadow-2); transition: transform var(--dur-2) var(--ease-out); }
.plan-period[data-value="year"] .plan-period-thumb { transform: translateX(100%); }
.plan-period button { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 3rem; padding: 0 1rem; border: 0; border-radius: var(--r-full); background: transparent; color: var(--text-2); font-size: var(--text-md); font-weight: 650; cursor: pointer; transition: color var(--dur-2) ease; }
.plan-period button:hover { color: var(--text); }
.plan-period button[aria-checked="true"] { color: var(--on-accent); }
.plan-period button:focus-visible { outline: none; box-shadow: var(--focus); }
.plan-period-badge { padding: 0.125rem 0.5rem; border-radius: var(--r-full); background: var(--ok-soft); color: var(--ok); font-size: var(--text-xs); font-weight: 700; white-space: nowrap; }
.plan-period button[aria-checked="true"] .plan-period-badge { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }
@media (max-width: 30rem) { .plan-period button { flex-direction: column; gap: 0.125rem; min-height: 3.5rem; font-size: var(--text-base); } }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: var(--s3); }
.modal.wide:has(.plans) { width: min(64rem, calc(100vw - 2 * var(--s4))); max-width: none; }
@media (max-width: 40rem) { .plan-card-hi { order: -1; } }   /* on a phone, the plan that unlocks what they tried comes first */
.plan-card { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); }
.plan-card-hi { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-2); }
.plan-card-current { background: var(--bg-sunken); }
.plan-card header { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.plan-card h3 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; }
.plan-tag { padding: 0.125rem 0.5rem; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.plan-tagline { color: var(--text-2); font-size: var(--text-sm); }
.plan-price { margin-top: var(--s1); }
.plan-price b { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.plan-price span { color: var(--text-2); font-size: var(--text-sm); }
.plan-billed { margin-top: -0.25rem; color: var(--text-3); font-size: var(--text-xs); }
.plan-card .btn { width: 100%; justify-content: center; }
.plan-list { display: grid; gap: var(--s2); margin: var(--s2) 0 0; padding: 0; list-style: none; font-size: var(--text-sm); color: var(--text-2); }
.plan-list li { display: flex; gap: var(--s2); align-items: flex-start; }
.plan-list svg { flex: none; margin-top: 0.1875rem; color: var(--ok); }
.plans-status { min-height: 1.25rem; font-size: var(--text-sm); color: var(--text-2); }
.plans-status.bad { color: var(--danger); }
.plans-fine { color: var(--text-3); font-size: var(--text-xs); }
.plans-fine a { color: var(--accent-ink); }

.locked-row { display: flex; align-items: flex-start; gap: var(--s3); width: 100%; padding: var(--s3); border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: transparent; color: var(--text-2); text-align: left; cursor: pointer; transition: background-color var(--dur-1), border-color var(--dur-1); }
.locked-row:hover { background: var(--hover); border-color: var(--gold-border); }
.locked-row > span:first-child { flex: 1 1 auto; min-width: 0; }
.locked-row .menu-plan { align-self: center; }
.locked-row b { display: block; color: var(--text); font-weight: 600; }
.locked-row small { display: block; color: var(--text-3); }

.handover-logo-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.handover-logo { max-height: 2.5rem; max-width: 8rem; border-radius: var(--r-xs); background: var(--white); }
.handover-brand input[type="color"] { width: 3rem; height: 2.25rem; padding: 0.125rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.handover-kits { align-items: center; }
.handover-kits select { flex: 1; min-width: 0; }

.gate-soft { cursor: default; }
.gate-later { margin-top: var(--s1); }

/* /static/css/components/admin.css */
/*
 * admin.css — the admin panel (#/admin): nav rail, section header, KPI tiles, charts, tables, drawer, editors
 * Styles for: .admin and everything inside it (features/admin/*.js)
 * Breakpoint: all (the nav becomes a top strip under 64rem)
 * Dense on purpose: it is a working tool, read by one person, often with a lot of rows.
 */
.admin { position: fixed; inset: 0; z-index: 280; display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); background: var(--bg); animation: fade var(--dur-2) ease both; }
body.admin-open { overflow: hidden; }

/* --- NAV --- */
.adm-nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s2); border-right: 1px solid var(--hairline); background: var(--bg-sunken); overflow-y: auto; }
.adm-brand { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; padding: var(--s2) var(--s2) var(--s4); }
.adm-brand b { font-family: var(--font-display); font-size: var(--text-md); font-weight: 700; letter-spacing: var(--track-snug); }
.adm-brand .adm-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.adm-nav-item { display: flex; align-items: center; gap: 0.625rem; min-height: 2.125rem; padding: 0 0.625rem; border-radius: var(--r-md); color: var(--text-2); font-size: var(--text-sm); font-weight: 500; text-align: left; transition: background-color var(--dur-1), color var(--dur-1); }
.adm-nav-item .icon { color: var(--text-3); }
.adm-nav-item:hover { background: var(--hover); color: var(--text); }
.adm-nav-item[aria-current="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--border); }
.adm-nav-item[aria-current="true"] .icon { color: var(--accent-ink); }
.adm-nav-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--hairline); }

/* --- MAIN --- */
.adm-main { overflow-y: auto; scrollbar-gutter: stable; }
.adm-main:focus { outline: none; }
.adm-section { display: grid; gap: var(--s4); max-width: 82rem; margin: 0 auto; padding: var(--s6) var(--s6) var(--s12); animation: msg-in var(--dur-3) var(--ease-out) both; }
.adm-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--s3) var(--s4); }
.adm-head h1 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; font-stretch: 92%; letter-spacing: var(--track-tight); line-height: 1.1; }
.adm-head p { margin-top: 0.25rem; color: var(--text-3); font-size: var(--text-sm); max-width: 48rem; }
.adm-head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.adm-muted { color: var(--text-3); font-size: var(--text-sm); }
.adm-spacer { flex: 1; }
.adm-card { display: grid; gap: var(--s3); align-content: start; min-width: 0; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-1); }
.adm-card h2 { font-size: var(--text-base); font-weight: 650; }
.adm-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.adm-stack { display: grid; gap: var(--s4); min-width: 0; }
.adm-section h3 { margin-top: var(--s2); font-size: var(--text-sm); font-weight: 650; }
.adm-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.adm-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.adm-loading { display: flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 8rem; color: var(--text-3); font-size: var(--text-sm); }
.adm-spinner { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--accent-tint); border-top-color: var(--accent); animation: log-spin 800ms linear infinite; }
.adm-error { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border: 1px solid var(--danger-border); border-radius: var(--r-lg); background: var(--danger-soft); color: var(--danger); font-size: var(--text-sm); }

/* --- KPI TILES --- */
.adm-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.adm-kpi { display: grid; gap: 0.125rem; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-1); }
.adm-kpi-label { font-size: var(--text-xs); font-weight: 600; color: var(--text-3); }
.adm-kpi-value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; letter-spacing: var(--track-tight); line-height: 1.15; font-variant-numeric: tabular-nums; }
.adm-kpi small { font-size: var(--text-xs); color: var(--text-3); }
.adm-kpi.is-live .adm-kpi-value { color: var(--ok); }
.adm-kpi.is-good .adm-kpi-value { color: var(--accent-ink); }
.adm-kpi.is-warn .adm-kpi-value { color: var(--warn); }

/* --- CHARTS --- */
.adm-figure { display: grid; gap: var(--s2); margin: 0; }
.adm-figure figcaption { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.adm-figure figcaption b { font-family: var(--font-display); font-size: var(--text-md); color: var(--text); font-variant-numeric: tabular-nums; }
.adm-chart { width: 100%; height: 7.5rem; display: block; }
.adm-bar { fill: var(--accent); opacity: 0.85; transition: opacity var(--dur-1); }
.adm-bar:hover { opacity: 1; }
.adm-axis { stroke: var(--border); }
.adm-chart-x { display: flex; justify-content: space-between; font-size: var(--text-2xs); color: var(--text-4); }
.adm-meters { display: grid; gap: 0.375rem; }
.adm-meters li { display: grid; grid-template-columns: minmax(5rem, 9rem) 1fr auto 2.75rem; align-items: center; gap: var(--s2); font-size: var(--text-sm); }
.adm-meter-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.adm-meter { height: 0.5rem; border-radius: var(--r-full); background: var(--hover); overflow: hidden; }
.adm-meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.adm-meters b { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.adm-meters small { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.adm-funnel { display: grid; gap: 0.375rem; }
.adm-funnel li { position: relative; display: grid; grid-template-columns: 1fr auto 8rem; align-items: center; gap: var(--s2); min-height: 2rem; padding: 0 var(--s3); border-radius: var(--r-md); overflow: hidden; font-size: var(--text-sm); }
.adm-funnel-bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-right: 2px solid var(--accent); z-index: 0; }
.adm-funnel li > :not(.adm-funnel-bar) { position: relative; z-index: 1; }
.adm-funnel b { font-variant-numeric: tabular-nums; }
.adm-funnel small { color: var(--text-3); text-align: right; }
.adm-dbbar { height: 0.625rem; border-radius: var(--r-full); background: var(--hover); overflow: hidden; }
.adm-dbbar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.adm-dbbar i.is-warn { background: var(--warn); }

/* --- TOOLBAR, TABLE, PAGER --- */
.adm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.adm-toolbar select, .adm-toolbar input[type="text"], .adm-toolbar input[type="number"] { height: 2.125rem; min-height: 0; font-size: var(--text-sm); }
.adm-toolbar select { padding: 0 1.75rem 0 0.625rem; border-color: var(--border-strong); }
.adm-search { position: relative; flex: 1 1 16rem; max-width: 24rem; }
.adm-search .icon { position: absolute; left: 0.625rem; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.adm-search input { padding-left: 2rem; height: 2.125rem; min-height: 0; }
.adm-short { width: 8rem !important; }
.adm-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); max-height: 70vh; }
.adm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.adm-table th { position: sticky; top: 0; z-index: 1; padding: 0.5rem 0.75rem; background: var(--bg-sunken); border-bottom: 1px solid var(--border); text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--text-3); white-space: nowrap; }
.adm-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table tr.is-link { cursor: pointer; }
.adm-table tbody tr:hover td { background: var(--hover); }
.adm-table tr.is-selected td { background: var(--accent-soft); }
.adm-table code { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-3); word-break: break-all; }
.adm-check { width: 2.25rem; }
.adm-check input { width: 0.9375rem; height: 0.9375rem; }
.adm-empty { padding: var(--s8) !important; text-align: center; color: var(--text-3) !important; }
.adm-who { display: inline-flex; align-items: center; gap: 0.625rem; min-width: 0; }
.adm-who img, .adm-who > i { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; object-fit: cover; }
.adm-who > i { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-style: normal; font-size: var(--text-xs); font-weight: 700; }
.adm-who img.adm-thumb { width: 2.5rem; height: 1.75rem; border-radius: var(--r-sm); }
.adm-who > span { display: grid; min-width: 0; line-height: 1.3; }
.adm-who b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-who small { color: var(--text-3); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-pager { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-sm); color: var(--text-3); }
.adm-bulk { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: 0.5rem 0.75rem; border: 1px solid var(--accent-tint); border-radius: var(--r-lg); background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); box-shadow: var(--shadow-2); animation: pop var(--dur-2) var(--ease-out); }
.adm-bulk > b { color: var(--accent-ink); font-size: var(--text-sm); }
.adm-row-actions { display: inline-flex; gap: 2px; }

/* --- CHIPS AND PILLS --- */
.adm-chip { display: inline-flex; align-items: center; height: 1.375rem; padding: 0 0.5rem; border-radius: var(--r-full); background: var(--hover); color: var(--text-2); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.adm-model { display: flex; flex-direction: column; gap: 0.15rem; white-space: nowrap; }
.adm-model code { font-size: 0.78em; color: var(--text-3); }
.adm-block { display: block; }
.adm-chips-inline { display: inline-flex; gap: 0.25rem; }
.adm-chip.is-good { background: var(--accent-soft); color: var(--accent-ink); }
.adm-chip.is-bad { background: var(--danger-soft); color: var(--danger); }
.adm-chip.is-warn { background: var(--warn-soft); color: var(--warn-ink); }
.adm-chip.is-accent { background: var(--ok-soft); color: var(--ok); }
.adm-chip.is-quiet { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--text-3); font-weight: 500; }
.adm-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.adm-pill { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.875rem; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); font-size: var(--text-xs); font-weight: 500; color: var(--text-2); }
.adm-pill b { color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.adm-pill:hover { border-color: var(--border-strong); color: var(--text); }
.adm-pill.is-on { background: var(--accent-soft); border-color: var(--accent-tint); color: var(--accent-ink); }

/* --- DRAWER (one person) --- */
.adm-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 290; width: min(40rem, 100vw); overflow-y: auto; background: var(--surface-raised); border-left: 1px solid var(--border); box-shadow: var(--shadow-4); animation: drawer-in var(--dur-3) var(--ease-out) both; }
.adm-drawer.is-leaving { animation: drawer-out 180ms var(--ease-in) both; }
@keyframes drawer-in { from { transform: translateX(2rem); opacity: 0; } }
@keyframes drawer-out { to { transform: translateX(2rem); opacity: 0; } }
.adm-drawer-close { position: absolute; top: var(--s3); right: var(--s3); z-index: 2; }
.adm-drawer-body { display: grid; gap: var(--s4); padding: var(--s6); }
.adm-person { display: flex; align-items: center; gap: var(--s4); padding-right: var(--s8); }
.adm-person img, .adm-person > i { flex: none; width: 3rem; height: 3rem; border-radius: 50%; object-fit: cover; }
.adm-person > i { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-style: normal; font-size: var(--text-lg); font-weight: 700; }
.adm-person h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; letter-spacing: var(--track-snug); line-height: 1.2; }
.adm-person a { font-size: var(--text-sm); color: var(--text-3); }
.adm-person .adm-chips { margin-top: 0.375rem; }
.adm-banned { padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: var(--text-sm); }
.adm-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.adm-facts { display: grid; grid-template-columns: 10rem 1fr; gap: 0.375rem var(--s4); font-size: var(--text-sm); }
.adm-facts dt { color: var(--text-3); }
.adm-facts dd { color: var(--text); overflow-wrap: anywhere; }
.adm-field { display: grid; gap: 0.3125rem; font-size: var(--text-sm); font-weight: 600; }
.adm-field small { font-weight: 400; color: var(--text-3); }
.adm-transcript { display: grid; gap: var(--s3); }
.adm-msg { display: grid; gap: 0.25rem; padding: var(--s3); border-radius: var(--r-lg); background: var(--bg-sunken); border: 1px solid var(--border); font-size: var(--text-sm); }
.adm-msg.is-user { background: var(--surface); }
.adm-msg small { color: var(--text-3); font-size: var(--text-xs); }
.adm-msg p { white-space: pre-wrap; color: var(--text); }

/* --- SETTINGS, PLANS, ANNOUNCEMENTS --- */
.adm-setting { grid-template-columns: 1fr; }
.adm-plans { gap: var(--s2); }
.adm-plan { display: grid; grid-template-columns: 6rem 1fr auto; align-items: center; gap: var(--s3); }
.adm-plan code { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-3); }
.adm-inline { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--text-sm); color: var(--text-3); }
.adm-inline input { width: 7rem; }
.adm-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: var(--s5); }
.adm-preview-wrap { display: grid; gap: var(--s2); align-content: start; position: sticky; top: 0; }
.adm-preview { padding: var(--s4); border-radius: var(--r-xl); background: var(--scrim); }
.adm-preview-card { width: 100%; max-height: none; animation: none; }
.adm-checks { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.adm-check-row, .form .adm-check-row { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--text-sm); font-weight: 500; }
.adm-chosen { display: flex; align-items: center; gap: var(--s2); }
.modal:has(.adm-editor) { width: min(64rem, 100%); }

.adm-mbar, .adm-nav-scrim { display: none; }
@media (max-width: 63.98rem) {
  .admin { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  /* Phones and tablets: a slim bar (back to the app, "Admin", the current section). The section button opens every section as a sheet
     under the bar, two to a row, so all of them are in view at once: a sideways-scrolling row hid most of them, and wrapping them all
     above the content took half a phone's screen (owner's reports, 2026-11-17). */
  .adm-mbar { display: flex; align-items: center; gap: var(--s2); min-height: 3.25rem; padding: env(safe-area-inset-top) var(--s2) 0; border-bottom: 1px solid var(--hairline); background: var(--bg-sunken); position: relative; z-index: 3; }
  .adm-mbar-back { display: inline-flex; align-items: center; gap: 0.125rem; min-height: 2.5rem; padding: 0 0.625rem 0 0.375rem; border-radius: var(--r-full); color: var(--text-2); font-size: var(--text-sm); font-weight: 600; }
  .adm-mbar-back:hover { background: var(--hover); color: var(--text); }
  .adm-mbar-title { font-family: var(--font-display); font-size: var(--text-md); font-weight: 700; letter-spacing: var(--track-snug); }
  .adm-mbar-pick { display: inline-flex; align-items: center; gap: 0.5rem; margin-left: auto; min-height: 2.5rem; max-width: 60%; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--text); font-size: var(--text-sm); font-weight: 600; box-shadow: var(--shadow-1); }
  .adm-mbar-pick .adm-mbar-icon { display: inline-grid; color: var(--accent-ink); }
  .adm-mbar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .adm-mbar-pick > .icon:last-child { color: var(--text-3); transition: transform var(--dur-2) var(--ease); }
  .adm-nav-open .adm-mbar-pick > .icon:last-child { transform: rotate(180deg); }
  .adm-nav { position: absolute; left: 0; right: 0; top: calc(3.25rem + env(safe-area-inset-top)); z-index: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s1);
    max-height: calc(100dvh - 4rem); overflow-y: auto; padding: var(--s2) var(--s2) var(--s3); border-right: 0; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-3);
    transform: translateY(-0.5rem); opacity: 0; visibility: hidden; transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), visibility 0s linear var(--dur-2); }
  .adm-nav-open .adm-nav { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
  .adm-nav-scrim { display: block; position: absolute; inset: 0; z-index: 1; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--dur-2); }
  .adm-nav-open .adm-nav-scrim { opacity: 1; pointer-events: auto; }
  .adm-brand, .adm-nav-foot { display: none; }
  .adm-nav-item { min-height: 2.75rem; padding: 0 0.75rem; gap: 0.5rem; }
  .adm-head-actions { width: 100%; }
  .adm-head-actions .seg-pick { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; grid-template-columns: none; flex: 1 1 auto; width: auto; }
  .adm-head-actions .seg-pick button { padding: 0 0.5rem; }
  .adm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adm-grid-2, .adm-grid-3, .adm-editor { grid-template-columns: 1fr; }
  .adm-section { padding: var(--s4) var(--s3) var(--s10); }
  .adm-facts { grid-template-columns: 1fr; gap: 0 var(--s4); }
  .adm-facts dd { margin-bottom: var(--s2); }
}

/* /static/css/diagram-svg.css */
/*
 * diagram-svg.css — everything the SVG diagram needs. Self-contained (variables live on svg.diagram) so SVG export can embed it.
 * Styles for: nodes, edges, tokens, focus/search/zoom states, change highlights, object styles (flat / outline / elevated / 3D).
 * Colours come from the theme: js/visuals/themes.js writes --c-<name>-fill/stroke/ink/side, --edge, --canvas ... onto the <svg>.
 * The fallbacks below are the "Modern" theme, so a diagram with no theme applied still looks right.
 */
svg.diagram {
  --edge: #7b8896; --edge-lit: #2948f4; --label-bg: #fafbfc; --label-line: #d6dce4; --ink: #17212c; --ink-2: #465465;
  --pulse: #ffb000; --token: #ffb000; --paper: #fafbfc; --ew: 1.8; --nsw: 1.7; --fs: 14;
  --tag-bg: #17212c; --tag-ink: #fff; --sheen: 0.5; --shadow: rgba(23, 33, 44, 0.22);
  display: block; width: 100%; height: 100%;
  font-family: var(--font, "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif);
  user-select: none; -webkit-user-select: none;
}
.diagram .edge-base { fill: none; stroke: var(--edge); stroke-width: var(--ew); stroke-linecap: round; stroke-linejoin: round; }
.diagram .edge.dashed .edge-base { stroke-dasharray: 7 6; }
.diagram .edge-lit { fill: none; stroke: var(--edge-lit); stroke-width: calc(var(--ew) + 1); stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.diagram .edge-flow { fill: none; stroke: var(--edge-lit); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 0.1 18; opacity: 0; }
.diagram .edge-arrow { fill: var(--edge); opacity: 0; }
.diagram .edge-arrow.lit { fill: var(--edge-lit); }
.diagram .edge-label { opacity: 0; }
.diagram .edge-label rect { fill: var(--label-bg); stroke: var(--label-line); stroke-width: 1; }
.diagram .edge-label text { font-size: 12px; font-weight: 500; fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }

.diagram .node { opacity: 0; }
.diagram .node .body { fill: var(--fill); stroke: var(--stroke); stroke-width: var(--nsw); stroke-linejoin: round; }
.diagram .node .halo { fill: none; stroke: var(--pulse); stroke-width: 3; opacity: 0; stroke-linejoin: round; }
.diagram .node .ring { fill: none; stroke: var(--edge-lit); stroke-width: 2.4; opacity: 0; stroke-linejoin: round; }
.diagram .node text { font-size: 14px; font-weight: 500; fill: var(--ink-n); text-anchor: middle; dominant-baseline: central; }

.diagram .token { opacity: 0; pointer-events: none; }
.diagram .token-glow { fill: var(--token); opacity: 0.28; }
.diagram .token-core { fill: var(--token); stroke: var(--paper); stroke-width: 2.5; }
.diagram .token-tag rect { fill: var(--tag-bg); }
.diagram .token-tag text { font-size: 11px; font-weight: 600; fill: var(--tag-ink); text-anchor: middle; dominant-baseline: central; }

.diagram .c-blue   { --fill: var(--c-blue-fill, #e6ecff);   --stroke: var(--c-blue-stroke, #3b5bdb);   --ink-n: var(--c-blue-ink, #1a2b7a);   --side: var(--c-blue-side, #2a4096); }
.diagram .c-teal   { --fill: var(--c-teal-fill, #dcf3ef);   --stroke: var(--c-teal-stroke, #1c9a8a);   --ink-n: var(--c-teal-ink, #0e5249);   --side: var(--c-teal-side, #136b5f); }
.diagram .c-violet { --fill: var(--c-violet-fill, #ebe4fb); --stroke: var(--c-violet-stroke, #7048e8); --ink-n: var(--c-violet-ink, #3e2488); --side: var(--c-violet-side, #4e32a2); }
.diagram .c-amber  { --fill: var(--c-amber-fill, #fff0cc);  --stroke: var(--c-amber-stroke, #d9930a);  --ink-n: var(--c-amber-ink, #6b4800);  --side: var(--c-amber-side, #983f00); }
.diagram .c-green  { --fill: var(--c-green-fill, #ddf3df);  --stroke: var(--c-green-stroke, #2f9e44);  --ink-n: var(--c-green-ink, #175a26);  --side: var(--c-green-side, #217030); }
.diagram .c-red    { --fill: var(--c-red-fill, #fde3e1);    --stroke: var(--c-red-stroke, #d6403a);    --ink-n: var(--c-red-ink, #7a1c18);    --side: var(--c-red-side, #962c28); }
.diagram .c-slate  { --fill: var(--c-slate-fill, #e8ecf1);  --stroke: var(--c-slate-stroke, #5b6b7d);  --ink-n: var(--c-slate-ink, #243040);  --side: var(--c-slate-side, #404b58); }
.diagram .c-plum   { --fill: var(--c-plum-fill, #f9e3f0);   --stroke: var(--c-plum-stroke, #b83280);   --ink-n: var(--c-plum-ink, #6b1a4a);   --side: var(--c-plum-side, #81235a); }
.diagram .c-bronze { --fill: var(--c-bronze-fill, #f2e8dc); --stroke: var(--c-bronze-stroke, #8f6a3e); --ink-n: var(--c-bronze-ink, #4f3a1f); --side: var(--c-bronze-side, #644a2b); }

/* --- OBJECT STYLES (the diagram's data-obj attribute; "flat" is the base look above) --- */
.diagram .node .depth, .diagram .node .sheen { pointer-events: none; }
.diagram .node .side { fill: var(--side); stroke: var(--side); stroke-width: var(--nsw); stroke-linejoin: round; }
.diagram .node .sheen { stroke: none; }
.diagram[data-obj="outline"] .node .body { fill: var(--paper); stroke-width: calc(var(--nsw) * 1.3); }
.diagram[data-obj="solid"] .node .body { stroke-width: calc(var(--nsw) * 0.9); }

/* --- INTERACTION STATES --- */
.diagram .node, .diagram .edge { transition: opacity 180ms ease; }
.diagram.has-focus .node.is-dim { opacity: 0.18 !important; }
.diagram.has-focus .edge.is-dim { opacity: 0.12; }
.diagram.has-focus .edge.is-hot .edge-base { stroke: var(--edge-lit); stroke-width: 2.4; }
.diagram.has-focus .edge.is-hot .edge-arrow { fill: var(--edge-lit); }
.diagram .node.is-focus .body { stroke-width: 3; }
.diagram.has-search .node:not(.is-match) { opacity: 0.28 !important; }
.diagram .node.is-match .body { stroke: var(--pulse); stroke-width: 3.2; }
.diagram .node { cursor: pointer; }
.diagram.is-far .edge-label { display: none; }
.diagram .node text { font-size: calc(var(--fs, 14) * 1px * var(--tcs, 1)); }
@keyframes changed { 0%, 100% { filter: none; } 30%, 70% { filter: drop-shadow(0 0 7px rgba(255, 176, 0, 0.95)); } }
.diagram .is-changed .body { animation: changed 1.1s ease-in-out 3; stroke: var(--pulse); }
.diagram .edge.is-changed .edge-base { animation: changed 1.1s ease-in-out 3; stroke: var(--pulse); }
@media (prefers-reduced-motion: reduce) { .diagram * { animation: none !important; transition: none !important; } }
.diagram .lane rect { fill: var(--ink, #17212c); fill-opacity: 0.035; stroke: var(--ink, #17212c); stroke-opacity: 0.14; stroke-width: 1; }
.diagram .lane-title { font-size: 12px; font-weight: 600; fill: var(--ink2, #465465); }

/* /static/css/motion.css */
/*
 * motion.css — exit transitions, a few missing entrances, hover easing, and LITE MODE.
 * Styles for: .is-leaving (set by core/leave.js), .children.is-opening, status dot ring, html[data-motion="lite"]
 * Breakpoint: all
 *
 * Cost rules for everything in this file (keep them when editing):
 *   1. Only opacity and transform are animated (compositor work, no layout). Hover easing touches colours of small elements only.
 *   2. Everything is short (120-200 ms) and plays once. The only repeating animations are the live dot's blink and ring, and both are transform+opacity only.
 *   3. No will-change, no new blur. Nothing here runs unless the element actually appears, disappears or is hovered.
 *   4. html[data-motion="lite"] (set by core/perf.js on slow devices, slow connections, Data Saver, reduced motion, or by the user) turns ALL of it off.
 */

/* --- EXITS: leave(el) adds .is-leaving, plays one of these, then removes the element --- */
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-out { to { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@keyframes rise-out { to { opacity: 0; transform: translateY(0.5rem) scale(0.985); } }
.is-leaving { pointer-events: none; }
.menu.is-leaving { animation: pop-out 120ms var(--ease) both; }
.overlay.is-leaving { animation: fade-out 170ms ease both; }
.overlay.is-leaving > .modal, .overlay.is-leaving > .onb { animation: rise-out 190ms var(--ease) both; }
.toast.is-leaving { animation: rise-out 190ms var(--ease) both; }
.studio.is-leaving { animation: fade-out 160ms ease both; }

/* --- ENTRANCES that were missing --- */
@keyframes appear { from { opacity: 0; } }
@keyframes child-open { from { opacity: 0; transform: translateY(-4px); } }
.children.is-opening { animation: child-open var(--dur-2) var(--ease) both; }
.to-bottom:not([hidden]), .attach-row:not([hidden]), .live-panel:not([hidden]) { animation: appear var(--dur-1) ease both; }
.msg.no-anim { animation: none; }   /* restored history: the thread fades as one piece instead (controller.renderAll) */

/* --- HOVER / STATE EASING for things that had none (small elements, colour only) --- */
.row, .menu-item, .crumb, .crumb-title, .result, .foot-btn, .sb-cta, .tab, .row-btn {
  transition: background-color var(--dur-1) ease, color var(--dur-1) ease, border-color var(--dur-1) ease;
}
.status-chip { transition: background-color var(--dur-2) ease, border-color var(--dur-2) ease, color var(--dur-2) ease; }
.status-dot { transition: background-color var(--dur-2) ease; }

/* --- LITE MODE: the lightest the interface can be --- */
html[data-motion="lite"] *, html[data-motion="lite"] *::before, html[data-motion="lite"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
/* Backdrop blur re-blurs everything behind it every frame the page changes; it is the single costliest effect here. */
html[data-motion="lite"] .overlay, html[data-motion="lite"] .topbar, html[data-motion="lite"] .drop-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
html[data-motion="lite"] .overlay { background: var(--scrim); }
html[data-motion="lite"] .topbar { background: var(--bg); }
/* The live pill's sweeping light is decoration: off in lite mode (the text and log still say what is happening). */
html[data-motion="lite"] .live-head::after { display: none; }
/* A running stage in lite mode: the level bars stand still as a rising staircase (still clearly "in progress", unlike a frozen spinner) and its
   seconds counter keeps ticking, which is a text update, not an animation. The moving bar under it is left out. */
html[data-motion="lite"] .log-mark.is-live i:nth-child(1) { transform: scaleY(0.4); }
html[data-motion="lite"] .log-mark.is-live i:nth-child(2) { transform: scaleY(0.7); }
html[data-motion="lite"] .log-mark.is-live i:nth-child(3) { transform: scaleY(1); }
html[data-motion="lite"] .log-track { display: none; }

/* --- THEME SWITCH: the whole page cross-fades its colours together for a moment (core/appearance.js adds the class for ~260 ms). --- */
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: background-color 240ms ease, border-color 240ms ease, color 240ms ease, fill 240ms ease, stroke 240ms ease !important; }
@media (prefers-reduced-motion: reduce) {
  .live-head::after, .log-track { display: none; }
  .log-mark.is-live i { animation: none; }
  .log-mark.is-live i:nth-child(1) { transform: scaleY(0.4); } .log-mark.is-live i:nth-child(2) { transform: scaleY(0.7); } .log-mark.is-live i:nth-child(3) { transform: scaleY(1); }
}

/* /static/css/lang-zh.css */
/*
  lang-zh.css
  Simplified Chinese typesetting, active only when core/i18n.js sets <html lang="zh-CN"> (visits from mainland China, or Settings > Language).
  Every rule is scoped to :lang(zh-CN), so English pages are untouched.

  - Fonts: Latin keeps Atkinson / Bricolage (self-hosted, nothing from another origin, which also matters in China where foreign font CDNs are
    slow or blocked); Chinese characters fall through to the system's own Chinese UI font: PingFang SC (Apple), HarmonyOS Sans SC (Huawei),
    MiSans (Xiaomi), Microsoft YaHei (Windows), Noto / Source Han Sans (Linux, Android). No webfont download for CJK.
  - Rhythm: Chinese needs more line height than Latin (about 1.65 for body text, 1.25+ for headings) and no negative tracking.
  - No fake italics (Chinese has none): emphasis in a reply becomes 着重号, the dot under each character that Chinese typesetting uses.
  - Line breaking follows the mainland rules (line-break: strict: no line starts with 。，、 or a closing bracket), and a small gap is added
    between Chinese and Latin text where the browser supports it (text-autospace).
  Depends on: tokens.css (the --font-* and --track-* tokens it overrides).
*/
:root:lang(zh-CN) {
  --font-cjk: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "WenQuanYi Micro Hei";
  --font-sans: "Atkinson Hyperlegible Next", var(--font-cjk), system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", var(--font-cjk), system-ui, sans-serif;
  --track-tight: 0;
  --track-snug: 0;
}

:lang(zh-CN) body { line-height: 1.65; line-break: strict; word-break: normal; overflow-wrap: break-word; text-autospace: normal; text-spacing-trim: trim-start; }
:lang(zh-CN) .msg-text { line-height: 1.75; }
:lang(zh-CN) .msg-text p + p { margin-top: 0.5em; }

/* headings: the Latin display sizes are set tight (1.0 to 1.1), which clips the top and bottom of Chinese characters */
:lang(zh-CN) .w-head h1,
:lang(zh-CN) .onb h2,
:lang(zh-CN) .gate-card h1,
:lang(zh-CN) .ann-body h2 { line-height: 1.3; font-weight: 700; }
:lang(zh-CN) .w-head h1 { font-size: calc(var(--text-hero) * 0.86); }
:lang(zh-CN) .block-head h3,
:lang(zh-CN) .msg-text h1, :lang(zh-CN) .msg-text h2, :lang(zh-CN) .msg-text h3 { line-height: 1.4; }

/* small caps-style labels: uppercase does nothing to Chinese and wide tracking pulls the characters apart */
:lang(zh-CN) .w-label,
:lang(zh-CN) .day-sep,
:lang(zh-CN) .slash-head,
:lang(zh-CN) .gate-or,
:lang(zh-CN) .ann-kicker { letter-spacing: 0.04em; text-transform: none; }

/* emphasis: 着重号 under the characters instead of a slanted fallback font */
:lang(zh-CN) .msg-text em { font-style: normal; text-emphasis: filled dot; -webkit-text-emphasis: filled dot; text-emphasis-position: under right; -webkit-text-emphasis-position: under; }
:lang(zh-CN) .log-earlier { font-style: normal; }

/* buttons and chips hold fewer, wider characters: keep them from looking cramped */
:lang(zh-CN) .btn { letter-spacing: 0.02em; }

/* /static/css/lang-ru.css */
/*
  lang-ru.css
  Russian typesetting, active only when core/i18n.js sets <html lang="ru"> (Russia's time zones, a Russian browser, or Settings > Language).
  Every rule is scoped to :lang(ru), so other languages are untouched.

  - Fonts: the shipped Atkinson and Bricolage files have no Cyrillic, so a Russian word would mix their Latin capitals with a fallback font's
    Cyrillic letters. The interface therefore uses one system family for both scripts: San Francisco (Apple), Segoe UI (Windows), Roboto
    (Android, ChromeOS), then PT Sans and Arial. Nothing is downloaded. Diagram text keeps its own font (diagram-svg.css --font), so the
    server's text measurements (app/diagram/text_metrics.py) are unchanged.
  - Russian runs about a quarter longer than English: buttons and chips may wrap instead of overflowing; long words hyphenate in replies only.
  - Russian has no small caps tradition for UI labels: uppercase labels keep their caps but lose the wide tracking.
  Depends on: tokens.css (the --font-* and --track-* tokens it overrides).
*/
:root:lang(ru) {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "PT Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "PT Sans", "Helvetica Neue", Arial, sans-serif;
  --track-tight: -0.01em;
}

:lang(ru) body { overflow-wrap: break-word; }
/* hyphenation only in long reading text: Russian interfaces never break words in headings, buttons or labels */
:lang(ru) .msg-text p, :lang(ru) .msg-text li { hyphens: auto; -webkit-hyphens: auto; }
:lang(ru) .w-head h1, :lang(ru) .onb h2 { font-stretch: normal; line-height: 1.12; text-wrap: balance; }
:lang(ru) .w-head h1 { font-size: calc(var(--text-hero) * 0.9); }
:lang(ru) .onb-1 h2 { font-size: clamp(2.1rem, 1rem + 2.7vw, 3.3rem); }   /* the Russian headline is a third longer: keep it to three or four lines so the card still fits */

/* labels in caps: Cyrillic capitals are wide, so the Latin tracking makes them sprawl */
:lang(ru) .w-label,
:lang(ru) .day-sep,
:lang(ru) .slash-head,
:lang(ru) .gate-or,
:lang(ru) .ann-kicker { letter-spacing: 0.03em; }

/* longer words: let compact controls wrap rather than spill out of their box */
:lang(ru) .btn { white-space: normal; text-align: center; line-height: 1.2; }
:lang(ru) .chip-btn, :lang(ru) .seg-pick button { white-space: normal; hyphens: manual; }

/* /static/css/lang-es-pt.css */
/*
  lang-es-pt.css
  Latin American Spanish and Brazilian Portuguese typesetting, active only when core/i18n.js sets <html lang="es-419"> or <html lang="pt-BR">
  (those time zones, a Spanish or Portuguese browser, or Settings > Language). Every rule is scoped to :lang(es) / :lang(pt), so other languages
  are untouched.

  - Fonts: the shipped Atkinson and Bricolage files cover the Latin accents both languages need (á é í ó ú ñ ü ã õ â ê ô ç ¿ ¡), so the fonts
    stay exactly as in English. Nothing extra is downloaded.
  - Spanish and Portuguese run about a fifth to a third longer than English: buttons and chips may wrap instead of overflowing, the hero
    headlines are set a little smaller, and long words hyphenate in replies only.
  Depends on: tokens.css (--text-hero).
*/
:lang(es) .msg-text p, :lang(es) .msg-text li,
:lang(pt) .msg-text p, :lang(pt) .msg-text li { hyphens: auto; -webkit-hyphens: auto; }

:lang(es) .w-head h1, :lang(es) .onb h2,
:lang(pt) .w-head h1, :lang(pt) .onb h2 { text-wrap: balance; }
:lang(es) .w-head h1, :lang(pt) .w-head h1 { font-size: calc(var(--text-hero) * 0.92); }
:lang(es) .onb-1 h2, :lang(pt) .onb-1 h2 { font-size: clamp(2.1rem, 1rem + 2.8vw, 3.4rem); }   /* the headline is a third longer than the English: keep the card's height */

/* longer words: let compact controls wrap rather than spill out of their box */
:lang(es) .btn, :lang(pt) .btn { white-space: normal; text-align: center; line-height: 1.2; }
:lang(es) .chip-btn, :lang(es) .seg-pick button,
:lang(pt) .chip-btn, :lang(pt) .seg-pick button { white-space: normal; hyphens: manual; }

/* /static/css/mobile.css */
/*
 * mobile.css — 0–47.9375rem. The sidebar is a drawer; the thread is full width.
 * Styles for: drawer, spacing, touch targets
 * Breakpoint: mobile: 0–47.9375rem (all larger files build on this)
 */
.sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 21.25rem); z-index: 120; transform: translateX(-104%); transition: transform 260ms var(--ease), box-shadow 260ms; box-shadow: none; }
.app[data-sidebar="open"] .sidebar { transform: none; box-shadow: var(--shadow-4); }
.scrim { display: block; position: fixed; inset: 0; z-index: 110; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 220ms; }
.app[data-sidebar="open"] .scrim { opacity: 1; pointer-events: auto; }
.thread { padding: var(--s4) var(--s3) var(--s8); }
.row .row-act { display: inline-grid; }
.row:hover .when { display: inline; }
.msg.user .msg-main { max-width: 92%; }
.msg-actions { opacity: 1; }
.avatar { width: 1.5rem; height: 1.5rem; }
.msg { gap: var(--s2); }
.status-chip { display: none; }
.block-head { padding: 0.5rem var(--s3); }
.composer-note { display: none; }
.dv-time, .dv-speed { display: none; }
.dv-walk-row { flex-wrap: wrap; } .dv-scrub { order: 9; flex-basis: 100%; }
.studio-find { flex: 1 1 100%; order: 5; }
.tl-item { grid-template-columns: 4rem 1rem 1fr; } .tl-item::before { left: calc(4rem + var(--s3) + 0.4375rem); }
.toasts { bottom: 7.5rem; }
.modal { max-height: 92dvh; }
.new-chat kbd { display: none; }
/* reasoning row and pin, a little tighter on phones */
:root { --work-h: 2rem; --topbar-h: 3rem; }
.topbar { padding: 0 var(--s2); }
.dock { padding: 0 var(--s2) max(var(--s2), env(safe-area-inset-bottom)); }
.composer-box { border-radius: var(--r-xl); }
.welcome { padding-top: var(--s4); gap: var(--s5); }
.pin-btn { width: 1.875rem; height: 1.875rem; }
.msg-head > .pin-btn { margin-top: calc((var(--work-h) - 1.875rem) / 2); }
/* Keyboard shortcuts mean nothing on a touch phone: its button gives the chat title the room. */
@media (max-width: 47.99rem) and (pointer: coarse) { #btn-help { display: none; } .top-sep { display: none; } }
/* Studio on a phone: the actions become icon buttons beside the title (their names stay as aria-labels), so the canvas keeps the height.
   The minimap would cover a third of a phone canvas; pinch and drag already move the view. */
@media (max-width: 47.99rem) {
  .studio-bar { gap: var(--s2); padding: 0.25rem var(--s2); }
  .studio-title { flex: 1 1 0; }
  .studio-actions { flex-wrap: nowrap; gap: 2px; }
  .studio-actions .btn-label { display: none; }
  .studio-actions .btn { min-width: 2.5rem; min-height: 2.5rem; padding-inline: 0.5rem; justify-content: center; }
  .studio-find { min-width: 0; }
  .minimap { display: none; }
  .studio-legend { max-width: calc(100% - 1.5rem); bottom: 3.75rem; }   /* above the zoom controls, which stay visible */
}

/* --- PHONES: an app, not a shrunken web page (owner's request, 2026-11-17). ---
   Type and controls at a phone's own size: the interface-size setting still works, from 0.8x of its desktop size (the default 1.25 gives
   16px per rem, the size iOS and Android apps use). The composer is one slim row, like a messaging app: Attach and Tune on the left, the text
   in the middle growing upward as it is typed, Send on the right. The Tune strip folds away behind its button (composer.js .bar-tune). */
@media (max-width: 47.99rem) {
  :root { --device-scale: 0.8; --topbar-h: 3.25rem; }
  html, body { overscroll-behavior-y: none; }
  .topbar { padding: 0 var(--s2); padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .thread { padding: var(--s3) var(--s4) var(--s6); }
  .dock { padding: var(--s1) var(--s2) max(var(--s2), env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 0.75rem); }
  .composer-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.125rem; padding: 0.3125rem; border-radius: 1.5rem; box-shadow: var(--shadow-1); }
  .composer-box:focus-within { box-shadow: var(--shadow-2), 0 0 0 2px var(--accent-ring); }
  .composer-bar { display: contents; }
  .ctx-slot { order: 0; flex: 1 1 100%; }
  .ctx-slot:empty { display: none; }
  .composer-input { order: 2; flex: 1 1 0; width: auto; min-width: 0; min-height: 2.5rem; max-height: 38dvh; padding: 0.5rem 0.375rem; font-size: max(16px, 1rem); line-height: 1.45; }   /* 16px+: iOS never zooms the page on focus */
  .bar-attach, .bar-tune { order: 1; display: inline-grid; width: 2.5rem; height: 2.5rem; border-radius: var(--r-full); }
  .bar-tune[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-ink); }
  .bar-end { order: 3; margin-left: 0; }
  .send-btn { width: 2.5rem; height: 2.5rem; }
  .counter { display: none; }
  .composer-box .tune-core { order: 4; display: none; }
  .composer-box.tune-shown .tune-core { display: flex; animation: pop var(--dur-2) var(--ease-out); }
  .welcome { padding-top: var(--s3); gap: var(--s4); }
  .msg.user .msg-main { max-width: 85%; }
  .toasts { bottom: 5.5rem; }
}
/* A phone held sideways: the same phone sizes, the same slim composer (short.css keeps the bars thin). */
@media (max-height: 512px) and (pointer: coarse) {
  :root { --device-scale: 0.8; }
}

/* /static/css/tablet.css */
@media (min-width: 768px) {
/*
 * tablet.css — 48rem–63.9375rem
 * Styles for: roomier thread, status chip back, studio inspector height
 * Breakpoint: tablet: min-width 48rem
 */
.thread { padding: var(--s6) var(--s6) var(--s10); }
.dock { padding: 0 var(--s6) var(--s3); }
.dock-inner { max-width: calc(var(--col) - 2 * var(--s6)); }   /* the thread's content edge: text, cards and the composer line up */
.status-chip { display: inline-flex; }
.msg-actions { opacity: 0; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.row .row-act { display: none; }
.row:hover .when { display: none; }
.composer-note { display: block; }
.dv-time, .dv-speed { display: inline; }
.dv-walk-row { flex-wrap: nowrap; } .dv-scrub { order: 0; flex-basis: auto; }
.studio-find { flex: 0 1 17.5rem; order: 0; }
.tl-item { grid-template-columns: 6rem 1.125rem 1fr; } .tl-item::before { left: calc(6rem + var(--s3) + 0.5rem); }

}
/* /static/css/desktop.css */
@media (min-width: 1024px) {
/*
 * desktop.css — 64rem and up. The sidebar is docked; the studio shows the inspector beside the canvas.
 * Styles for: docked sidebar (collapsible), studio two-column layout
 * Breakpoint: desktop: min-width 64rem
 */
.sidebar { position: relative; inset: auto; width: var(--sb-w); flex: none; transform: none; box-shadow: none; transition: margin-left 260ms var(--ease); z-index: auto; }
.app[data-sidebar="closed"] .sidebar { margin-left: calc(var(--sb-w) * -1); }
.app.no-slide .sidebar { transition: none; }   /* the first state at start-up (app.js boot) */
.scrim { display: none !important; }
.menu-btn { display: none; }
.app[data-sidebar="closed"] .menu-btn { display: inline-grid; }
.studio-main { flex-direction: row; }
.studio-inspector { width: 22rem; max-height: none; border-top: 0; border-left: 1px solid var(--border); flex: none; }
.thread { padding-top: var(--s8); }
.new-chat kbd { display: inline-block; }
.app[data-sidebar] .sidebar { box-shadow: none; }

/* The composer shares the conversation's column, so text, cards and the box line up on one edge. */
.dock-inner { max-width: calc(var(--col) - 2 * var(--s6)); }

}
/* /static/css/wide.css */
@media (min-width: 1440px) {
/*
 * wide.css — 90rem and up
 * Styles for: wider conversation column and sidebar
 * Breakpoint: wide: min-width 90rem
 */
:root { --col: 50rem; --sb-w: 18.5rem; }
.studio-inspector { width: 24rem; }

}
/* /static/css/short.css */
@media (max-height: 512px) {
/*
 * short.css — windows under 32rem tall: phones held sideways, split-screen tablets, small laptop windows.
 * Styles for: a slimmer top bar and composer so the conversation keeps most of the height; dialogs and sheets that fit the height.
 * Breakpoint: short: max-height 32rem (loaded last, so it wins over the width files)
 */
:root { --topbar-h: 2.75rem; }
.thread { padding-top: var(--s3); padding-bottom: var(--s6); }
.composer-note { display: none; }
.composer-input { min-height: 2.75rem; max-height: 38dvh; padding-top: 0.625rem; }
.composer-bar { padding-bottom: 0.375rem; }
.dock { padding-bottom: max(var(--s2), env(safe-area-inset-bottom)); }
.dock::before { height: var(--s4); }
.welcome { padding-top: var(--s2); gap: var(--s4); }
.modal { max-height: calc(100dvh - 1rem); }
.tune-options { max-height: calc(100dvh - 7rem); }
.tune-pop { max-height: calc(100dvh - 1rem); }
.toasts { bottom: 5.5rem; }
/* Studio held sideways: one bar row, the inspector beside the canvas instead of under it, the toolbar a single swipeable row. */
.studio-bar { flex-wrap: nowrap; min-height: 2.75rem; padding-block: 0.25rem; gap: var(--s2); }
.studio-title { flex: 0 1 auto; min-width: 0; max-width: 32%; }
.studio-find { flex: 1 1 8rem; min-width: 6rem; order: 0; }
.studio-search { height: 2rem; }
.studio-actions { flex-wrap: nowrap; gap: 2px; }
.studio-actions .btn-label { display: none; }
.studio-actions .btn { padding-inline: 0.5rem; }
.minimap { display: none; }
.edit-bar { top: 0.375rem; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; max-width: calc(100% - 0.75rem); }
.edit-bar::-webkit-scrollbar { display: none; }
@media (min-width: 37.5rem) {
  .studio-main { flex-direction: row; }
  .studio-inspector { width: min(22rem, 44%); min-width: 0; max-height: none; border-top: 0; border-left: 1px solid var(--border); flex: none; }
}
/* a narrow inspector: a caption above its control instead of beside it, so no field runs past the edge */
.studio-body { overflow-x: hidden; }
.studio-inspector .ep-field { flex-wrap: wrap; }
.studio-inspector .ep-field > .ep-text, .studio-inspector .ep-field > .ep-seg, .studio-inspector .ep-field > .seg { flex: 1 1 100%; min-width: 0; }
.studio-legend { bottom: 3.5rem; max-width: calc(100% - 1.5rem); padding: 0.375rem 0.625rem; }   /* above the zoom controls, which stay visible */
.tbl-scroll { max-height: 70dvh; }   /* a table never scrolls inside a box taller than the window */

}