/* MentalCure — "Warm margins" (palette V3, owner's pick 2026-11-19): the site-wide design system.
   Pale sage paper, warm-neutral ink. Green is for acting (buttons, mic, brand); blue is for meaning (serif italics,
   step numbers); a small clay accent in the margins (--sage); a warm charcoal deep section.
   Source Sans 3 + Fraunces Italic (both OFL). */

@font-face {
  font-family: "Source Sans 3";
  src: url("/static/fonts/source-sans-3.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face { /* Russian pages: Fraunces has no Cyrillic, so the italic accents switch to Lora (OFL) */
  font-family: "Lora";
  src: url("/static/fonts/lora-italic.woff2") format("woff2");
  font-weight: 400 500;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/static/fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #e2e4d4;
  --paper-2: #dcdac8;
  --sheet-light: #f2efe6;
  --card: #fbf9f3;
  --ink: #2a2622;
  --ink-2: #524a43;
  --ink-3: #5f564e;
  --line: rgba(42, 38, 34, .14);
  --line-2: rgba(42, 38, 34, .24);
  --primary: #2f6447;
  --primary-soft: #7ba487;
  --primary-tint: #cde0cf;
  --on-primary: #f6f9f2;
  --sage: #8a4b2f;
  --sage-soft: #c9916f;
  --sage-tint: #f0dfd2;
  --blue: #34557a;
  --blue-soft: #7d98b4;
  --blue-tint: #dde4ea;
  --blob: #dad8c6;
  --deep: #2a2521;
  --on-deep: #f1ece3;
  --on-deep-2: #d0c7b9;
  --deep-accent: #adc6e0;
  --grain-opacity: .22;
  --shadow: 0 1px 0 rgba(42, 38, 34, .04), 0 12px 32px -18px rgba(60, 45, 30, .28);
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --wrap: 1240px;
  --gutter: clamp(20px, 5vw, 56px);
  --sheet-r: clamp(28px, 4vw, 56px);
  --focus: 0 0 0 3px var(--paper), 0 0 0 5px var(--blue);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #1a1715;
    --paper-2: #201c19;
    --sheet-light: #221e1b;
    --card: #28231f;
    --ink: #efe8de;
    --ink-2: #cbc1b4;
    --ink-3: #aca192;
    --line: rgba(239, 232, 222, .13);
    --line-2: rgba(239, 232, 222, .24);
    --primary: #8cc79e;
    --primary-soft: #5a9670;
    --primary-tint: #1f3528;
    --on-primary: #0e1a12;
    --sage: #e2a383;
    --sage-soft: #b8785a;
    --sage-tint: #3a2a21;
    --blue: #a9c2dc;
    --blue-soft: #6f89a5;
    --blue-tint: #232b33;
    --blob: #211d1a;
    --deep: #2a2420;
    --on-deep: #efe8de;
    --on-deep-2: #cbc1b4;
    --deep-accent: #adc6e0;
    --grain-opacity: .35;
    --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 16px 36px -20px rgba(0, 0, 0, .7);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
@media (min-width: 768px) { body { font-size: 1.125rem; } }
/* viewport-fit=cover (standalone home-screen app): keep content out of the notch / rounded corners in landscape. */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
body::before { /* paper grain */
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: url("/static/grain.svg") repeat;
  background-size: 220px;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) { body::before { mix-blend-mode: soft-light; } }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--primary); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--primary-tint); color: var(--ink); }

h1, h2, h3, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; color: var(--paper); }

.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

