/* ===========================================================================
   Academica — clinical design system
   =========================================================================== */
:root, :root[data-theme="light"] {
  color-scheme: light;
  /* brand */
  --teal: #0e7c7b;
  --teal-dark: #0a5e5d;
  --teal-50: #e6f3f3;
  --accent: #0e7c7b;
  --accent-2: #6d5efc;                 /* violet — bolder secondary accent */
  --grad: linear-gradient(135deg, #12938f 0%, #0a5e5d 100%);
  --grad-brand: linear-gradient(120deg, #0e7c7b 0%, #17a29e 52%, #6d5efc 128%);
  --on-accent: #ffffff;
  /* neutrals */
  --ink: #131a24;
  --ink-soft: #43515f;
  --muted: #6a7889;
  --line: #e3e8ef;
  --line-soft: #eef2f7;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  /* frosted / glass surfaces (theme-aware) */
  --frost: rgba(255, 255, 255, .82);
  --glass: rgba(255, 255, 255, .55);
  --glass-border: rgba(255, 255, 255, .66);
  --hover: rgba(20, 40, 60, .05);
  --code-bg: #0f1b24;
  --code-fg: #e6edf3;
  /* status */
  --danger: #d64545;
  --danger-soft: #fdecec;
  /* elevation */
  --shadow-sm: 0 1px 2px rgba(20, 40, 60, .06);
  --shadow: 0 4px 16px rgba(20, 40, 60, .10);
  --shadow-glow: 0 10px 40px -8px rgba(14, 124, 123, .35);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --ease-spring: cubic-bezier(.16, 1, .3, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --teal: #2dd4bf;
  --teal-dark: #7ff0e0;
  --teal-50: rgba(45, 212, 191, .14);
  --accent: #2dd4bf;
  --accent-2: #8b7bff;
  --grad: linear-gradient(135deg, #16b3a4 0%, #0c8f84 100%);
  --grad-brand: linear-gradient(120deg, #2dd4bf 0%, #29b6c9 52%, #8b7bff 128%);
  --on-accent: #062521;
  --ink: #e8eef4;
  --ink-soft: #b3bec9;
  --muted: #808d9c;
  --line: #273140;
  --line-soft: #1b2530;
  --bg: #0b1016;
  --surface: #141c25;
  --surface-2: #1a232e;
  --frost: rgba(16, 22, 30, .82);
  --glass: rgba(30, 40, 52, .5);
  --glass-border: rgba(255, 255, 255, .10);
  --hover: rgba(255, 255, 255, .06);
  --code-bg: #0a1219;
  --code-fg: #dbe4ec;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 34px rgba(0, 0, 0, .55);
  --shadow-glow: 0 10px 44px -8px rgba(45, 212, 191, .4);
}

/* No-JS fallback: honour the OS preference until the app sets data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --teal: #2dd4bf; --teal-dark: #7ff0e0; --teal-50: rgba(45,212,191,.14);
    --accent: #2dd4bf; --accent-2: #8b7bff;
    --grad: linear-gradient(135deg, #16b3a4 0%, #0c8f84 100%);
    --grad-brand: linear-gradient(120deg, #2dd4bf 0%, #29b6c9 52%, #8b7bff 128%);
    --on-accent: #062521;
    --ink: #e8eef4; --ink-soft: #b3bec9; --muted: #808d9c;
    --line: #273140; --line-soft: #1b2530;
    --bg: #0b1016; --surface: #141c25; --surface-2: #1a232e;
    --frost: rgba(16,22,30,.82); --glass: rgba(30,40,52,.5); --glass-border: rgba(255,255,255,.10);
    --hover: rgba(255,255,255,.06); --code-bg: #0a1219; --code-fg: #dbe4ec;
    --danger: #f87171; --danger-soft: rgba(248,113,113,.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 10px 34px rgba(0,0,0,.55);
    --shadow-glow: 0 10px 44px -8px rgba(45,212,191,.4);
  }
}

/* ===========================================================================
   Theme flavors — ride ON TOP of a base mode. data-theme stays light/dark (so
   every mode-keyed rule keeps working); data-flavor overrides the palette.
   Placed after both base blocks so they win on equal specificity.
   =========================================================================== */
/* Paper — warm sepia reading light */
:root[data-flavor="paper"] {
  --bg: #f4eee1; --surface: #fbf7ec; --surface-2: #f0e9d9;
  --line: #e2d8c2; --line-soft: #ebe3d1;
  --ink: #2f2a20; --ink-soft: #5a5240; --muted: #8b8068;
  --hover: rgba(80, 60, 20, .06);
  --frost: rgba(251, 247, 236, .85); --glass: rgba(251, 247, 236, .55); --glass-border: rgba(255, 255, 255, .6);
  --shadow-sm: 0 1px 2px rgba(80, 60, 20, .08); --shadow: 0 4px 16px rgba(80, 60, 20, .12);
  --teal: #0b6e5f; --teal-dark: #095648; --teal-50: rgba(11, 110, 95, .12); --accent: #0b6e5f;
  --code-bg: #2c261b; --code-fg: #f0e9d9;
}
/* Slate — cool blue-grey dark, softer than the default */
:root[data-flavor="slate"] {
  --bg: #161b25; --surface: #1e2533; --surface-2: #252d3d;
  --line: #333d50; --line-soft: #2a3344;
  --ink: #e6ebf3; --ink-soft: #b7c1cf; --muted: #8592a6;
  --frost: rgba(30, 37, 51, .84); --glass: rgba(40, 50, 68, .55);
  --hover: rgba(255, 255, 255, .06);
  --code-bg: #111620;
}
/* Forest — deep green-black dark */
:root[data-flavor="forest"] {
  --bg: #0c1410; --surface: #121c17; --surface-2: #18241e;
  --line: #24352c; --line-soft: #1a2921;
  --ink: #e7efe9; --ink-soft: #b5c4ba; --muted: #7f9387;
  --frost: rgba(18, 28, 23, .84); --glass: rgba(24, 36, 30, .55);
  --hover: rgba(255, 255, 255, .06);
  --code-bg: #0a110d;
}
/* High contrast — light with strong ink and lines */
:root[data-flavor="contrast"] {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f2f2f2;
  --line: #6b6b6b; --line-soft: #9a9a9a;
  --ink: #000000; --ink-soft: #1a1a1a; --muted: #3d3d3d;
  --hover: rgba(0, 0, 0, .08);
  --teal: #005f5e; --teal-dark: #004544; --teal-50: rgba(0, 95, 94, .14); --accent: #005f5e;
  --shadow-sm: none; --shadow: 0 0 0 1px #6b6b6b;
}
/* Midnight — true-black OLED dark (inherits dark's ink/teal) */
:root[data-flavor="midnight"] {
  --bg: #000000; --surface: #0a0d12; --surface-2: #11151c;
  --line: #1d232d; --line-soft: #14191f;
  --frost: rgba(4, 6, 9, .86); --glass: rgba(15, 20, 26, .6);
  --hover: rgba(255, 255, 255, .07);
  --shadow: 0 10px 34px rgba(0, 0, 0, .8);
  --code-bg: #05080c;
}

/* ---- Personalization tokens (data-* on <html>; js/app.js PREFS) ----
   Accent: every teal token routes through these six, light and dark. */
:root[data-accent="blue"]   { --teal: #2563eb; --teal-dark: #1d4ed8; --teal-50: rgba(37, 99, 235, .12);  --accent: #2563eb; --grad: linear-gradient(135deg, #3b82f6, #1d4ed8); --shadow-glow: 0 10px 40px -8px rgba(37, 99, 235, .35); }
:root[data-accent="violet"] { --teal: #6d5efc; --teal-dark: #5646d6; --teal-50: rgba(109, 94, 252, .12); --accent: #6d5efc; --grad: linear-gradient(135deg, #8b7bff, #5646d6); --shadow-glow: 0 10px 40px -8px rgba(109, 94, 252, .35); }
:root[data-accent="green"]  { --teal: #15803d; --teal-dark: #166534; --teal-50: rgba(21, 128, 61, .12);  --accent: #15803d; --grad: linear-gradient(135deg, #22c55e, #166534); --shadow-glow: 0 10px 40px -8px rgba(21, 128, 61, .35); }
:root[data-accent="amber"]  { --teal: #b45309; --teal-dark: #92400e; --teal-50: rgba(180, 83, 9, .12);   --accent: #b45309; --grad: linear-gradient(135deg, #f59e0b, #92400e); --shadow-glow: 0 10px 40px -8px rgba(180, 83, 9, .35); }
:root[data-accent="rose"]   { --teal: #be123c; --teal-dark: #9f1239; --teal-50: rgba(190, 18, 60, .12);  --accent: #be123c; --grad: linear-gradient(135deg, #f43f5e, #9f1239); --shadow-glow: 0 10px 40px -8px rgba(190, 18, 60, .35); }
:root[data-theme="dark"][data-accent="blue"]   { --teal: #60a5fa; --teal-dark: #93c5fd; --teal-50: rgba(96, 165, 250, .16);  --accent: #60a5fa; --on-accent: #0b1016; --grad: linear-gradient(135deg, #3b82f6, #1e40af); }
:root[data-theme="dark"][data-accent="violet"] { --teal: #8b7bff; --teal-dark: #b3a8ff; --teal-50: rgba(139, 123, 255, .16); --accent: #8b7bff; --on-accent: #0b1016; --grad: linear-gradient(135deg, #7c6cf6, #4c3fc4); }
:root[data-theme="dark"][data-accent="green"]  { --teal: #4ade80; --teal-dark: #86efac; --teal-50: rgba(74, 222, 128, .16);  --accent: #4ade80; --on-accent: #0b1016; --grad: linear-gradient(135deg, #22c55e, #15803d); }
:root[data-theme="dark"][data-accent="amber"]  { --teal: #fbbf24; --teal-dark: #fde68a; --teal-50: rgba(251, 191, 36, .16);  --accent: #fbbf24; --on-accent: #0b1016; --grad: linear-gradient(135deg, #f59e0b, #b45309); }
:root[data-theme="dark"][data-accent="rose"]   { --teal: #fb7185; --teal-dark: #fda4af; --teal-50: rgba(251, 113, 133, .16); --accent: #fb7185; --on-accent: #0b1016; --grad: linear-gradient(135deg, #f43f5e, #be123c); }
/* Font: reading text and chrome follow --font */
:root[data-font="serif"]   { --font: Charter, 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Times New Roman', serif; }
:root[data-font="classic"] { --font: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
/* Spacing: line height of reading text and the gap between turns */
:root { --reading-lh: 1.65; --msg-gap: 22px; }
:root[data-density="compact"] { --reading-lh: 1.5;  --msg-gap: 14px; }
:root[data-density="relaxed"] { --reading-lh: 1.85; --msg-gap: 32px; }
/* Motion: the explicit switch mirrors prefers-reduced-motion */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}
[hidden] { display: none !important; }
a { color: var(--teal); }

/* ---- Loading splash ---- */
.app-loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 100;
}
.spinner {
  display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner.big { width: 34px; height: 34px; border-width: 3px; color: var(--teal); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid #fff; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---- Buttons ---- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: none;
  border-radius: var(--radius-sm); padding: 10px 16px; transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--teal); color: #fff; width: 100%; padding: 12px; }
.btn-primary:hover { background: var(--teal-dark); }
.btn:disabled { opacity: .6; cursor: default; }

/* ===========================================================================
   Landing view
   =========================================================================== */
.landing { height: 100%; overflow-y: auto; background: var(--bg); }
.lp-nav {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--frost); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.lp-nav .brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.lp-nav-cta { display: flex; gap: 8px; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-primary-sm { background: var(--teal); color: #fff; padding: 9px 16px; }
.btn-primary-sm:hover { background: var(--teal-dark); }

.lp-hero {
  max-width: 760px; margin: 0 auto; text-align: center; padding: 64px 24px 40px;
}
.lp-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.lp-logo svg { border-radius: 16px; box-shadow: 0 8px 30px rgba(14,124,123,.28); }
.lp-badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--teal-dark); background: var(--teal-50); border: 1px solid #cfe6e5; padding: 5px 12px; border-radius: 20px; margin-bottom: 18px;
}
.lp-hero h1 { font-size: 44px; line-height: 1.1; letter-spacing: -1px; margin: 0 0 18px; }
.grad { background: linear-gradient(100deg, var(--teal), #1aa39c); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-sub { font-size: 17px; color: var(--ink-soft); max-width: 620px; margin: 0 auto 28px; line-height: 1.6; }
.lp-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lp-cta.center { margin-top: 26px; }
.lp-cta .btn-primary { width: auto; padding: 13px 26px; font-size: 15px; }
.lp-cta .btn-ghost { padding: 13px 22px; font-size: 15px; }
.lp-fineprint { font-size: 12.5px; color: var(--muted); margin-top: 20px; }

.lp-features {
  max-width: 1040px; margin: 0 auto; padding: 24px 24px 16px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.lp-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.lp-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #cfe6e5; }
.lp-ico {
  display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px;
  border-radius: 11px; background: var(--teal-50); color: var(--teal-dark); margin-bottom: 14px;
}
.lp-card h3 { font-size: 16px; margin: 0 0 6px; }
.lp-card p { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.55; }

.lp-why { max-width: 880px; margin: 0 auto; padding: 48px 24px 24px; text-align: center; }
.lp-why h2 { font-size: 28px; letter-spacing: -.5px; margin: 0 0 28px; }
.lp-why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; text-align: left; }
.lp-why-item { font-size: 14px; color: var(--ink-soft); line-height: 1.6; padding: 18px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line-soft); }
.lp-why-item b { color: var(--ink); }
.lp-foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 40px 24px; border-top: 1px solid var(--line-soft); margin-top: 32px; }

.auth-back { text-decoration: none; display: inline-block;
  position: absolute; top: 14px; left: 14px; background: none; border: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 13px; padding: 4px 6px; border-radius: 6px;
}
.auth-back:hover { color: var(--ink); background: var(--surface-2); }

@media (max-width: 880px) {
  .lp-features, .lp-why-grid { grid-template-columns: 1fr; }
  .lp-hero h1 { font-size: 34px; }
  .lp-hero { padding-top: 44px; }
}

/* ===========================================================================
   Auth view
   =========================================================================== */
.auth-view {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--teal-50), var(--bg));
}
.auth-card {
  position: relative;
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo { font-size: 40px; }
.auth-brand h1 { margin: 6px 0 2px; font-size: 24px; letter-spacing: -.4px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.auth-form input {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink);
}
.auth-form input:focus { outline: none; border-color: var(--teal); background: var(--surface); box-shadow: 0 0 0 3px var(--teal-50); }
.auth-hint, .auth-note { font-size: 12.5px; color: var(--muted); margin: -4px 0 0; }
.auth-note { color: var(--ink-soft); }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.auth-error {
  background: var(--danger-soft); color: var(--danger); border: 1px solid #f3c9c9;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
.auth-foot { font-size: 12px; color: var(--muted); text-align: center; max-width: 380px; }

/* ===========================================================================
   App layout
   =========================================================================== */
/* App shell: window scroll is off in app mode; the grid row is pinned to the
   viewport so long content can only scroll inside #messages / .conv-list. */
body.app-mode { overflow: hidden; }
.app-view {
  display: grid; grid-template-columns: 280px 1fr; grid-template-rows: 100%;
  height: 100%; overflow: hidden;
}
.chat { min-height: 0; }
/* Research (beta): a view in the chat's column; the chat stays in the DOM, hidden, while it is open */
.research-view { display: none; min-height: 0; min-width: 0; height: 100%; flex-direction: column; }
.app-view.research-on > .chat { display: none; }
.app-view.research-on > .research-view { display: flex; }
.research-frame { flex: 1; width: 100%; min-height: 0; border: 0; display: block; background: var(--bg); }
.messages { min-height: 0; }
.conv-list { min-height: 0; }
/* The drawer backdrop lives inside .app-view but must NEVER be a grid item —
   without this base rule it silently claims the 1fr column on desktop and
   shoves the chat into the sidebar track. Shown only by the mobile drawer. */
#sidebar-backdrop { display: none; }

/* ---- Sidebar ---- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar-head { padding: 14px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 12px; position: relative; }
/* Drawer close — hidden on desktop (the sidebar is permanent there). Needs to
   out-rank .icon-btn's display:grid, which appears later in the file. */
.icon-btn.sidebar-close { display: none; position: absolute; top: 10px; right: 10px; color: var(--muted); }
.icon-btn.sidebar-close:hover { color: var(--ink); }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; letter-spacing: -.3px; }
.brand-logo { font-size: 18px; }
.btn-new {
  background: var(--teal-50); color: var(--teal-dark); border: 1px solid #cfe6e5;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 14px;
}
.btn-new:hover { background: #d8edec; }
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-empty { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }
.conv-item {
  display: flex; align-items: center; border-radius: var(--radius-sm); margin-bottom: 2px;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--teal-50); }
.conv-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  background: none; border: none; cursor: pointer; text-align: left; padding: 9px 10px; font: inherit;
}
.conv-title { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { font-size: 11px; color: var(--muted); }
.conv-actions { display: none; gap: 2px; padding-right: 6px; }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions { display: flex; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--muted); font-size: 14px;
  width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.sidebar-foot {
  border-top: 1px solid var(--line-soft); padding: 10px 12px; display: flex; align-items: center; gap: 8px;
}
.user-chip { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-email { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Chat column ---- */
.chat { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  /* The premium layer's backdrop-filter makes this an ATOMIC stacking context;
     without an explicit z-index the messages (later in the DOM) paint straight
     over the settings/export pop-overs, which read as a "transparent" panel. */
  position: relative; z-index: 30;
}
.sidebar-toggle { display: none; }
/* Desktop: the sidebar collapses to zero width from the header toggle (or its
   own close button). The column animates; the content keeps its width so it
   slides out instead of squashing. */
@media (min-width: 761px) {
  /* The header button only exists while the sidebar is hidden — open, the
     sidebar carries its own hide button, so there is never a stray control. */
  .sidebar-toggle { display: none; }
  :root[data-sidebar="collapsed"] .sidebar-toggle { display: grid; }
  .icon-btn.sidebar-close { display: grid; }
  .app-view { transition: grid-template-columns .22s var(--ease-out); }
  .sidebar { overflow: hidden; min-width: 0; }
  .sidebar > * { min-width: 280px; }
  :root[data-sidebar="collapsed"] .app-view { grid-template-columns: 0 1fr; }
  :root[data-sidebar="collapsed"] .sidebar { visibility: hidden; border-right-width: 0; transition: visibility 0s .22s; }
  :root[data-sidebar="collapsed"] body.shared-mode .app-view { grid-template-columns: 1fr; }
}
.chat-title { font-size: 15px; font-weight: 600; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-wrap { display: flex; align-items: center; gap: 6px; }
.mode-label { font-size: 12px; color: var(--muted); }
.mode-select {
  font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--surface-2); color: var(--ink-soft);
}

/* Text-size control (Small / Standard / Large): three A glyphs sharing a
   baseline so they read as an ascending size ramp. Soft tray, tinted active. */
.fontsize-toggle {
  display: inline-flex; align-items: baseline; gap: 1px; padding: 3px 4px;
  border-radius: 10px; background: var(--surface-2);
}
.fs-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 3px 7px; border-radius: 7px; line-height: 1; font-weight: 650;
  letter-spacing: -.01em;
  transition: color .16s ease, background .16s ease, transform .18s var(--ease-spring);
}
.fs-btn[data-size="small"]    { font-size: 11px; }
.fs-btn[data-size="standard"] { font-size: 14px; }
.fs-btn[data-size="large"]    { font-size: 18px; }
.fs-btn:hover:not(.active) { color: var(--ink); }
.fs-btn:active { transform: scale(.9); }
.fs-btn.active { color: var(--teal-dark); background: var(--teal-50); font-weight: 800; }

/* ---- Messages ---- */
.messages { flex: 1; overflow-y: auto; padding: 24px 0; scroll-behavior: smooth; }
.loading-conv { text-align: center; color: var(--muted); padding: 40px; }
.error-banner { margin: 20px auto; max-width: 720px; background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); }

.msg { display: flex; gap: 14px; max-width: 820px; margin: 0 auto var(--msg-gap, 22px); padding: 0 24px; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
}
.msg-avatar.user { background: var(--ink); color: #fff; }
.msg-avatar.assistant { background: none; }
.ico { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.brand-mark, .msg-avatar svg, .welcome-logo svg, .auth-logo svg { display: block; }
.msg-bubble { min-width: 0; flex: 1; padding-top: 3px; }
.msg-user .msg-content { color: var(--ink); white-space: pre-wrap; font-size: calc(15px * var(--reading-scale, 1)); }
/* a long question folds; js/app.js foldLong */
.msg-user .msg-content.folded:not(.expanded) { max-height: 9em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.msg-more { display: inline-block; margin-top: 4px; padding: 2px 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.msg-more:hover { color: var(--ink); text-decoration: underline; }
.msg-more[hidden] { display: none; }
.msg-status { color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.msg-status .plan { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.msg-rich { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.error-inline { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; font-size: 13.5px; margin-top: 8px; }

/* ---- Welcome ---- */
.welcome { max-width: 640px; margin: 6vh auto; text-align: center; padding: 0 24px; }
.welcome-logo { display: flex; justify-content: center; }
.auth-logo { display: inline-flex; }
.welcome h1 { font-size: 28px; margin: 8px 0 6px; letter-spacing: -.6px; }
.welcome-sub { color: var(--muted); max-width: 460px; margin: 0 auto 26px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suggestion {
  font: inherit; text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer; color: var(--ink-soft);
  font-size: 13.5px; transition: border-color .15s, box-shadow .15s;
}
.suggestion:hover { border-color: var(--teal); box-shadow: var(--shadow-sm); color: var(--ink); }

/* ---- Markdown content ---- */
/* Reading text scales with the header's A− A A+ control (see --reading-scale).
   Headings/tables use em so they scale in proportion with the base. */
.markdown { font-size: calc(15px * var(--reading-scale, 1)); color: var(--ink); line-height: var(--reading-lh, 1.65); }
.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.3; margin: 18px 0 8px; }
.markdown h3 { font-size: 1.067em; color: var(--teal-dark); }
.markdown h2 { font-size: 1.2em; }
.markdown p { margin: 0 0 12px; }
.markdown ul, .markdown ol { margin: 0 0 12px; padding-left: 22px; }
.markdown li { margin: 3px 0; }
.markdown code { font-family: var(--mono); font-size: .88em; background: var(--line-soft); padding: 1px 5px; border-radius: 4px; }
.markdown pre { background: var(--code-bg); color: var(--code-fg); padding: 14px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--line); }
.markdown pre code { background: none; padding: 0; color: inherit; }
.markdown blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--teal); color: var(--ink-soft); }
.markdown table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 0.9em; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--surface-2); }
.markdown a { text-decoration: underline; }

/* ---- Writer prompt editor (docs/WRITER_PROMPT.md; prompt-editors only) ---- */
.wp-open { padding: 5px 10px; font-size: 12.5px; }
.writer-chip {
  font: inherit; font-size: 11.5px; font-weight: 600; color: #b8730f; background: rgba(230, 160, 40, .14);
  border: 1px solid rgba(230, 160, 40, .35); border-radius: 999px; padding: 3px 10px; cursor: pointer; white-space: nowrap;
  max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
}
.wp-modal { min-width: min(880px, 92vw); gap: 12px; }
.wp-expand { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
/* Expanded: the panel fills the window and the editor takes the free height */
.lb-panel.wp-expanded { width: 96vw; height: 94vh; max-height: 94vh; }
.lb-panel.wp-expanded .lb-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lb-panel.wp-expanded .wp-modal { flex: 1; min-height: 0; min-width: 0; }
.lb-panel.wp-expanded .wp-cols { flex: 1; min-height: 0; }
.lb-panel.wp-expanded .wp-list { max-height: none; }
.lb-panel.wp-expanded .wp-editor { min-height: 0; }
.lb-panel.wp-expanded .wp-text { flex: 1; min-height: 0; resize: none; }
/* Composer picker (editors only) */
.writer-pick {
  align-self: flex-end; margin-bottom: 1px; max-width: 170px; font-size: 12px; padding: 7px 26px 7px 9px;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.writer-pick.custom { border-color: rgba(230, 160, 40, .6); color: #b8730f; font-weight: 600; }
.wp-top { display: flex; align-items: center; gap: 14px; }
.wp-modelbl { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.wp-status { flex: 1; text-align: right; }
.wp-cols { display: grid; grid-template-columns: 200px 1fr; gap: 14px; min-height: 380px; }
.wp-list { display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--line); padding-right: 12px; overflow-y: auto; max-height: 60vh; }
.wp-list-title { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 10px 0 3px 8px; }
.wp-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left;
  background: none; border: none; font: inherit; color: var(--ink-soft); padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.wp-item:hover { background: var(--surface-2); color: var(--ink); }
.wp-item.active { background: var(--teal-50); color: var(--teal-dark); }
.wp-item-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.wp-item-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.wp-new { color: var(--teal-dark); font-weight: 600; }
.wp-editor { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wp-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wp-name { flex: 1; min-width: 160px; font-size: 13px; }
.wp-toolbar .btn { padding: 7px 12px; font-size: 12.5px; }
.wp-danger { color: var(--danger); }
.wp-text {
  flex: 1; min-height: 320px; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none;
}
.wp-text:focus { border-color: var(--teal); background: var(--surface); }
.wp-text.ro { color: var(--ink-soft); }
.wp-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.wp-meta.over { color: var(--danger); }
.wp-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); }
.wp-usenote { font-size: 12.5px; color: var(--ink-soft); }
@media (max-width: 760px) {
  .wp-cols { grid-template-columns: 1fr; }
  .wp-list { border-right: none; padding-right: 0; max-height: 160px; flex-direction: row; flex-wrap: wrap; }
  .wp-list-title { width: 100%; }
  .writer-chip { display: none; }
}

/* ---- DEV environment badge ---- */
.env-badge { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: #fff; background: #d64545; border-radius: 5px; padding: 2px 6px; }
.access-banner { margin: 10px 12px; }

/* ---- Dev lanes (DEV_UI_HANDOUT.md §3) ---- */
/* 3a reference chip */
.enh-ref { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; font-size: 12.5px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.enh-ref-k { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.enh-ref-link { color: var(--teal-dark); font-weight: 600; text-decoration: none; }
.enh-ref-link:hover { text-decoration: underline; }
.enh-ref-src { font-size: 11px; color: var(--muted); }
.enh-ref-why { flex-basis: 100%; font-size: 12px; color: var(--ink-soft); }
/* 3b missing-info box */
.enh-mi { border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.enh-mi-title { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--teal-dark); margin-bottom: 10px; }
.enh-mi-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; }
.enh-mi-item { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.enh-mi-ask { color: var(--ink); font-weight: 600; }
.enh-mi-tier { margin-left: 6px; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--danger); }
.enh-mi-safety .enh-mi-ask { color: var(--danger); }
.enh-mi-row { display: flex; align-items: center; gap: 6px; }
.enh-mi-ctl { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--ink); flex: 1; min-width: 0; }
.enh-mi-ctl:focus { outline: none; border-color: var(--teal); background: var(--surface); }
.enh-mi-num { max-width: 140px; }
.enh-mi-unit { font-size: 12px; color: var(--muted); }
.enh-mi-why { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.enh-mi-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.enh-mi-send { padding: 7px 14px; font-size: 12.5px; }
.enh-mi-status { font-size: 12px; color: var(--muted); }
/* 3c manufacturer's instructions */
.enh-ifu { font-size: 13px; }
.enh-ifu-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 10px; }
.enh-ifu-name { font-weight: 700; color: var(--teal-dark); text-decoration: none; }
.enh-ifu-name:hover { text-decoration: underline; }
.enh-ifu-cat, .enh-ifu-doc { font-size: 11.5px; color: var(--muted); }
.enh-ifu-sec { margin: 8px 0; }
.enh-ifu-sec-title { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.enh-ifu-row { margin: 4px 0; padding: 7px 10px; border-left: 3px solid var(--line); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--ink); line-height: 1.5; transition: background .3s ease; }
.enh-ifu-contraindication, .enh-ifu-warning { border-left-color: var(--danger); }
.enh-ifu-row.flash { background: var(--teal-50); }
.enh-ifu-type { display: inline-block; margin-right: 6px; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.enh-ifu-contraindication .enh-ifu-type, .enh-ifu-warning .enh-ifu-type { color: var(--danger); }
.enh-ifu-page { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.enh-ifu-note { margin: 10px 0 0; color: var(--ink-soft); font-size: 12.5px; }
.enh-ifu-stance, .enh-fig-stance { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); font-style: italic; }
.enh-card.flash > .enh-card-head { background: var(--teal-50); }
/* 3d published figures */
/* one picture per row, the text column's full width, 240-320 px high; the whole picture shows (no crop) */
.enh-figs { display: grid; grid-template-columns: 1fr; gap: 18px; }
.enh-fig { margin: 0; font-size: 12px; }
.enh-fig-frame { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); cursor: zoom-in; height: clamp(240px, 42vw, 320px); }
.enh-fig-img { width: 100%; height: 100%; object-fit: contain; display: block; transition: filter .25s ease; }
.enh-fig-capmore { border: 0; background: none; padding: 0; font: inherit; color: var(--teal-dark); cursor: pointer; text-decoration: underline; }
.enh-fig-anchor { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-align: left; border: 0; background: none; padding: 0; font: inherit; color: var(--ink-soft); cursor: pointer; line-height: 1.4; }
.enh-fig-anchor:hover { color: var(--ink); }
.enh-fig-anchor-k { font-weight: 600; color: var(--ink); }
.enh-fig-serves { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.enh-anchor-flash { animation: enh-anchor-flash 1.6s ease-out; border-radius: 4px; }
@keyframes enh-anchor-flash { 0%, 30% { background: var(--teal-50); } 100% { background: transparent; } }.enh-fig-frame.graphic { cursor: pointer; }
.enh-fig-frame.graphic .enh-fig-img { filter: blur(18px) saturate(.6); }
.enh-fig-veil { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink); background: rgba(0, 0, 0, .12); text-align: center; padding: 10px; }
.enh-fig-frame:not(.graphic) .enh-fig-veil { display: none; }
.enh-fig figcaption { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.enh-fig-cap { color: var(--ink); line-height: 1.4; }
.enh-fig-dx { color: var(--teal-dark); font-weight: 600; }
.enh-fig-why { color: var(--ink-soft); }
.enh-fig-attr { font-size: 11px; color: var(--muted); line-height: 1.4; }
.enh-fig-attr a { color: var(--teal-dark); }
.enh-fig-lb img { max-width: min(90vw, 1000px); max-height: 70vh; display: block; margin: 0 auto; }
.enh-fig-lb .enh-fig-attr { margin-top: 8px; text-align: center; }

/* ---- Patient context strip (docs/PATIENT_CONTEXT_UI.md) ---- */
/* Panel above the input, opened from the pill in the tools row */
.patient-strip {
  max-width: 820px; margin: 0 auto 8px; padding: 10px 14px 2px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius); animation: pcIn .16s ease both;
}
@keyframes pcIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.chat.empty .patient-strip { max-width: 640px; }
.chat[data-view="wide"] .patient-strip { max-width: 1180px; }
.pc-head { display: flex; align-items: center; gap: 8px; padding: 0 0 8px; color: var(--ink); }
.pc-close {
  margin-left: auto; width: 24px; height: 24px; border-radius: 6px; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 12px;
}
.pc-close:hover { background: var(--hover, var(--surface)); color: var(--ink); }
.pc-dirty + .pc-close, .pc-ro + .pc-close { margin-left: 4px; }
/* The pill in the composer tools row */
.patient-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--teal-dark); background: var(--teal-50);
  border: 1px solid transparent; border-radius: 999px; padding: 4px 11px; cursor: pointer; position: relative;
  transition: border-color .15s ease, background .15s ease;
}
.patient-btn:hover, .patient-btn.open { border-color: var(--teal); }
.pb-count { font-weight: 500; color: var(--ink-soft); }
.patient-btn.dirty::after {
  content: ''; position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%;
  background: #e6a028; box-shadow: 0 0 0 2px var(--surface);
}
.pc-title { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--teal-dark); }
.pc-summary { font-size: 12px; color: var(--muted); }
.pc-dirty { font-size: 11.5px; color: #b8730f; background: rgba(230, 160, 40, .14); border-radius: 999px; padding: 1px 8px; margin-left: auto; }
.pc-ro { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.pc-body { padding: 0 0 8px; }
.pc-list { display: flex; flex-wrap: wrap; gap: 6px; max-width: 860px; }
.pc-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  font: inherit; font-size: 12.5px; line-height: 1.3; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px 4px 10px;
}
.pc-chip .pc-label { overflow-wrap: anywhere; }
.pc-ico { display: inline-flex; color: var(--teal); }
.pc-sub { font-size: 11px; color: var(--muted); }
.pc-sub::before { content: '· '; }
.pc-pre { font-size: 11px; font-weight: 700; color: var(--muted); }
.pc-demographic, .pc-condition { background: var(--teal-50); border-color: transparent; color: var(--teal-dark); font-weight: 600; }
.pc-allergy.pc-present { background: var(--danger-soft); border-color: transparent; color: var(--danger); font-weight: 600; }
.pc-absent .pc-label { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--ink-soft); }
/* Missing = a prompt, not a fact: dashed ghost, clickable to fill */
.pc-not_stated { background: transparent; border-style: dashed; color: var(--muted); cursor: pointer; }
.pc-not_stated:not(:disabled):hover, .pc-add:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-50); }
.pc-not_stated .pc-pre { color: var(--teal); }
.pc-add { background: transparent; border-style: dashed; color: var(--muted); cursor: pointer; }
.pc-local { box-shadow: inset 0 0 0 1px var(--teal); }
.pc-x {
  background: none; border: none; font: inherit; font-size: 14px; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 0 0 0 2px; margin-right: -3px; border-radius: 50%; opacity: .55;
}
.pc-chip:hover .pc-x { opacity: 1; }
.pc-x:hover { color: var(--danger); }
.pc-editing { padding: 2px 6px; border-color: var(--teal); background: var(--surface); }
.pc-input { font: inherit; font-size: 12.5px; border: none; outline: none; background: transparent; color: var(--ink); min-width: 220px; }
.pc-foot { display: flex; align-items: baseline; gap: 12px; margin-top: 7px; }
.pc-note { font-size: 11.5px; color: var(--muted); }
.pc-reset { background: none; border: none; font: inherit; font-size: 11.5px; color: var(--teal-dark); cursor: pointer; padding: 0; text-decoration: underline; }
.patient-strip.locked .pc-chip { opacity: .8; }
@media (max-width: 760px) {
  .patient-strip { padding: 8px 10px 2px; }
  .pc-chip { font-size: 12px; padding: 3px 8px 3px 9px; }
  .pc-dirty { display: none; }
  .pc-note { display: none; }
}
@media (hover: none), (pointer: coarse) { .pc-x { opacity: 1; } }

/* ---- Composer ---- */
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 14px 24px 10px; }

/* Empty state (new session): welcome + composer sit together, centered
   vertically — auto margins on the group's outer edges split the free space.
   Once a turn exists the .empty class drops and the composer returns to the
   bottom rail. */
.chat.empty .messages { flex: 0 0 auto; overflow: visible; margin-top: auto; padding: 8px 0; }
.chat.empty .welcome { margin: 0 auto; }
.chat.empty .composer {
  margin-bottom: auto; border-top: none; background: transparent;
  backdrop-filter: none; padding-top: 6px;
}
.chat.empty .composer-inner, .chat.empty .composer-tools, .chat.empty .composer-disclaimer, .chat.empty .starter-list { max-width: 640px; }
.chat.empty .welcome-sub { margin-bottom: 14px; }
/* Short windows: the start group scrolls instead of clipping (auto margins
   collapse to 0 when there is no free space, so it starts at the top). */
.chat.empty { overflow-y: auto; }
/* Example questions: plain rows stacked under the input, hairline between */
.starter-list { margin: 14px auto 0; display: flex; flex-direction: column; }
.chat:not(.empty) .starter-list { display: none; }
.starter {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  font: inherit; font-size: 13.5px; color: var(--ink-soft); background: none; border: none;
  border-bottom: 1px solid var(--line-soft); padding: 11px 6px; cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.starter:last-child { border-bottom: none; }
.starter:hover { color: var(--ink); background: var(--hover); }
.starter-q { flex: 1; min-width: 0; }
.starter-go { color: var(--muted); font-size: 13px; opacity: 0; transition: opacity .15s ease, color .15s ease; }
.starter:hover .starter-go { opacity: 1; color: var(--teal); }
@media (hover: none) { .starter-go { opacity: .6; } }
.composer-inner {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
  padding: 8px 8px 8px 14px; transition: border-color .15s, box-shadow .15s;
}
.composer-inner:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-50); background: var(--surface); }
.composer-input {
  flex: 1; border: none; background: none; resize: none; font: inherit; font-size: 15px;
  color: var(--ink); max-height: 200px; padding: 6px 0; line-height: 1.5;
}
.composer-input:focus { outline: none; }
.btn-send, .btn-stop {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 9px; padding: 0;
  display: grid; place-items: center; font-size: 16px;
}
.btn-send { background: var(--teal); color: #fff; }
.btn-send:hover { background: var(--teal-dark); }
.btn-stop { background: var(--danger); color: #fff; }
.composer-disclaimer { max-width: 820px; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); }
/* Answer-mode control under the input: three pills, hint alongside */
.composer-tools { max-width: 820px; margin: 8px auto 0; display: flex; align-items: center; gap: 12px; min-width: 0; }
.mode-seg { display: inline-flex; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.mode-seg-btn {
  font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); background: none; border: none;
  border-radius: 999px; padding: 4px 12px; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.mode-seg-btn:hover { color: var(--ink); }
.mode-seg-btn.active { background: var(--surface); color: var(--teal-dark); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.mode-seg-hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat[data-view="wide"] .composer-tools { max-width: 1180px; }

/* ===========================================================================
   Rich blocks (knowledge cards, concept map, sources)
   =========================================================================== */
.rich-block { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.rich-head {
  width: 100%; display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: none; cursor: pointer; padding: 10px 14px; font: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink-soft);
}
.rich-head:hover { background: var(--line-soft); }
.rich-caret { color: var(--muted); font-size: 11px; width: 12px; }
.rich-title { flex: 1; text-align: left; }
.rich-count { background: var(--teal-50); color: var(--teal-dark); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 20px; }
.rich-body { display: none; }
.rich-block.open .rich-body { display: block; }
.rich-body > * { padding: 12px 14px; border-top: 1px solid var(--line-soft); }
@media (prefers-reduced-motion: no-preference) {
  .rich-block.open .rich-body > * { animation: revealDown .34s var(--ease-out); }
}
@keyframes revealDown { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } }

/* Knowledge cards */
.kc-list { display: flex; flex-direction: column; gap: 8px; }
.kc { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.kc > summary { list-style: none; cursor: pointer; padding: 10px 12px; }
.kc > summary::-webkit-details-marker { display: none; }
.kc-head { display: flex; align-items: center; gap: 8px; }
.kc-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.kc-title { font-weight: 600; font-size: 14px; }
.kc-cat { font-size: 11px; text-transform: capitalize; font-weight: 600; }
.kc-score { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 1px 7px; border-radius: 20px; }
.kc-detail { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.kc-scope { margin: 0; font-size: 13px; color: var(--ink-soft); }
.kc-codes { display: flex; flex-wrap: wrap; gap: 6px; }
.code-chip { font-size: 11px; font-family: var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; color: var(--ink-soft); }
.code-chip b { color: var(--teal-dark); font-weight: 700; }
.kc-rels { display: flex; flex-direction: column; gap: 6px; }
.kc-rel { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; font-size: 12.5px; align-items: start; }
.kc-rel-label { font-weight: 600; color: var(--ink-soft); }
.kc-rel-label.critical { color: var(--danger); }
.kc-rel-targets { color: var(--ink); }
.kc-rel-src { color: var(--muted); font-size: 11px; }
.kc-onto { font-size: 11px; color: var(--muted); }
.kc-insights { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.kc-insights-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.kc-insight { font-size: 12.5px; color: var(--ink-soft); padding: 2px 0; }

/* Concept map */
.cm-wrap { display: flex; flex-direction: column; gap: 8px; }
.concept-map { width: 100%; height: auto; background: var(--surface-2); border-radius: var(--radius-sm); }
.cm-label { font-size: 11px; font-family: var(--font); pointer-events: none; }
.cm-node { cursor: default; }
.cm-node:hover circle { stroke: var(--ink); stroke-width: 1.5; }
.cm-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-soft); }
.cm-legend-item { display: flex; align-items: center; gap: 5px; text-transform: capitalize; }
.cm-legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* Sources — body-size typography, reads like the answer text */
.src-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.src-item { display: flex; gap: 12px; }
.src-idx { width: 24px; height: 24px; flex-shrink: 0; background: var(--teal-50); color: var(--teal-dark); border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.src-body { min-width: 0; }
.src-title { font-size: 15px; line-height: 1.45; font-weight: 600; color: var(--ink); }
.src-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Figures */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.img-cell { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.img-cell img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); }
.img-cap { font-size: 11px; color: var(--muted); }

/* Follow-ups */
.followups { margin-top: 4px; }
.followups-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; }
.followups-list { display: flex; flex-direction: column; gap: 6px; }
.followup {
  font: inherit; font-size: 13px; text-align: left; cursor: pointer; color: var(--teal-dark);
  background: var(--teal-50); border: 1px solid #cfe6e5; border-radius: 8px; padding: 8px 12px;
}
.followup:hover { background: #d8edec; }

/* ===========================================================================
   Responsive
   =========================================================================== */
/* Touch devices: row actions can't wait for hover, and targets need meat. */
@media (hover: none) {
  .conv-item .conv-actions { display: flex; }
}
@media (pointer: coarse) {
  .icon-btn { width: 36px; height: 36px; }
  .fs-btn { padding: 5px 8px; }
  .lb-close { width: 38px; height: 38px; }
  .conv-open { padding-top: 10px; padding-bottom: 10px; }
}

@media (max-width: 760px) {
  /* ---- Off-canvas sidebar drawer + backdrop ---- */
  .app-view { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(85vw, 320px); z-index: 60;
    transform: translateX(-102%);          /* 2% margin swallows fractional-width slivers */
    visibility: hidden;                    /* fully gone when closed (also untabbable) */
    transition: transform .24s var(--ease-out), visibility 0s .24s;
    box-shadow: none;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0); visibility: visible;
    transition: transform .24s var(--ease-out), visibility 0s;
    box-shadow: 24px 0 60px -18px rgba(0, 0, 0, .45);
  }
  .icon-btn.sidebar-close { display: grid; }
  #sidebar-backdrop { display: none; }
  body.sidebar-open #sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(8, 12, 16, .45); backdrop-filter: blur(2px);
  }
  .sidebar-toggle { display: grid; }

  /* ---- Header: with the selects folded into the options pop-over, everything
     fits one row even at 375px: menu · title · options · export · theme ---- */
  .chat-head { padding: 8px 10px; gap: 8px; }
  .settings-menu { min-width: 232px; max-width: calc(100vw - 20px); }

  /* ---- Reading area ---- */
  .messages { padding: 16px 0; }
  .enh-drugtab-bar { top: -16px; }   /* match this width's scroller padding */
  .msg { padding: 0 12px; gap: 10px; margin-bottom: 18px; }
  .msg-avatar { width: 26px; height: 26px; font-size: 12.5px; border-radius: 7px; }
  .welcome { margin: 4vh auto; }
  .suggestions { grid-template-columns: 1fr; }
  .kc-rel { grid-template-columns: 1fr; gap: 2px; }

  /* ---- Composer: 16px input so iOS doesn't zoom on focus ---- */
  .composer { padding: 10px 10px 8px; }
  .composer-input { font-size: 16px; }
  .composer-disclaimer { font-size: 10.5px; margin-top: 6px; }
  .composer-tools { justify-content: center; }
  .mode-seg-hint { display: none; }
  .mode-seg-btn { padding: 4px 10px; font-size: 11.5px; }

  /* ---- Lightbox fills the phone ---- */
  .lb-overlay { padding: 10px; }
  .lb-panel { width: 100%; max-height: 94dvh; border-radius: 14px; }
  .lb-body { padding: 14px; }
  .lb-head { padding: 12px 14px; }

  /* ---- Enhanced turn bits ---- */
  .enh-task { flex-wrap: wrap; }
  .enh-task-kind { min-width: 0; flex-basis: 100%; margin-left: 23px; order: 2; }
  .enh-card-head { padding: 9px 11px; }
  .enh-card-body { padding: 10px 11px; }
  .enh-src { gap: 8px; }

  /* ---- Account / feedback modals ---- */
  .acct-modal { min-width: 0; }

  /* ---- Landing ---- */
  .lp-hero h1 { font-size: 30px; letter-spacing: -.5px; }
  .lp-sub { font-size: 15px; }
  .lp-cta .btn-primary, .lp-cta .btn-ghost { padding: 12px 18px; font-size: 14px; }
  .landing nav, .lp-nav { padding-left: 14px; padding-right: 14px; }
}

/* Very narrow phones */
@media (max-width: 430px) {
  .msg-avatar { display: none; }
  .export-menu { right: auto; left: 0; }
}

/* ===========================================================================
   Premium layer — motion, depth, polish (Apple-vibe)
   =========================================================================== */

/* Global smoothing */
html { scroll-behavior: smooth; }
::selection { background: rgba(14, 124, 123, .18); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

/* Refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(100, 120, 140, .35) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: rgba(100, 120, 140, .32); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(100, 120, 140, .55); border: 3px solid transparent; background-clip: content-box; }

/* Buttons — spring hover, gradient primaries, glow */
.btn { transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease-out), background .2s, opacity .2s, border-color .2s; will-change: transform; }
.btn-primary, .lp-cta .btn-primary { background: linear-gradient(135deg, #129b98, #0a5e5d); box-shadow: var(--shadow-glow); }
.btn-primary:hover, .lp-cta .btn-primary:hover { background: linear-gradient(135deg, #14a8a4, #0a5e5d); box-shadow: 0 14px 40px -8px rgba(14,124,123,.5); transform: translateY(-2px); }
.btn-primary-sm { background: linear-gradient(135deg, #129b98, #0a5e5d); box-shadow: 0 4px 14px rgba(14,124,123,.3); }
.btn-primary-sm:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(14,124,123,.42); }
.btn-send { transition: transform .25s var(--ease-spring), background .2s; }
.btn-send:hover { transform: translateY(-1px) scale(1.05); }
.btn:active { transform: translateY(0) scale(.96); transition-duration: .08s; }
.btn-ghost { transition: background .2s, border-color .2s, transform .25s var(--ease-spring); }
.btn-ghost:hover { transform: translateY(-1px); }
.btn-new:hover { transform: translateY(-1px); }

/* Icon buttons + conversation rows */
.icon-btn { transition: background .18s, color .18s, transform .2s var(--ease-spring); }
.icon-btn:active { transform: scale(.9); }
.conv-item { transition: background .2s var(--ease-out); }
.conv-open, .suggestion, .followup, .src-item, .lp-card, .mode-select { transition: all .25s var(--ease-out); }

/* Inputs — smooth focus */
.auth-form input, .composer-inner, .mode-select { transition: border-color .2s var(--ease-out), box-shadow .25s var(--ease-out), background .2s; }

/* Frosted, layered surfaces */
.auth-card { box-shadow: 0 1px 1px rgba(20,40,60,.04), 0 12px 40px -12px rgba(20,40,60,.22); }
.chat-head { backdrop-filter: saturate(1.4) blur(6px); background: var(--frost); }

/* Animated thinking spinner → softer */
.msg-status .spinner { color: var(--teal); }

/* ---- Keyframes ---- */
@keyframes viewIn { from { opacity: 0; transform: translateY(10px) scale(.994); } to { opacity: 1; transform: none; } }
@keyframes floatIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes nodePulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .8; } }
@keyframes meshDrift { 0% { transform: translate(0,0) scale(1); } 50% { transform: translate(4%, 3%) scale(1.12); } 100% { transform: translate(0,0) scale(1); } }
@keyframes sheen { from { background-position: -150% 0; } to { background-position: 250% 0; } }

/* Hero ambient gradient mesh */
.lp-hero { position: relative; isolation: isolate; }
.lp-hero::before {
  content: ''; position: absolute; z-index: -1; top: -180px; left: 50%; width: 900px; height: 700px;
  transform: translateX(-50%);
  background:
    radial-gradient(420px 320px at 38% 30%, rgba(20,168,160,.30), transparent 70%),
    radial-gradient(420px 360px at 66% 42%, rgba(59,108,183,.20), transparent 70%),
    radial-gradient(360px 300px at 52% 12%, rgba(14,124,123,.22), transparent 70%);
  filter: blur(34px); pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  /* View transitions (re-fire on display:none -> visible) */
  #landing-view:not([hidden]), #auth-view:not([hidden]), #app-view:not([hidden]) { animation: viewIn .55s var(--ease-spring) both; }

  /* Landing hero staggered reveal */
  .lp-logo   { animation: floatIn .7s var(--ease-spring) both; }
  .lp-badge  { animation: floatIn .7s var(--ease-spring) .08s both; }
  .lp-hero h1{ animation: floatIn .8s var(--ease-spring) .15s both; }
  .lp-sub    { animation: floatIn .8s var(--ease-spring) .24s both; }
  .lp-hero .lp-cta { animation: floatIn .8s var(--ease-spring) .33s both; }
  .lp-fineprint    { animation: floatIn .8s var(--ease-spring) .42s both; }

  /* Living logo (hero only) */
  .lp-logo .brand-mark { animation: floatIn .7s var(--ease-spring) both, logoFloat 6s var(--ease-in-out) 1s infinite; }
  .lp-logo .brand-mark circle { transform-box: fill-box; transform-origin: center; animation: nodePulse 3.2s var(--ease-in-out) infinite; }
  .lp-logo .brand-mark circle:nth-of-type(1) { animation-delay: 0s; }
  .lp-logo .brand-mark circle:nth-of-type(2) { animation-delay: .35s; }
  .lp-logo .brand-mark circle:nth-of-type(3) { animation-delay: .7s; }
  .lp-logo .brand-mark circle:nth-of-type(4) { animation-delay: 1.05s; }

  /* Ambient mesh drift */
  .lp-hero::before { animation: meshDrift 16s var(--ease-in-out) infinite; }

  /* Hero primary CTA sheen */
  .lp-hero .lp-cta .btn-primary { position: relative; overflow: hidden; }
  .lp-hero .lp-cta .btn-primary::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.35) 50%, transparent 65%);
    background-size: 250% 100%; animation: sheen 5.5s ease-in-out 2s infinite;
  }

  /* Messages + welcome + rich blocks entrance */
  .msg { animation: msgIn .5s var(--ease-out) both; }
  .welcome { animation: viewIn .6s var(--ease-spring) both; }
  .msg-rich .rich-block { animation: popIn .4s var(--ease-out) both; }

  /* Scroll-reveal (class added by JS) */
  .reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-spring); }
  .reveal.in { opacity: 1; transform: none; }
}

/* Card hover refined */
.lp-card:hover { transform: translateY(-5px); box-shadow: 0 20px 45px -18px rgba(20,40,60,.30); border-color: #bfe0df; }
.lp-card .lp-ico { transition: transform .3s var(--ease-spring), background .25s; }
.lp-card:hover .lp-ico { transform: scale(1.08) rotate(-3deg); background: #d6ecec; }
.suggestion:hover { transform: translateY(-2px); }
.followup:hover { transform: translateX(2px); }

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

/* ===========================================================================
   View modes (reading-area layout) — set via data-view on .chat
   =========================================================================== */

/* Wide — reclaim the side margins */
.chat[data-view="wide"] .msg,
.chat[data-view="wide"] .composer-inner,
.chat[data-view="wide"] .composer-disclaimer { max-width: 1180px; }

/* ---- Glass 3D — experimental layered translucent panels ---- */
.chat[data-view="glass"] { position: relative; overflow: hidden; }
.chat[data-view="glass"]::before {
  content: ''; position: absolute; inset: -10%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(700px 520px at 16% 0%, rgba(20,168,160,.20), transparent 60%),
    radial-gradient(680px 560px at 92% 22%, rgba(59,108,183,.18), transparent 60%),
    radial-gradient(620px 520px at 60% 108%, rgba(125,60,181,.14), transparent 60%),
    radial-gradient(520px 420px at 38% 60%, rgba(14,124,123,.12), transparent 60%);
  filter: blur(8px);
}
.chat[data-view="glass"] .chat-head { position: relative; z-index: 3; background: var(--frost); }
.chat[data-view="glass"] .messages {
  position: relative; z-index: 1; background: transparent;
  perspective: 1700px; perspective-origin: 50% 22%;
}
.chat[data-view="glass"] .composer {
  position: relative; z-index: 3;
  background: var(--frost); backdrop-filter: blur(14px) saturate(1.4);
}

.chat[data-view="glass"] .msg { max-width: 1040px; transform-style: preserve-3d; }
.chat[data-view="glass"] .msg-avatar {
  transition: transform .45s var(--ease-spring), box-shadow .45s;
  box-shadow: 0 10px 24px -10px rgba(20,40,60,.5);
}
.chat[data-view="glass"] .msg-bubble {
  padding: 18px 24px; border-radius: 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: 0 26px 60px -26px rgba(20,40,60,.5), inset 0 1px 0 rgba(255,255,255,.75);
  transform: rotateX(1.4deg) translateZ(0);
  transform-style: preserve-3d;
  transition: transform .5s var(--ease-spring), box-shadow .5s var(--ease-out);
}
.chat[data-view="glass"] .msg:hover .msg-bubble {
  transform: rotateX(0deg) translateZ(46px);
  box-shadow: 0 44px 96px -30px rgba(20,40,60,.55), inset 0 1px 0 rgba(255,255,255,.85);
}
.chat[data-view="glass"] .msg:hover .msg-avatar { transform: translateZ(60px); }
/* User panels = solid teal glass; assistant = clear glass */
.chat[data-view="glass"] .msg-user .msg-bubble {
  background: linear-gradient(135deg, rgba(16,138,136,.85), rgba(10,94,93,.85));
  border-color: var(--glass-border);
}
.chat[data-view="glass"] .msg-user .msg-content { color: #fff; }
.chat[data-view="glass"] .msg-user .msg-more { color: rgba(255,255,255,.8); }
/* Rich blocks become translucent too, so layers read as glass-on-glass */
.chat[data-view="glass"] .rich-block { background: var(--glass); border-color: var(--glass-border); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.chat[data-view="glass"] .rich-head { background: var(--glass); }
.chat[data-view="glass"] .kc, .chat[data-view="glass"] .concept-map, .chat[data-view="glass"] .lp-card { background: var(--glass); }

@media (prefers-reduced-motion: no-preference) {
  .chat[data-view="glass"]::before { animation: meshDrift 18s var(--ease-in-out) infinite; }
  /* gentle entrance for the layered panels */
  .chat[data-view="glass"] .msg-bubble { animation: glassIn .6s var(--ease-spring) both; }
}
@keyframes glassIn { from { opacity: 0; transform: rotateX(8deg) translateZ(-40px); } to { opacity: 1; transform: rotateX(1.4deg) translateZ(0); } }

/* (the old narrow-screen header-wrap block is gone: with the selects folded
   into the options pop-over, the header is icon-compact at every width) */

/* ===========================================================================
   Deck view — swipeable stack of page-cards
   =========================================================================== */
.deck-layer { display: none; flex: 1; position: relative; overflow: hidden; min-height: 0; }
.chat[data-view="deck"] .messages { display: none; }
.chat[data-view="deck"] .deck-layer { display: flex; align-items: center; justify-content: center; }
.chat[data-view="deck"] .deck-layer {
  background:
    radial-gradient(680px 480px at 18% 0%, rgba(20,168,160,.10), transparent 60%),
    radial-gradient(640px 520px at 92% 30%, rgba(59,108,183,.10), transparent 60%);
}

.deck-empty { color: var(--muted); font-size: 14px; }

.deck-stackwrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.deck-stack { position: relative; width: min(720px, 90%); height: min(78%, 660px); }

/* Table of contents rail (left margin) */
.deck-toc {
  display: none; position: absolute; left: 22px; top: 50%; transform: translateY(-50%); z-index: 55;
  flex-direction: column; gap: 2px; width: 152px; max-height: 80%; overflow-y: auto; padding: 6px;
}
.deck-toc-item {
  display: flex; align-items: center; gap: 9px; width: 100%; cursor: pointer; text-align: left;
  font: inherit; color: var(--muted); background: none; border: none; padding: 7px 10px; border-radius: 9px;
  transition: background .18s, color .18s;
}
.deck-toc-item:hover { background: var(--frost); color: var(--ink-soft); }
.deck-toc-item.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.deck-toc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.deck-toc-dot.crit { background: var(--danger); }
.deck-toc-dot.ess { background: var(--teal); }
.deck-toc-dot.act { background: #3b6cb7; }
.deck-toc-dot.det { background: #7d3cb5; }
.deck-toc-dot.note, .deck-toc-dot.ref { background: #6b7a89; }
.deck-toc-dot.q { background: var(--ink); }
.deck-toc-item.active .deck-toc-dot { box-shadow: 0 0 0 3px rgba(14, 124, 123, .18); }
.deck-toc-txt { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bottom nav bar (prev · counter · next) */
.deck-navbar {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 8px;
  background: var(--frost); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 24px; padding: 5px 8px; box-shadow: var(--shadow-sm);
}
.deck-navbar .deck-nav { position: static; transform: none; width: 34px; height: 34px; border: none; background: transparent; box-shadow: none; }
.deck-navbar .deck-nav:hover { transform: none; background: var(--surface-2); }
.deck-navbar .deck-counter { position: static; transform: none; border: none; background: none; box-shadow: none; padding: 0 4px; min-width: 42px; text-align: center; }

@media (min-width: 1180px) {
  .chat[data-view="deck"] .deck-toc { display: flex; }
  .chat[data-view="deck"] .deck-stackwrap { padding-left: 165px; }
}

.deck-card {
  position: absolute; inset: 0; overflow: auto; box-sizing: border-box;
  /* background + blur driven by the see-through slider (--deck-glass: 0..1) */
  background: color-mix(in srgb, var(--surface), transparent calc(var(--deck-glass, 0) * 74%));
  -webkit-backdrop-filter: blur(calc(var(--deck-glass, 0) * 16px)) saturate(1.3);
  backdrop-filter: blur(calc(var(--deck-glass, 0) * 16px)) saturate(1.3);
  border: 1px solid rgba(170, 188, 200, calc(0.35 + var(--deck-glass, 0) * 0.4));
  border-radius: 22px;
  padding: 50px 38px 34px; box-shadow: 0 34px 80px -28px rgba(20, 40, 60, .42), 0 2px 6px rgba(20,40,60,.06);
  transform-origin: center bottom; will-change: transform, opacity;
  touch-action: pan-y; cursor: grab; -webkit-user-select: none; user-select: none;
}
/* the top (focused) card in priority mode gets a subtle accent rail */
.deck-card:has(.deck-tier.crit) { box-shadow: 0 34px 80px -28px rgba(214,69,69,.3), inset 3px 0 0 var(--danger); }
.deck-card:has(.deck-tier.ess) { box-shadow: 0 34px 80px -28px rgba(14,124,123,.3), inset 3px 0 0 var(--teal); }

/* Importance tier pill */
.deck-tier {
  position: absolute; top: 18px; left: 24px; z-index: 2;
  font-size: 10px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 20px;
}
.deck-tier.crit { background: var(--danger-soft); color: var(--danger); }
.deck-tier.ess  { background: var(--teal-50); color: var(--teal-dark); }
.deck-tier.act  { background: #e7eefb; color: #3b6cb7; }
.deck-tier.note { background: #eef2f6; color: #6b7a89; }
.deck-tier.det  { background: #f3eef8; color: #7d3cb5; }
.deck-tier.ref  { background: #eef2f6; color: #6b7a89; }
.deck-tier.q    { background: #e9edf0; color: var(--ink); }

/* Order toggle (Priority / Reading) */
.deck-order {
  position: absolute; top: 12px; left: 16px; z-index: 60;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.85); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 6px 4px 12px; box-shadow: var(--shadow-sm);
}
.deck-order-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.deck-order-btn {
  font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; border: none;
  background: transparent; color: var(--ink-soft); padding: 4px 10px; border-radius: 14px;
  transition: background .2s, color .2s;
}
.deck-order-btn.on { background: var(--teal); color: #fff; }
.deck-order-btn:not(.on):hover { background: var(--surface-2); }
.deck-card:active { cursor: grabbing; }
.deck-card::-webkit-scrollbar { width: 8px; }

.deck-page-no {
  position: absolute; top: 16px; right: 20px; font-size: 12px; font-weight: 700;
  color: var(--teal); opacity: .5;
}
.deck-card-body { font-size: 16px; line-height: 1.62; }
.deck-card-body > *:first-child { margin-top: 0; }
.deck-q { font-weight: 700; color: var(--teal-dark); font-size: 19px; line-height: 1.35; margin-bottom: 4px; letter-spacing: -.2px; }
.deck-card-body .rich-block { margin-top: 12px; }

.deck-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 60;
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: var(--frost);
  backdrop-filter: blur(6px); color: var(--ink-soft); font-size: 24px; line-height: 1;
  box-shadow: var(--shadow-sm); transition: transform .2s var(--ease-spring), background .2s;
}
.deck-nav:hover { background: var(--surface); transform: translateY(-50%) scale(1.08); color: var(--teal-dark); }
.deck-nav:active { transform: translateY(-50%) scale(.94); }
.deck-nav.prev { left: 10px; }
.deck-nav.next { right: 10px; }

.deck-counter {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 60;
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  background: var(--frost); padding: 4px 12px; border-radius: 20px; border: 1px solid var(--line);
}
.deck-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60;
  font-size: 11px; color: var(--muted); letter-spacing: .2px;
}
.deck-glass-ctrl {
  position: absolute; top: 12px; right: 16px; z-index: 60;
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--frost); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px;
  font-size: 11px; font-weight: 600; color: var(--muted); box-shadow: var(--shadow-sm);
}
.deck-glass-ctrl input[type="range"] { width: 96px; accent-color: var(--teal); cursor: pointer; }

@media (max-width: 620px) { .deck-card { padding: 26px 24px; } .deck-glass-ctrl { top: 8px; right: 8px; } }

/* ===========================================================================
   Theming, brand pop & delight
   =========================================================================== */
/* Smooth cross-fade only while toggling (avoids permanent transition conflicts) */
html.theme-anim,
html.theme-anim *:not(.spinner):not(.dots i):not(.brand-mark):not(.brand-mark *) {
  transition: background-color .35s ease, color .3s ease, border-color .35s ease, box-shadow .3s ease, fill .3s ease !important;
}

/* Bolder brand: teal → violet wordmark gradient on the hero */
.grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-badge { background: linear-gradient(120deg, var(--teal-50), color-mix(in srgb, var(--accent-2) 16%, transparent)); }

/* Theme toggle button */
.theme-toggle { position: relative; }
.theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .ico-sun { display: none; }
  :root:not([data-theme]) .theme-toggle .ico-moon { display: inline-block; }
}
#lp-theme.btn-ghost { padding: 9px; width: 40px; display: inline-grid; place-items: center; }

/* Animated typing indicator (three bouncing dots) */
.dots { display: inline-flex; gap: 4px; align-items: center; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); display: inline-block; animation: dotPulse 1.2s var(--ease-in-out) infinite; }
.dots i:nth-child(2) { animation-delay: .16s; }
.dots i:nth-child(3) { animation-delay: .32s; }
@keyframes dotPulse { 0%, 60%, 100% { transform: scale(.6); opacity: .4; } 30% { transform: scale(1); opacity: 1; } }

/* Streaming caret on the assistant message while it types */
.msg-content.streaming::after {
  content: ''; display: inline-block; width: 2px; height: 1.05em; margin-left: 2px;
  background: var(--teal); vertical-align: -0.16em; border-radius: 1px; animation: caretBlink 1s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

/* Dark-mode niceties for surfaces that were tuned for light */
:root[data-theme="dark"] .lp-hero::before { opacity: .8; }
:root[data-theme="dark"] .concept-map { background: var(--surface-2); }
:root[data-theme="dark"] .markdown code { background: rgba(255,255,255,.08); }
:root[data-theme="dark"] .kc, :root[data-theme="dark"] .lp-why-item { background: var(--surface-2); }
:root[data-theme="dark"] .auth-view { background: radial-gradient(1200px 600px at 50% -10%, rgba(45,212,191,.10), var(--bg)); }
:root[data-theme="dark"] .app-loading { background: var(--bg); }

/* ===========================================================================
   Clinical Brain engine — calculators, patient context, drug labels, verify
   =========================================================================== */
.engine-wrap .mode-select { font-weight: 600; color: var(--teal-dark); }

/* Evidence impact badge (fwci) */
.src-titlerow { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.src-impact { font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 1px 7px; white-space: nowrap; }
.src-impact.high { color: var(--teal-dark); background: var(--teal-50); border-color: transparent; }

/* Calculators */
.calc-wrap { display: flex; flex-direction: column; gap: 10px; }
.calc-flag { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; font-weight: 600; color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: var(--radius-sm); padding: 9px 12px; }
.calc-flag-ico { flex-shrink: 0; }
.calc-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 12px 14px; }
.calc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.calc-name { font-weight: 600; font-size: 13.5px; }
.calc-risk { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 2px 9px; border-radius: 20px; }
.risk-normal { background: var(--teal-50); color: var(--teal-dark); }
.risk-low { background: rgba(46,160,90,.16); color: #2e9d5a; }
.risk-moderate { background: rgba(200,140,20,.16); color: #b5742b; }
.risk-high { background: rgba(230,120,30,.18); color: #d97a1e; }
.risk-very_high { background: rgba(214,69,69,.16); color: var(--danger); }
.risk-critical { background: var(--danger); color: #fff; }
.calc-value { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 2px; }
.calc-num { font-size: 26px; font-weight: 800; letter-spacing: -.5px; color: var(--ink); }
.calc-unit { font-size: 13px; color: var(--muted); }
.calc-interp { font-size: 13px; color: var(--ink-soft); }
.calc-inputs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.calc-chip { font-size: 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; color: var(--ink-soft); }
.calc-chip b { color: var(--ink-soft); font-weight: 600; text-transform: capitalize; }
.calc-stats { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Patient context panel */
.pt-panel { display: flex; flex-direction: column; gap: 9px; }
.pt-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start; font-size: 13px; }
.pt-key { font-weight: 700; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding-top: 3px; }
.pt-val { color: var(--ink); }
.pt-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-tag { font-size: 12px; background: var(--teal-50); color: var(--teal-dark); border-radius: 20px; padding: 2px 10px; }
.pt-tag.med { background: color-mix(in srgb, var(--accent-2) 15%, transparent); color: var(--accent-2); }
.pt-lab { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; color: var(--ink-soft); }
.pt-lab b { color: var(--ink); text-transform: capitalize; }

/* Counter-questions */
.cq-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cq-item { border-left: 3px solid var(--accent-2); padding: 2px 0 2px 12px; }
.cq-q { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.cq-why { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* Drug labels */
.dl-wrap { display: flex; flex-direction: column; gap: 12px; }
.dl-name { font-weight: 700; font-size: 14px; text-transform: capitalize; margin-bottom: 6px; }
.dl-section { border: 1px solid var(--line); border-radius: 7px; margin-bottom: 5px; background: var(--surface-2); }
.dl-section > summary { cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); list-style: none; }
.dl-section > summary::-webkit-details-marker { display: none; }
.dl-section.boxed { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.dl-section.boxed > summary { color: var(--danger); }
.dl-text { font-size: 12.5px; color: var(--ink-soft); line-height: 1.55; padding: 0 12px 12px; margin: 0; white-space: pre-wrap; }

/* Inline citation markers (numbered, clickable, match the "Sources cited" list) */
.markdown .cites { font-size: .66em; line-height: 0; vertical-align: super; white-space: nowrap; margin-left: 1px; }
.markdown .cite { color: var(--teal-dark); font-weight: 700; text-decoration: none; padding: 0 1px; }
.markdown .cite:hover { text-decoration: underline; }

/* ===========================================================================
   Clinical Brain visualizations — interaction matrix + decision tables
   =========================================================================== */
.viz-caption { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }

/* Severity palette (shared by matrix cells + badges) */
.sev-contraindicated { --sv: var(--danger); }
.sev-major   { --sv: #e0791f; }
.sev-moderate{ --sv: #c88a14; }
.sev-minor   { --sv: #b59a1e; }
.sev-none    { --sv: var(--teal); }

/* Interaction matrix grid */
.ixm-scroll { overflow-x: auto; border-radius: var(--radius-sm); }
.ix-matrix { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.ix-matrix th { font-weight: 600; color: var(--ink-soft); padding: 4px 6px; white-space: nowrap; }
.ixm-colh { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; max-height: 90px; }
.ixm-rowh { text-align: right; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.ixm-cell { width: 24px; height: 24px; border-radius: 5px; background: var(--surface-2); text-align: center; }
.ixm-cell.diag { background: var(--line); }
.ixm-cell.sev-none { background: color-mix(in srgb, var(--teal) 12%, var(--surface-2)); }
.ixm-cell[class*="sev-"]:not(.sev-none) { background: color-mix(in srgb, var(--sv) 32%, transparent); }
.ixm-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--sv); vertical-align: middle; }

/* Interaction detail cards */
.ixm-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ixm-item { border: 1px solid var(--line); border-left: 3px solid var(--sv); border-radius: var(--radius-sm); background: var(--surface-2); padding: 9px 12px; }
.ixm-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ixm-pair { font-weight: 600; font-size: 13px; text-transform: capitalize; }
.ixm-sev { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 20px; color: #fff; background: var(--sv); }
.ixm-effect { font-size: 12.5px; color: var(--ink); margin-top: 5px; }
.ixm-mgmt { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.ixm-mgmt::before { content: '→ '; color: var(--sv); font-weight: 700; }

/* Decision tables (generic) */
.viz-table-wrap { overflow-x: auto; }
.viz-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.viz-table th { text-align: left; font-weight: 700; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.viz-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); color: var(--ink); vertical-align: top; text-transform: capitalize; }
.viz-row.boxed td { background: var(--danger-soft); }
.cell-red { color: var(--danger); font-weight: 700; }
.cell-amber { color: #c88a14; font-weight: 700; }
.cell-yellow { color: #b59a1e; font-weight: 600; }
.viz-src-h, .viz-src-cell { width: 30px; text-align: center; }
.viz-src { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 4px; border-radius: 5px; }
.viz-src:hover { background: var(--hover); color: var(--ink); }
.viz-quote-row td { background: var(--surface-2); }
.viz-quote { font-size: 12px; color: var(--ink-soft); font-style: italic; text-transform: none; display: block; }
.viz-src-d { margin-top: 6px; }
.viz-src-d > summary { cursor: pointer; font-size: 11.5px; color: var(--teal-dark); font-weight: 600; }
.viz-src-d .viz-quote { margin-top: 5px; }

/* ===========================================================================
   Inline viz placement + structured drug facts + [drug label] badge
   =========================================================================== */
/* A viz placed inline at its [viz:id] tag inside the prose */
.markdown .viz-inline, .msg-content .viz-inline { margin: 14px 0; }

/* [drug label] citation badge */
.dl-cite {
  display: inline-block; font-size: 10.5px; font-weight: 700; line-height: 1.4;
  color: var(--teal-dark); background: var(--teal-50); border-radius: 20px;
  padding: 0 8px; vertical-align: baseline; white-space: nowrap;
}

/* Structured drug facts */
.df-wrap { display: flex; flex-direction: column; gap: 14px; }
.df-table { border: 1px solid var(--line); border-radius: 7px; margin-bottom: 5px; background: var(--surface-2); }
.df-table > summary {
  cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.df-table > summary::-webkit-details-marker { display: none; }
.df-count { font-size: 10.5px; font-weight: 700; color: var(--teal-dark); background: var(--teal-50); border-radius: 20px; padding: 1px 7px; }
.df-rows { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
.df-row { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.df-row:first-child { border-top: none; padding-top: 0; }
.df-row-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.df-primary { font-size: 13px; font-weight: 600; color: var(--ink); }
.df-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 1px 8px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.df-badge[class*="sev-"] { color: #fff; background: var(--sv); border-color: transparent; }
.df-badge.df-red { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.df-badge.df-amber { color: #c88a14; background: rgba(200,138,20,.14); border-color: transparent; }
.df-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.df-chip { font-size: 11.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; color: var(--ink-soft); }
.df-chip b { font-weight: 600; text-transform: capitalize; color: var(--muted); }

/* Viz content is height-capped and scrolls internally when long — an opened
   matrix or big decision table never dominates the prose or the panel column. */
.viz-inline .rich-body > *,
.rich-block .rich-body > .ixm-wrap,
.rich-block .rich-body > .viz-table-wrap { max-height: 420px; overflow-y: auto; }

/* ===========================================================================
   Lightbox — focused view for visualizations and source details
   =========================================================================== */
.lb-overlay {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(8, 12, 18, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 4vh 16px;
}
body.lb-open { overflow: hidden; }
.lb-panel {
  width: min(880px, 96vw); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .55);
}
.lb-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.lb-title { font-weight: 700; font-size: 16px; line-height: 1.35; }
.lb-close {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; border: none; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font-size: 14px;
}
.lb-close:hover { background: var(--hover); color: var(--ink); }
.lb-body { padding: 18px 20px; overflow-y: auto; }
@media (prefers-reduced-motion: no-preference) {
  .lb-overlay { animation: lbFade .18s ease both; }
  .lb-panel { animation: lbPop .28s var(--ease-spring) both; }
}
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbPop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* Viz inside the lightbox: no chrome, always open, no height cap */
.lb-body > .rich-block { border: none; background: transparent; }
.lb-body > .rich-block > .rich-head { display: none; }
.lb-body > .rich-block .rich-body { display: block; }
.lb-body > .rich-block .rich-body > * { max-height: none; padding: 0; border-top: none; }

/* Expand control on viz blocks */
.rich-block { position: relative; }
.rich-expand {
  position: absolute; top: 7px; right: 40px; z-index: 2;
  width: 26px; height: 26px; border-radius: 7px; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 13px; line-height: 1;
}
.rich-expand:hover { background: var(--hover); color: var(--ink); }
.rich-block.has-expand .rich-head { padding-right: 70px; }

/* Source detail lightbox content */
.src-detail { display: flex; flex-direction: column; gap: 14px; }
.src-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.src-pmid { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; color: var(--muted); }
.src-cited-badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--teal-dark); background: var(--teal-50); border-radius: 20px; padding: 1px 8px; }
.src-abstract { margin: 0; font-size: 14px; line-height: 1.65; color: var(--ink); }
.src-abstract.muted { color: var(--muted); font-style: italic; }
.src-detail-actions .btn-primary-sm { text-decoration: none; display: inline-block; }
.src-title { cursor: pointer; }

/* Share dialog */
.share-modal { min-width: min(440px, 80vw); }
.share-linkrow { display: flex; gap: 8px; }
.share-link { flex: 1; font-family: var(--mono); font-size: 12.5px; }
.share-modal .btn-primary-sm { white-space: nowrap; }

/* Shared read-only view: hide the interactive chrome */
.shared-banner { display: flex; align-items: center; gap: 8px; }
body.shared-mode #sidebar-toggle,
body.shared-mode .composer,
body.shared-mode #share-btn,
body.shared-mode .settings-wrap,
body.shared-mode .export-wrap,
body.shared-mode .msg-actions,
body.shared-mode .msg-copy { display: none !important; }
body.shared-mode .app-view { grid-template-columns: 1fr; }
/* Shared view keeps the composer shell only for the read-only patient panel */
body.shared-mode .composer { display: block !important; border-top: none; background: transparent; padding-top: 0; }
body.shared-mode .composer-inner, body.shared-mode .mode-seg, body.shared-mode .mode-seg-hint,
body.shared-mode .composer-disclaimer { display: none !important; }
body.shared-mode .composer-tools { margin-top: 0; padding-bottom: 6px; }
body.shared-mode .sidebar { display: none; }

.legal-link { color: var(--muted); text-decoration: underline; }
.legal-link:hover { color: var(--teal-dark); }

/* Copy-answer button: top-right of the assistant bubble, hover-revealed
   (always faintly visible on touch, where hover doesn't exist) */
.msg-bubble { position: relative; }
.icon-btn.msg-copy {
  position: absolute; top: 0; right: 0; opacity: 0;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.msg:hover .icon-btn.msg-copy, .icon-btn.msg-copy:focus-visible { opacity: 1; }
.icon-btn.msg-copy.copied { color: var(--teal); opacity: 1; }
@media (hover: none) { .icon-btn.msg-copy { opacity: .55; } }

/* Sidebar history search */
.conv-search { padding: 4px 12px 8px; }
.conv-search input {
  width: 100%; font: inherit; font-size: 13px; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink);
}
.conv-search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-50); }
.conv-search input::placeholder { color: var(--muted); }

/* Account modal + delete danger zone */
.acct-modal { display: flex; flex-direction: column; gap: 18px; min-width: min(340px, 78vw); }

/* Tabbed account shell: side menu + pane */
.acct-tabbed { flex-direction: row; gap: 20px; min-width: min(600px, 84vw); min-height: 320px; }
.acct-nav { display: flex; flex-direction: column; gap: 3px; flex: 0 0 148px; }
.acct-tab {
  text-align: left; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
  background: none; border: none; cursor: pointer; padding: 9px 12px; border-radius: 9px;
  transition: background .15s ease, color .15s ease;
}
.acct-tab:hover { background: var(--surface-2); color: var(--ink); }
.acct-tab.active { background: var(--teal-50); color: var(--teal-dark); }
.acct-panehost { flex: 1; min-width: 0; }
.acct-pane { display: flex; flex-direction: column; gap: 16px; animation: acctIn .18s ease both; }
@keyframes acctIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.acct-profile { display: flex; align-items: center; gap: 14px; }
.acct-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.acct-profile-meta { min-width: 0; }
.acct-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.acct-wide { justify-content: center; display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; }
.acct-wide.armed { color: var(--danger); border-color: var(--danger); }
.acct-desc { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }
.acct-links { margin-top: 4px; }
.acct-about-row {
  display: flex; justify-content: space-between; gap: 16px; font-size: 13px;
  padding: 6px 0; border-bottom: 1px solid var(--line-soft);
}
.acct-about-row:last-of-type { border-bottom: none; }
.acct-about-v { font-family: var(--mono); font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .acct-tabbed { flex-direction: column; min-width: 0; gap: 12px; }
  .acct-nav { flex-direction: row; flex: none; overflow-x: auto; gap: 4px; }
  .acct-tab { white-space: nowrap; padding: 7px 11px; font-size: 12.5px; }
}
.acct-field { display: flex; flex-direction: column; gap: 3px; }
.acct-label { font-size: 12px; color: var(--muted); }
.acct-email { font-size: 14.5px; font-weight: 650; color: var(--ink); word-break: break-all; }
.acct-section {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  background: var(--surface-2); display: flex; flex-direction: column; gap: 10px;
}
/* Password-manager pairing target: must stay in the layout tree (display:none
   fields get ignored for autofill pairing), just invisible. */
.acct-hidden-user {
  position: absolute; width: 1px; height: 1px; opacity: 0;
  pointer-events: none; border: 0; padding: 0; margin: 0;
}
.acct-section-title { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.acct-section .btn-primary-sm { align-self: flex-start; }
.acct-danger {
  border: 1px solid var(--danger); border-radius: 12px; padding: 16px;
  background: var(--danger-soft); display: flex; flex-direction: column; gap: 11px;
}
.acct-danger-title { font-size: 13.5px; font-weight: 800; color: var(--danger); }
.acct-danger-desc { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.acct-confirm {
  font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink);
}
.acct-confirm:focus { outline: none; border-color: var(--danger); box-shadow: 0 0 0 3px rgba(203, 68, 74, .18); }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover:not(:disabled) { filter: brightness(.93); }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; }
.acct-status { font-size: 12.5px; color: var(--muted); min-height: 16px; }
.acct-status.error { color: var(--danger); }
/* Sidebar user chip is now a button that opens the account modal */
.user-chip { border: none; background: none; text-align: left; cursor: pointer; border-radius: 8px; padding: 4px 6px; transition: background .15s ease; }
.user-chip:hover { background: var(--hover); }

/* ===========================================================================
   Enhanced engine (js/enhanced.js) — layered turn: tasks, preamble, prose,
   tables, sources, counter-questions, withheld surface
   =========================================================================== */
.enh-sec:empty { display: none; }
.enh-sec { margin: 12px 0; }
/* overflow stays visible — an overflow:hidden ancestor would become the sticky
   containment box and kill the drug-tab bar's stickiness; corners are rounded
   on the head/body instead of clipped. */
.enh-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin: 10px 0; }
.enh-card-head { border-radius: 11px 11px 0 0; }
.enh-card:not(.open) .enh-card-head { border-radius: 11px; }
.enh-card-body { border-radius: 0 0 11px 11px; }
.enh-card-head {
  width: 100%; display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 14px; background: var(--surface-2); border: none; text-align: left;
  font: inherit; color: var(--ink); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.enh-card-head:hover { background: var(--hover); }
.enh-chev { color: var(--muted); transition: transform .18s ease; display: inline-block; }
.enh-card:not(.open) .enh-chev { transform: rotate(-90deg); }
.enh-card-title { flex: 1; color: var(--ink-soft); }
.enh-card-badge { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: none; }
.enh-card-body { padding: 12px 14px; }
.enh-card:not(.open) .enh-card-body { display: none; }
.enh-expand {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 6px; font-size: 10px; letter-spacing: .06em; padding: 3px 9px; cursor: pointer;
}
.enh-expand:hover { color: var(--teal-dark); border-color: var(--teal); }

/* Task list (fills in as `vetted` lands) */
.enh-task-list { display: flex; flex-direction: column; gap: 2px; }
.enh-task { display: flex; gap: 9px; align-items: baseline; padding: 4px 0; font-size: 13.5px; }
.enh-task-dot { flex: none; width: 14px; color: var(--muted); }
.enh-task.done .enh-task-dot { color: var(--teal); }
.enh-task.gap .enh-task-dot { color: #c9821f; }
.enh-task-kind { font-family: var(--mono); font-size: 10.5px; color: var(--muted); min-width: 104px; flex: none; }
.enh-task-q { color: var(--ink); }
.enh-task-src { color: var(--muted); font-size: 11.5px; }
.enh-task-gap { color: #c9821f; font-size: 11.5px; }

/* Evidence-base preamble ("Retrieved N sources…") hidden for now at the clinician's request;
   the data still streams and renders, so re-enable by deleting this rule. */
.enh-pre { display: none; }
.enh-pre-body { font-size: 13.5px; line-height: 1.6; color: var(--ink-soft); }
.enh-prose { margin: 6px 0; }
.enh-wh-note { color: #c9821f; font-style: italic; }

/* Tables */
.enh-table-wrap { overflow-x: auto; }
.enh-table { border-collapse: collapse; table-layout: fixed; min-width: 100%; font-size: 12.5px; }
/* A cell never grows past ~5 lines; longer text scrolls inside the cell */
.enh-cell { max-height: 8.4em; overflow-y: auto; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.enh-cell::-webkit-scrollbar { width: 6px; }
.enh-cell::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.enh-table-wrap { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.enh-table th, .enh-table td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.enh-table th { color: var(--muted); font-weight: 700; background: var(--surface-2); }
.enh-table tr.hi td { background: var(--teal-50); box-shadow: inset 2px 0 var(--teal); }
/* Rows a clicked [viz:…#rows] marker asked for */
.enh-table tr.req td { background: rgba(230, 160, 40, .16); box-shadow: inset 2px 0 #e6a028; }
/* Folded, not-cited tables: sub-cards inside one control */
.enh-more-tables > .enh-card { margin: 6px 0; }
.enh-more-tables > .enh-card:first-child { margin-top: 0; }
.enh-more-tables > .enh-card:last-child { margin-bottom: 0; }
.enh-table-foot { color: var(--muted); font-size: 11.5px; margin-top: 8px; }

/* One drug-labels card: top tab bar of drug pills, one dossier at a time */
.enh-drugtab-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  border-bottom: 1px solid var(--line-soft);
  /* Stays attached while a long dossier scrolls by — sticks to the top of
     whichever scroller holds it (#messages or the lightbox body). Negative
     margins + matching padding bleed the background across the card padding. */
  /* top offsets cancel the scroller's padding-top (#messages: 24px desktop /
     16px mobile) so the pinned bar sits flush with the visible top edge. */
  position: sticky; top: -24px; z-index: 5; background: var(--surface);
  margin: -12px -14px 12px; padding: 12px 14px 11px;
}
.lb-body .enh-drugtab-bar { margin: -18px -20px 12px; padding: 14px 20px 11px; top: -18px; }
.enh-drugtab {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
  border-radius: 20px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.enh-drugtab:hover { color: var(--teal-dark); border-color: var(--teal); }
.enh-drugtab.active { background: var(--teal); border-color: var(--teal); color: #fff; }

/* Grouped drug-label card: one card per drug, sections stacked inside */
.enh-drug-secs { display: flex; flex-direction: column; gap: 16px; }
.enh-drug-sec-title {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--teal-dark); margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.enh-drug-sec-cited { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; }

/* Sources */
.enh-src-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.enh-src { display: flex; gap: 10px; }
.enh-src-n {
  flex: none; min-width: 20px; height: 20px; border-radius: 5px; background: var(--teal-50);
  color: var(--teal-dark); font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.enh-src-title { color: var(--ink); font-size: 13px; text-decoration: none; font-weight: 600; }
.enh-src-title:hover { color: var(--teal-dark); text-decoration: underline; }
.enh-src-fda { margin-left: 7px; vertical-align: 1px; }
.enh-src-meta { color: var(--muted); font-size: 11.5px; margin-top: 1px; }

.enh-cq-list { display: flex; flex-direction: column; gap: 7px; }
.enh-cq-item { font-size: 13px; line-height: 1.5; padding-left: 14px; position: relative; }
.enh-cq-item::before { content: '•'; position: absolute; left: 0; color: var(--teal); }
/* One tap asks the follow-up */
.enh-cq-btn {
  background: none; border: none; font: inherit; color: var(--ink); text-align: left;
  cursor: pointer; border-radius: 8px; padding: 5px 8px 5px 18px; margin: -2px 0;
  transition: background .15s ease, color .15s ease;
}
.enh-cq-btn::before { left: 6px; top: 5px; }
.enh-cq-btn:hover { background: var(--teal-50); color: var(--teal-dark); }
.enh-cq-btn:hover::after { content: ' ↵'; color: var(--teal); font-size: 11px; }

/* Per-source citation copy + actions note */
.enh-cite-copy {
  background: none; border: 1px solid var(--line); border-radius: 5px; cursor: pointer;
  color: var(--muted); padding: 1px 5px; margin-left: 7px; vertical-align: 1px; line-height: 1;
}
.enh-cite-copy:hover { color: var(--teal-dark); border-color: var(--teal); }
.act-note { font-size: 11.5px; color: var(--muted); align-self: center; margin-left: 6px; font-style: italic; }

/* Withheld-sentences honesty surface */
.enh-withheld-card .enh-card-head { background: var(--danger-soft); }
.enh-withheld-card .enh-card-title { color: var(--danger); }
.enh-wh-list { display: flex; flex-direction: column; gap: 10px; }
.enh-wh-item { display: flex; gap: 10px; }
.enh-wh-sev {
  flex: none; font-size: 9.5px; font-weight: 800; letter-spacing: .5px; padding: 1px 6px;
  border-radius: 5px; height: fit-content; background: var(--surface-2); color: var(--muted);
}
.enh-wh-sev.sev-high { background: var(--danger-soft); color: var(--danger); }
.enh-wh-sev.sev-medium { background: rgba(201,130,31,.14); color: #c9821f; }
.enh-wh-sentence { font-size: 13px; color: var(--ink); }
.enh-wh-why { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.enh-marks { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 12px; }
.cite-mark { font-family: var(--mono); font-size: .9em; }

/* Options pop-over (chat header): one icon, a small box that scales in */
.settings-wrap { position: relative; display: inline-flex; }
.settings-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45; min-width: 248px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 50px -10px rgba(0, 0, 0, .4); padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0; transform: scale(.92) translateY(-6px); transform-origin: top right;
  visibility: hidden; pointer-events: none;
  transition: opacity .16s ease, transform .22s var(--ease-spring), visibility 0s .22s;
}
.settings-menu.open {
  opacity: 1; transform: none; visibility: visible; pointer-events: auto;
  transition: opacity .16s ease, transform .22s var(--ease-spring), visibility 0s;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 7px 9px; border-radius: 8px;
}
.set-row:hover { background: var(--surface-2); }
.set-row[hidden] { display: none; }
.set-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.set-row .mode-select { max-width: 150px; }
.icon-btn.active-ctl { background: var(--teal-50); color: var(--teal-dark); }

/* Export menu (chat header) */
.export-wrap { position: relative; display: inline-flex; }
.export-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 168px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 40px -8px rgba(0, 0, 0, .35); padding: 5px; display: flex; flex-direction: column;
}
.export-menu button {
  border: none; background: none; cursor: pointer; text-align: left; font: inherit;
  font-size: 13px; color: var(--ink); padding: 8px 11px; border-radius: 7px;
}
.export-menu button:hover { background: var(--teal-50); color: var(--teal-dark); }

/* Archived (previous-system) conversations: read-only */
.conv-archived {
  margin-left: 6px; font-size: 9.5px; font-weight: 800; letter-spacing: .5px;
  text-transform: uppercase; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 20px; padding: 0 6px;
}
.enh-archive-banner {
  max-width: 820px; margin: 0 auto 18px; padding: 10px 16px; font-size: 13px;
  color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--muted); border-radius: 10px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
}
.enh-archive-new { font-size: 12.5px; padding: 5px 12px; }
/* archived (read-only) conversation: no input box */
.composer.read-only { display: none; }

/* Preamble phrase styling (fixed computed phrases from the server) */
.enh-pre-chip {
  display: inline-block; font-size: 12px; font-weight: 650; color: var(--teal-dark);
  background: var(--teal-50); border-radius: 7px; padding: 2px 8px; margin-bottom: 4px;
}
.enh-pre-gap { color: #c9821f; }
.enh-pre-scope { color: var(--muted); }

/* Focused-mode offer: set-aside sub-questions as one-click follow-ups */
.enh-nx { margin: 4px 0 2px; }
.enh-nx-title { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.enh-nx-list { display: flex; flex-wrap: wrap; gap: 8px; }
.enh-nx-btn {
  font: inherit; font-size: 13px; line-height: 1.4; text-align: left; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px 7px 12px; cursor: pointer; max-width: 100%;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.enh-nx-btn::before { content: '+'; font-weight: 700; color: var(--teal); margin-right: 7px; }
.enh-nx-btn:hover { border-color: var(--teal); background: var(--teal-50); color: var(--teal-dark); }
.enh-nx-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
/* The computed closing line when the buttons above already carry the offer */
.enh-notexp-line { margin: 14px 0 4px; font-size: 13px; font-style: italic; color: var(--muted); }
/* Settings pop-over: personalization controls */
.accent-picker { display: flex; gap: 7px; align-items: center; }
.accent-dot {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
  background: var(--dot); box-shadow: 0 0 0 1px var(--line); transition: transform .12s ease, box-shadow .12s ease;
}
.accent-dot:hover { transform: scale(1.12); }
.accent-dot.active { border-color: var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.accent-dot[data-accent="teal"]   { --dot: #0e7c7b; }
.accent-dot[data-accent="blue"]   { --dot: #2563eb; }
.accent-dot[data-accent="violet"] { --dot: #6d5efc; }
.accent-dot[data-accent="green"]  { --dot: #15803d; }
.accent-dot[data-accent="amber"]  { --dot: #d97706; }
.accent-dot[data-accent="rose"]   { --dot: #be123c; }
:root[data-theme="dark"] .accent-dot[data-accent="teal"]   { --dot: #2dd4bf; }
:root[data-theme="dark"] .accent-dot[data-accent="blue"]   { --dot: #60a5fa; }
:root[data-theme="dark"] .accent-dot[data-accent="violet"] { --dot: #8b7bff; }
:root[data-theme="dark"] .accent-dot[data-accent="green"]  { --dot: #4ade80; }
:root[data-theme="dark"] .accent-dot[data-accent="amber"]  { --dot: #fbbf24; }
:root[data-theme="dark"] .accent-dot[data-accent="rose"]   { --dot: #fb7185; }
.set-check input { width: 16px; height: 16px; accent-color: var(--teal); margin: 0; }
.set-reset {
  align-self: flex-end; background: none; border: none; font: inherit; font-size: 11.5px; color: var(--muted);
  cursor: pointer; padding: 2px 0 0; text-decoration: underline;
}
.set-reset:hover { color: var(--ink); }
/* Settings pop-over: one-line hint for the selected mode */
.set-hint { margin: -4px 0 6px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.set-hint:empty { display: none; }

/* "Not expanded in clinical mode" footer → go-deeper affordance */
.enh-notexp {
  margin: 14px 0 4px; padding: 10px 14px; font-size: 13px; font-style: italic;
  color: var(--ink-soft); background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: 10px; cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.enh-notexp:hover { border-color: var(--teal); background: var(--teal-50); }
.enh-deeper { font-style: normal; font-weight: 700; color: var(--teal-dark); white-space: nowrap; }

/* FDA / DailyMed label lightbox */
.fda-detail { display: flex; flex-direction: column; gap: 14px; }
.src-fda-badge {
  font-size: 10px; font-weight: 800; letter-spacing: .5px; color: #7a4dbf;
  background: rgba(125, 60, 181, .12); border-radius: 20px; padding: 1px 7px;
}
.fda-toc {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line-soft);
}
.fda-toc-chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
  border-radius: 20px; padding: 4px 11px; font-size: 12px; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.fda-toc-chip:hover { background: var(--teal-50); color: var(--teal-dark); border-color: var(--teal); }
.fda-body { display: flex; flex-direction: column; gap: 18px; }
.fda-cat {
  margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .6px;
  text-transform: uppercase; color: var(--teal-dark);
}
.fda-sec { border-top: 1px solid var(--line-soft); }
.fda-sec:first-of-type { border-top: none; }
.fda-sec-h {
  cursor: pointer; padding: 9px 0; font-size: 13.5px; font-weight: 650; color: var(--ink);
  list-style: none;
}
.fda-sec-h::-webkit-details-marker { display: none; }
.fda-sec-h::before { content: '▸ '; color: var(--muted); font-size: 11px; }
.fda-sec[open] > .fda-sec-h::before { content: '▾ '; }
.fda-sec-body { padding: 0 0 12px 14px; }
.fda-sec-body p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.62; color: var(--ink); }
.fda-sec-body p:last-child { margin-bottom: 0; }

/* ===========================================================================
   Brand logo image (Academica wordmark, transparent PNG)
   =========================================================================== */
/* align-self prevents flex-column parents (sidebar head) from stretching the
   image to full width; object-fit keeps the aspect no matter what. */
.brand-img { height: 34px; width: auto; display: block; align-self: center; object-fit: contain; }
.lp-nav .brand-img.nav { height: 30px; }
.auth-logo-img { height: 64px; width: auto; display: block; margin: 0 auto 8px; object-fit: contain; }
.lp-logo-img { height: 92px; width: auto; display: block; object-fit: contain; }
.welcome-logo-img { height: 76px; width: auto; display: block; margin: 0 auto 12px; object-fit: contain; }

/* Dark mode: flip the dark wordmark to light; hue-rotate keeps the bars blue */
:root[data-theme="dark"] .brand-img,
:root[data-theme="dark"] .auth-logo-img,
:root[data-theme="dark"] .lp-logo-img,
:root[data-theme="dark"] .welcome-logo-img { filter: invert(1) hue-rotate(195deg) saturate(1.2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .brand-img,
  :root:not([data-theme]) .auth-logo-img,
  :root:not([data-theme]) .lp-logo-img,
  :root:not([data-theme]) .welcome-logo-img { filter: invert(1) hue-rotate(195deg) saturate(1.2); }
}

/* Hero logo keeps the gentle float (replaces the old brand-mark animation) */
@media (prefers-reduced-motion: no-preference) {
  .lp-logo .lp-logo-img { animation: floatIn .7s var(--ease-spring) both, logoFloat 6s var(--ease-in-out) 1s infinite; }
}

/* ===========================================================================
   Clinician feedback — action row + lightbox form
   =========================================================================== */
.msg-actions { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.act-btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; font-weight: 600;
  color: var(--muted); background: none; border: 1px solid transparent; border-radius: 7px;
  padding: 4px 8px; cursor: pointer; transition: color .15s, background .15s;
}
.act-btn:hover { color: var(--ink); background: var(--hover); }
.act-btn.on { color: var(--teal-dark); background: var(--teal-50); }
.act-fb { margin-left: 4px; }
/* Copy controls: always visible, outlined so they read as buttons */
.act-btn.act-copy { color: var(--ink-soft); border-color: var(--line); background: var(--surface); }
.act-btn.act-copy:hover { color: var(--ink); border-color: var(--muted); }
.act-sep { width: 1px; height: 16px; background: var(--line); margin: 0 6px; }
.act-sep:last-child { display: none; }
/* The row is hidden until the turn has text; feedback buttons join it later */
.msg-actions:empty { display: none; }

.fb-form { display: flex; flex-direction: column; gap: 14px; }
.fb-row { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-seg, .fb-chip {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 14px; cursor: pointer; transition: all .15s;
}
.fb-seg:hover, .fb-chip:hover { border-color: var(--muted); }
.fb-seg.on, .fb-chip.on { color: var(--teal-dark); background: var(--teal-50); border-color: transparent; }
.fb-chip { text-transform: capitalize; }
.fb-text {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; resize: vertical;
}
.fb-text:focus { outline: none; border-color: var(--teal); background: var(--surface); box-shadow: 0 0 0 3px var(--teal-50); }
.fb-form .btn-primary { width: auto; align-self: flex-start; padding: 10px 22px; }
.fb-status { font-size: 13px; color: var(--teal-dark); min-height: 18px; }

.fb-existing { border-top: 1px solid var(--line-soft); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.fb-existing:empty { display: none; }
.fb-existing-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.fb-entry { font-size: 13px; }
.fb-entry-head { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); flex-wrap: wrap; }
.fb-mini.up { color: var(--teal-dark); } .fb-mini.down { color: var(--danger); }
.fb-cat { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 0 8px; color: var(--muted); }
.fb-date { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.fb-entry-text { color: var(--ink); margin-top: 3px; }

/* Feedback dismiss */
.fb-del { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px 5px; border-radius: 5px; display: inline-flex; }
.fb-del:hover { color: var(--danger); background: var(--danger-soft); }
.fb-del:disabled { opacity: .5; cursor: default; }
.fb-del-err { font-size: 10.5px; color: var(--muted); font-style: italic; }

/* FDA label viewer: pinned top bar (drug, label date, DailyMed) + chapter chips */
.lb-body .fda-top {
  position: sticky; top: -18px; z-index: 5; background: var(--surface);
  margin: -18px -20px 0; padding: 14px 20px 12px; border-bottom: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 10px;
}
.fda-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fda-top-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); }
.fda-top-drug { font-weight: 700; color: var(--ink); font-size: 14px; }
.fda-top-dm { text-decoration: none; white-space: nowrap; }
.fda-top .fda-toc { padding-bottom: 0; border-bottom: none; }
.fda-detail .fda-body { gap: 22px; }
.fda-group .fda-cat { margin-bottom: 4px; }
.fda-sec-body p { max-width: 72ch; }
@media (max-width: 640px) {
  .lb-body .fda-top { top: -14px; margin: -14px -14px 0; padding: 12px 14px 10px; }
}

/* Manufacturer's instructions: compact tile in the answer + lightbox */
.ifu-tile {
  border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: var(--radius);
  background: var(--surface); padding: 14px 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.ifu-tile:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.ifu-tile:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.ifu-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ifu-tile-kicker { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ifu-tile-cited { font-size: 11px; color: var(--teal-dark); background: var(--teal-50); border-radius: 20px; padding: 2px 9px; white-space: nowrap; }
.ifu-tile-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.ifu-tile-facts { font-size: 12.5px; color: var(--muted); }
.ifu-tile-highlights { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.ifu-tile-actions { display: flex; align-items: center; gap: 14px; margin-top: 2px; }
.ifu-tile-pdf { font-size: 12.5px; color: var(--teal-dark); text-decoration: none; }
.ifu-tile-pdf:hover { text-decoration: underline; }

.ifu-row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 8px; background: var(--surface-2);
  border-left: 3px solid var(--line); font-size: 13px; line-height: 1.55; color: var(--ink);
  transition: background .3s ease;
}
.ifu-row-safety { border-left-color: var(--danger); }
.ifu-row.flash { background: var(--teal-50); }
.ifu-quote { flex: 1 1 260px; }
.ifu-page { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.ifu-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
  padding: 1px 7px; border-radius: 20px; background: var(--hover); color: var(--ink-soft);
}
.ifu-tag-warning, .ifu-tag-contraindication, .ifu-tag-danger, .ifu-tag-caution { background: var(--danger-soft); color: var(--danger); }

.lb-body .ifu-top {
  position: sticky; top: -18px; z-index: 5; background: var(--surface);
  margin: -18px -20px 0; padding: 14px 20px 12px; border-bottom: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 10px;
}
.ifu-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ifu-top-meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; font-size: 12.5px; color: var(--muted); }
.ifu-top-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.ifu-top-doc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.ifu-top-pdf { text-decoration: none; white-space: nowrap; }
.ifu-top .fda-toc { padding-bottom: 0; border-bottom: none; }
.ifu-chip-safety { border-color: var(--danger); color: var(--danger); }
.ifu-detail { display: flex; flex-direction: column; gap: 16px; }
.ifu-note { margin-top: 14px; padding: 10px 14px; border-radius: 8px; background: var(--teal-50); color: var(--ink); font-size: 13px; line-height: 1.55; }
.ifu-note-label { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--teal-dark); margin-bottom: 4px; }
.ifu-body { display: flex; flex-direction: column; gap: 22px; margin-top: 14px; }
.ifu-sec { display: flex; flex-direction: column; gap: 6px; }
.ifu-sec-title { margin: 0 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--teal-dark); display: flex; gap: 10px; align-items: baseline; }
.ifu-sec-safety .ifu-sec-title { color: var(--danger); }
.ifu-sec-page { font-family: var(--mono); font-size: 10.5px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); }
.ifu-stance { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); font-style: italic; }
@media (max-width: 640px) {
  .lb-body .ifu-top { top: -14px; margin: -14px -14px 0; padding: 12px 14px 10px; }
  .ifu-top-doc { max-width: 100%; }
}
.ifu-top-row { flex-wrap: nowrap; }
.ifu-top-meta { flex: 1 1 auto; overflow: hidden; }
.ifu-top-doc { max-width: 220px; }
.ifu-top-pdf { flex-shrink: 0; padding: 6px 12px; font-size: 12.5px; }
.ifu-chip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .ifu-top-row { flex-wrap: wrap; } .ifu-top-doc { display: none; } }

/* ===== Dev lanes 2026-10-15 / 10-17 (beta): inline figures, 3D views, product card, equipment box,
   privacy line, record-entry draft ===== */

/* inline placeholders while the stream runs; filled or removed when the answer finishes */
.enh-inline { display: block; margin: 12px 0; }
.enh-inline:empty::before {
  display: block; content: "Figure loading\2026"; padding: 14px 16px; border: 1px dashed var(--line);
  border-radius: var(--radius); color: var(--muted); font-size: 12.5px; background: var(--surface-2);
}
.enh-inline-model:empty::before { content: "3D view loading\2026"; }
span.enh-inline { display: inline; margin: 0; }
span.enh-inline:empty::before { display: none; }

/* inline figure (manual F / published L) */
.inl-fig { margin: 14px 0 16px; padding: 0; }
.inl-fig-kicker { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.inl-fig-frame {
  display: flex; align-items: center; justify-content: center; cursor: zoom-in;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden;
}
.inl-fig-frame:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.inl-fig-img { display: block; width: 100%; height: 280px; object-fit: contain; }
.inl-fig figcaption { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }
.inl-fig figcaption > .inl-fig-line:first-child { color: var(--ink); font-weight: 600; }
.inl-fig figcaption > .inl-fig-cap:first-child { font-weight: 400; color: var(--ink-soft); }
.inl-fig-intext-label, .inl-fig-ai { color: var(--muted); }
.inl-fig-attr, .inl-fig-src { font-size: 11.5px; color: var(--muted); }
.inl-fig-attr a { color: var(--teal-dark); text-decoration: none; }
.inl-fig-more { border: none; background: none; padding: 0; color: var(--teal-dark); cursor: pointer; font-size: 12px; }
.inl-fig-missing {
  padding: 26px 16px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: 12.5px; background: var(--surface-2);
}
.inl-fig-lb img { display: block; max-width: 100%; max-height: 64vh; margin: 0 auto 12px; background: #fff; border-radius: 8px; }
.inl-fig-lb p { margin: 4px 0; font-size: 13px; color: var(--ink-soft); }

/* 3D view card + related views */
.inl-3d {
  display: flex; align-items: center; gap: 14px; margin: 12px 0; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.inl-3d-badge {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: var(--on-accent); background: var(--grad);
}
.inl-3d-main { flex: 1 1 auto; min-width: 0; }
.inl-3d-title { font-weight: 700; color: var(--ink); font-size: 14px; }
.inl-3d-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.inl-3d-note { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 3px; }
.inl-3d-open { flex-shrink: 0; white-space: nowrap; }
.inl-3d-related-title { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 4px 0 6px; }
@media (max-width: 560px) { .inl-3d { flex-wrap: wrap; } .inl-3d-open { width: 100%; } }

/* 3D viewer side panel */
.jaw3d-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(50vw, 900px); z-index: 900;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px -20px rgba(0, 0, 0, .45);
}
.jaw3d-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.jaw3d-head .lb-close { position: static; flex-shrink: 0; }
.jaw3d-title { font-weight: 700; font-size: 15px; color: var(--ink); }
.jaw3d-sub { font-size: 11.5px; color: var(--muted); }
.jaw3d-frame { flex: 1 1 auto; width: 100%; border: 0; background: #0b0f14; }
@media (max-width: 900px) { .jaw3d-panel { width: 100vw; border-left: none; } }

/* product card (in the manual lightbox) + photo/intended use on the tile */
.pcard {
  display: grid; grid-template-columns: 160px 1fr; gap: 16px; margin-top: 14px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.pcard.pcard-nophoto { grid-template-columns: 1fr; }
.pcard-photo { width: 160px; height: 160px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line-soft); }
.pcard-photo-missing { display: grid; place-items: center; font-size: 11.5px; color: var(--muted); text-align: center; padding: 8px; box-sizing: border-box; }
.pcard-main { min-width: 0; }
.pcard-name { font-weight: 700; font-size: 15px; color: var(--ink); }
.pcard-cat { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pcard-use { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink); }
.pcard-use-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.pcard-specs { margin-top: 10px; border-collapse: collapse; font-size: 12.5px; width: 100%; }
.pcard-specs tr + tr { border-top: 1px solid var(--line-soft); }
.pcard-specs th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 4px 12px 4px 0; vertical-align: top; }
.pcard-specs td { padding: 4px 12px 4px 0; color: var(--ink); vertical-align: top; }
.pcard-specs td.pcard-spec-page { text-align: right; padding-right: 0; white-space: nowrap; }
.pcard-page-link { border: none; background: none; padding: 0; font-family: var(--mono); font-size: 11px; color: var(--teal-dark); cursor: pointer; }
.pcard-page-link:hover { text-decoration: underline; }
.pcard-doc { margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.pcard-doc a { color: var(--teal-dark); text-decoration: none; }
@media (max-width: 640px) { .pcard { grid-template-columns: 1fr; } .pcard-photo { width: 100%; height: 180px; } }
.ifu-tile-body { display: flex; gap: 14px; align-items: flex-start; }
.ifu-tile-photo { flex-shrink: 0; width: 76px; height: 76px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line-soft); }
.ifu-tile-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ifu-tile-use { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; }
.ifu-figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.ifu-figs .inl-fig { margin: 0; }
.ifu-figs .inl-fig-img { height: 180px; }

/* "your equipment" box */
.sugg-box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.sugg-head { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 11px 14px; }
.sugg-head::-webkit-details-marker { display: none; }
.sugg-head::before { content: "\25B8"; color: var(--muted); font-size: 11px; }
.sugg-box[open] > .sugg-head::before { content: "\25BE"; }
.sugg-kicker { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--teal-dark); }
.sugg-name { font-weight: 700; color: var(--ink); font-size: 13.5px; }
.sugg-src { font-size: 11.5px; color: var(--muted); }
.sugg-body { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.sugg-why, .sugg-note { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.sugg-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.sugg-foot a { color: var(--teal-dark); text-decoration: none; }

/* privacy line + masked tokens */
.privacy-line { margin-top: 6px; font-size: 11.5px; opacity: .75; }
.mask-chip {
  display: inline-block; padding: 0 7px; margin: 0 1px; border-radius: 20px; font-size: 11px; line-height: 17px;
  background: var(--hover); color: var(--muted); vertical-align: 1px;
}

/* record-entry draft */
.cd-modal { display: flex; flex-direction: column; gap: 14px; }
.cd-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cd-disclaimer { font-size: 12.5px; color: var(--danger); font-weight: 600; }
.cd-top-actions { display: flex; align-items: center; gap: 10px; }
.cd-status { font-size: 12px; color: var(--muted); }
.cd-loading, .cd-error { padding: 18px 4px; color: var(--muted); font-size: 13px; }
.cd-error { color: var(--danger); }
.cd-blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cd-block { display: flex; flex-direction: column; gap: 5px; }
.cd-block-head { display: flex; align-items: center; gap: 8px; }
.cd-block-title { font-size: 12px; font-weight: 800; color: var(--ink); }
.cd-tag { font-size: 10.5px; padding: 1px 8px; border-radius: 20px; background: var(--teal-50); color: var(--teal-dark); }
.cd-text {
  width: 100%; box-sizing: border-box; resize: vertical; font: inherit; font-size: 13px; line-height: 1.5;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.cd-proposal .cd-text { border-style: dashed; }
.cd-grounds { font-size: 11.5px; color: var(--muted); }
.cd-codes { display: flex; flex-direction: column; gap: 6px; }
.cd-codes-title { font-size: 12px; font-weight: 800; color: var(--ink); }
.cd-code {
  display: grid; grid-template-columns: auto 150px 80px 1fr; gap: 4px 10px; align-items: baseline;
  padding: 7px 10px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; cursor: pointer;
}
.cd-sys { color: var(--muted); font-size: 11.5px; }
.cd-code-val { font-family: var(--mono); }
.cd-code-none { opacity: .7; cursor: default; }
.cd-leaf { color: var(--danger); font-size: 11.5px; }
.cd-rests { grid-column: 2 / -1; font-size: 11.5px; color: var(--muted); }
@media (max-width: 640px) {
  .cd-blocks { grid-template-columns: 1fr; }
  .cd-code { grid-template-columns: auto 1fr; }
  .cd-code-val, .cd-code-name, .cd-sys { grid-column: 2; }
}

/* "Show in 3D" tool loop: the caption under the viewer (composed by the server from the tools' results) */
.jaw3d-caption { padding: 10px 16px 12px; border-top: 1px solid var(--line-soft); font-size: 13px; line-height: 1.5; color: var(--ink); }
.jaw3d-caption[hidden] { display: none; }
.jaw3d-caption.busy { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.jaw3d-caption .spinner { color: var(--teal); }
.jaw3d-caption-note { margin-top: 3px; font-size: 11px; font-style: italic; color: var(--muted); }

/* 3D panel: ask line, standalone workspace; figures "show more"; sidebar 3D button */
.jaw3d-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.jaw3d-ask { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line-soft); }
.jaw3d-ask-input {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 13.5px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.jaw3d-ask-input:focus { outline: none; border-color: var(--teal); }
.jaw3d-ask-input:disabled { opacity: .6; }
.jaw3d-panel.jaw3d-studio { width: 100vw; border-left: none; }
.jaw3d-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 280px 1fr; }
.jaw3d-side { overflow-y: auto; padding: 12px; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 14px; }
.jaw3d-side-sec { display: flex; flex-direction: column; gap: 2px; }
.jaw3d-side-title { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px 6px; }
.jaw3d-side-empty { font-size: 12px; color: var(--muted); padding: 2px 6px; }
.jaw3d-side-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left;
  border: none; background: none; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit;
}
.jaw3d-side-item:hover:not(:disabled) { background: var(--hover); }
.jaw3d-side-item:disabled { opacity: .5; cursor: default; }
.jaw3d-side-q { font-size: 13px; line-height: 1.35; }
.jaw3d-side-meta { font-size: 11px; color: var(--muted); }
.jaw3d-cat > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); padding: 5px 6px; border-radius: 8px; }
.jaw3d-cat > summary:hover { background: var(--hover); }
.jaw3d-cat > .jaw3d-side-item { padding-left: 18px; }
.jaw3d-new { justify-content: center; }
@media (max-width: 760px) {
  .jaw3d-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 32vh) 1fr; }
  .jaw3d-side { border-right: none; border-bottom: 1px solid var(--line-soft); }
}
.enh-fig-more { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.enh-fig-more-btn { font-size: 12.5px; padding: 6px 12px; }
.enh-fig-none { font-size: 12.5px; color: var(--muted); }
.btn-3d { display: flex; align-items: center; gap: 8px; margin-top: -4px; padding: 8px 12px; font-size: 13.5px; color: var(--ink-soft); }
.btn-3d:hover { color: var(--ink); background: var(--hover); }

/* ===== Dev handout 2026-10-28 (beta): product nutshell / generic procedure / documents, translation line,
   skills (adapt row, tools, charts, commands), calculators, figure search ===== */

/* page links to the original PDF */
a.ifu-page-link { color: var(--teal-dark); text-decoration: none; white-space: nowrap; }
a.ifu-page-link:hover { text-decoration: underline; }
.ifu-sec-title a.ifu-sec-page { font-weight: 500; }

/* nutshell */
.pn { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.pn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pn-kicker { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--teal-dark); }
.pn-chip { display: inline-block; font-size: 11px; padding: 1px 9px; border-radius: 20px; background: var(--hover); color: var(--ink-soft); }
.pn-page { font-size: 12px; color: var(--teal-dark); text-decoration: none; margin-left: auto; }
.pn-banner { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; }
.pn-group-title { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ifu-matched { margin: 18px 0 2px; }
.pn-safety { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; border-left: 3px solid var(--danger); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.pn-block-title { font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.pn-block-note { font-weight: 500; color: var(--muted); }
.pn-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.pn-item { font-size: 13px; line-height: 1.5; color: var(--ink); }
.pn-item .ifu-tag { margin-right: 6px; }
.pn-item .ifu-page, .pn-item .ifu-page-link { margin-left: 6px; font-size: 11.5px; }
.pn-heading { color: var(--muted); }
.pn-values { font-weight: 600; }
.pn-mkt { display: inline-block; margin-left: 6px; font-size: 10.5px; padding: 0 7px; border-radius: 20px; background: #fff4d6; color: #8a5a00; }
.pn-marketing .ifu-quote { color: var(--ink-soft); }
.pn-notheld { margin: 0; font-size: 12.5px; color: var(--muted); font-style: italic; }
.ifu-tile-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }

/* generic procedure */
.gp { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.gp > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; padding: 11px 14px; }
.gp > summary::-webkit-details-marker { display: none; }
.gp > summary::before { content: "\25B8"; color: var(--muted); font-size: 11px; }
.gp[open] > summary::before { content: "\25BE"; }
.gp-class { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.gp > :not(summary) { margin-left: 14px; margin-right: 14px; }
.gp-stance { font-size: 12px; color: var(--muted); margin-top: 0; }
.gp-phase { margin-bottom: 10px; }
.gp-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.gp-step-text { font-size: 13px; line-height: 1.5; color: var(--ink); }
.gp-branch { font-weight: 700; color: var(--teal-dark); }
.gp-varies { display: inline-block; margin-left: 6px; font-size: 10.5px; padding: 0 7px; border-radius: 20px; background: var(--teal-50); color: var(--teal-dark); }
.gp-evidence { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.gp-support summary { cursor: pointer; font-size: 11.5px; color: var(--teal-dark); }
.gp-support ul { margin: 4px 0 0; padding-left: 16px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.gp-maker { font-weight: 600; }
.gp-actions { padding-bottom: 12px; }

/* documents table */
.pdocs { margin-top: 14px; }
.pdocs-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; }
.pdocs-table td { padding: 6px 8px 6px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
.pdocs-doc a, .pdocs-pages a, .pdocs-meta a { color: var(--teal-dark); text-decoration: none; }
.pdocs-doc a { word-break: break-all; }
.pdocs-maker, .pdocs-meta { color: var(--muted); }
.pdocs-pages { white-space: nowrap; }
.pdocs-note { font-size: 11px; color: var(--muted); margin: 6px 0 0; }

/* translation line */

/* skills row under an answer */
.act-skills.on { color: var(--teal-dark); background: var(--teal-50); }
.sk-row-host { margin-top: 10px; }
.sk-row { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.sk-title { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.sk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sk-card {
  text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.sk-card:hover { border-color: var(--teal); color: var(--teal-dark); }
.sk-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sk-tool { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 20px; padding: 4px 11px; font: inherit; font-size: 12px; cursor: pointer; }
.sk-tool:hover:not(:disabled) { color: var(--ink); border-color: var(--teal); }
.sk-tool:disabled { opacity: .6; cursor: progress; }
.sk-tool-group { display: inline-flex; gap: 4px; align-items: center; }
.sk-fmt { font-size: 12px; padding: 3px 6px; }
.sk-status { font-size: 12px; color: var(--muted); }
.sk-empty { font-size: 12.5px; color: var(--muted); padding: 6px 2px; }
.sk-error { color: var(--danger); font-size: 13px; }
.sk-error p { margin: 0 0 8px; }
.sk-ask { margin-top: 4px; }

/* adapt draft panel */
.adapt { display: flex; flex-direction: column; gap: 12px; }
.adapt-tag { font-size: 12px; font-weight: 700; color: var(--danger); }
.adapt-doc { padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); outline: none; }
.adapt-doc:focus { border-color: var(--teal); }
.adapt-doc h2 { font-size: 15px; margin: 14px 0 6px; }
.adapt-blank { background: #fff4d6; color: #8a5a00; border-radius: 4px; padding: 0 3px; }
.adapt-general { display: inline-block; font-size: 10.5px; font-weight: 650; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; vertical-align: 1px; user-select: none; }
.adapt-doc.copying .adapt-general { display: none; }
/* documents made from a turn (skill runs), under its actions */
.sk-runs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.sk-runs-title { color: var(--muted); }
.sk-run { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 20px; padding: 3px 10px; font: inherit; cursor: pointer; }
.sk-run:hover:not(:disabled) { color: var(--ink); border-color: var(--teal); }
.sk-run:disabled { opacity: .6; cursor: progress; }
.sk-run-old { border-style: dashed; }
.cd-icd { font-size: 12px; }
.adapt-left summary { cursor: pointer; font-size: 12.5px; color: var(--ink-soft); }
.adapt-left ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-soft); }
.adapt-why { color: var(--muted); }
.adapt-foot { margin: 0; font-size: 11.5px; color: var(--muted); }

/* charts */
.sk-chart { width: 100%; overflow-x: auto; background: var(--surface); border-radius: 8px; padding: 8px; box-sizing: border-box; }
.sk-chart-caption { font-size: 12.5px; color: var(--ink-soft); margin: 8px 0 2px; }
.sk-chart-note { font-size: 11.5px; color: var(--muted); margin: 2px 0; }

/* /help, slash command hint and autocomplete */
.sk-help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sk-help-table td { padding: 5px 10px 5px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
.sk-help-note { font-size: 12.5px; color: var(--muted); }
.sk-raw { white-space: pre-wrap; font-size: 12px; max-height: 60vh; overflow: auto; }
.composer { position: relative; }
.sk-cmd-hint { font-size: 12px; color: var(--muted); padding: 4px 6px 0; min-height: 0; }
.sk-cmd-hint:empty { display: none; }
.sk-cmd-hint.error { color: var(--danger); }
.sk-ac {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 50; max-height: 300px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 4px;
}
.sk-ac[hidden] { display: none; }
.sk-ac-item { display: flex; gap: 12px; align-items: baseline; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--ink-soft); }
.sk-ac-item code { color: var(--ink); white-space: nowrap; }
.sk-ac-item.on, .sk-ac-item:hover { background: var(--hover); }

/* chart note without a patient, topic codes */
.cd-withheld-note { font-size: 13px; color: var(--ink-soft); }
.cd-note-plain { font-size: 12.5px; color: var(--muted); }
.cd-topics { display: flex; flex-direction: column; gap: 6px; }
.cd-topic { font-size: 13px; }
.cd-discussed { color: var(--muted); font-size: 11.5px; }

/* settings: your equipment */
.set-equip { flex-wrap: wrap; }
.equip-input { flex: 1 1 160px; min-width: 0; font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.set-help { flex-basis: 100%; font-size: 11px; color: var(--muted); }

/* sidebar dev tools */
.dev-tools { display: flex; flex-direction: column; gap: 2px; margin-top: -4px; }
.dev-tools .btn-3d { margin-top: 0; }
.dev-tools .btn-3d.on { color: var(--ink); background: var(--hover); font-weight: 600; }

/* calculators + figure search */
.calc, .fs { display: flex; flex-direction: column; gap: 10px; }
.calc-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.calc-search { flex: 1 1 220px; min-width: 0; font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.calc-count, .calc-more { font-size: 12px; color: var(--muted); margin: 0; }
.calc-list { display: flex; flex-direction: column; gap: 2px; }
.calc-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--ink); }
.calc-item:hover { background: var(--hover); }
/* Calculator catalogue: search + letter strip stay on top while the A–Z list scrolls under them. */
.calc-top { position: sticky; top: -18px; z-index: 2; margin: -18px -20px 0; padding: 18px 20px 8px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.calc-az { display: flex; flex-wrap: wrap; gap: 2px; }
.calc-az-btn { min-width: 24px; padding: 2px 5px; border: none; border-radius: 6px; background: none; color: var(--teal-dark); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.calc-az-btn:hover { background: var(--hover); }
.calc-letter { margin: 12px 0 2px; padding: 0 10px 3px; font-size: 13px; font-weight: 700; color: var(--teal-dark); border-bottom: 1px solid var(--line); }
.calc-list > .calc-letter:first-child { margin-top: 0; }
.calc-item.active { background: var(--hover); box-shadow: inset 2px 0 0 var(--teal); }
.calc-item { scroll-margin-top: 100px; }
.calc { min-height: min(70vh, 640px); }
.calc-hit { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--teal); text-decoration-thickness: 2px; text-underline-offset: 2px; }
@media (max-width: 760px) { .calc-top { top: -14px; margin: -14px -14px 0; padding: 14px 14px 8px; } }
.calc-name { font-weight: 600; font-size: 13.5px; }
.calc-purpose { font-size: 12.5px; color: var(--ink-soft); margin: 0; }
.calc-back { align-self: flex-start; border: none; background: none; color: var(--teal-dark); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.calc-title { margin: 0; font-size: 17px; }
.calc-pop { font-size: 12px; color: var(--muted); margin: 0; }
.calc-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.calc-field { display: flex; flex-direction: column; gap: 3px; }
.calc-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.calc-row { display: flex; align-items: center; gap: 6px; }
.calc-ctl { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.calc-unit, .calc-help { font-size: 11.5px; color: var(--muted); }
.calc-actions { display: flex; gap: 8px; }
.calc-result { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.calc-value { font-size: 15px; } .calc-value b { font-size: 22px; }
.calc-interp { font-size: 13.5px; font-weight: 600; }
.calc-missing { font-size: 12.5px; color: var(--ink-soft); }
.calc-items { border-collapse: collapse; font-size: 12.5px; }
.calc-items td { padding: 3px 14px 3px 0; border-top: 1px solid var(--line-soft); }
.calc-pts { text-align: right; color: var(--ink-soft); }
.calc-formula, .calc-src, .calc-notes { font-size: 11.5px; color: var(--muted); margin: 0; }
.calc-src a { color: var(--teal-dark); }
.fs-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.fs-filters .mode-select { font-size: 12px; }
.fs-problems { font-size: 12px; color: var(--danger); }
.fs-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.gp-support .ifu-page-link, .gp-support .ifu-page { margin-left: 6px; font-size: 11.5px; }

/* ===== Dev handout update 2026-10-30 (beta): attachments, procedure cards, product answers ===== */

/* paperclip + tray */
.att-btn { flex-shrink: 0; align-self: flex-end; color: var(--muted); }
.att-btn:hover { color: var(--ink); }
.att-tray { max-width: 820px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.att-tray[hidden] { display: none; }

/* file chip */
.att-chip { display: inline-flex; align-items: stretch; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.att-chip-main { display: inline-flex; align-items: flex-start; gap: 7px; padding: 6px 9px; border: none; background: none; color: var(--ink); font: inherit; text-align: left; min-width: 0; }
button.att-chip-main { cursor: pointer; }
button.att-chip-main:hover { background: var(--hover); }
.att-chip-ico { color: var(--muted); margin-top: 1px; display: inline-flex; }
.att-chip-text { display: flex; flex-direction: column; min-width: 0; }
.att-chip-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.att-chip-meta, .att-chip-status { font-size: 11px; color: var(--muted); }
.att-chip-x { border: none; border-left: 1px solid var(--line-soft); background: none; color: var(--muted); padding: 0 8px; cursor: pointer; font-size: 11px; }
.att-chip-x:hover { color: var(--ink); background: var(--hover); }
.att-needs-review { border-color: #d9a400; }
.att-needs-review .att-chip-status { color: #8a5a00; font-weight: 600; }
.att-refused, .att-error, .att-empty, .att-needs-ocr { border-color: var(--danger); }
.att-refused .att-chip-status, .att-error .att-chip-status, .att-empty .att-chip-status, .att-needs-ocr .att-chip-status { color: var(--danger); }
.att-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.att-conv { max-width: 820px; margin: 0 auto 12px; padding: 0 4px; }
.att-conv-title { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* confirm a machine reading: original beside the editable text */
.lb-panel:has(.att-review) { width: min(1180px, 96vw); }
.att-review { display: flex; flex-direction: column; gap: 10px; }
.att-review-check { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.att-review-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.att-review-col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.att-orig { height: 58vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.att-orig .cd-loading, .att-orig-note { color: #555; padding: 14px; }
.att-orig-pdf { width: 100%; height: 100%; border: 0; }
.att-orig-img { max-width: 100%; display: block; }
.att-text { height: 58vh; resize: none; font-family: var(--mono); font-size: 12.5px; }
.att-review-actions { justify-content: flex-end; }
@media (max-width: 760px) {
  .att-review-cols { grid-template-columns: 1fr; }
  .att-orig, .att-text { height: 40vh; }
}

/* procedure cards */
.inl-3d-unverified { font-size: 11.5px; font-weight: 600; color: #8a5a00; margin-top: 3px; }
.jaw3d-cardbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 16px; background: #fff4d6; }
.jaw3d-cardbar[hidden] { display: none; }
.jaw3d-card-label { font-size: 12px; font-weight: 600; color: #8a5a00; }
.jaw3d-card-btn { flex-shrink: 0; border: 1px solid #d9a400; background: none; color: #8a5a00; border-radius: 20px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.jaw3d-cardtext { flex: 0 0 42%; min-height: 0; overflow-y: auto; padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 13px; line-height: 1.5; color: var(--ink); }
.jaw3d-cardtext[hidden] { display: none; }
.jaw3d-cardtext h4 { margin: 10px 0 3px; font-size: 12.5px; }
.jaw3d-cardtext ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.jaw3d-cardtext > .jaw3d-card-label { margin: 0; }
.jaw3d-side-unv { font-size: 10.5px; color: #8a5a00; }

/* product answers */
.ifu-tile-gap { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.ifu-tile-gap a { color: var(--teal-dark); text-decoration: none; }
.pcard-photo-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pcard-credit { font-size: 10.5px; line-height: 1.35; color: var(--muted); }
.pcard-credit a { color: inherit; }

/* enlarged picture, above the lightbox and the 3D panel */
img.zoomable { cursor: zoom-in; transition: box-shadow .15s; }
img.zoomable:hover, img.zoomable:focus-visible { box-shadow: 0 0 0 2px var(--teal); outline: none; }
.img-zoom { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; box-sizing: border-box; background: rgba(0, 0, 0, .86); cursor: zoom-out; }
.img-zoom-img { width: min(92vw, 1000px); height: min(84vh, 1000px); object-fit: contain; background: #fff; border-radius: 10px; }
.img-zoom-cap { color: #fff; font-size: 13px; }
.img-zoom-x { position: absolute; top: 14px; right: 14px; color: #fff; }

/* voice input (10-28 handout section 2.4) */
.composer-inner { position: relative; }
.voice-btn { flex-shrink: 0; align-self: flex-end; color: var(--muted); }
.voice-btn:hover { color: var(--ink); }
.voice-btn.recording { color: #fff; background: #c8413b; }
.voice-btn.recording:hover { color: #fff; background: #ad352f; }
.voice-btn:disabled { opacity: .45; cursor: default; }
.voice-lang { flex-shrink: 0; align-self: flex-end; height: 32px; border: none; background: none; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; }
.voice-lang:disabled { opacity: .45; cursor: default; }
.btn-send:disabled { opacity: .45; cursor: default; transform: none; }
.voice-marks { position: absolute; box-sizing: border-box; overflow: hidden; pointer-events: none; color: transparent; white-space: pre-wrap; overflow-wrap: break-word; }
.voice-marks u { text-decoration: underline 2px var(--teal); text-underline-offset: 3px; }
.voice-status { max-width: 820px; margin: 6px auto 0; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.voice-status[hidden] { display: none; }
.voice-dot { width: 8px; height: 8px; border-radius: 50%; background: #c8413b; animation: voice-pulse 1.2s ease-in-out infinite; }
@keyframes voice-pulse { 50% { opacity: .35; } }
.voice-link { border: none; background: none; padding: 0; font: inherit; color: var(--teal-dark); text-decoration: underline; cursor: pointer; }
.chat[data-view="wide"] .voice-status { max-width: 1180px; }
.chat.empty .voice-status { max-width: 640px; }

/* interaction rows: other wordings, class membership chip */
.enh-via-chip { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 20px; background: var(--hover); color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.enh-wordings { margin-top: 4px; font-size: 11.5px; }
.enh-wordings summary { color: var(--teal-dark); cursor: pointer; }
.enh-wording { margin-top: 4px; color: var(--ink-soft); }
.enh-wordings-note { margin-top: 4px; color: var(--muted); font-size: 11px; }

/* closest-match offer */
.sugg-closest { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); padding: 9px 13px; font-size: 13px; color: var(--ink-soft); }

/* product list (section 4.10) */
.plist { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.plist-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; padding: 10px 13px; cursor: pointer; }
.plist-scope { font-size: 13px; font-weight: 600; color: var(--ink); }
.plist-total { margin-left: auto; font-size: 12px; color: var(--muted); }
.plist-body { padding: 0 13px 11px; }
.plist-group + .plist-group, .plist-overview { margin-top: 10px; }
.plist .plist-items, .plist .plist-overview { list-style: none; margin: 4px 0 0; padding: 0; }
.plist-item { padding: 7px 8px; margin: 0 -8px; border-radius: 6px; border-top: 1px solid var(--line-soft); transition: background .3s; }
.plist-item:first-child { border-top: none; }
.plist-item.flash { background: var(--teal-50); }
.plist-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.plist-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
a.plist-name:hover { color: var(--teal-dark); }
.plist-held { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--teal-50); color: var(--teal-dark); }
.plist-held-safety, .plist-held-marketing, .plist-held-none { background: var(--hover); color: var(--muted); }
.plist-quote { margin-top: 3px; font-size: 12.5px; color: var(--ink-soft); }
.plist-quote .ifu-page, .plist-quote .ifu-page-link { margin-left: 6px; white-space: nowrap; }
.plist-overview li { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.plist-overview li:first-child { border-top: none; }
.plist-ov-name { font-weight: 600; color: var(--ink); }
.plist-ov-count { color: var(--muted); }
.plist-ov-eg { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.plist-nouse { margin: 9px 0 0; font-size: 12.5px; color: var(--muted); }
.plist-stance { margin: 9px 0 0; font-size: 11.5px; color: var(--muted); }

/* UI language picker in the sign-in footer (js/i18n.js) */
.auth-lang { margin-left: 8px; padding: 1px 2px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: inherit; cursor: pointer; }
