/* ============================================================
   Dawn — drug & alcohol support for Derbyshire and the UK
   "First light": a pre-dawn slate base with one warm accent that
   appears only where it matters (send, focus, numbers, the sun mark).
   Type: Young Serif for the wordmark and headings,
         Atkinson Hyperlegible Next for everything else.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #131924;
  --bg-deep: #0f141d;
  --surface: #1a2130;
  --raised: #232c3d;
  --line: rgba(230, 234, 240, .08);
  --line-strong: rgba(230, 234, 240, .15);
  --text: #e6eaf0;
  --muted: #a0a9b8;
  --faint: #7c8698;
  --accent: #f2c46d;
  --accent-ink: #f2c46d;
  --on-accent: #1d1607;
  --accent-wash: rgba(242, 196, 109, .13);
  --danger: #f28b7d;
  --danger-wash: rgba(242, 139, 125, .12);
  --glow: rgba(255, 180, 116, .24);
  --sky: rgba(126, 116, 214, .11);
  --scrim: rgba(5, 8, 14, .62);
  --shadow-pop: 0 18px 40px -16px rgba(3, 6, 12, .7), 0 0 0 1px var(--line-strong);

  --serif: "Young Serif", ui-serif, Georgia, serif;
  --sans: "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --fs-xs: 12.5px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 20px;
  --fs-xl: 26px;
  --fs-display: clamp(30px, 3.2vw + 14px, 42px);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;

  --side: 284px;
  --col: 46rem;

  --ease: cubic-bezier(.22, .8, .24, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --t1: 120ms;
  --t2: 200ms;
  --t3: 320ms;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f8;
    --bg-deep: #e9edf2;
    --surface: #ffffff;
    --raised: #e6eaf0;
    --line: rgba(23, 32, 49, .08);
    --line-strong: rgba(23, 32, 49, .15);
    --text: #172031;
    --muted: #4f5b6e;
    --faint: #687182;
    --accent-ink: #855809;
    --accent-wash: rgba(242, 196, 109, .26);
    --danger: #b83a28;
    --danger-wash: rgba(184, 58, 40, .08);
    --glow: rgba(255, 184, 108, .34);
    --sky: rgba(160, 150, 240, .14);
    --scrim: rgba(23, 32, 49, .34);
    --shadow-pop: 0 18px 40px -18px rgba(23, 32, 49, .28), 0 0 0 1px var(--line-strong);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-base)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow: hidden; overflow-x: clip;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-wash); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand__mark { width: 30px; height: 18px; flex: none; }
.brand__sun { fill: var(--accent); }
.brand__line { fill: currentColor; }
.brand__word { font-family: var(--serif); font-size: 21px; line-height: 1; letter-spacing: -.005em; }
.brand__sub { font-size: var(--fs-sm); color: var(--muted); margin-left: 2px; }

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap; user-select: none;
  background: var(--accent); color: var(--on-accent);
  transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease), color var(--t1) var(--ease), transform var(--t1) var(--ease), opacity var(--t1);
}
.btn:hover { background: #f6d084; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--raised); }
.btn--quiet { background: transparent; color: var(--muted); }
.btn--quiet:hover { background: var(--raised); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger); filter: brightness(1.08); }
@media (prefers-color-scheme: dark) { .btn--danger { color: #2a0f0b; } }
.btn__spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.is-busy { color: transparent; pointer-events: none; }
.btn.is-busy .btn__spinner { display: block; position: absolute; color: var(--on-accent); }

.icon-btn {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease), transform var(--t1) var(--ease);
}

.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- form fields ---------- */
.field { display: grid; gap: 6px; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.field__wrap { position: relative; display: flex; }
.field__input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  transition: border-color var(--t1) var(--ease), box-shadow var(--t2) var(--ease);
}
.field__input::placeholder { color: var(--faint); }
.field__input:hover { border-color: color-mix(in srgb, var(--text) 26%, transparent); }
.field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.field__input[aria-invalid="true"] { border-color: var(--danger); }
.field__input--pw { padding-right: 52px; }
.field__reveal { position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; }
.field__reveal .eye-off { display: none; }
.field__reveal[aria-pressed="true"] .eye { display: none; }
.field__reveal[aria-pressed="true"] .eye-off { display: block; }

/* ---------- screens ---------- */
.screen { display: none; }
body[data-screen="gate"] #gate,
body[data-screen="pending"] #pending { display: grid; }
body[data-screen="app"] #shell { display: flex; }

/* the one expressive moment: first light on the horizon */
.horizon {
  position: fixed; left: 0; right: 0; bottom: 0; height: 58vh; pointer-events: none; z-index: 0;
  background:
    radial-gradient(42% 46% at 50% 100%, var(--glow), transparent 70%),
    radial-gradient(95% 90% at 50% 100%, var(--sky), color-mix(in srgb, var(--sky) 40%, transparent) 45%, transparent 88%);
}
.entry .horizon { animation: rise 2.2s var(--ease) backwards; }