/* type */
.serif, em.serif, h1 em, h2 em, .pull em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -.01em;
}
h1 em, h2 em { font-size: 1.06em; line-height: 1; }
.eyebrow {
  display: inline-flex; align-items: center; gap: .6em;
  font-size: .8125rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-2);
}
.eyebrow::before {
  content: ""; width: 22px; height: 2px; border-radius: 2px; background: var(--sage);
}
.h2 {
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -.022em;
  font-weight: 600;
  text-wrap: balance;
}
.h2 em { color: var(--blue); }
.lead {
  font-size: clamp(1.125rem, 1rem + .5vw, 1.3125rem);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 38em;
  text-wrap: pretty;
}
.note { font-size: .9375rem; color: var(--ink-3); }
.note-serif { font-family: var(--serif); font-style: italic; color: var(--ink-2); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-height: 48px; padding: .7em 1.35em;
  border-radius: 999px; border: 1.5px solid transparent;
  font: 600 1.0625rem/1 var(--sans); letter-spacing: .005em;
  text-decoration: none; cursor: pointer;
  transition: transform .2s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
}
.btn svg { width: 18px; height: 18px; transition: transform .25s ease; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { color: var(--on-primary); background: color-mix(in srgb, var(--primary) 88%, var(--ink)); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-ghost { border-color: var(--line-2); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { min-height: 40px; padding: .5em 1.05em; font-size: .9375rem; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:active { transform: translateY(1px); }

/* stroke classes for inline SVG art */
.ln { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ln-thin { stroke-width: 1.1; }
.ln-primary { stroke: var(--primary); }
.ln-sage { stroke: var(--sage); }
.ln-blue { stroke: var(--blue); }
.ln-faint { stroke: var(--line-2); }
.ln-dash { stroke-dasharray: 2 5; }
.fill-primary { fill: var(--primary); }
.fill-sage { fill: var(--sage); }
.fill-blue { fill: var(--blue); }
.fill-ink { fill: var(--ink); }
.fill-paper { fill: var(--paper); }
.fill-blob { fill: var(--blob); }
.txt-serif { font-family: var(--serif); font-style: italic; fill: var(--ink); }
.txt-sage { fill: var(--sage); }
.txt-blue { fill: var(--blue); }
.txt-primary { fill: var(--primary); }
.txt-sans { font-family: var(--sans); fill: var(--ink-3); }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  padding-top: env(safe-area-inset-top);   /* under the status bar / notch when the page runs edge to edge */
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
  backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, box-shadow .3s ease;
}
.site-head.scrolled { border-bottom-color: var(--line); }
.head-row { display: flex; align-items: center; gap: 16px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 1.1875rem; letter-spacing: -.01em; }
.brand:hover { color: var(--ink); }
.brand .mark { width: 32px; height: 32px; flex: none; }
.mark-bg { fill: var(--primary); }
.mark-ln { fill: none; stroke: var(--on-primary); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav { display: none; gap: 28px; margin-left: auto; font-size: .96875rem; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 6px 0; }
.nav a:hover { color: var(--primary); }
.head-cta { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.head-cta .signin { font-weight: 600; font-size: .96875rem; text-decoration: none; padding: 8px 6px; }
.head-cta .btn-primary { display: none; }
.head-cta .btn-primary.keep { display: inline-flex; }
@media (min-width: 560px) { .head-cta .btn-primary { display: inline-flex; } }
@media (min-width: 1000px) {
  .nav { display: flex; }
  .head-cta { margin-left: 32px; }
}


/* footer */
.site-foot { padding-block: 56px 40px; border-top: 1px solid var(--line); margin-top: clamp(48px, 7vw, 96px); }
.foot-grid { display: grid; gap: 32px; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.foot-grid h2 { font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }
.foot-grid ul { display: grid; gap: 8px; }
.foot-grid a { text-decoration: none; color: var(--ink-2); }
.foot-grid a:hover { color: var(--primary); }
.foot-tag { margin-top: 12px; color: var(--ink-2); max-width: 22em; font-size: 1rem; }
.foot-small { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between; font-size: .875rem; color: var(--ink-3); }

/* ======================================================================================
   Site-wide components (every page except the home sections, which live in home.css)
   ====================================================================================== */

/* compatibility aliases (test.css and any older rule speak these names) */
:root {
  --bg: var(--paper); --surface: var(--card); --text: var(--ink); --muted: var(--ink-3);
  --accent: var(--sage); --accent-text: var(--on-primary); --accent-soft: var(--sage-tint);
  --border: var(--line-2); --radius: 16px;
  --danger: #9b2f22; --danger-tint: #f6ddd5; --ok-tint: var(--sage-tint);
}
@media (prefers-color-scheme: dark) { :root { --danger: #f09a86; --danger-tint: #3d221c; } }

/* header extras: signed-in account links, brand word */
body:not(.home) .site-head { border-bottom-color: var(--line); }
body:not(.home) .head-cta { margin-left: auto; }
.acct { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; }
.acct a, .acct .linklike {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 9px; border-radius: 999px;
  font: 500 .9375rem/1 var(--sans); color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.acct a:hover, .acct .linklike:hover { background: var(--paper-2); color: var(--ink); }
.site-head.authed .brand-word { display: none; }
@media (min-width: 560px) { .site-head.authed .brand-word { display: inline; } .acct { gap: 6px; } }
form.inline { display: inline; margin: 0; }
/* Narrow phones, signed in: brand mark + language + four account links used to be ~25px wider than a 390px screen
   ("Sign out" was cut off). Tighter spacing, and the links wrap onto a second line rather than overflow (Russian). */
@media (max-width: 479px) {
  .site-head.authed .head-row { gap: 8px; }
  .site-head.authed .lang-switch + .head-cta { margin-left: 2px; }
  .site-head.authed .head-cta { min-width: 0; }
  .site-head.authed .acct { gap: 0; flex-wrap: wrap; justify-content: flex-end; }
  .site-head.authed .acct a, .site-head.authed .acct .linklike { padding: 0 6px; font-size: .875rem; min-height: 36px; }
}

/* Russian pages: same system, Cyrillic-capable italic for the accents (English pages are untouched) */
:lang(ru) { --serif: "Lora", "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif; }
:lang(ru) h1 em, :lang(ru) h2 em { font-weight: 500; letter-spacing: -.005em; }

/* language switch: each language named in its own language; the current one marked */
.lang-switch { display: flex; align-items: center; gap: 2px; margin-left: auto; font-size: .9375rem; }
.lang-switch a, .lang-switch .linklike {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font: 500 .9375rem/1 var(--sans);
}
.lang-switch a:hover, .lang-switch .linklike:hover { color: var(--primary); background: none; }
.lang-switch .is-current a, .lang-switch a.is-current, .lang-switch .is-current .linklike { color: var(--ink); font-weight: 650; }
.lang-sep { color: var(--ink-3); }
.site-head .lang-switch + .head-cta { margin-left: 12px; }
@media (max-width: 559px) { /* phones: only the other language, to leave room for the account links */
  .lang-switch .is-current, .lang-switch .lang-sep { display: none; }
}
@media (min-width: 1000px) { .home .lang-switch { margin-left: 28px; } .site-head .lang-switch + .head-cta { margin-left: 18px; } }

/* page frame */
body.page main { padding: clamp(28px, 6vw, 72px) var(--gutter) clamp(40px, 7vw, 88px); }
.moved { margin-top: 0; margin-bottom: 0; padding-bottom: 8px; font-size: .875rem; color: var(--ink-3); }
.moved a { color: var(--primary); text-decoration: underline; }
.flash { max-width: 720px; margin: 0 auto 24px; padding: 12px 18px; border-radius: 16px; background: var(--sage-tint); color: var(--ink); }

/* prose: the reading column for every content page */
.prose { max-width: 720px; margin-inline: auto; }
.prose.wide, body.wide .prose { max-width: 1120px; }
.prose h1 { font-size: clamp(2rem, 1.5rem + 2.2vw, 3rem); line-height: 1.06; letter-spacing: -.025em; font-weight: 650; text-wrap: balance; margin-bottom: 18px; }
.prose h2 { font-size: clamp(1.375rem, 1.2rem + .6vw, 1.625rem); line-height: 1.2; letter-spacing: -.012em; font-weight: 650; margin: 2.2em 0 .6em; }
.prose h3 { font-size: 1.1875rem; line-height: 1.3; font-weight: 650; margin: 1.6em 0 .4em; }
.prose p, .prose ul, .prose ol, .prose dl, .prose pre { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--primary); }
.prose a:not(.button) { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--primary) 70%, transparent); text-decoration-thickness: 1.5px; }
.prose a:not(.button):hover { color: var(--primary); }
.prose > h1 + p { font-size: clamp(1.0625rem, 1rem + .3vw, 1.1875rem); color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: .9375rem; font-weight: 400; }
.center { text-align: center; }
.row { display: flex; gap: 10px 12px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 18px; }
.stack { margin-bottom: 1.5rem; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2rem; }

/* narrow pages (sign in, set password, errors) sit on a sheet of card paper */
.prose.narrow {
  max-width: 480px;
  background: var(--card); border: 1px solid var(--line); border-radius: 30px 30px 30px 8px; box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 44px);
}
.prose.narrow h1 { font-size: clamp(1.875rem, 1.5rem + 1.6vw, 2.5rem); }
.prose.narrow > .hint:last-child { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }

/* buttons: every <button> is a pill; .btn (home) and .button (links) share the look */
button, .button, summary.button-like {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 46px; padding: .6em 1.3em; border-radius: 999px; border: 1.5px solid var(--primary);
  background: var(--primary); color: var(--on-primary); font: 600 1rem/1.2 var(--sans); text-decoration: none;
  cursor: pointer; transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
button:hover, .button:hover, summary.button-like:hover {
  background: color-mix(in srgb, var(--primary) 88%, var(--ink)); border-color: color-mix(in srgb, var(--primary) 88%, var(--ink)); color: var(--on-primary);
}
button:disabled, button:disabled:hover { opacity: .5; cursor: default; }
button:focus-visible, .button:focus-visible, summary.button-like:focus-visible { outline: none; box-shadow: var(--focus); }
button.ghost, .button.ghost, summary.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
button.ghost:hover, .button.ghost:hover, summary.ghost:hover { background: var(--paper-2); border-color: var(--ink-3); color: var(--ink); }
button.small, .button.small, summary.small { min-height: 38px; padding: .4em 1em; font-size: .9375rem; font-weight: 500; }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--card); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 85%, var(--ink)); border-color: transparent; color: var(--card); }
button.primary { min-height: 52px; padding: .7em 1.7em; font-size: 1.0625rem; }
button.linklike, .linklike {
  min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; color: var(--ink-2);
  font: inherit; text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px;
}
button.linklike:hover { background: none; color: var(--primary); }
.acct .linklike { text-decoration: none; }
form.stack > button[type=submit] { width: 100%; }
@media (min-width: 560px) { form.stack > button[type=submit] { width: auto; } }

/* forms */
label { display: block; font-weight: 600; font-size: 1rem; color: var(--ink); }
label .hint { display: inline; margin-left: .3em; font-size: .875rem; }
label > input, label > select, label > textarea { margin-top: 7px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  display: block; width: 100%; min-height: 48px; padding: .65em .9em;
  font: 400 1.0625rem/1.4 var(--sans); color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line-2); border-radius: 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent); }
select {
  appearance: none; padding-right: 2.4em; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat;
}
textarea { resize: vertical; }
input.short { width: 9em; display: inline-block; }
input.mono, pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
label.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; line-height: 1.5; }
label.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
fieldset.consents {
  margin: 28px 0 0; padding: 22px clamp(18px, 3vw, 28px) 24px; border: 0; border-radius: 26px 26px 26px 8px;
  background: var(--paper-2);
}
fieldset.consents > * + * { margin-top: 16px; }
fieldset.consents legend {
  float: left; width: 100%; padding: 0; margin-bottom: 4px;
  font-family: var(--serif); font-style: italic; font-size: 1.5rem; font-weight: 400; color: var(--primary);
}
fieldset.consents legend + * { clear: both; margin-top: 0; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-status { color: var(--ink-3); font-size: .9375rem; }
.form-status.bad { color: var(--danger); }

/* notices */
.alert, .banner {
  border-radius: 18px; padding: 14px 18px; margin: 0 0 20px;
  background: var(--danger-tint); color: var(--ink); border-left: 3px solid var(--danger);
}
.alert p { margin: 0 0 .3em; }
.alert ul { margin: 0; padding-left: 1.2rem; list-style: disc; }
.alert.ok { background: var(--ok-tint); border-left-color: var(--sage); }
.banner { background: var(--primary-tint); border-left-color: var(--primary); }
.banner p { margin: 0 0 .5em; }
.banner blockquote { margin: 8px 0 12px; padding-left: 14px; border-left: 2px solid var(--line-2); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* data */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 6px 22px 16px; margin-bottom: 16px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .04em; background: var(--sage-tint); color: var(--sage); border-radius: 999px; padding: 2px 9px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
table.small { font-size: .875rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--ink-3); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; background: var(--paper-2); }
dl { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: 6px 16px; }
dt { color: var(--ink-3); font-size: .9375rem; }
dd { margin: 0; overflow-wrap: anywhere; }
.prewrap, .plain { white-space: pre-wrap; overflow-wrap: anywhere; }
pre.resources { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; font-family: inherit; font-size: 1rem; }
details summary { cursor: pointer; }
form.danger, .danger-zone {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: 22px; padding: 6px 22px 18px; margin-top: 18px;
}
form.danger h3 { color: var(--danger); }

/* settings: the voice-learning card */
.voice-learn { background: var(--sage-tint); border-radius: 22px; padding: 4px 22px 18px; }
.voice-learn h3 { margin-top: 18px; }

/* legal pages */
.legal { max-width: 780px; }
.legal-head h1 { margin-bottom: 6px; }
.legal-meta { color: var(--ink-3); font-size: .9375rem; }
.legal-summary {
  margin: 28px 0; padding: 22px clamp(18px, 3vw, 28px) 18px; border-radius: 26px 26px 26px 8px;
  background: var(--sage-tint); color: var(--ink);
}
.legal-summary h2 { margin: 0 0 8px; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.5rem; color: var(--sage); }
.legal-summary ul { margin: 0; }
.legal-summary li::marker { color: var(--sage); }
.legal-toc { margin: 28px 0 40px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); }
.legal-toc h2 { margin: 0 0 8px; font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.legal-toc ol { margin: 0; columns: 2; column-gap: 32px; }
.legal-toc li { margin: 4px 0; break-inside: avoid; }
.legal-section { margin: 40px 0; scroll-margin-top: 88px; }
.legal-section h2 { margin: 0 0 10px; scroll-margin-top: 88px; }
.legal-num { color: var(--primary); margin-right: 6px; font-variant-numeric: tabular-nums; }
.legal-note { margin: 6px 0 0; font-size: .875rem; line-height: 1.5; color: var(--ink-3); }
@media (max-width: 560px) { .legal-toc ol { columns: 1; } }

/* ======================================================================================
   The app: conversation, onboarding, "learn my voice"
   ====================================================================================== */
body.chatpage main { padding: clamp(16px, 4vw, 40px) var(--gutter) 0; }
body.chatpage .site-head { position: sticky; top: 0; }
.app { max-width: 760px; margin-inline: auto; }

/* thread */
#thread { padding-bottom: 8px; }
#load-older { margin-bottom: 12px; }
.msg { margin: 26px 0; overflow-wrap: anywhere; }
.msg.user {
  margin-left: auto; width: fit-content; max-width: min(88%, 560px);
  background: var(--primary-tint); color: var(--ink); border-radius: 22px 22px 6px 22px;
  padding: 12px 18px; white-space: pre-wrap; font-size: 1.0625rem; line-height: 1.55;
}
.msg.assistant { max-width: 620px; padding-left: 16px; border-left: 2px solid var(--sage-soft); font-size: 1.125rem; line-height: 1.62; }
@media (min-width: 768px) { .msg.assistant { font-size: 1.1875rem; } }
.msg.assistant p { margin: 0 0 .85em; }
.msg.assistant p:last-of-type { margin-bottom: 0; }
.msg.assistant.notice { border-left-color: var(--primary); }
.msg .tag-line {
  display: flex; align-items: center; gap: 7px; margin-top: 10px;
  font-size: .8125rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-3);
}
.msg .tag-line::before { content: ""; width: 10px; height: 9px; flex: none; border-radius: 58% 42% 55% 45% / 52% 60% 40% 48%; background: var(--sage); }
.msg.note { color: var(--ink-2); font-size: .9375rem; white-space: pre-wrap; text-align: center; padding: 8px 14px; border: 1px dashed var(--line-2); border-radius: 14px; }
#live { border-left-color: var(--line-2); }
.status { color: var(--ink-3); font-size: .9375rem; margin: 0 0 6px; min-height: 1.4em; display: flex; align-items: center; gap: 8px; }
.status.error { color: var(--danger); }
.status.working::before {
  content: ""; width: 9px; height: 9px; flex: none; border-radius: 58% 42% 55% 45% / 52% 60% 40% 48%; background: var(--sage);
}
@media (prefers-reduced-motion: no-preference) { .status.working::before { animation: pulse 1.4s ease-in-out infinite; } }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: none; } }

