/* ===========================================================================
   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);
  }
}

* { 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 {
  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-view { display: grid; grid-template-columns: 280px 1fr; height: 100%; }

/* ---- 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; }
.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);
}
.sidebar-toggle { display: none; }
.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 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)); }
.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); }
.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; }

/* ---- Composer ---- */
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 14px 24px 10px; }
.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); }

/* ===========================================================================
   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
   =========================================================================== */
@media (max-width: 760px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: grid; }
  .suggestions { grid-template-columns: 1fr; }
  .kc-rel { grid-template-columns: 1fr; gap: 2px; }
  .msg { padding: 0 16px; }
}

/* ===========================================================================
   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; }
/* 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); } }

/* Header can hold two selects — let it wrap gracefully on narrow screens */
@media (max-width: 620px) {
  .chat-head { flex-wrap: wrap; row-gap: 6px; }
  .chat-head .chat-title { flex-basis: 100%; order: -1; }
}

/* ===========================================================================
   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; }

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

/* 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; }

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