/* =========================================================================
   Thesis — the classroom-chatbot design system, built for research.

   Same Resense Lab language as the tutor: translucent glass over a soft
   navy-and-white ambient ground, Penn State blue as the one accent (Beaver
   Blue #1E407C over Nittany Navy #001E44), IBM Plex Sans for the interface and Source Serif 4 for reading,
   JetBrains Mono for anything that is data. The layout is the tutor's: a
   floating glass header carrying the mode switch, a transcript card with
   the composer floating beneath it as its own pill, and one 340px panel on
   the right with a segmented control.

   Flat glass, as in the tutor. Surfaces are glass: a flat translucent fill
   that blurs and saturates the soft washes behind it, a lit top edge and a
   layered shadow. Controls are flat: a selected option, a primary button
   and a send button are one solid block of Penn State blue, with no
   gradient, no glow and no inner highlight. Those three effects together
   are what made the old controls look inflated, and inside a scrolling
   list a glow is clipped into a hard-edged smudge anyway.

   Restraint, also from Meridian: glass is for chrome — header, transcript
   shell, composer, side panel, sheets. Data surfaces inside them (source
   cards, claims, tables of numbers) stay solid, because a source has to be
   read accurately and blur behind it only makes that harder.
   ========================================================================= */

/* Self-hosted fonts: a privacy-first tool should not tell Google Fonts who
   is reading it. Variable fonts, Latin and Latin Extended subsets. */
/* IBM Plex Sans for the interface, Source Serif 4 for reading and titles
   (both SIL OFL). Latin subsets; other scripts fall back to the system. */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url('fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url('fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('fonts/ibm-plex-sans-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: italic;
  font-display: swap;
  font-weight: 400;
  src: url('fonts/ibm-plex-sans-latin-400-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url('fonts/source-serif-4-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-display: swap;
  font-weight: 200 900;
  src: url('fonts/source-serif-4-latin-wght-italic.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('fonts/jetbrains-mono-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Accent — Penn State blue. A true navy, deliberately not the
     indigo-violet that reads as generic AI. */
  --accent: #1E407C;              /* text and icons: 9.1:1 on white */
  --accent-bright: #2F63B8;       /* fills, rings and progress */
  --accent-soft: rgba(30, 64, 124, 0.09);
  --accent-line: rgba(30, 64, 124, 0.22);
  --accent-hover: #16305E;
  --navy: #001E44;
  /* A selected chip or tab: a block of accent with text on top. Its own
     token because --accent is tuned as a text colour and lightens after
     dark; white on that pale blue is unreadable. */
  --accent-fill: #1E407C;
  --accent-on: #ffffff;

  /* Ground */
  --bg: #E8EBF1;
  --bg-gradient: radial-gradient(900px 520px at 12% -8%, #CBD9EE 0%, transparent 62%),
                 radial-gradient(760px 480px at 88% 4%, #DCE2EC 0%, transparent 58%),
                 radial-gradient(640px 520px at 50% 108%, #D2DAE8 0%, transparent 60%),
                 var(--bg);

  /* Glass */
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.55);
  --surface-3: rgba(0, 30, 68, 0.055);
  --card: rgba(255, 255, 255, 0.78);       /* solid-reading data surface */
  --card-hover: rgba(255, 255, 255, 0.95);
  --border: rgba(255, 255, 255, 0.85);
  --border-hair: rgba(0, 30, 68, 0.09);
  --glass-blur: blur(24px) saturate(180%);
  /* the lit top edge of the glass: the one highlight a surface keeps */
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --glass-edge: var(--glass-inset);
  /* Flat fills, three weights: chrome, panels, and the composer, which
     carries the most text and so is the most opaque. */
  --glass-fill: rgba(255, 255, 255, 0.72);
  --glass-fill-chrome: rgba(255, 255, 255, 0.68);
  --glass-fill-composer: rgba(255, 255, 255, 0.80);
  --menu-fill: rgba(255, 255, 255, 0.97);
  --scrim: rgba(8, 14, 28, 0.32);

  /* Type */
  --text: #10141B;
  --text-2: #3A4250;
  --text-muted: #5B6676;
  --text-faint: #8A94A6;

  /* Layered and tinted toward the navy, never one flat black drop */
  --shadow: 0 1px 2px rgba(0, 30, 68, 0.05), 0 14px 38px rgba(0, 30, 68, 0.09);
  --shadow-sm: 0 1px 2px rgba(0, 30, 68, 0.04), 0 8px 22px rgba(0, 30, 68, 0.07);
  --shadow-lift: 0 2px 4px rgba(0, 30, 68, 0.06), 0 22px 48px rgba(0, 30, 68, 0.16);

  --user-bubble: #1E407C;
  --user-bubble-text: #ffffff;
  --bot-text: #1A1F28;

  /* The primary button is the one fill that must NOT follow --accent:
     pinned to mid-blue so white text holds contrast in both themes. */
  --btn-text: #ffffff;
  /* the flat fill a primary or send button takes, per state */
  --btn-fill: #1E407C;
  --btn-fill-hover: #2F63B8;
  --btn-fill-active: #16305E;
  --danger-fill: #C33349;
  --danger-fill-hover: #D6455D;

  /* One scrollbar everywhere: the platform's thin bar (arrow, pill, arrow)
     over a transparent track, so no rectangle ever pokes out against a
     rounded card edge. */
  --scroll-thumb: rgba(18, 24, 32, 0.25);
  --scroll-thumb-hover: rgba(18, 24, 32, 0.38);

  /* Verdicts and claim states. Text colours are tuned per theme: the old
     sheet used dark-mode pastels everywhere, which vanished on white. */
  --ok: #16a34a;
  --ok-text: #166534;
  --ok-soft: rgba(22, 163, 74, 0.11);
  --ok-line: rgba(22, 163, 74, 0.28);
  --warn: #d97706;
  --warn-text: #92400E;
  --warn-soft: rgba(245, 158, 11, 0.13);
  --warn-line: rgba(217, 119, 6, 0.30);
  --bad: #dc2626;
  --bad-text: #B91C1C;
  --bad-soft: rgba(220, 38, 38, 0.09);
  --bad-line: rgba(220, 38, 38, 0.28);

  --code-bg: #14171D;
  --focus-ring: rgba(47, 99, 184, 0.10);

  --r-xl: 32px;
  --r-lg: 28px;
  --r-md: 18px;
  --r-sm: 12px;
  --r-xs: 8px;
  --r-pill: 999px;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-liquid: cubic-bezier(0.32, 0.72, 0, 1);

  --gap: 20px;
  --side-w: 340px;
  --rail-w: 54px;
  --rail-open-w: 190px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: 'Source Serif 4', 'Iowan Old Style', Charter, Georgia, serif;

  color-scheme: light;
}

[data-theme="dark"] {
  /* The same scheme after dark: smoked glass, the blue lifted for contrast. */
  --accent: #86AEEC;
  --accent-bright: #9DC2F5;
  --accent-soft: rgba(134, 174, 236, 0.15);
  --accent-line: rgba(134, 174, 236, 0.30);
  --accent-hover: #A6C6F7;
  --accent-fill: #2F63B8;
  --accent-on: #ffffff;

  --bg: #080C14;
  --bg-gradient: radial-gradient(900px 520px at 12% -8%, rgba(47, 99, 184, 0.20), transparent 62%),
                 radial-gradient(760px 480px at 88% 4%, rgba(120, 140, 175, 0.10), transparent 58%),
                 radial-gradient(640px 520px at 50% 108%, rgba(0, 30, 68, 0.55), transparent 60%),
                 var(--bg);

  --surface: rgba(20, 28, 44, 0.72);
  --surface-solid: #141C2C;
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.10);
  --border-hair: rgba(255, 255, 255, 0.075);
  --glass-blur: blur(24px) saturate(160%);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --glass-edge: var(--glass-inset);
  --glass-fill: rgba(20, 28, 44, 0.72);
  --glass-fill-chrome: rgba(20, 28, 44, 0.68);
  --glass-fill-composer: rgba(24, 33, 52, 0.82);
  --menu-fill: rgba(22, 30, 47, 0.98);
  --scrim: rgba(2, 6, 14, 0.55);

  --text: #E9EDF5;
  --text-2: #C9D2E1;
  --text-muted: #96A2B8;
  --text-faint: #6E7A90;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 16px 42px rgba(0, 8, 24, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 8, 24, 0.42);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 26px 60px rgba(0, 8, 24, 0.65);

  --user-bubble: #2F63B8;
  --bot-text: #DEE4EF;

  --btn-fill: #2F63B8;
  --btn-fill-hover: #3A72C8;
  --btn-fill-active: #24509A;
  --danger-fill: #C33349;
  --danger-fill-hover: #D6455D;

  --scroll-thumb: rgba(190, 210, 240, 0.22);
  --scroll-thumb-hover: rgba(190, 210, 240, 0.36);

  --ok: #4ade80;
  --ok-text: #86EFAC;
  --ok-soft: rgba(74, 222, 128, 0.13);
  --ok-line: rgba(74, 222, 128, 0.32);
  --warn: #fbbf24;
  --warn-text: #FCD34D;
  --warn-soft: rgba(250, 204, 21, 0.11);
  --warn-line: rgba(250, 204, 21, 0.30);
  --bad: #f87171;
  --bad-text: #FCA5A5;
  --bad-soft: rgba(248, 113, 113, 0.13);
  --bad-line: rgba(248, 113, 113, 0.34);

  --code-bg: #0B0F17;
  --focus-ring: rgba(134, 174, 236, 0.14);

  color-scheme: dark;
}

/* A translucent surface over a busy ground is unreadable without the blur.
   Where the browser cannot do it, fall back to opaque. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --surface: #ffffff; --surface-2: #F1F4F9;
    --glass-fill: #ffffff; --glass-fill-chrome: #ffffff; --glass-fill-composer: #ffffff;
    --border: rgba(0, 30, 68, 0.11);
  }
  [data-theme="dark"] {
    --surface: #141C2C; --surface-2: #1C2538;
    --glass-fill: #141C2C; --glass-fill-chrome: #141C2C; --glass-fill-composer: #182136;
    --border: rgba(255, 255, 255, 0.12);
  }
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
::selection { background: rgba(47, 99, 184, 0.22); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2.5px solid var(--accent-bright);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* ------------------------------------------------------------ glass base */

/* Flat glass: one translucent fill, the blur that makes it glass, a lit top
   edge and a soft shadow. No gradient fill, no rim stroke. */
.glass {
  position: relative;
  background: var(--glass-fill);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow), var(--glass-inset);
}

/* ---------------------------------------------------------------- layout */

/* The header across the top; below it the rail and whichever space is
   open. No width cap: a wide monitor shows more (the side panels step up
   below) instead of leaving dead margins on both sides. */
.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--gap);
  padding: 18px 22px 16px;
}

.app-body {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: var(--gap);
  transition: grid-template-columns 0.34s var(--ease-liquid);
}

body.rail-open { --rail-w: var(--rail-open-w); }

/* ---------------------------------------------------------------- header */

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 12px 10px 14px;
  border-radius: var(--r-lg);
  background: var(--glass-fill-chrome);
  box-shadow: var(--shadow-sm), var(--glass-inset);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* The lab's mark, as in the tutor: a fixed 42px tile, nothing painted on
   top of it. */
.logo {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface-solid);
  box-shadow: 0 0 0 1px var(--border-hair);
}