/* ---------- entry (sign in / pending) ---------- */
.entry {
  position: relative; min-height: 100vh; min-height: var(--app-height, 100dvh);
  place-items: center; padding: max(32px, env(safe-area-inset-top)) 24px max(40px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.entry__inner { position: relative; z-index: 1; width: 100%; max-width: 400px; animation: enter .6s var(--ease) both; }
.entry .brand { margin-bottom: 40px; }
.entry__title { font-family: var(--serif); font-weight: 400; font-size: var(--fs-display); line-height: 1.12; letter-spacing: -.012em; margin: 0 0 14px; text-wrap: balance; }
.entry__lede { margin: 0 0 32px; color: var(--muted); font-size: 17px; line-height: 1.55; text-wrap: pretty; }
.entry__form { display: grid; gap: 16px; }
.entry__form .btn { margin-top: 6px; }
.entry__error { min-height: 22px; margin: -4px 0 0; font-size: var(--fs-sm); color: var(--danger); }
.entry__help { margin: 36px 0 0; padding-top: 20px; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); line-height: 1.55; }
.entry__help a { color: var(--text); font-weight: 600; text-decoration-color: var(--accent); text-underline-offset: 3px; font-variant-numeric: tabular-nums; }
.entry__actions { display: grid; gap: 10px; }
.entry__status { min-height: 22px; margin: 4px 0 0; font-size: var(--fs-sm); color: var(--muted); }

/* segmented sign in / create account */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 24px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.seg__thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 9px; background: var(--raised); box-shadow: 0 1px 2px rgba(0,0,0,.12); transition: transform var(--t3) var(--ease); }
.seg[data-mode="register"] .seg__thumb { transform: translateX(100%); }
.seg__btn { position: relative; z-index: 1; height: 38px; border: 0; background: none; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 15px; transition: color var(--t2) var(--ease); }
.seg__btn[aria-selected="true"] { color: var(--text); }
.shake { animation: shake .42s var(--ease-io); }

/* ---------- app shell ---------- */
.shell { position: relative; height: 100vh; height: var(--app-height, 100dvh); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

.sidebar { width: var(--side); flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--bg-deep); border-right: 1px solid var(--line); }
.sidebar__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(14px + env(safe-area-inset-top)) 12px 10px 18px; }
.convos { flex: 1; min-height: 0; padding: 6px 10px 16px; }
.convos__group { margin: 18px 8px 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--faint); }
.convos__group:first-child { margin-top: 6px; }
.convos__empty { margin: 14px 8px; font-size: var(--fs-sm); color: var(--faint); line-height: 1.5; }
.convo { position: relative; display: flex; align-items: center; border-radius: 10px; transition: background-color var(--t1) var(--ease); }

.convo.is-active { background: var(--raised); }
.convo__link { flex: 1; min-width: 0; padding: 9px 8px 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--t1) var(--ease); }
.convo:hover .convo__link, .convo.is-active .convo__link { color: var(--text); }
.convo__del { width: 32px; height: 32px; margin-right: 3px; border-radius: 8px; opacity: 0; }
.convo__del svg { width: 16px; height: 16px; }
.convo:hover .convo__del, .convo.is-active .convo__del, .convo__del:focus-visible { opacity: 1; }
@media (hover: none) { .convo:not(.is-active) .convo__del { display: none; } }

.sidebar__foot { position: relative; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.account { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; transition: background-color var(--t1) var(--ease); }
.account:hover, .account[aria-expanded="true"] { background: var(--surface); }
.avatar { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-wash); color: var(--accent-ink); font-weight: 700; font-size: 13px; text-transform: uppercase; }
.account__name { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account__chev { width: 16px; height: 16px; color: var(--faint); }

/* popover menu */
.menu {
  position: fixed; margin: 0; inset: auto; min-width: 220px; padding: 6px; border: 0; border-radius: var(--r-md);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(6px) scale(.98); transform-origin: bottom left;
  transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease), overlay var(--t2) allow-discrete, display var(--t2) allow-discrete;
}
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(6px) scale(.98); } }
.menu__item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: var(--fs-sm); text-decoration: none; text-align: left; transition: background-color var(--t1) var(--ease); }
.menu__item:hover, .menu__item:focus-visible { background: var(--raised); outline: none; }
.menu__item svg { width: 17px; height: 17px; color: var(--muted); }

/* ---------- main column ---------- */
.main { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.topbar__menu { display: none; margin-left: -6px; }
.topbar__brand { display: none; }
.topbar__title { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 1; transition: opacity var(--t2) var(--ease); }
.topbar__title:empty { opacity: 0; }
.help-btn {
  flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px;
  border-radius: 99px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
  font-size: var(--fs-sm); font-weight: 600;
  transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.help-btn:hover { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 45%, var(--line-strong)); }
.help-btn:active { transform: scale(.97); }
.help-btn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px var(--danger-wash); }

.stream { position: relative; z-index: 1; flex: 1; min-height: 0; overflow-x: hidden; overflow-wrap: anywhere; padding: 0 24px; scroll-padding-bottom: 24px; }
.thread { width: 100%; max-width: var(--col); min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; padding: 12px 0 32px; }