/* live transcript while you speak, and "you said" afterwards */
#voice-live:not(:empty) {
  margin: 8px 0 14px auto; width: fit-content; max-width: min(88%, 560px); padding: 12px 16px; border-radius: 22px 22px 6px 22px;
  border: 1.5px dashed color-mix(in srgb, var(--primary) 45%, transparent); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere;
}
#voice-live .voice-said { font-family: var(--serif); font-style: italic; font-size: 1rem; color: var(--primary); }
#voice-live .voice-timeline { color: var(--ink); }

/* a voice turn is the user's bubble: "you said [en]:", the timeline, notes */
.msg.user .voice-said { font-family: var(--serif); font-style: italic; font-size: .9375rem; color: var(--primary); }
.msg.user .voice-timeline { margin: 4px 0 0 10px; white-space: pre-wrap; }
.msg.user .voice-incomplete { margin-top: 6px; font-size: .875rem; font-style: italic; color: var(--ink-3); }
.msg.user .voice-spectral { margin-top: 6px; font-size: .875rem; color: var(--ink-3); white-space: pre-wrap; }
#voice-live .voice-timeline { white-space: pre-wrap; margin: 4px 0 8px 12px; }

/* ▶ under each reply: voice it in the chosen voice. 44px tap target, quiet until used. */
.msg-tools { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-height: 44px; }
.msg-tools .reply-play {
  min-width: 44px; min-height: 44px; padding: 0 0 0 2px; border-radius: 999px; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; font-size: .875rem; font-weight: 600; line-height: 1;
  border: 1px solid var(--line-2); background: transparent; color: var(--primary); cursor: pointer; touch-action: manipulation;
}
.msg-tools .reply-play:hover { background: var(--card); border-color: var(--primary-soft); }
.msg-tools .reply-play.is-playing, .msg-tools .reply-play.is-loading { background: var(--primary); border-color: var(--primary); color: var(--on-primary); padding: 0; }
.msg-tools .reply-play.is-blocked { padding: 0 16px 0 14px; border-color: var(--primary); background: var(--primary-tint); color: var(--ink); }
@media (prefers-reduced-motion: no-preference) { .msg-tools .reply-play.is-loading { animation: pulse 1.2s ease-in-out infinite; } }