.logo img { display: block; width: 100%; height: 100%; object-fit: cover; }

.brand-text { min-width: 0; }

.brand-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.25;
  white-space: nowrap;
}

.brand-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.status-dot.is-off { background: var(--text-faint); box-shadow: none; }
.status-dot.is-bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.brand-sep { opacity: 0.5; }

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, transform 0.18s var(--ease-spring);
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

.head-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.head-divider { width: 1px; height: 24px; background: var(--border-hair); margin: 0 8px; flex-shrink: 0; }

/* The project switcher: which research question everything below belongs to. */
.project-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: 260px;
  height: 42px;
  padding: 0 12px 0 11px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s var(--ease-spring);
}

.project-btn:hover { background: var(--card-hover); border-color: var(--accent-line); }
.project-btn:active { transform: scale(0.98); }
.project-btn[aria-expanded="true"] { border-color: var(--accent-line); background: var(--card-hover); }

.proj-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-xs);
  flex-shrink: 0;
  background: var(--accent-bright);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent);
}

.proj-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.proj-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.proj-name { font-size: 13px; font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-chev { flex-shrink: 0; color: var(--text-faint); }

/* Search everything: the command palette's front door. */
.search-pill {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: min(440px, 100%);
  height: 40px;
  padding: 0 7px 0 14px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.search-pill:hover { background: var(--card-hover); border-color: var(--accent-line); color: var(--text-muted); }
.search-pill svg { flex-shrink: 0; }
.sp-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-kbd { flex-shrink: 0; font-size: 10.5px; padding: 2px 7px; border-radius: var(--r-sm); }

/* Chat or voice: the tutor's switch. Same flat pill as every other choice. */
.mode-toggle .seg-btn { min-height: 36px; padding: 0 16px; }

.trust-btn { position: relative; }
.trust-btn .status-dot {
  position: absolute;
  left: 25px;
  top: 25px;
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 2px var(--surface-solid);
}
.status-dot.is-pending { background: var(--warn); box-shadow: 0 0 0 2px var(--surface-solid); }

.icon-btn.sm { width: 34px; height: 34px; border-radius: var(--r-sm); }

/* --------------------------------------------------------------- the rail */

/* Mirrors the tutor's rail: the same glass as the side panel, the same
   height as the space beside it, far thinner. Spaces at the top, the things
   you reach for rarely at the bottom. Collapsed it shows icons; expanding
   widens it and the labels, which are always laid out and only clipped by
   the width, slide out from under the icons instead of popping in. */
.rail {
  grid-column: 1;
  grid-row: 1;
  z-index: 25;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 7px;
  overflow: hidden;
  border-radius: var(--r-lg);
}

.rail-group { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.rail-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.18s ease, color 0.18s ease;
}

.rail-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.rail-btn:hover { background: var(--surface-3); color: var(--text); }
.rail-btn[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.rail-btn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -2px; }

.rail-label {
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s ease 0.04s, transform 0.28s var(--ease-liquid) 0.04s;
}

body.rail-open .rail-label { opacity: 1; transform: none; }

/* The library's size: a small badge on the icon, a count beside the label
   once there is room for one. */
.rail-count {
  position: absolute;
  left: 24px;
  top: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  display: inline-grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  background: var(--accent-fill);
  color: var(--accent-on);
  transition: left 0.34s var(--ease-liquid), top 0.34s var(--ease-liquid);
}

body.rail-open .rail-count { left: auto; right: 9px; top: 12px; background: var(--surface-3); color: var(--text-muted); }

.rail-sep { height: 1px; background: var(--border-hair); margin: 4px 6px; }
.rail-expand svg { transition: transform 0.34s var(--ease-liquid); }
body.rail-open .rail-expand svg { transform: rotate(180deg); }
.rail-more { display: none; }

.theme-btn .ico-sun { display: none; }
[data-theme="dark"] .theme-btn .ico-sun { display: block; }
[data-theme="dark"] .theme-btn .ico-moon { display: none; }

/* ------------------------------------------------------------ segmented */

/* One flat block of blue slides to the chosen option. A moving block says
   "same control, new choice" better than one background blinking off and
   another on; flat, because the old glossy droplet (gradient, glow and an
   inner highlight) is what read as an inflated balloon. Positioned from a
   measurement of the active option, never an index, so it survives font
   loading, resizing and label changes. */
.seg {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  isolation: isolate;
}

.seg-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: var(--pill-l, 3px);
  right: var(--pill-r, 100%);
  border-radius: var(--r-sm);
  background: var(--accent-fill);
  z-index: 0;
  opacity: 0;
  transition: left 0.32s var(--ease-out), right 0.32s var(--ease-out), opacity 0.2s ease;
}

.seg-pill.is-ready { opacity: 1; }
.seg-pill.no-anim { transition: none; }

.seg-btn {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.seg-btn svg { flex-shrink: 0; opacity: 0.9; }
.seg-btn:hover:not(.is-on) { color: var(--text); }
.seg-btn.is-on { color: var(--accent-on); }

/* No JS yet (or reduced motion before measuring): the same flat fill. */
.seg:not(.has-pill) .seg-btn.is-on { background: var(--accent-fill); }

.seg-count {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  display: inline-grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-muted);
  transition: background 0.25s ease, color 0.25s ease;
}

.seg-btn.is-on .seg-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

.seg-sm .seg-btn { min-height: 28px; padding: 0 11px; font-size: 12px; }

.label-short { display: none; }

/* ------------------------------------------------------------- the zones */

.spaces {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.space {
  flex: 1 1 auto;
  min-height: 0;
  animation: space-in 0.42s var(--ease-out) both;
}

@keyframes space-in {
  from { opacity: 0; transform: translateY(8px) scale(0.995); }
  to   { opacity: 1; transform: none; }
}

.zones {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  gap: var(--gap);
  align-items: stretch;
}

/* The chat column is a transparent stack holding two cards: the transcript,
   and the composer beneath it. Separate cards give the composer its own
   presence instead of welding it to the bottom of a scroll area. */
.chat-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.messages-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
}

/* The conversation's own bar: which thread this is, and a new one. */
.thread-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 0 14px;
  flex: 0 0 auto;
}