/* welcome */
.welcome { margin: auto 0; padding: 4vh 0 2vh; animation: enter .55s var(--ease) both; }
.welcome__title { font-family: var(--serif); font-weight: 400; font-size: var(--fs-display); line-height: 1.12; letter-spacing: -.012em; margin: 0 0 12px; }
.welcome__lede { max-width: 34rem; margin: 0 0 36px; color: var(--muted); font-size: 17px; line-height: 1.55; text-wrap: pretty; }
.starters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; border-top: 1px solid var(--line); }
.starter {
  display: grid; gap: 2px; padding: 16px 10px 16px 0; margin: 0; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left; color: var(--text); position: relative;
  transition: color var(--t1) var(--ease);
}
.starter__title { font-weight: 600; font-size: 15.5px; transition: transform var(--t2) var(--ease); }
.starter__hint { font-size: var(--fs-sm); color: var(--faint); transition: transform var(--t2) var(--ease), color var(--t1) var(--ease); }
.starter::before { content: ""; position: absolute; left: -14px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); opacity: 0; transform: scale(.4); transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease); }
.starter:hover .starter__title, .starter:focus-visible .starter__title,
.starter:hover .starter__hint, .starter:focus-visible .starter__hint { transform: translateX(4px); }
.starter:hover .starter__hint { color: var(--muted); }
.starter:hover::before, .starter:focus-visible::before { opacity: 1; transform: none; }
.starter:focus-visible { outline-offset: -2px; }

/* horizon behind the welcome view; fades away once a conversation starts */
.main .horizon { position: absolute; height: 62%; transition: opacity .7s var(--ease); }
.main[data-state="welcome"] .horizon { animation: rise 2.2s var(--ease) backwards; }
.main[data-state="chat"] .horizon { opacity: 0; }

/* ---------- messages ---------- */
.msg { animation: msg-in var(--t3) var(--ease) both; }
.msg--user { display: flex; justify-content: flex-end; }
.msg__bubble { max-width: min(82%, 36rem); padding: 11px 16px; border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg); background: var(--raised); white-space: pre-wrap; line-height: 1.55; }
.msg--dawn { min-width: 0; }

/* status + thinking disclosure */
.status { display: inline-flex; align-items: center; gap: 10px; min-height: 28px; color: var(--muted); font-size: var(--fs-sm); }
.status__sun { position: relative; width: 14px; height: 14px; flex: none; }
.status__sun::before, .status__sun::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.status__sun::after { inset: 0; background: var(--accent); opacity: .3; animation: breathe 1.6s var(--ease-io) infinite; }
.status__label {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--text) 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2.2s linear infinite;
}
.think { margin: -2px 0 14px; }
.think__toggle { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px 0 8px; margin-left: -8px; border: 0; border-radius: 8px; background: none; color: var(--faint); font-size: var(--fs-sm); transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease); }
.think__toggle:disabled { cursor: default; color: var(--muted); }
.think__sun { position: relative; width: 12px; height: 12px; flex: none; display: none; }
.think__sun::before, .think__sun::after { content: ""; position: absolute; border-radius: 50%; background: var(--accent); }
.think__sun::before { inset: 3px; }
.think__sun::after { inset: 0; opacity: .3; animation: breathe 1.6s var(--ease-io) infinite; }
.think.is-working .think__sun { display: block; }
.think.is-working .think__label {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--text) 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2.2s linear infinite;
}
.think__chev { width: 15px; height: 15px; transition: transform var(--t2) var(--ease); }
.think.is-working .think__chev { display: none; }
.think.is-open .think__chev { transform: rotate(90deg); }
.think__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t3) var(--ease); }
.think.is-open .think__panel { grid-template-rows: 1fr; }
.think__steps { min-height: 0; overflow: hidden; margin-left: 5px; padding-left: 15px; border-left: 1px solid var(--line-strong); font-size: var(--fs-sm); line-height: 1.6; color: var(--faint); }
.think__steps > :first-child { margin-top: 8px; }
.think__steps > :last-child { margin-bottom: 4px; }
/* while live, the panel holds a few lines; older thoughts drift up and fade as new ones arrive */
.think.is-capped .think__steps { max-height: 10.5em; }
.think.is-capped .think__steps.is-clipped { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 2.6em); mask-image: linear-gradient(to bottom, transparent, #000 2.6em); }
.think.is-gone { overflow: hidden; opacity: 0; margin-bottom: 0; transition: height var(--t3) var(--ease), opacity var(--t2) var(--ease), margin var(--t3) var(--ease); }
.reason { margin: 6px 0; color: var(--muted); white-space: pre-wrap; }
.step { display: flex; align-items: baseline; gap: 10px; margin: 7px 0; color: var(--faint); animation: step-in var(--t3) var(--ease) both; transition: color var(--t2) var(--ease); }
.step__dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; transform: translateY(-1px); transition: background-color var(--t2) var(--ease), opacity var(--t2) var(--ease); }
.step.is-active { color: var(--muted); }
.step.is-active .step__dot { background: var(--accent); opacity: 1; animation: breathe 1.2s var(--ease-io) infinite; }
.step__q { color: var(--faint); }