/* conversation actions: in the flow under the thread (never sticky), so they never cover it */
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 12px; }
.actions button.small, .actions summary.small {
  min-height: 36px; padding: .35em .95em; font-size: .875rem; font-weight: 500;
  background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2);
}
.actions button.small:hover, .actions summary.small:hover { background: var(--card); border-color: var(--line-2); color: var(--ink); }
.actions #btn-wrong { border-style: dashed; background: transparent; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary::after { content: ""; width: 6px; height: 6px; margin: -3px 0 0 2px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-135deg); }
details.menu[open] summary { background: var(--card); border-color: var(--line-2); color: var(--ink); }
.menu-list {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 30; display: flex; flex-direction: column; gap: 2px;
  width: min(340px, calc(100vw - 2 * var(--gutter))); max-height: 60vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 8px; box-shadow: var(--shadow);
}
.menu-list button.small {
  justify-content: flex-start; text-align: left; width: 100%; min-height: 40px; border: 0; border-radius: 12px;
  background: none; color: var(--ink); font-size: .9375rem;
}
.menu-list button.small:hover { background: var(--sage-tint); color: var(--ink); }

/* composer: one compact row (text + mic + send) that stays at the bottom without eating the thread */
.composer {
  position: sticky; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6px;
  margin: 0 calc(-1 * var(--gutter)); padding: 10px calc(var(--gutter) + 6px) max(16px, env(safe-area-inset-bottom)) var(--gutter);
  background: linear-gradient(to bottom, transparent, var(--paper) 16px);
}
.composer::before { /* the paper card behind the row */
  content: ""; position: absolute; z-index: -1;
  inset: 10px var(--gutter) max(16px, env(safe-area-inset-bottom));
  background: var(--card); border: 1.5px solid var(--line-2); border-radius: 26px 26px 26px 10px; box-shadow: var(--shadow);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.composer:focus-within::before { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
.composer textarea {
  min-height: 52px; max-height: 40vh; margin: 0; padding: 14px 4px 14px 18px; resize: none;
  border: 0; border-radius: 26px 0 0 10px; background: none; box-shadow: none; font-size: 1.0625rem; line-height: 1.45;
}
.composer textarea:hover { border: 0; }
.composer textarea:focus-visible { box-shadow: none; }
.composer textarea::placeholder { color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
#send { min-height: 44px; padding: .5em 1.15em; }
body.voice-active #send { display: none; }

/* voice.js sizes its controls with inline styles; these rules re-dress them in the paper style */
#voice-controls { display: flex !important; flex-direction: row !important; align-items: center !important; gap: 8px !important; padding: 0 !important; min-width: 0; }
#voice-controls .voice-row { gap: 8px !important; flex-wrap: nowrap !important; }
#voice-controls .voice-mic {
  width: 44px !important; height: 44px !important; padding: 0 !important; min-height: 0;
  border: 0 !important; border-radius: 46% 54% 50% 50% / 54% 46% 54% 46% !important;
  background: var(--primary) !important; color: var(--on-primary) !important; box-shadow: 0 0 0 4px var(--primary-tint);
}
#voice-controls .voice-mic svg { width: 22px; height: 22px; }
#voice-controls .voice-mic:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)) !important; }
#voice-controls .voice-mic:focus-visible { box-shadow: 0 0 0 4px var(--primary-tint), var(--focus); }
#voice-controls .voice-hint { font-size: .9375rem; color: var(--ink-2); opacity: 1 !important; }
body:not(.voice-active) #voice-controls .voice-hint { display: none; }
#voice-controls .voice-cancel, #voice-controls .voice-stop, #voice-controls .voice-play {
  min-height: 40px !important; min-width: 0 !important; padding: 0 16px !important; border-radius: 999px !important;
  border: 1.5px solid var(--line-2) !important; background: transparent !important; color: var(--ink) !important; font-weight: 600 !important;
}
#voice-controls .voice-send {
  min-height: 44px !important; padding: 0 22px !important; border-radius: 999px !important;
  border: 1.5px solid var(--primary) !important; background: var(--primary) !important; color: var(--on-primary) !important;
}
#voice-controls .voice-dot { background: var(--primary) !important; }
@media (prefers-reduced-motion: no-preference) { #voice-controls .voice-dot { animation: pulse 1.2s ease-in-out infinite; } }
#voice-controls .voice-timer { font-weight: 600; color: var(--ink); }
#voice-controls .voice-player-label { font-size: .875rem; color: var(--ink-2); opacity: 1 !important; }
#voice-controls .voice-status:empty, #voice-controls .voice-note:empty { display: none !important; }
body:not(.voice-active) #voice-controls .voice-status:not(:empty) {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 100%; text-align: center !important;
  font-size: .875rem; color: var(--ink-2); padding: 2px 10px; background: var(--paper); border-radius: 999px;
}
#voice-controls .voice-status.voice-error { color: var(--danger); }
#voice-controls .voice-note { font-size: .8125rem !important; color: var(--ink-3); opacity: 1 !important; }
/* while recording (or while a reply is playing) the controls take a full row under the text */
body.voice-active .composer, .composer:has(.voice-player[style*="display: flex"]) { grid-template-columns: minmax(0, 1fr); }
body.voice-active .composer-row, .composer:has(.voice-player[style*="display: flex"]) .composer-row { justify-content: center; padding: 0 12px 12px; }
body.voice-active #voice-controls { flex-direction: column !important; width: 100%; }
body.voice-active #voice-controls .voice-row { flex-wrap: wrap !important; justify-content: center !important; }