.thread-bar .grow { flex: 1; }

.thread-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 650;
  transition: background 0.2s ease, color 0.2s ease;
}

.thread-title:hover { background: var(--surface-3); color: var(--text); }
.thread-title .tt-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-title svg { flex-shrink: 0; opacity: 0.7; }

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
  padding: 18px clamp(18px, 3vw, 34px) 34px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  /* content dissolves into the glass edge instead of being cut by it */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 22px), transparent 100%);
}


/* ------------------------------------------------------------ empty hero */

.hero {
  margin: auto;
  width: min(640px, 100%);
  padding: 12px 0 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise 0.6s var(--ease-out) both;
}

.hero-mark {
  width: 64px;
  height: 64px;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent-fill);
  margin-bottom: 22px;
  position: relative;
}

.hero-title {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.hero-title em { font-style: normal; color: var(--accent); }

.hero-sub {
  margin: 12px auto 0;
  max-width: 520px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  text-wrap: pretty;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 26px;
}

.hero-pillars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-hair);
  width: 100%;
}

.pillar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}

.pillar svg { color: var(--accent); }

.hero-warning {
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

/* ------------------------------------------------------------------ chips */

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: transform 0.14s var(--ease-spring), background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.chip-btn:hover { background: var(--card-hover); border-color: var(--accent-line); color: var(--text); }
.chip-btn:active { transform: scale(0.97); }

/* ---------------------------------------------------------------- messages */

.msg { display: flex; animation: rise 0.42s var(--ease-out) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.msg-user { justify-content: flex-end; }

.bubble-user {
  max-width: min(72%, 640px);
  padding: 13px 18px;
  border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg);
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-user .mode-tag {
  display: block;
  margin-bottom: 3px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  opacity: 0.72;
}

.msg-thea {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.thea-avatar {
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}

.thea-body { min-width: 0; max-width: 780px; }

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 5px 0 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.eyebrow .dot { opacity: 0.6; }
.eyebrow .mono { font-family: var(--mono); letter-spacing: 0; text-transform: none; font-weight: 500; }

/* Prose: the answer itself. */
.prose {
  font-size: 15px;
  line-height: 1.7;
  color: var(--bot-text);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.prose p { margin: 0 0 0.85em; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 0.85em; padding-left: 1.3em; }
.prose li { margin: 0.25em 0; padding-left: 0.15em; }
.prose li::marker { color: var(--text-faint); }
.prose strong { font-weight: 700; color: var(--text); }
.prose h4 { margin: 1.1em 0 0.4em; font-size: 15px; font-weight: 750; letter-spacing: -0.01em; color: var(--text); }
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.1em 0.38em;
  border-radius: var(--r-xs);
  background: var(--surface-3);
}
.prose a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.prose a:hover { border-bottom-color: currentColor; }

/* Inline citations: tappable, previewable, and the jump to the source. */
.cite-group { white-space: nowrap; }

.cite {
  display: inline-grid;
  place-items: center;
  min-width: 1.45em;
  height: 1.45em;
  margin: 0 1px;
  padding: 0 0.35em;
  border: 0;
  border-radius: var(--r-xs);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74em;
  font-weight: 750;
  line-height: 1;
  vertical-align: 0.12em;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s var(--ease-spring);
}

.cite:hover, .cite:focus-visible, .cite.is-active {
  background: var(--accent-fill);
  color: var(--accent-on);
  transform: translateY(-1px);
}

.cite.is-missing { background: var(--bad-soft); color: var(--bad-text); }

/* --------------------------------------------------------- chips / badges */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 11px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip svg { flex-shrink: 0; }
.chip.good { color: var(--ok-text); background: var(--ok-soft); border-color: var(--ok-line); }
.chip.warn { color: var(--warn-text); background: var(--warn-soft); border-color: var(--warn-line); }
.chip.bad { color: var(--bad-text); background: var(--bad-soft); border-color: var(--bad-line); }
.chip.accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.chip .mono { font-family: var(--mono); font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.verified { color: var(--ok-text); background: var(--ok-soft); }
.badge.indexed { color: var(--accent); background: var(--accent-soft); }
.badge.retracted { color: var(--bad-text); background: var(--bad-soft); }
.badge.preprint { color: var(--warn-text); background: var(--warn-soft); }

.vdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.vdot.verified { background: var(--ok); }
.vdot.indexed { background: var(--accent-bright); }
.vdot.retracted { background: var(--bad); }
.vdot.preliminary { background: var(--warn); }

/* ------------------------------------------------------------ sections */

.section {
  margin-top: 24px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 11px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.section-label .count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
  color: var(--text-muted);
}

.section-label .spacer { flex: 1; }

/* ------------------------------------------------------- source cards */

/* Solid, not glass: a source is data and has to read cleanly. */
.sources { display: flex; flex-direction: column; gap: 8px; }

.source {
  position: relative;
  padding: 14px 16px 13px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--card);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.3s ease;
}

.source:hover { background: var(--card-hover); }

.source.flash { animation: flash 1.6s var(--ease-out); }

@keyframes flash {
  0%   { box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent-bright); }
  100% { box-shadow: 0 0 0 0 transparent; border-color: var(--border-hair); }
}

.source.is-retracted { background: var(--bad-soft); border-color: var(--bad-line); }

.source-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 11px;
  align-items: start;
}

.source-num {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 1px;
}

.source-num.plain { background: var(--surface-3); color: var(--text-muted); }

.source-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.42;
  color: var(--text);
  overflow-wrap: anywhere;
}