/* markdown */
.md { line-height: 1.68; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md__stable > :first-child, .md__live > :first-child { margin-top: 0; }
.md__live > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .9em; text-wrap: pretty; }
.md strong { font-weight: 700; }
.md ul, .md ol { margin: .4em 0 1em; padding-left: 1.35em; }
.md li { margin: .35em 0; padding-left: .2em; }
.md li::marker { color: var(--faint); }
.md a { color: var(--text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; transition: text-decoration-color var(--t1); }
.md a:hover { text-decoration-color: var(--accent); }
.md h1, .md h2, .md h3, .md h4 { margin: 1.4em 0 .5em; font-weight: 700; line-height: 1.3; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.18em; } .md h3 { font-size: 1.06em; } .md h4 { font-size: 1em; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.md blockquote { margin: 1em 0; padding: 2px 0 2px 16px; border-left: 2px solid var(--accent); color: var(--muted); }
.md code { font-family: var(--sans); font-size: .95em; font-weight: 700; font-variant-numeric: tabular-nums; padding: .08em .42em; border-radius: 6px; background: var(--raised); }
.md pre { margin: 1em 0; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); overflow-x: auto; }
.md pre code { padding: 0; background: none; font-weight: 400; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; line-height: 1.55; }
.md table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1em 0; font-size: .94em; font-variant-numeric: tabular-nums; }
.md th, .md td { padding: 8px 14px 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { font-weight: 700; border-bottom-color: var(--line-strong); white-space: nowrap; }
.md img { max-width: 100%; border-radius: var(--r-md); }
/* helpline numbers and websites become tappable */
.md a.chip-link { text-decoration: none; white-space: nowrap; }
.md a.chip-link code { color: var(--accent-ink); background: var(--accent-wash); transition: background-color var(--t1) var(--ease); }
.md a.chip-link:hover code { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.caret { display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: var(--accent); vertical-align: .05em; animation: breathe 1.1s var(--ease-io) infinite; }

.msg__actions { display: flex; gap: 2px; margin: 10px 0 0 -8px; opacity: 0; transition: opacity var(--t2) var(--ease); }
.msg--dawn:hover .msg__actions, .msg__actions:focus-within { opacity: 1; }
@media (hover: none) { .msg__actions { opacity: 1; } }
.act { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 8px; border: 0; border-radius: 8px; background: none; color: var(--faint); font-size: var(--fs-xs); font-weight: 600; transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease); }

.act svg { width: 15px; height: 15px; }
.act.is-done { color: var(--accent-ink); }

.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; }
.notice--error { background: var(--danger-wash); color: var(--text); }
.notice--error svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--danger); }

/* jump to latest */
.jump {
  position: absolute; z-index: 3; left: 50%; bottom: calc(100% + 12px); width: 38px; height: 38px; margin-left: -19px;
  display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(6px) scale(.9); pointer-events: none;
  transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease), background-color var(--t1);
}
.jump.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.jump:hover { background: var(--raised); }
.jump svg { width: 18px; height: 18px; }

/* ---------- composer ---------- */
.composer { position: relative; z-index: 2; flex: none; padding: 4px 24px calc(14px + env(safe-area-inset-bottom)); }
.composer__inner { position: relative; max-width: var(--col); margin: 0 auto; }
/* soften the edge where the conversation scrolls away behind the composer */
.composer::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--bg)); }
.main[data-state="welcome"] .composer::before { display: none; }
.composer__box {
  display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 18px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 8px 28px -18px rgba(0, 0, 0, .5);
  transition: border-color var(--t2) var(--ease), box-shadow var(--t2) var(--ease);
}
.composer__box:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); box-shadow: 0 0 0 4px var(--accent-wash), 0 8px 28px -18px rgba(0, 0, 0, .5); }
.composer__input { flex: 1; min-width: 0; max-height: 200px; padding: 9px 0; border: 0; outline: none; resize: none; background: none; line-height: 1.5; font-size: var(--fs-base); }
.composer__input::placeholder { color: var(--faint); }
.send {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 13px;
  background: var(--accent); color: var(--on-accent);
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease), transform var(--t1) var(--ease), opacity var(--t2);
}
.send svg { width: 19px; height: 19px; }
.send:hover:not(:disabled) { background: #f6d084; }
.send:active:not(:disabled) { transform: scale(.92); }
.send:disabled { background: var(--raised); color: var(--faint); cursor: default; }
.send .i-stop { display: none; }
.send.is-stop { background: var(--text); color: var(--bg); }
.send.is-stop .i-send { display: none; }
.send.is-stop .i-stop { display: block; }
.composer__note { margin: 10px 0 0; text-align: center; font-size: var(--fs-xs); color: var(--faint); text-wrap: balance; }

.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--t3) var(--ease); }