/* reply voice: a chip in the actions row opens the list (pick + ▶ preview); the composer stays one line */
.actions { position: relative; }
.actions .voice-menu { position: static; }          /* the list anchors to the whole row, so it never overflows */
.voice-menu summary { gap: 6px; max-width: 13rem; }
.voice-menu .vm-ico { width: 16px; height: 16px; flex: none; color: var(--primary); }
.voice-menu .vm-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions .voice-list { width: min(380px, 100%); gap: 2px; padding: 8px 8px 6px; }
.vl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 4px 8px 8px; margin: 0;
  font-weight: 650; font-size: .9375rem; color: var(--ink); }
.vl-head .hint { font-size: .8125rem; font-weight: 400; }
.voice-opt { display: flex; align-items: center; gap: 4px; }
.actions .voice-list button.vo-pick {
  flex: 1; min-width: 0; justify-content: flex-start; gap: 6px; min-height: 44px; padding: 0 10px; border: 0;
  border-radius: 12px; background: none; color: var(--ink); font-size: .9375rem; font-weight: 500; text-align: left;
}
.actions .voice-list button.vo-pick::before {
  content: ""; width: 10px; height: 9px; flex: none; margin-right: 4px; border-radius: 58% 42% 55% 45% / 52% 60% 40% 48%;
  border: 1.5px solid var(--line-2);
}
.actions .voice-list button.vo-pick:hover { background: var(--paper); }
.actions .voice-list button.vo-pick[aria-pressed="true"] { background: var(--sage-tint); font-weight: 650; }
.actions .voice-list button.vo-pick[aria-pressed="true"]::before { background: var(--sage); border-color: var(--sage); }
.vo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vo-hint { color: var(--ink-3); font-size: .8125rem; font-weight: 400; white-space: nowrap; }
.vo-hint::before { content: "· "; }
button.vo-play, .actions .voice-list button.vo-play {
  flex: none; width: 40px; min-width: 40px; min-height: 40px; padding: 0 0 0 2px; border-radius: 999px;
  justify-content: center; text-align: center;
  border: 1px solid var(--line-2); background: var(--card); color: var(--primary); font-size: .75rem; font-weight: 600;
}
button.vo-play:hover, .actions .voice-list button.vo-play:hover { border-color: var(--primary-soft); background: var(--card); color: var(--primary); }
button.vo-play.is-playing, button.vo-play.is-loading, .actions .voice-list button.vo-play.is-playing,
.actions .voice-list button.vo-play.is-loading { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
@media (prefers-reduced-motion: no-preference) { button.vo-play.is-loading { animation: pulse 1.2s ease-in-out infinite; } }
.vl-auto { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 4px 0 0; padding: 0 10px; border-top: 1px solid var(--line);
  font-size: .9375rem; color: var(--ink); cursor: pointer; }
.vl-auto input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--primary); }
.vl-status { margin: 0; padding: 4px 10px 2px; font-size: .8125rem; }
.vl-status:empty { display: none; }
/* Settings: listen to each voice */
.voice-samples ul { list-style: none; margin: 6px 0 0; padding: 0; border-top: 1px solid var(--line); }
.voice-samples li { display: flex; align-items: center; gap: 8px; min-height: 52px; border-bottom: 1px solid var(--line); margin: 0; }
.voice-samples li .vo-hint { margin-right: auto; }
.voice-samples .vo-name { font-weight: 500; }