.source-title a { color: inherit; text-decoration: none; }
.source-title a:hover { color: var(--accent); }

.source-side { display: inline-flex; align-items: center; gap: 6px; }

.source-meta {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.source-meta .sep { margin: 0 6px; opacity: 0.45; }

.source-body { grid-column: 2 / -1; min-width: 0; }

.source-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 9px;
  font-size: 12px;
}

.id-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.id-link:hover { text-decoration: underline; text-underline-offset: 2px; }

.via {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
  font-size: 11.5px;
}

.via .prov {
  padding: 1px 7px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10.5px;
}

.why-line {
  margin: 8px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent-line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}

.retraction-note {
  margin: 8px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--bad-text);
}

.rel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.rel-track {
  flex: 1;
  max-width: 220px;
  height: 4px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  overflow: hidden;
}

.rel-fill {
  height: 100%;
  border-radius: var(--r-sm);
  background: var(--accent-bright);
  transform-origin: left;
  animation: grow 0.8s var(--ease-out) both;
}

@keyframes grow { from { transform: scaleX(0); } }

.rel-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.rel-label { font-size: 11px; color: var(--text-faint); }

details.read { margin-top: 9px; }

details.read summary,
details.fold summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--r-xs);
}

details.read summary::-webkit-details-marker,
details.fold summary::-webkit-details-marker { display: none; }

details.read summary:hover,
details.fold summary:hover { color: var(--accent); }

details summary .chev { transition: transform 0.25s var(--ease-out); }
details[open] > summary .chev { transform: rotate(90deg); }

.read-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.read-body .passage + .passage { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-hair); }
.read-body .passage-label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 3px; }

/* bookmark star */
.star-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-faint);
  transition: color 0.15s ease, background 0.15s ease, transform 0.2s var(--ease-spring);
}

.star-btn:hover { color: var(--accent); background: var(--surface-3); }
.star-btn.is-saved { color: #E0A82E; }
.star-btn.is-saved svg { fill: currentColor; }
.star-btn.pop { animation: pop 0.4s var(--ease-spring); }

@keyframes pop { 50% { transform: scale(1.3); } }

/* ------------------------------------------------------------ claim audit */

details.fold {
  margin-top: 18px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--card);
}

details.fold > summary {
  display: flex;
  width: 100%;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-2);
}

details.fold > summary .grow { flex: 1; }
details.fold > summary .fold-meta { font-weight: 500; color: var(--text-muted); font-size: 12px; }

.fold-body { padding: 0 14px 14px; }

.audit-bar {
  display: flex;
  height: 6px;
  width: 92px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
}

.audit-bar span { display: block; height: 100%; }
.audit-bar .s { background: var(--ok); }
.audit-bar .p { background: var(--warn); }
.audit-bar .c { background: var(--bad); }

.claims { display: flex; flex-direction: column; gap: 8px; }

.claim {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-hair);
}

.claim-mark {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.claim-mark.supported { background: var(--ok-soft); color: var(--ok-text); }
.claim-mark.preliminary { background: var(--warn-soft); color: var(--warn-text); }
.claim-mark.contradicted { background: var(--bad-soft); color: var(--bad-text); }

.claim-text { font-size: 13.5px; font-weight: 550; line-height: 1.5; color: var(--text); }

.claim-tags { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: 5px; font-size: 11.5px; color: var(--text-muted); }
.claim-tags .tag { display: inline-flex; align-items: center; gap: 4px; }
.claim-tags .tag.s { color: var(--ok-text); }
.claim-tags .tag.p { color: var(--warn-text); }
.claim-tags .tag.c { color: var(--bad-text); }
.claim-tags .cite { font-size: 10.5px; }

/* --------------------------------------------------------- provenance row */

.seal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 11px 12px 11px 14px;
  border-radius: var(--r-lg);
  border: 1px dashed var(--accent-line);
  background: var(--accent-soft);
}

.seal-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--accent);
  flex-shrink: 0;
}

.seal-text { flex: 1; min-width: 180px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.seal-text strong { color: var(--text); font-weight: 700; }
.seal-text .mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }

.verify-panel {
  flex-basis: 100%;
  margin-top: 2px;
  padding: 12px 13px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1px solid var(--border-hair);
  font-size: 12px;
  animation: rise 0.3s var(--ease-out);
}

.verify-ok, .verify-fail {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 9px;
}

.verify-ok { color: var(--ok-text); }
.verify-fail { color: var(--bad-text); }

.kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 14px;
  align-items: baseline;
}

.kv dt { color: var(--text-muted); font-size: 12px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--text); overflow-wrap: anywhere; }
.kv dd.prose-dd { font-family: inherit; font-size: 12.5px; color: var(--text-2); }

/* --------------------------------------------------------------- actions */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.18s var(--ease-spring);
}

.ghost-btn:hover { background: var(--card-hover); border-color: var(--accent-line); color: var(--accent); }
.ghost-btn:active { transform: scale(0.96); }
.ghost-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.ghost-btn.is-done { color: var(--ok-text); border-color: var(--ok-line); }

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 15px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--btn-fill);
  color: var(--btn-text);
  font-size: 12.5px;
  font-weight: 700;
  transition: transform 0.14s var(--ease-spring), background 0.18s ease;
}

/* Flat, not bubbly: a fill and nothing else, so there is no glow for a
   scrolling list to clip. */
.primary-btn:hover { background: var(--btn-fill-hover); }
.primary-btn:active { background: var(--btn-fill-active); transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* --------------------------------------------------------- thinking state */

.thinking .skeleton { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; max-width: 560px; }

.skel {
  height: 11px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-3) 0%, color-mix(in srgb, var(--accent-bright) 16%, var(--surface-3)) 50%, var(--surface-3) 100%);
  background-size: 220% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skel:nth-child(1) { width: 92%; }
.skel:nth-child(2) { width: 78%; animation-delay: 0.12s; }
.skel:nth-child(3) { width: 54%; animation-delay: 0.24s; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

.stage-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.stage-line .elapsed { font-family: var(--mono); font-weight: 500; font-size: 12px; color: var(--text-faint); }

.spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent-bright);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------- deep research */

.plan {
  margin-top: 4px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--card);
  overflow: hidden;
}

.plan-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border-hair);
}

.plan-head .title { flex: 1; font-size: 13.5px; font-weight: 700; color: var(--text); }
.plan-head .sub { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.plan-progress {
  height: 3px;
  background: var(--surface-3);
}

.plan-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-bright);
  transition: width 0.6s var(--ease-out);
}

.steps { list-style: none; margin: 0; padding: 6px 0; }

.step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: start;
  padding: 9px 15px;
}

.step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border-hair);
  color: transparent;
  margin-top: 1px;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.step.running .step-dot { border-color: var(--accent-bright); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.step.done .step-dot { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-text); }