/* ---------- dialogs ---------- */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); overflow: auto;
  opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity var(--t2) var(--ease), transform var(--t3) var(--ease), overlay var(--t3) allow-discrete, display var(--t3) allow-discrete;
}
.dialog[open] { opacity: 1; transform: none; }
@starting-style { .dialog[open] { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog::backdrop { background: transparent; transition: background-color var(--t3) var(--ease), overlay var(--t3) allow-discrete, display var(--t3) allow-discrete; }
.dialog[open]::backdrop { background: var(--scrim); }
@starting-style { .dialog[open]::backdrop { background: transparent; } }
.dialog__body { padding: 24px; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.dialog__title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: var(--fs-xl); line-height: 1.2; }
.dialog__close { margin: -6px -10px 0 0; }
.dialog__text { margin: 0 0 22px; color: var(--muted); }
.dialog__title + .dialog__text { margin-top: 10px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

.lines { list-style: none; margin: 0 -8px; padding: 0; }
.lines li + li { border-top: 1px solid var(--line); }
.line { display: grid; grid-template-columns: 10.25rem 1fr; grid-template-areas: "num text"; gap: 14px; align-items: baseline; padding: 14px 8px; margin: 2px 0; border-radius: var(--r-md); text-decoration: none; transition: background-color var(--t1) var(--ease); }
.line__text { grid-area: text; }

.line__num { grid-area: num; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--accent-ink); white-space: nowrap; }
.line--urgent .line__num { color: var(--danger); font-size: 22px; }
.line__name { display: block; font-weight: 700; }
.line__what { display: block; color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  padding: 10px 16px; border-radius: 99px; background: var(--text); color: var(--bg); font-size: var(--fs-sm); font-weight: 600;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- admin ---------- */
.admin-page { display: flex; flex-direction: column; height: 100vh; height: var(--app-height, 100dvh); }
.admin-bar { flex: none; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: var(--bg-deep); }
.admin-bar .brand { margin-right: auto; }
.admin { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 340px minmax(0, 1fr); }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.pane:last-child { border-right: 0; }
.pane--people { background: var(--bg-deep); }
.pane__head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 68px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.pane__heading { flex: 1; min-width: 0; }
.pane__title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane__meta { margin: 1px 0 0; font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane__back { display: none; margin-left: -10px; }
.pane__body { flex: 1; min-height: 0; padding: 8px 10px 24px; }
.pane__group { margin: 16px 10px 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--faint); }
.pane__group:first-child { margin-top: 8px; }
.empty { margin: 0; padding: 40px 20px; text-align: center; color: var(--faint); font-size: var(--fs-sm); text-wrap: balance; }

.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; transition: background-color var(--t1) var(--ease); }

.row.is-active { background: var(--raised); }
.row__main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row__title { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__tags { display: flex; gap: 6px; margin-top: 3px; }
.row__tags .tag { margin-left: 0; }
.row__sub { font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; margin-left: 8px; vertical-align: 1px; line-height: 1.5; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--accent-wash); color: var(--accent-ink); }
.waiting { display: grid; gap: 10px; padding: 12px 10px 14px; border-radius: 10px; }
.waiting + .waiting { border-top: 1px solid var(--line); border-radius: 0; }
.waiting__actions { display: flex; gap: 8px; }
.waiting__actions .btn { flex: 1; }

.transcript { padding: 24px clamp(20px, 4vw, 48px) 48px; }
.transcript__inner { max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.transcript .msg { animation: none; }
.who { margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--faint); }
.msg--user .who { text-align: right; }
.msg--user.msg--stack { flex-direction: column; align-items: flex-end; }
.danger-text { color: var(--danger); }
.tag--danger { background: var(--danger-wash); color: var(--danger); }
.msg.is-focus { outline: 2px solid var(--accent); outline-offset: 10px; border-radius: 10px; }
.asrc { margin: 10px 0 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--faint); display: grid; gap: 3px; }
.asrc a { color: var(--muted); }
.arate { display: inline-block; margin-top: 8px; }

/* ---------- sidebar tools ---------- */
.tools { display: grid; gap: 2px; padding: 2px 10px 6px; }
.tool { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: var(--fs-sm); text-align: left; transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease); }
.tool svg { width: 18px; height: 18px; flex: none; }

/* ---------- menus: extras ---------- */
.menu--right { width: 240px; transform-origin: top right; }
.menu__sep { height: 1px; margin: 5px 6px; border: 0; background: var(--line); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__check { width: 17px; height: 17px; flex: none; border-radius: 5px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease); }
.menu__item[aria-checked="true"] .menu__check { background: var(--accent); border-color: var(--accent); }
.menu__item[aria-checked="true"] .menu__check::after { content: ""; width: 8px; height: 4px; margin-top: -2px; border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: rotate(-45deg); }

/* ---------- topbar extras ---------- */
.topbar__actions { flex: none; margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar__actions .help-btn { margin-left: 0; }
.exit-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 10px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--bg); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease), transform var(--t1) var(--ease); }
.exit-btn svg { width: 17px; height: 17px; }
.exit-btn:active { transform: scale(.97); }
.private-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: 99px; background: var(--accent-wash); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700; }
.private-pill svg { width: 14px; height: 14px; }

/* ---------- private chat switch ---------- */
.private-toggle { display: inline-flex; align-items: center; gap: 12px; margin-top: 26px; cursor: pointer; user-select: none; }
.private-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex: none; width: 40px; height: 24px; border-radius: 99px; background: var(--raised); border: 1px solid var(--line-strong); transition: background-color var(--t2) var(--ease), border-color var(--t2) var(--ease); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform var(--t2) var(--ease), background-color var(--t2) var(--ease); }
.private-toggle input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.private-toggle input:checked + .switch::after { transform: translateX(16px); background: var(--on-accent); }
.private-toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.private-toggle__text { display: grid; line-height: 1.35; }
.private-toggle__title { font-weight: 600; font-size: 15px; }
.private-toggle__hint { font-size: var(--fs-sm); color: var(--faint); }