/* the formulation */
dialog {
  width: min(680px, calc(100vw - 24px)); max-height: 88vh; padding: clamp(18px, 4vw, 32px);
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 28px 28px 28px 8px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(30, 42, 33, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 1.625rem; font-weight: 650; letter-spacing: -.015em; }
dialog > .hint { margin-bottom: 8px; }
.f-section { margin: 18px 0; padding-top: 14px; border-top: 1px solid var(--line); }
.f-section .f-section { margin: 6px 0; padding-top: 0; border-top: 0; }
.f-section h3 { margin: 0 0 6px; font-size: 1.0625rem; font-weight: 650; }
.f-section h3::first-letter { text-transform: uppercase; }
.f-section h4 { margin: 10px 0 4px; font-size: .9375rem; font-weight: 600; color: var(--ink-2); }
.f-section p { margin: 0 0 .6em; }
.f-section ul { margin: 4px 0 10px; padding-left: 1.2rem; list-style: disc; }
.f-section li::marker { color: var(--sage); }
.f-conf { color: var(--ink-3); font-size: .875rem; font-weight: 400; font-variant-numeric: tabular-nums; }
/* "What I remember" (memory panel) */
.mem-meta { color: var(--ink-3); font-size: .875rem; }
.mem-unclear > span:first-child { text-decoration: underline dotted var(--sage); text-underline-offset: 3px; }
.mem-section details { margin: 8px 0; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mem-section summary { cursor: pointer; font-weight: 600; }
.mem-section details p { margin: .5em 0; }
.mem-section blockquote { margin: .4em 0 .4em .2em; padding-left: .8em; border-left: 2px solid var(--sage-soft); color: var(--ink-2); font-style: italic; }

/* first visit: the honest intro */
.intro, .calibration { max-width: 620px; margin: 0 auto; padding: 8px 0 48px; }
.intro-head h1, .calibration h1 { font-size: clamp(2rem, 1.5rem + 2.2vw, 2.75rem); line-height: 1.08; letter-spacing: -.022em; font-weight: 650; text-wrap: balance; margin: 8px 0 14px; }
.intro-lede { font-size: 1.1875rem; line-height: 1.55; color: var(--ink-2); margin: 0 0 24px; }
.intro-block {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px 24px 24px 8px;
  padding: 18px 22px 8px; margin: 0 0 12px;
}
.intro-block:nth-of-type(3n+1) { border-top: 3px solid var(--primary-soft); }
.intro-block:nth-of-type(3n+2) { border-top: 3px solid var(--sage-soft); }
.intro-block:nth-of-type(3n) { border-top: 3px solid var(--blue-soft); }
.intro-block h2 { margin: 0 0 8px; font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.intro-block p { margin: 0 0 .8em; overflow-wrap: anywhere; }
.intro-actions, .cal-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 28px 0 10px; }
.intro-note { margin: 0; }

/* "learn my voice" */
.cal-why { color: var(--ink-2); font-size: 1.0625rem; }
.cal-why p { margin: 0 0 .6em; }
.cal-subhead { font-size: 1.1875rem; font-weight: 650; margin: 28px 0 4px; }
.cal-pick-hint { margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; }
.chip {
  justify-content: flex-start; text-align: left; min-height: 44px; padding: .5em 1.1em;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--line-2); font-weight: 500;
}
.chip:hover { background: var(--card); border-color: var(--primary-soft); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--primary-tint); border-color: var(--primary); color: var(--ink); }
.cal-prompt { font-size: clamp(1.375rem, 1.2rem + .9vw, 1.75rem); line-height: 1.3; font-weight: 600; letter-spacing: -.01em; margin: 12px 0; }
.cal-helpers { color: var(--ink-2); }
.cal-helpers .hint { margin: 0 0 4px; }
.cal-helpers ul { margin: 0 0 16px; padding-left: 1.2rem; list-style: disc; }
.cal-helpers li::marker { color: var(--sage); }
.cal-meter { position: relative; width: 156px; height: 156px; margin: 20px auto; }
.cal-ring { width: 100%; height: 100%; display: block; }
.cal-ring circle { fill: none; stroke-width: 6; }
.cal-ring-track { stroke: var(--paper-2); }
.cal-ring-bar { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 339.292; stroke-dashoffset: 339.292; transition: stroke-dashoffset .4s linear; }
.cal-timer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-status { justify-content: center; text-align: center; }
.cal-live { color: var(--ink-2); border-left: 2px solid var(--primary-soft); padding-left: 14px; margin: 14px 0; }
.cal-live .hint { margin: 0 0 4px; }
.cal-live-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9rem; overflow-y: auto; }
.cal-back { margin: 6px 0 0; }
.cal-finish-text { color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .cal-ring-bar { transition: none; } }

@media (max-width: 560px) {
  dl { grid-template-columns: 1fr; gap: 2px 0; }
  dd + dt { margin-top: 8px; }
  .msg.user { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .ap:hover { transform: none; }
}