.step.failed .step-dot { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-text); }

.step-goal { font-size: 13px; font-weight: 650; color: var(--text); line-height: 1.4; }
.step.queued .step-goal { color: var(--text-muted); }
.step-query { grid-column: 2; font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); overflow-wrap: anywhere; }
.step-found { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1px solid var(--border-hair);
  font-size: 12px;
  color: var(--text-muted);
}

.stat b { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }

/* ------------------------------------------------------------- errors */

.error-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-lg);
  background: var(--bad-soft);
  border: 1px solid var(--bad-line);
  color: var(--bad-text);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.5;
}

.error-card .actions { margin-top: 10px; }

.note {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-hair);
  font-size: 13px;
  color: var(--text-2);
  margin-top: 14px;
}

.notice.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.notice.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-text); }
.notice svg { flex-shrink: 0; margin-top: 2px; }

/* --------------------------------------------------- filters + composer */

.dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Thea's modes sit right above the composer they change, centred on it.
   Where she looks and the search filters live inside the composer. */
.dock-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.mode-seg {
  background: var(--glass-fill-chrome);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm), var(--glass-inset);
  border: 1px solid var(--border);
}

.mode-seg .seg-btn { min-height: 30px; padding: 0 13px; font-size: 12.5px; }

.dock-tools { display: flex; align-items: center; gap: 6px; min-width: 0; }

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  max-width: 260px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--glass-fill-chrome);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm), var(--glass-inset);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.18s var(--ease-spring);
}

.tool-chip > span { overflow: hidden; text-overflow: ellipsis; }
.tool-chip:hover, .tool-chip[aria-expanded="true"], .tool-chip.is-on { border-color: var(--accent-line); color: var(--accent); }
.tool-chip:active { transform: scale(0.97); }
.tool-chip.is-lib { color: var(--accent); }
.tool-chip svg { flex-shrink: 0; }
.filters .tool-chip { box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--card); border-color: var(--border-hair); min-height: 30px; }

.chip-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-sm);
  display: inline-grid;
  place-items: center;
  background: var(--accent-fill);
  color: var(--accent-on);
  font-family: var(--mono);
  font-size: 10.5px;
}

/* Attached papers and a "focus on these papers" chip, above the composer. */
.attach-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
}

.tray-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 30px;
  padding: 0 4px 0 11px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  animation: rise 0.3s var(--ease-out) both;
}

.tray-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-chip.focus { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.tray-chip svg { flex-shrink: 0; }
.tray-x { width: 22px; height: 22px; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--text-faint); }
.tray-x:hover { background: var(--surface-3); color: var(--text); }
.tray-note { font-size: 11.5px; color: var(--text-faint); padding-left: 4px; }

.filters-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.38s var(--ease-out), opacity 0.3s ease;
  opacity: 0;
}

.filters-wrap.is-open { grid-template-rows: 1fr; opacity: 1; }
.filters-wrap > .filters-inner { overflow: hidden; min-height: 0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 10px 14px;
  margin: 1px;
  border-radius: var(--r-lg);
  background: var(--glass-fill-chrome);
  box-shadow: var(--shadow-sm), var(--glass-edge);
}

.filter-group { display: inline-flex; align-items: center; gap: 8px; }

.filter-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.year-input {
  width: 74px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--card);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.year-input::-webkit-outer-spin-button,
.year-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.year-input::placeholder { color: var(--text-faint); font-family: var(--sans); }
.year-input:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }

.dash { color: var(--text-faint); }

/* iOS switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  user-select: none;
}

.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch .track {
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-hair);
  position: relative;
  transition: background 0.25s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 30, 68, 0.25);
  transition: transform 0.3s var(--ease-spring), width 0.2s ease;
}

.switch input:checked + .track { background: var(--accent-fill); box-shadow: none; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2.5px solid var(--accent-bright); outline-offset: 2px; }

.link-btn {
  border: 0;
  background: none;
  padding: 4px 2px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}

.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* The composer: its own glass card under the transcript. The question
   gets the full width; underneath it, a row of tools: add papers, where
   Thea looks, filters, then dictation and send on the right. */
.composer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: var(--r-lg);
  background: var(--glass-fill-composer);
  transition: box-shadow 0.25s ease;
}

.composer:focus-within {
  box-shadow: var(--shadow), var(--glass-inset), 0 0 0 3px var(--focus-ring);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.composer-tools .grow { flex: 1 1 auto; }

.composer .tool-chip {
  min-height: 32px;
  background: transparent;
  border-color: var(--border-hair);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--text-muted);
}

.composer .tool-chip:hover,
.composer .tool-chip[aria-expanded="true"],
.composer .tool-chip.is-on { background: var(--surface-3); color: var(--accent); border-color: var(--accent-line); }
.composer .tool-chip.is-lib { color: var(--accent); }
.tc-chev { opacity: 0.6; }

.composer-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.2s ease, color 0.2s ease, transform 0.18s var(--ease-spring);
}

.composer-btn:hover { background: var(--surface-3); color: var(--accent); }
.composer-btn:active { transform: scale(0.92); }

/* Dictation: the ring breathes with your voice while listening. */
.mic-btn { position: relative; }
.mic-btn::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent-soft);
  transform: scale(var(--level, 0));
  opacity: 0;
  transition: transform 0.08s linear, opacity 0.2s ease;
}
.mic-btn svg { position: relative; }
.mic-btn.is-listening { color: #fff; background: var(--danger-fill); }
.mic-btn.is-listening::before { opacity: 1; background: rgba(214, 69, 93, 0.28); inset: -5px; transform: scale(calc(0.86 + var(--level, 0) * 0.5)); }
.mic-btn.is-working { color: var(--accent); }
.mic-btn.is-working svg { animation: breathe-o 1s ease-in-out infinite; }
@keyframes breathe-o { 50% { opacity: 0.35; } }
.mic-btn.is-unavailable { opacity: 0.45; }

.dictation-live {
  color: var(--text-faint);
}

.composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 168px;
  padding: 9px 12px 6px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 22px;
}

.composer textarea::placeholder { color: var(--text-faint); }

.send-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--btn-fill);
  color: #fff;
  transition: transform 0.14s var(--ease-spring), opacity 0.2s ease, background 0.18s ease;
}

.send-btn:hover { background: var(--btn-fill-hover); }
.send-btn:active { background: var(--btn-fill-active); transform: scale(0.94); }
.send-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.send-btn .ico-stop { display: none; }
.send-btn.is-busy { background: #4A5465; }
.send-btn.is-busy .ico-send { display: none; }
.send-btn.is-busy .ico-stop { display: block; }

.composer-note {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 0 12px;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
}

.composer-note .keys { display: inline-flex; gap: 4px; align-items: center; }
.composer-note .note-short { display: none; }

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-hair);
  background: var(--card);
  color: var(--text-muted);
}

/* ------------------------------------------------------------ side panel */

.side {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
}

.side-head { padding: 16px 16px 0; }
.side-head .seg-btn { font-size: 13px; }

.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
}


.pane { padding: 20px 20px 24px; animation: pane-in 0.35s var(--ease-out); }

@keyframes pane-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.pane-label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-label .grow { flex: 1; }
.pane-label .mono { font-family: var(--mono); letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--text-muted); }

.pane-section { margin-top: 24px; }
.pane-section:first-child { margin-top: 0; }

.big-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.big-num {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--text);
}