/* ---------- voice input ---------- */
.mic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 13px; background: none; color: var(--muted); transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease); }
.mic svg { width: 20px; height: 20px; }
.mic[aria-pressed="true"] { background: var(--danger-wash); color: var(--danger); animation: listen 1.4s var(--ease-io) infinite; }

/* ---------- help sheet: talk to a person ---------- */
.dialog__subhead { margin: 22px 0 8px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.person-link { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 -8px; padding: 12px 8px; border-radius: var(--r-md); text-decoration: none; transition: background-color var(--t1) var(--ease); }
.person-link svg { flex: none; width: 18px; height: 18px; color: var(--faint); }

/* ---------- side panels (reader, library, sources, drinking check) ---------- */
.dialog--panel {
  width: min(600px, 100vw); max-width: none; height: 100dvh; max-height: none; margin: 0 0 0 auto; border-radius: 0;
  transform: translateX(32px);
}
.dialog--panel[open] { transform: none; }
@starting-style { .dialog--panel[open] { transform: translateX(32px); } }
.panel { display: flex; flex-direction: column; height: 100%; }
.panel__head { flex: none; display: flex; align-items: flex-start; gap: 10px; padding: calc(18px + env(safe-area-inset-top)) 16px 14px 28px; border-bottom: 1px solid var(--line); }
.panel__heading { flex: 1; min-width: 0; }
.panel__title { margin: 2px 0 0; font-family: var(--serif); font-weight: 400; font-size: var(--fs-xl); line-height: 1.2; text-wrap: balance; }
.panel__meta { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.panel__back { margin: 0 -4px 0 -14px; }
.panel__back svg { transform: rotate(180deg); }
.panel__body { flex: 1; min-height: 0; padding: 20px 28px 40px; }
.panel__foot { flex: none; display: flex; gap: 8px; padding: 12px 28px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.panel__foot .btn svg { width: 17px; height: 17px; }
.panel__search { flex: none; position: relative; margin: 14px 28px 0; }
.panel__search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--faint); pointer-events: none; }
.panel__search input { width: 100%; height: 44px; padding: 0 14px 0 42px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); transition: border-color var(--t1) var(--ease), box-shadow var(--t2) var(--ease); }
.panel__search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 99px; background: var(--raised); color: var(--muted); font-size: 12px; font-weight: 700; }
.chip--accent { background: var(--accent-wash); color: var(--accent-ink); }
.chip--danger { background: var(--danger-wash); color: var(--danger); }

/* library */
.lib-cat { margin: 26px 0 6px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.lib-cat:first-child { margin-top: 2px; }
.lib-doc { display: grid; gap: 2px; margin: 0 -10px; padding: 10px; width: calc(100% + 20px); border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; transition: background-color var(--t1) var(--ease); }
.lib-doc__title { font-weight: 600; font-size: 15px; }
.lib-doc__cat { font-size: var(--fs-xs); font-weight: 600; color: var(--accent-ink); }
.lib-doc__summary { font-size: var(--fs-sm); color: var(--faint); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-count { margin: 0 0 6px; font-size: var(--fs-sm); color: var(--faint); }

/* reader */
.reader-note { display: flex; gap: 10px; margin: 0 0 22px; padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-wash); font-size: var(--fs-sm); line-height: 1.5; }
.reader-note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--accent-ink); }
.refs { margin: 34px 0 0; padding-top: 20px; border-top: 1px solid var(--line); }
.refs__title { margin: 0 0 10px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.refs ol { margin: 0; padding-left: 1.3em; font-size: var(--fs-sm); color: var(--muted); line-height: 1.55; }
.refs li { margin: 6px 0; padding-left: .2em; }
.refs a { color: var(--text); text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 3px; }
.reader-loading { display: grid; gap: 12px; }
.reader-loading span { height: 14px; border-radius: 6px; background: var(--raised); animation: pulse-bg 1.4s var(--ease-io) infinite; }
.reader-loading span:nth-child(2) { width: 86%; } .reader-loading span:nth-child(3) { width: 72%; }

/* ---------- sources under an answer ---------- */
.srcs { margin: 14px 0 0; }
.srcs__toggle { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 6px; margin-left: -6px; border: 0; border-radius: 99px; background: none; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease); }
.srcs__marks { display: inline-flex; }
.srcs__mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--raised); border: 2px solid var(--bg); color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.srcs__mark + .srcs__mark { margin-left: -7px; }
.srcs__mark svg { width: 12px; height: 12px; }
.srcs__mark--bank { background: var(--accent-wash); color: var(--accent-ink); }
.srcs__toggle .think__chev { transition: transform var(--t2) var(--ease); }
.srcs.is-open .srcs__toggle .think__chev { transform: rotate(90deg); }
.srcs__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t3) var(--ease); }
.srcs.is-open .srcs__panel { grid-template-rows: 1fr; }
.srcs__inner { min-height: 0; overflow: hidden; }
.srcs__list { display: grid; gap: 2px; margin: 8px 0 0; padding: 0; list-style: none; }
.srcs__sub { margin: 12px 0 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--faint); }
.src { width: 100%; display: grid; grid-template-columns: 28px 1fr; gap: 2px 10px; padding: 10px; margin: 0 -10px; width: calc(100% + 20px); border: 0; border-radius: var(--r-md); background: none; color: var(--text); text-align: left; text-decoration: none; transition: background-color var(--t1) var(--ease); }
.src__icon { grid-row: span 3; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--raised); color: var(--muted); }
.src__icon svg { width: 16px; height: 16px; }
.src--bank .src__icon { background: var(--accent-wash); color: var(--accent-ink); }
.src__title { font-weight: 600; font-size: var(--fs-sm); line-height: 1.4; }
.src__meta { font-size: var(--fs-xs); color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.src__quote { margin: 4px 0 0; padding-left: 10px; border-left: 2px solid var(--line-strong); font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.src--plain { cursor: default; }

/* ---------- cards inside answers ---------- */
.card-emergency { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; padding: 14px 14px 14px 16px; border-radius: var(--r-md); background: var(--danger-wash); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); animation: msg-in var(--t3) var(--ease) both; }
.card-emergency p { flex: 1; margin: 0; font-size: var(--fs-sm); line-height: 1.5; }
.card-emergency strong { display: block; font-size: 15px; }
.card-emergency .btn { flex: none; background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .card-emergency .btn { color: #2a0f0b; } }
.card-units { display: flex; align-items: center; gap: 18px; margin: 0 0 16px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); animation: msg-in var(--t3) var(--ease) both; }
.card-units__num { font-family: var(--serif); font-size: 34px; line-height: 1; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.card-units__num small { display: block; margin-top: 4px; font-family: var(--sans); font-size: var(--fs-xs); font-weight: 600; color: var(--faint); }
.card-units__body { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; }
.meter { height: 6px; margin-top: 8px; border-radius: 99px; background: var(--raised); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: left; animation: grow .7s var(--ease) both; }
.meter--over span { background: var(--danger); }

/* ---------- actions, feedback, follow-ups ---------- */
.act--icon { width: 30px; padding: 0; justify-content: center; }
.act.is-on { color: var(--accent-ink); }
.act.is-on svg { fill: color-mix(in srgb, var(--accent) 35%, transparent); }
.followups { display: grid; gap: 6px; justify-items: start; margin: 16px 0 0; }
.followup { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 14px 8px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: none; color: var(--text); font-size: var(--fs-sm); text-align: left; animation: step-in var(--t3) var(--ease) both; transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease), transform var(--t1) var(--ease); }
.followup:nth-child(2) { animation-delay: 60ms; } .followup:nth-child(3) { animation-delay: 120ms; }
.followup svg { flex: none; width: 15px; height: 15px; color: var(--accent-ink); }
.followup:active { transform: scale(.98); }

/* ---------- drinking check ---------- */
.q { margin: 0 0 26px; padding: 0; border: 0; }
.q legend { padding: 0; margin: 0 0 4px; font-weight: 700; font-size: 16px; line-height: 1.4; }
.q__hint { margin: 0 0 12px; font-size: var(--fs-sm); color: var(--faint); }
.opts { display: grid; gap: 6px; }
.opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong); cursor: pointer; transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease); }
.opt input { position: absolute; opacity: 0; }
.opt__dot { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); transition: border-color var(--t1) var(--ease), border-width var(--t1) var(--ease); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.opt:has(input:checked) .opt__dot { border: 5px solid var(--accent); }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.audit-result { text-align: left; animation: enter .45s var(--ease) both; }
.audit-score { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 4px; }
.audit-score b { font-family: var(--serif); font-weight: 400; font-size: 64px; line-height: 1; color: var(--accent-ink); }
.audit-score span { color: var(--faint); font-weight: 600; }
.audit-band { margin: 6px 0 14px; font-size: var(--fs-lg); font-weight: 700; }
.audit-result p { color: var(--muted); }
.audit-result .meter { height: 8px; margin: 14px 0 22px; }
.fine-print { margin-top: 18px; font-size: var(--fs-xs); color: var(--faint); }

/* ---------- larger text ---------- */
:root.is-large-text { --fs-base: 18px; --fs-sm: 15.5px; --fs-xs: 14px; }
:root.is-large-text .md, :root.is-large-text .msg__bubble { font-size: 18px; }