.big-unit { font-size: 14px; font-weight: 650; color: var(--text-2); }
.big-delta { font-size: 13px; font-weight: 650; color: var(--ok-text); }
.big-delta.muted { color: var(--text-muted); }

.pane-sub {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.meters { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }

.meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
}

.meter-name { font-size: 13px; font-weight: 550; color: var(--text-2); }
.meter-val { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--accent); }

.meter-track { height: 7px; border-radius: var(--r-sm); background: var(--surface-3); overflow: hidden; }

.meter-fill {
  height: 100%;
  border-radius: var(--r-sm);
  background: var(--accent-bright);
  transform-origin: left;
  transition: width 0.7s var(--ease-out);
}

.meter-fill.ok { background: var(--ok); }
.meter-fill.low { background: color-mix(in srgb, var(--accent-bright) 40%, transparent); }

/* pipeline */
.pipeline { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }

.pipe {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 11px;
  padding: 0 0 15px;
}

.pipe::before {
  content: "";
  position: absolute;
  left: 9.5px;
  top: 22px;
  bottom: 2px;
  width: 1px;
  background: var(--border-hair);
}

.pipe:last-child::before { display: none; }
.pipe:last-child { padding-bottom: 0; }

.pipe-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border-hair);
  background: var(--surface-solid);
  color: transparent;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.pipe.running .pipe-dot {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: breathe 1.4s ease-in-out infinite;
}

.pipe.done .pipe-dot { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-text); }
.pipe.skipped .pipe-dot { background: var(--surface-3); border-color: transparent; }

@keyframes breathe {
  50% { box-shadow: 0 0 0 7px transparent; }
}

.pipe-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 20px; }
.pipe.queued .pipe-name { color: var(--text-faint); font-weight: 550; }
.pipe-detail { font-size: 12px; color: var(--text-muted); line-height: 1.45; margin-top: 1px; }

/* provider status */
.prov-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.prov-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: var(--card);
  border: 1px solid var(--border-hair);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.prov-chip.failed { color: var(--bad-text); border-color: var(--bad-line); background: var(--bad-soft); }

/* list rows (claims in the panel, library rows) */
.rows { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--border-hair);
  text-align: left;
  width: 100%;
  color: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s var(--ease-spring);
}

button.row:hover, a.row:hover { background: var(--card-hover); border-color: var(--accent-line); }
button.row:active { transform: scale(0.985); }

.row-lead {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
}

.row-lead.ok { background: var(--ok-soft); color: var(--ok-text); }
.row-lead.warn { background: var(--warn-soft); color: var(--warn-text); }
.row-lead.bad { background: var(--bad-soft); color: var(--bad-text); }

.row-main { min-width: 0; }
.row-title { display: block; font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-sub { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { color: var(--text-faint); display: inline-flex; align-items: center; gap: 4px; }

.row .x-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--text-faint);
}

.row .x-btn:hover { background: var(--bad-soft); color: var(--bad-text); }

.empty {
  margin-top: 10px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px dashed var(--border-hair);
  background: var(--surface-2);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.empty strong { display: block; color: var(--text); font-size: 13px; margin-bottom: 3px; }

.legend-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.legend-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.legend-row strong { color: var(--text); font-weight: 650; }
.legend-row .vdot { margin-top: 5px; }

/* guide */
.guide-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.guide-title em { font-style: normal; color: var(--accent); }

.mode-rows .row-lead { font-family: inherit; }
.mode-rows .row.is-current { border-color: var(--accent-line); background: var(--accent-soft); }

.trust-steps { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.trust-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.trust-steps strong { display: block; color: var(--text); font-size: 13px; font-weight: 650; }
.trust-steps .n { width: 24px; height: 24px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--mono); font-size: 11.5px; font-weight: 600; }

.privacy-text { margin: 10px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.privacy-text strong { color: var(--text-2); }

.chip-col { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.chip-col .chip-btn { width: 100%; justify-content: flex-start; border-radius: var(--r-md); padding: 10px 13px; min-height: 0; line-height: 1.4; }

/* ----------------------------------------------------- popover + sheets */

.popover {
  position: fixed;
  z-index: 60;
  width: min(340px, calc(100vw - 24px));
  padding: 13px 14px;
  border-radius: var(--r-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.2s var(--ease-out);
  box-shadow: var(--shadow-lift), var(--glass-edge);
}

.popover.is-open { opacity: 1; transform: none; }

/* A preview is a reading surface: denser glass than the chrome, so the line
   it floats over never competes with the title inside it. */
.popover.glass { background: var(--menu-fill); }
.popover .pv-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.popover .pv-num { font-family: var(--mono); font-size: 11.5px; color: var(--accent); font-weight: 600; }
.popover .pv-title { font-size: 13.5px; font-weight: 700; line-height: 1.4; color: var(--text); }
.popover .pv-meta { margin-top: 5px; font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.popover .pv-id { margin-top: 7px; font-family: var(--mono); font-size: 11px; color: var(--accent); overflow-wrap: anywhere; }
.popover .pv-hint { margin-top: 8px; font-size: 11px; color: var(--text-faint); }

dialog.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 48px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text);
  background: var(--glass-fill);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lift), var(--glass-edge);
  overflow: visible;
}

dialog.sheet[open] { animation: sheet-in 0.38s var(--ease-out); }

dialog.sheet::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  animation: fade-in 0.3s ease;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade-in { from { opacity: 0; } }

.sheet-inner { position: relative; z-index: 2; max-height: inherit; overflow-y: auto; padding: 22px 24px 24px; border-radius: inherit; }

.sheet-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.sheet-head .grow { flex: 1; min-width: 0; }
.sheet-title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.025em; }
.sheet-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.status-big {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--border-hair);
}

.status-big .ring {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.status-big .ring.ok { background: var(--ok-soft); color: var(--ok-text); }
.status-big .ring.bad { background: var(--bad-soft); color: var(--bad-text); }
.status-big .ring.idle { background: var(--surface-3); color: var(--text-muted); }
.status-big .label { font-size: 15px; font-weight: 750; }
.status-big .detail { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.sheet .kv { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border-hair); }

/* mobile side sheet: the same panel, sliding up */
.side-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.side-open .side-backdrop { opacity: 1; pointer-events: auto; }

.side-grabber { display: none; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s var(--ease-spring);
  box-shadow: var(--shadow-lift), var(--glass-edge);
}

.toast.is-open { opacity: 1; transform: translate(-50%, 0); }
.toast .t-ico { color: var(--ok-text); display: inline-grid; }
.toast.is-error .t-ico { color: var(--bad-text); }

/* ------------------------------------------------------ library in Thea */

.source.is-library { background: color-mix(in srgb, var(--accent-soft) 55%, var(--card)); border-color: var(--accent-line); }
.source-num.lib { background: var(--accent-fill); color: var(--accent-on); }
.badge.library { color: var(--accent); background: var(--accent-soft); }
.badge.unverified { color: var(--warn-text); background: var(--warn-soft); }
.badge.registered { color: var(--accent); background: var(--accent-soft); }
.badge.mismatch { color: var(--warn-text); background: var(--warn-soft); }
.badge.not-found { color: var(--text-muted); background: var(--surface-3); }
.badge.checking, .badge.unknown { color: var(--text-muted); background: var(--surface-3); }
.lib-key { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--accent); }
.chip.lib { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.chip.tiny { min-height: 22px; padding: 1px 8px; font-size: 11px; }
.vdot.library { background: var(--accent-fill); box-shadow: 0 0 0 2px var(--accent-soft); }
.cite.is-lib { background: var(--accent-fill); color: var(--accent-on); }
.cite.is-lib:hover { filter: brightness(1.12); }
.needs-cite {
  display: inline-block;
  padding: 0 6px;
  border-radius: var(--r-xs);
  background: var(--warn-soft);
  color: var(--warn-text);
  font-size: 0.78em;
  font-weight: 650;
  vertical-align: 0.08em;
}
.id-link.as-btn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-family: var(--mono); font-size: 11.5px; }
.id-link.lib-access { color: var(--ok-text); }