/* hover affordances only where hovering exists, so taps don't leave rows lit */
@media (hover: hover) {
  .row:hover { background: var(--surface); }
  .convo:hover { background: var(--surface); }
  .line:hover { background: var(--raised); }
  .think__toggle:not(:disabled):hover { background: var(--surface); color: var(--muted); }
  .act:hover { background: var(--surface); color: var(--text); }
  .icon-btn:hover { background: var(--raised); color: var(--text); }
  .convo.is-active:hover, .row.is-active:hover { background: var(--raised); }
  .convo__del:hover, .danger-text:hover { color: var(--danger); background: var(--danger-wash); }
  .tool:hover { background: var(--surface); color: var(--text); }
  .exit-btn:hover { background: var(--surface); color: var(--text); }
  .person-link:hover, .lib-doc:hover, a.src:hover, button.src:hover { background: var(--raised); }
  .srcs__toggle:hover { background: var(--surface); color: var(--text); }
  .followup:hover { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
  .opt:hover { border-color: color-mix(in srgb, var(--text) 30%, transparent); }
  .mic:hover { background: var(--raised); color: var(--text); }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .admin { grid-template-columns: 260px 300px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(86vw, 320px);
    transform: translateX(-100%); transition: transform var(--t3) var(--ease); box-shadow: none;
    padding-left: env(safe-area-inset-left);
  }
  .shell.is-open .sidebar { transform: none; box-shadow: 0 0 80px rgba(0, 0, 0, .45); }
  .shell.is-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar__menu { display: inline-grid; }
  .main[data-state="welcome"] .topbar__brand { display: inline-flex; }
  .main[data-state="welcome"] .topbar__title { display: none; }

  .admin { display: block; position: relative; overflow: hidden; }
  .pane { position: absolute; inset: 0; border-right: 0; background: var(--bg); visibility: hidden; opacity: 0; transform: translateX(24px); transition: opacity var(--t2) var(--ease), transform var(--t3) var(--ease), visibility 0s linear var(--t3); }
  .pane--people { background: var(--bg); }
  .admin[data-view="people"] .pane--people,
  .admin[data-view="chats"] .pane--chats,
  .admin[data-view="chat"] .pane--chat { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
  .pane__back { display: inline-grid; }
}

@media (max-width: 640px) {
  .dialog--panel { width: 100vw; transform: translateY(24px); }
  @starting-style { .dialog--panel[open] { transform: translateY(24px); } }
  .panel__head { padding-left: 20px; } .panel__body { padding: 18px 20px 36px; } .panel__foot { padding-left: 20px; padding-right: 20px; } .panel__search { margin: 12px 20px 0; }
  .exit-btn { width: 36px; padding: 0; justify-content: center; } .exit-btn__label { display: none; }
  .topbar__sources { display: none; }
  .private-pill { width: 28px; padding: 0; justify-content: center; }
  .private-pill__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar__actions { gap: 4px; }
  .card-emergency { flex-wrap: wrap; } .card-emergency .btn { width: 100%; }
  .stream { padding: 0 18px; }
  .composer { padding: 2px 12px calc(10px + env(safe-area-inset-bottom)); }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .thread { gap: 24px; }
  .welcome { padding-top: 2vh; }
  .welcome__lede { margin-bottom: 26px; font-size: 16px; }
  .starters { grid-template-columns: 1fr; }
  .starter { padding: 14px 0; }
  .msg__bubble { max-width: 88%; }
  .composer__note { margin-top: 8px; }
  .entry .brand { margin-bottom: 32px; }
  .entry__lede { font-size: 16px; margin-bottom: 28px; }
  .line { grid-template-columns: 1fr auto; grid-template-areas: "text num"; gap: 16px; }
  .line__num { font-size: 17px; }
  .line--urgent .line__num { font-size: 20px; }
  .dialog--sheet { width: 100vw; max-width: none; max-height: 88dvh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: env(safe-area-inset-bottom); transform: translateY(100%); }
  .dialog--sheet[open] { transform: none; }
  @starting-style { .dialog--sheet[open] { transform: translateY(100%); } }
  .help-btn { padding: 0 12px 0 11px; }
  /* iOS zooms into inputs under 16px */
  .field__input, .composer__input { font-size: 16px; }
}

.narrow-only { display: none; }
@media (max-width: 380px) {
  .topbar { gap: 6px; }
  .topbar__actions { gap: 3px; }
  .help-btn { padding: 0 10px 0 9px; gap: 6px; }
}
@media (max-width: 420px) {
  .admin-bar { gap: 2px; padding-left: max(16px, env(safe-area-inset-left)); }
  .admin-bar .brand__sub { display: none; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .status__label { animation: none; color: var(--muted); background: none; }
}

@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes step-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14%); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { transform: scale(.75); opacity: .35; } 50% { transform: scale(1); opacity: .9; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes listen { 0%, 100% { box-shadow: 0 0 0 0 var(--danger-wash); } 50% { box-shadow: 0 0 0 6px var(--danger-wash); } }
@keyframes pulse-bg { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 15%, 85% { transform: translateX(-2px); } 30%, 70% { transform: translateX(4px); } 45%, 55% { transform: translateX(-5px); } }

/* ---------- print: just the conversation ---------- */
@media print {
  :root { color-scheme: light; --bg: #fff; --text: #111; --muted: #333; --faint: #555; --raised: #eee; --surface: #fff; --line: #ddd; --accent-ink: #6b4500; --accent-wash: #f5e6c8; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .sidebar, .topbar, .composer, .horizon, .msg__actions, .followups, .think, .jump, .scrim, .toast, dialog, .card-emergency .btn { display: none !important; }
  .shell, .main, .stream { display: block !important; height: auto !important; overflow: visible !important; }
  .thread { max-width: none; padding: 0; }
  .srcs__panel { grid-template-rows: 1fr !important; }
  .srcs__toggle { display: none; }
  .msg { break-inside: avoid; animation: none !important; }
}