.lib-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-faint);
  transition: color 0.15s ease, background 0.15s ease, transform 0.2s var(--ease-spring);
}
.lib-btn:hover { color: var(--accent); background: var(--surface-3); }
.lib-btn.is-in { color: var(--ok-text); }
.lib-btn:disabled { opacity: 0.5; }
.label-note { text-transform: none; letter-spacing: 0; font-weight: 500; }
.popover .pv-passage { margin-top: 7px; padding-left: 9px; border-left: 2px solid var(--accent-line); font-size: 12px; line-height: 1.5; color: var(--text-2); }

.bubble-files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.bubble-files .bf {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 600;
}

/* paper checks */
.paper-checks { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.paper-check {
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: var(--card);
  overflow: hidden;
  animation: rise 0.35s var(--ease-out) both;
}

.pc-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 13px 14px; }
.pc-verdict {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-muted);
}
.pc-verdict.verified { background: var(--ok-soft); color: var(--ok-text); }
.pc-verdict.registered { background: var(--accent-soft); color: var(--accent); }
.pc-verdict.mismatch, .pc-verdict.error { background: var(--warn-soft); color: var(--warn-text); }
.pc-verdict.retracted { background: var(--bad-soft); color: var(--bad-text); }
.pc-verdict.not-found { background: var(--surface-3); color: var(--text-muted); }
.pc-title { font-size: 14px; font-weight: 650; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.pc-meta { margin-top: 3px; font-size: 12px; color: var(--text-muted); }
.pc-meta .sep { margin: 0 6px; opacity: 0.45; }
.pc-verdict-text { margin-top: 5px; font-size: 12.5px; font-weight: 650; color: var(--text-muted); }
.pc-verdict-text.verified { color: var(--ok-text); }
.pc-verdict-text.registered { color: var(--accent); }
.pc-verdict-text.mismatch, .pc-verdict-text.error { color: var(--warn-text); }
.pc-verdict-text.retracted { color: var(--bad-text); }
.pc-body { padding: 0 14px 13px 58px; }
.pc-body .stage-line { margin-top: 2px; font-size: 12.5px; }

.signals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.sig { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 7px; align-items: start; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.sig svg { margin-top: 2px; }
.sig.ok svg { color: var(--ok-text); }
.sig.warn svg { color: var(--warn-text); }
.sig.bad svg { color: var(--bad-text); }
.sig.bad { color: var(--bad-text); font-weight: 600; }

.paper-summary { margin-top: 10px; padding: 11px 13px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border-hair); }
.ps-label { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 5px; }
.paper-summary p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.ps-findings { margin: 7px 0 0; padding-left: 1.2em; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.ps-findings li { margin: 2px 0; }

.ghost-btn.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }
.ghost-btn.wide { width: 100%; justify-content: center; }
.ghost-btn.danger-text { color: var(--bad-text); }
.ghost-btn.danger-text:hover { border-color: var(--bad-line); color: var(--bad-text); }
.primary-btn.danger { background: var(--danger-fill); }
.primary-btn.danger:hover { background: var(--danger-fill-hover); }
.primary-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* hero additions */
.hero-project {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 5px 12px 5px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-hair);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.hero-project .sep { opacity: 0.45; }
.hero-upload {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  width: min(480px, 100%);
  padding: 14px 16px;
  border: 1.5px dashed var(--accent-line);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--accent);
  text-align: left;
  transition: background 0.2s ease, transform 0.18s var(--ease-spring);
}
.hero-upload:hover { background: color-mix(in srgb, var(--accent-bright) 14%, transparent); }
.hero-upload span { font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.hero-upload strong { display: block; font-size: 13.5px; color: var(--accent); }
.hero-upload svg { flex-shrink: 0; }

/* history rows: the whole row opens, the bin deletes */
.row .row-hit {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
}
.row:has(.row-hit) { grid-template-columns: minmax(0, 1fr) auto; }
.row:has(.row-hit):hover { background: var(--card-hover); border-color: var(--accent-line); }
.row.is-current { border-color: var(--accent-line); background: var(--accent-soft); }

/* ----------------------------------------------------------------- menus */

.menu {
  position: fixed;
  z-index: 80;
  max-width: min(360px, calc(100vw - 20px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--r-lg);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.22s var(--ease-out);
  box-shadow: var(--shadow-lift), var(--glass-edge);
  background: var(--menu-fill);
}

.menu.is-open { opacity: 1; transform: none; }

.menu-head { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint); }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--border-hair); }

.menu-item {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 550;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-item:disabled { opacity: 0.45; cursor: default; background: transparent; }
.menu-item.danger { color: var(--bad-text); }
.menu-item .mi-ico { display: grid; place-items: center; color: var(--accent); }
.menu-item .mi-main { min-width: 0; display: flex; flex-direction: column; }
.menu-item .mi-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-sub { font-size: 11.5px; font-weight: 500; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item.is-checked .mi-label { font-weight: 700; color: var(--accent); }

/* -------------------------------------------------------- sheet fields */

dialog.sheet.wide { width: min(760px, calc(100vw - 32px)); }
dialog.sheet.xwide { width: min(980px, calc(100vw - 32px)); }
.sheet-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.sheet-text { margin: 0 0 6px; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.sheet-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.sheet-actions .grow { flex: 1; }

.field-label { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 650; color: var(--text-2); }
.field-label:first-child { margin-top: 0; }
.field-label .opt { font-weight: 500; color: var(--text-faint); margin-left: 4px; }

.field {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--text-faint); }
textarea.field { min-height: 80px; }
select.field { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: var(--r-sm); border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); transition: transform 0.18s var(--ease-spring); }
.swatch:hover { transform: scale(1.08); }
.swatch.is-on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface-solid) inset; }

/* --------------------------------------------------------- drop overlay */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--scrim);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.drop-overlay.is-on { opacity: 1; }
.drop-card {
  width: min(460px, calc(100vw - 40px));
  padding: 30px 28px;
  border-radius: var(--r-lg);
  text-align: center;
  border: 2px dashed var(--accent-line);
  transform: scale(0.96);
  transition: transform 0.3s var(--ease-spring);
}
.drop-overlay.is-on .drop-card { transform: none; }
.drop-ico { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: var(--r-lg); display: grid; place-items: center; color: #fff; background: var(--accent-fill); }
.drop-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.drop-sub { margin-top: 6px; font-size: 13px; line-height: 1.55; color: var(--text-muted); }

/* ------------------------------------------------------------ lock screen */

.lock { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; background: var(--scrim); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.lock-card { width: min(420px, 100%); padding: 32px 28px; border-radius: var(--r-lg); text-align: center; display: flex; flex-direction: column; align-items: center; }
.lock-form { display: flex; gap: 8px; width: 100%; margin-top: 20px; }
.lock-err { min-height: 18px; margin: 10px 0 0; font-size: 12.5px; color: var(--bad-text); }

.toast .t-act { margin-left: 4px; padding: 3px 10px; border: 0; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; pointer-events: auto; }
.toast.is-open { pointer-events: auto; }

/* --------------------------------------------------------- responsive */

/* Wide monitors: the side panel widens to show more at once; the chat
   column takes the rest and the message column below keeps lines readable. */
@media (min-width: 1800px) {
  :root { --side-w: 400px; }
  .thea-body { max-width: 860px; }
}

@media (min-width: 2400px) {
  :root { --side-w: 460px; }
  .thea-body { max-width: 940px; }
}

@media (max-width: 1240px) {
  :root { --side-w: 310px; }
  .composer-note .keys { display: none; }
  .project-btn { max-width: 200px; }
  .search-pill { width: min(320px, 100%); }
}

/* Below this there is no room to push the space aside: the rail expands
   over it instead, as a sheet with its own shadow. */
@media (max-width: 1180px) {
  body.rail-open { --rail-w: 54px; }
  body.rail-open .rail { width: var(--rail-open-w); box-shadow: var(--shadow-lift), var(--glass-inset); background: var(--menu-fill); }
}

@media (max-width: 1080px) {
  .brand-sub { display: none; }
  .mode-seg .label-full { display: none; }
  .mode-seg .label-short { display: inline; }
  .composer-note .note-long { display: none; }
  .composer-note .note-short { display: inline; }
  .search-pill { width: 40px; padding: 0; justify-content: center; color: var(--text-muted); }
  .search-pill .sp-text, .search-pill .sp-kbd { display: none; }
}

/* Tablet and phone: one column. The side panel becomes a sheet that slides
   up over the conversation. */
@media (max-width: 900px) {
  body { overflow: hidden; }

  .app { padding: 12px 12px 10px; gap: 12px; }
  .app-body { gap: 12px; }

  .app-header { gap: 10px; padding: 8px 8px 8px 10px; border-radius: var(--r-lg); }
  .head-left .head-divider { display: none; }
  .brand-text { display: none; }
  .project-btn { max-width: 240px; }
  .mode-toggle .seg-btn { padding: 0 12px; }

  .zones { grid-template-columns: minmax(0, 1fr); }

  .evidence-btn { display: inline-grid; }

  .side {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 50;
    height: min(78dvh, 640px);
    border-radius: var(--r-lg);
    transform: translateY(calc(100% + 24px));
    transition: transform 0.45s var(--ease-liquid);
    visibility: hidden;
  }

  body.side-open .side { transform: none; visibility: visible; }

  .side-grabber {
    display: block;
    width: 38px;
    height: 5px;
    border-radius: var(--r-xs);
    background: var(--border-hair);
    margin: 9px auto 0;
  }

  .side-head { padding-top: 10px; }

  .messages { padding: 14px 16px 26px; gap: 24px; }

  .toast { bottom: 96px; }
}

@media (min-width: 901px) {
  .evidence-btn { display: none; }
}

/* Phone: the rail becomes a bottom bar. A 54px column off the side of a
   390px screen is 14% of the width spent on navigation. The rarely used
   actions fold into one More button. */
@media (max-width: 640px) {
  :root { --rail-w: 0px; }
  body.rail-open { --rail-w: 0px; }
  .app { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .app-body { grid-template-columns: minmax(0, 1fr); }
  .spaces { grid-column: 1; }

  .rail,
  body.rail-open .rail {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(6px + env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    z-index: 60;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    border-radius: var(--r-lg);
    background: var(--menu-fill);
    box-shadow: var(--shadow), var(--glass-inset);
  }

  .rail-group { flex-direction: row; gap: 0; }
  .rail-top { flex: 1 1 auto; justify-content: space-around; }
  .rail-btn { flex-direction: column; justify-content: center; gap: 0; width: auto; min-width: 42px; min-height: 46px; padding: 0 7px; }
  .rail-label, body.rail-open .rail-label { display: none; }
  .rail-bottom > .rail-btn:not(.rail-more), .rail-sep { display: none; }
  .rail-more { display: flex; }
  .rail-count, body.rail-open .rail-count { left: 50%; right: auto; top: 4px; margin-left: 2px; background: var(--accent-fill); color: var(--accent-on); }
}

@media (max-width: 560px) {
  .brand { display: none; }
  .header-actions { gap: 2px; }
  .icon-btn { width: 38px; height: 38px; }
  .project-btn { height: 40px; max-width: none; }
  .proj-label { display: none; }
  .mode-toggle .seg-btn { min-height: 34px; padding: 0 10px; }
  .mode-toggle .seg-label { display: none; }

  .mode-seg { flex: 1 1 100%; }
  .mode-seg .seg-btn { flex: 1 1 0; padding: 0 6px; }

  .msg-thea { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .thea-avatar { display: none; }
  .bubble-user { max-width: 88%; }
  .eyebrow { margin-top: 0; }

  .source { padding: 12px 13px; }
  .source-head { grid-template-columns: auto minmax(0, 1fr); }
  .source-side { grid-column: 1 / -1; justify-content: flex-end; margin-top: -2px; order: 3; }
  .source-body { grid-column: 1 / -1; }
  .pc-body { padding-left: 14px; }

  .hero { padding-top: 4px; }
  .hero-mark { width: 52px; height: 52px; border-radius: var(--r-lg); margin-bottom: 16px; }
  .hero-title { font-size: 25px; }
  .hero-sub { font-size: 14px; }
  .hero-chips { margin-top: 20px; }
  .hero-pillars { gap: 8px 14px; margin-top: 22px; padding-top: 16px; }
  .composer-note .keys { display: none; }
  .composer-note .note-long { display: none; }
  .composer-note .note-short { display: inline; }
  .composer-btn { width: 36px; height: 36px; }
  .composer .tool-chip { padding: 0 9px; max-width: 150px; }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 14px;
    padding: 9px 12px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .filters::-webkit-scrollbar { display: none; }
  .filter-group, .switch, .link-btn, .filters .tool-chip { flex-shrink: 0; }
  .year-input { width: 62px; }
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .msg, .hero, .pane, .verify-panel, dialog.sheet[open] { animation: none; }
  .seg-pill { transition: opacity 0.2s ease; }
  .app-body, .rail-label, .rail-expand svg { transition: none; }
  .skel { animation: none; }
  .rel-fill { animation: none; }
  .side { transition: none; }
  .space, .tray-chip, .paper-check { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- print */

.print-root { display: none; }

@media print {
  body { overflow: visible; background: #fff; }
  .app-header, .rail, .side, .dock, .actions, .lib-btn, .thread-bar { display: none !important; }
  .zones { display: block; }
  .messages { mask-image: none; -webkit-mask-image: none; overflow: visible; height: auto; }
  .glass { box-shadow: none; backdrop-filter: none; background: #fff; border: 0; }
  body.printing > :not(.print-root) { display: none !important; }
  body.printing .print-root { display: block; }
}

/* ================================================================
   SCROLLBARS: one treatment, everywhere, as in the tutor.
   The platform's thin bar (arrow, pill, arrow) with a transparent track,
   so nothing rectangular ever sits against a rounded card edge. Chromium
   and Firefox use the standard properties; Safari, which ignores them,
   gets the same slim pill through its own pseudo-elements.
   ================================================================ */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: var(--r-pill); min-height: 42px; }
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* a sheet or the palette takes focus as a whole when it opens; the ring
   belongs on the controls inside, not around the panel */
dialog:focus, dialog:focus-visible { outline: none; }
