/* Codaptable. Tokens from design/tokens.json: warm ivory ground, charcoal text, crimson as the
   single accent, rose red its softer form, stone gray for quiet text, soft gold rarely.
   Stone gray (#858585) is too light for body text on ivory, so text uses a deeper stone
   (--muted) that passes WCAG AA; the true stone is kept for decoration.
   Look (owner, 15 October 2026): soft, natural and serious. No cards: content sits on the ivory
   ground, organized by space, type and at most one thin hairline. Figtree for text, Source
   Serif 4 (bold) for headings, screen titles and navigation. Both are self-hosted (fonts/, SIL
   Open Font License), so no font requests leave the app.
   The variable names are shared with the marketing site; keep them stable. */

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('fonts/figtree-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Figtree';
  font-style: italic;
  font-weight: 300 900;
  font-display: swap;
  src: url('fonts/figtree-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('fonts/source-serif-4-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url('fonts/source-serif-4-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ground: #F7F1E8;
  --ground-deep: #EFE6D8;
  --surface: #FFFDF9;
  --text: #302E2D;
  --muted: #625E5A;
  --stone: #858585;
  --rule: #E2D6C4;
  --rule-strong: #CDBFAA;
  --accent: #A71930;        /* crimson, text and rules */
  --accent-fill: #A71930;   /* crimson, button fills */
  --on-accent: #F7F1E8;
  --accent-wash: #F6E4E1;
  --rose: #E45A68;
  --gold: #D6B77A;
  --coperson-rule: #302E2D;
  --mediator-bubble: #F1E9DD;
  --coperson-bubble: #F3ECE1;
  --user-bubble: #FBF7F0;
  --shadow: 0 1px 2px rgba(48, 46, 45, .06), 0 4px 14px rgba(48, 46, 45, .06);
  --focus: #A71930;
  --radius: 18px;
  --sb-w: 272px;
  --sb-rail: 72px;
  --gutter: 16px;
  --font-body: 'Figtree', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: 'Source Serif 4', Georgia, "Times New Roman", serif;
  --font: var(--font-body);
  --turn-gap: 36px;          /* between one speaker's turn and the next */
  --note-gap: 24px;          /* between a Coperson line and the Mediator's note under it */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #1E1C1B; --ground-deep: #262322; --surface: #2A2725; --text: #F2ECE3;
    --muted: #B5AEA6; --stone: #8F8984; --rule: #3A3533; --rule-strong: #4B4542;
    --accent: #F08A94; --accent-fill: #A71930; --on-accent: #F7F1E8; --accent-wash: #3A2427;
    --rose: #E45A68; --coperson-rule: #B5AEA6; --mediator-bubble: #282523;
    --coperson-bubble: #2A2624; --user-bubble: #242120;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); --focus: #F08A94;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #1E1C1B; --ground-deep: #262322; --surface: #2A2725; --text: #F2ECE3;
  --muted: #B5AEA6; --stone: #8F8984; --rule: #3A3533; --rule-strong: #4B4542;
  --accent: #F08A94; --accent-fill: #A71930; --on-accent: #F7F1E8; --accent-wash: #3A2427;
  --rose: #E45A68; --coperson-rule: #B5AEA6; --mediator-bubble: #282523;
  --coperson-bubble: #2A2624; --user-bubble: #242120;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); --focus: #F08A94;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
/* The app frame never scrolls; only the conversation and pages inside it do. (Screen-reader-only
   text is positioned inside the scrolling areas, so it can't stretch the document either.) */
html { overflow: hidden; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overflow: clip; /* programmatic scrolling (scrollIntoView, focus) can't shift the app frame */
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; line-height: 1.25; letter-spacing: -.005em; }
.icon { width: 22px; height: 22px; flex: none; display: block; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface);
  padding: 10px 14px; border-radius: 10px;
}
.skip-link:focus { top: 8px; }
.boot { padding: 24px var(--gutter); color: var(--muted); }

/* knot mark colors */
.knot .knot-a { stroke: var(--accent-fill); }
.knot .knot-b { stroke: var(--rose); }
:root[data-theme="dark"] .knot .knot-a { stroke: #D23B4E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .knot .knot-a { stroke: #D23B4E; } }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns .2s ease;
}
.app.sb-collapsed { grid-template-columns: var(--sb-rail) minmax(0, 1fr); }
.main { min-width: 0; min-height: 0; overflow: hidden; overflow: clip; height: 100%; display: flex; flex-direction: column; outline: none; }
.scrim { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--ground);
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; overflow-x: hidden;
  min-width: 0;
}
.sb-head { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 2px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-height: 44px; padding: 0 6px; border-radius: 10px; flex: 1; min-width: 0; }
.brand-mark svg, .brand-mark img { width: 30px; height: 30px; display: block; }
.brand-name { font-family: var(--font-heading); font-size: 1.12rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--ground-deep); }
.drawer-close { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 44px; padding: 8px 12px; border-radius: 12px;
  color: var(--text); text-decoration: none; background: transparent; border: 0;
  cursor: pointer; text-align: left; position: relative; white-space: nowrap;
  font-family: var(--font-heading); font-weight: 600; font-size: 1rem;
}
.nav-item:hover { background: var(--ground-deep); }
.nav-item[aria-current="page"] { color: var(--accent); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px; border-radius: 2px; background: var(--rose);
}
.nav-icon { display: grid; place-items: center; width: 24px; flex: none; color: var(--muted); }
.nav-item[aria-current="page"] .nav-icon { color: var(--accent); }
.new-chat { margin: 0 0 18px; color: var(--accent); font-family: var(--font-body); font-weight: 700; }
.new-chat .nav-icon { color: var(--accent); }
.upgrade-item .nav-icon { color: #8A6B2C; }
:root[data-theme="dark"] .upgrade-item .nav-icon { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .upgrade-item .nav-icon { color: var(--gold); } }

.sb-chats { flex: 1; min-height: 0; }
.chat-count { margin: 8px 12px 0; font-size: .86rem; color: var(--text); }
.sb-note { margin: 4px 12px 0; font-size: .78rem; color: var(--muted); line-height: 1.5; }
.current-chat .nav-text { overflow: hidden; text-overflow: ellipsis; font-family: var(--font-body); font-weight: 500; }
.sb-nav { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }

/* Recent chats: title and "Deletes in", a quiet delete control, no boxes */
.sb-heading { margin: 0 12px 2px; font-family: var(--font-body); font-size: .74rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.recent-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.recent-item { position: relative; display: flex; align-items: center; border-radius: 12px; }
.recent-item:hover, .recent-item:focus-within { background: var(--ground-deep); }
.recent-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-height: 48px; padding: 7px 4px 7px 12px; border: 0; background: transparent; border-radius: 12px;
  text-align: left; cursor: pointer; color: var(--text);
}
.recent-title { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: .94rem; line-height: 1.35; }
.recent-meta { font-size: .76rem; line-height: 1.35; color: var(--muted); }
.recent-item.is-current .recent-title { color: var(--accent); }
.recent-open[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px; border-radius: 2px; background: var(--rose); }
.recent-del { color: var(--muted); }
.recent-del .icon { width: 18px; height: 18px; }
.recent-del:hover { color: var(--accent); background: transparent; }
.sb-empty { margin: 10px 12px 0; font-size: .86rem; color: var(--muted); }
.sb-delete-all { margin: 6px 12px 0; font-size: .84rem; color: var(--muted); min-height: 40px; }
.sb-delete-all:hover { color: var(--accent); }
.sb-nav-top { border-top: 0; margin-top: 0; padding-top: 0; }

/* collapsed rail */
.sb-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
.sb-collapsed .sb-head { flex-direction: column; padding-bottom: 8px; }
.sb-collapsed .brand { flex: none; padding: 0; justify-content: center; }
.sb-collapsed .brand-name, .sb-collapsed .nav-text, .sb-collapsed .chat-count, .sb-collapsed .sb-note { display: none; }
.sb-collapsed .sb-chats > * { display: none; }
.sb-collapsed .nav-item { justify-content: center; padding: 8px 0; gap: 0; }
.sb-collapsed .new-chat { margin-bottom: 10px; }

/* ---------- views ---------- */
.view { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; overflow: clip; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  min-height: 60px; padding: 8px var(--gutter);
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--ground);
}
.menu-btn { display: none; margin-left: -10px; }
.topbar-title { flex: 1; min-width: 0; margin: 0; font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-link, .topbar-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border-radius: 999px; text-decoration: none; color: var(--accent); font-weight: 500; font-size: .9rem; flex: none;
}
.res-link .icon, .topbar-link .icon { width: 18px; height: 18px; }
.res-link:hover, .topbar-link:hover { background: var(--accent-wash); }

/* ---------- mode slider ---------- */
.modebar { background: var(--ground); padding: 4px var(--gutter) 14px; border-bottom: 1px solid var(--rule); }
.modebar-inner { max-width: 520px; margin: 0 auto; }
.seg {
  position: relative; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 3px; border-radius: 999px; background: var(--ground-deep);
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3);
  border-radius: 999px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(48, 46, 45, .08);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform .24s ease;
  pointer-events: none;
}
.seg.dragging .seg-thumb { transition: none; }
.seg-opt {
  position: relative; z-index: 1; min-height: 44px; padding: 4px 6px; border: 0; background: transparent;
  border-radius: 999px; cursor: pointer; color: var(--muted);
  font-family: var(--font-heading); font-size: .92rem; font-weight: 600; line-height: 1.15;
}
.seg-opt[aria-checked="true"] { color: var(--accent); font-weight: 700; }
.seg-opt[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.seg-opt:focus-visible { outline-offset: -3px; border-radius: 999px; }
.rung { display: flex; align-items: center; gap: 10px; margin: 10px auto 0; max-width: 220px; font-size: .68rem; color: var(--muted); }
.rung[hidden] { display: none; }
.rung-label { letter-spacing: .12em; text-transform: uppercase; }
.rung-thread { flex: 1; height: 8px; opacity: .8; }
.rung-thread svg { width: 100%; height: 8px; display: block; }
.mode-note { margin: 12px 0 0; font-size: .84rem; color: var(--muted); text-align: center; }

/* ---------- conversation ---------- */
.scroller { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.log-wrap { max-width: 720px; margin: 0 auto; padding: 32px var(--gutter) 56px; }
.log { display: flex; flex-direction: column; gap: var(--turn-gap); }

.msg { display: flex; flex-direction: column; max-width: min(86%, 600px); }
.msg-label { display: flex; align-items: center; gap: 8px; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px 2px; }
.mini-knot { width: 16px; height: 16px; }
/* Chat icons: the Mediator and the Coperson on the left at the start of their turns, the user on the
   right. The space is kept on every turn so bubbles line up. */
.msg-mediator, .msg-coperson { position: relative; padding-left: 46px; }
.msg-user { position: relative; padding-right: 46px; }
.avatar { position: absolute; top: 0; width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(60, 40, 30, .08); }
.msg-mediator > .avatar, .msg-coperson > .avatar { left: 0; }
.msg-mediator > .msg-label, .msg-coperson > .msg-label { min-height: 34px; margin-bottom: 4px; }
.msg-user > .avatar { right: 0; }
@media (max-width: 600px) {
  .msg-mediator, .msg-coperson { padding-left: 38px; }
  .msg-user { padding-right: 38px; }
  .avatar { width: 28px; height: 28px; }
  .msg-mediator > .msg-label, .msg-coperson > .msg-label { min-height: 28px; }
}
.label-mark { display: inline-flex; opacity: .85; }
.bubble { padding: 14px 18px; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }

.msg-mediator { align-self: flex-start; }
.msg-mediator .bubble { background: var(--mediator-bubble); }
.msg-mediator.kind-debrief .bubble { box-shadow: inset 2px 0 0 var(--rose); }

.msg-coperson { align-self: flex-start; }
.msg-coperson .bubble { background: var(--coperson-bubble); color: var(--text); }
.cop-name { font-weight: 600; letter-spacing: .1em; color: var(--text); }
.tag { font-size: .72rem; letter-spacing: .01em; text-transform: none; color: var(--muted); }
.tag::before { content: "\00B7"; margin-right: 6px; }

.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-user .bubble { position: relative; background: var(--user-bubble); padding-bottom: 16px; }
.msg-user .bubble::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: 7px; height: 1.5px; border-radius: 2px;
  background: var(--accent-fill);
}

/* The Mediator's note: italic, stone, with the rose thread down the left. Not a box. */
.msg-analysis {
  position: relative; align-self: flex-start; max-width: min(92%, 620px);
  margin: calc(var(--note-gap) - var(--turn-gap)) 0 0 10px; padding: 2px 0 2px 18px;
  border-left: 2px solid var(--rose);
}
.msg-analysis p { margin: 0; font-style: italic; color: var(--muted); line-height: 1.65; }
.msg-analysis.intro { margin-top: 0; }
.msg-analysis .analysis-knot { position: absolute; left: -10px; top: -8px; background: var(--ground); border-radius: 50%; padding: 1px; display: inline-flex; }
.log.quiet .msg-analysis:not(.keep), .log.quiet .rec-card.unasked { display: none; }

.divider { display: flex; align-items: center; gap: 14px; margin: 0; color: var(--muted); font-size: .8rem; text-align: center; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.divider span { max-width: 80%; }

/* chips: quiet, borderless options. A soft fill, a small check circle when choosing several,
   and crimson text with a check when chosen. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-reply { margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px;
  border-radius: 14px; border: 0; background: var(--ground-deep);
  cursor: pointer; text-align: left; line-height: 1.35; font-size: .95rem; color: var(--text);
}
.chip:hover { background: var(--rule); }
.chip-check {
  display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--rule-strong); color: transparent;
}
.chip-check .icon { width: 12px; height: 12px; }
.chip[aria-pressed="true"] { color: var(--accent); background: var(--ground-deep); }
.chip[aria-pressed="true"] .chip-check { border-color: var(--accent); background: var(--accent-fill); color: var(--on-accent); }
:root[data-theme="dark"] .chip[aria-pressed="true"] .chip-check { color: #fff; }

/* setup options: a list of rows with space between, two columns where there's room */
.chips.options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.chips.options .chip { width: 100%; padding: 10px 14px; }
@media (min-width: 900px) { .chips.options:not(.one) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* setup pickers: on the ground, no panel */
.picker { padding: 4px 0 0; outline: none; }
.picker:focus-visible { outline: 2px solid var(--rose); outline-offset: 6px; border-radius: 12px; }
.picker-q { margin: 0 0 14px; font-family: var(--font-heading); font-weight: 700; font-size: 1.08rem; }
.picker-hint { display: block; margin-top: 4px; font-family: var(--font-body); font-weight: 400; font-size: .86rem; color: var(--muted); }
.text-ask input, .text-ask textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--rule-strong);
  background: var(--surface); font-size: 16px; line-height: 1.5; resize: vertical;
}
.text-ask textarea { min-height: 96px; }
.text-count { display: block; text-align: right; font-size: .76rem; color: var(--muted); margin-top: 6px; }
.chip-group + .chip-group { margin-top: 22px; }
.chip-group-title { margin: 0 0 10px; font-family: var(--font-body); font-size: .74rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.picker-actions {
  display: flex; flex-wrap: wrap; gap: 12px; position: sticky; bottom: 0;
  margin: 18px 0 0; padding: 14px 0 16px; background: var(--ground);
  border-top: 1px solid var(--rule);
}
.inline-link { color: var(--accent); font-weight: 500; text-underline-offset: 3px; }
.error-note { color: var(--accent); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 500; cursor: pointer; text-decoration: none; font-size: .95rem; line-height: 1.2;
}
.btn .icon { width: 18px; height: 18px; }
.btn.primary { background: var(--accent-fill); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--rule-strong); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn.danger:hover { background: var(--accent-wash); }
.btn.small { min-height: 44px; padding: 8px 18px; font-size: .92rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.linkish {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0;
  color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 4px;
  text-decoration-thickness: 1px; cursor: pointer; min-height: 44px;
}
.linkish:disabled { opacity: .5; cursor: not-allowed; }

/* recommend: a quiet text button on the user's last turn, and the suggestion inline */
.rec-btn-wrap { margin-top: 6px; display: flex; justify-content: flex-end; }
.rec-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 4px;
  border: 0; background: transparent; color: var(--accent);
  font-weight: 500; font-size: .86rem; cursor: pointer;
}
.rec-btn .icon { width: 16px; height: 16px; }
.rec-btn:hover { text-decoration: underline; text-underline-offset: 4px; }
.rec-btn:disabled { opacity: .5; cursor: wait; }
.rec-card { align-self: flex-start; max-width: min(92%, 600px); padding: 0 0 0 20px; border-left: 2px solid var(--rose); margin-left: 10px; }
.rec-label { margin: 0 0 6px; font-size: .74rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.rec-card p { margin: 0 0 8px; }
.rec-try { font-family: var(--font-heading); font-size: 1.14rem; line-height: 1.5; color: var(--text); }
.rec-try q { quotes: "\201C" "\201D"; }
.rec-why { color: var(--muted); }
.rec-skill { font-size: .84rem; color: var(--muted); }
.rec-use { margin-top: 0; }

/* distress check-in: a question and a row of numbers, no box */
.suds { align-self: stretch; max-width: 600px; }
.suds-label { margin: 0 0 14px; display: flex; flex-direction: column; gap: 2px; }
.suds-label strong { font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; }
.suds-label span { font-size: .88rem; color: var(--muted); }
.suds-scale { display: grid; grid-template-columns: repeat(5, minmax(44px, 1fr)); gap: 4px 6px; max-width: 360px; }
@media (min-width: 560px) { .suds-scale { grid-template-columns: repeat(10, minmax(44px, 1fr)); max-width: 560px; } }
/* plain numerals, a thin underline on hover and focus */
.suds-btn {
  position: relative; min-height: 44px; border: 0; background: transparent; border-radius: 8px;
  cursor: pointer; font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--text);
}
.suds-btn::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 7px; height: 1.5px; border-radius: 2px; background: transparent; }
.suds-btn:hover { color: var(--accent); }
.suds-btn:hover::after, .suds-btn:focus-visible::after { background: var(--accent-fill); }

/* safety: plain words with a crimson thread, no box */
.safety-card { align-self: stretch; max-width: 600px; padding: 2px 0 2px 18px; border-left: 2px solid var(--accent); }
.safety-card p { margin: 0 0 12px; }
.safety-urgent a, .safety-banner a { font-weight: 700; }
.safety-banner { margin: 8px var(--gutter) 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--accent); }
.safety-banner p { margin: 0 0 6px; }
.safety-banner p:last-child { margin: 0; }

/* typing */
.typing { display: flex; align-items: center; gap: 10px; margin-top: var(--turn-gap); color: var(--muted); font-size: .86rem; }
.typing[hidden] { display: none; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--rose); animation: breathe 1.6s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes breathe { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

/* composer */
.composer { background: var(--ground); padding: 14px var(--gutter) calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); }
.composer-row { max-width: 720px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; min-height: 50px; max-height: 168px;
  padding: 13px 18px; border-radius: 25px; border: 1px solid var(--rule-strong); background: var(--surface);
  font-size: 16px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1.5px var(--focus); }
.send-btn {
  width: 50px; height: 50px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent-fill); color: var(--on-accent); display: grid; place-items: center;
}
.send-btn:disabled { opacity: .5; cursor: wait; }
.send-btn:focus-visible { border-radius: 50%; }
.composer-note { max-width: 720px; margin: 10px auto 0; font-size: .72rem; line-height: 1.5; color: var(--muted); text-align: center; }
.composer-note .note-short, .composer-note .note-about { display: none; }
.composer-note .note-about { min-height: 32px; font-size: inherit; color: var(--muted); }

/* the "New message" pill, above the composer */
.chat-view { position: relative; }
.pill-wrap { position: relative; height: 0; }
.new-pill {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 5;
  min-height: 36px; padding: 6px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--text); color: var(--ground); font-size: .84rem; box-shadow: var(--shadow);
}
.new-pill[hidden] { display: none; }

/* live preview: the Coperson's words as they stream in */
.typing.streaming { display: block; color: inherit; }
.typing.streaming .msg { opacity: .9; }

/* while a line is being revealed, its answer options wait */
.msg.revealing .chips-reply, .msg.revealing .bubble-actions { visibility: hidden; }
.fade-in { animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- pages ---------- */
.page-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; }
.page { max-width: 680px; margin: 0 auto; padding: 24px var(--gutter) 64px; }
.lede { font-size: 1.05rem; color: var(--muted); margin: 0 0 28px; line-height: 1.65; }
.muted { color: var(--muted); }
.small-print { font-size: .86rem; }
.field { margin-bottom: 22px; }
.field label, .theme-group legend { display: block; font-weight: 500; margin-bottom: 4px; }
.hint { margin: 0 0 8px; font-size: .86rem; color: var(--muted); line-height: 1.5; }
.field textarea, .field select, .del-demo select {
  width: 100%; border: 1px solid var(--rule-strong); border-radius: 14px; background: var(--surface);
  padding: 11px 14px; font-size: 16px; min-height: 44px; resize: vertical; line-height: 1.5;
}
.form-actions { margin-top: 10px; }
.card-section { margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--rule); }
.card-section h2 { font-size: 1.2rem; margin: 0 0 14px; }
.card-section > p { margin: 0 0 14px; }
.plain-list { list-style: none; padding: 0; margin: 0 0 16px; }
.plain-list li { margin-bottom: 8px; }
.theme-group { border: 0; padding: 0; margin: 0; }
.radio-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.radio-pill { position: relative; }
.radio-pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio-pill span { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--rule-strong); }
.radio-pill input:checked + span { border-color: var(--accent); background: var(--accent-wash); color: var(--text); font-weight: 500; }
.radio-pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.demo-note { font-size: .86rem; color: var(--muted); margin: 14px 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* invisible tables: muted labels left, values right, no borders */
.kv { margin: 0 0 8px; display: grid; gap: 18px; }
.kv-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 4px 24px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: .86rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-note { display: block; color: var(--muted); font-size: .84rem; line-height: 1.5; margin-top: 4px; }
.kv-link { margin-left: 14px; }
.kv-action { display: block; margin-top: 10px; }
.kv .profile-form.stack { margin-top: 14px; }
.kv .form-ok { margin-top: 12px; }
@media (max-width: 559.98px) { .kv-row { grid-template-columns: minmax(0, 1fr); } }

/* the profile form reads as a table on wider screens */
@media (min-width: 760px) {
  .profile-form:not(.stack) .field { display: grid; grid-template-columns: 170px minmax(0, 1fr); column-gap: 24px; }
  .profile-form:not(.stack) .field > label { grid-column: 1; grid-row: 1 / span 2; padding-top: 11px; font-weight: 400; color: var(--muted); font-size: .9rem; }
  .profile-form:not(.stack) .field > * { grid-column: 2; }
  .profile-form:not(.stack) .field > .hint { grid-row: 2; margin: 6px 0 0; }
  .profile-form:not(.stack) .field > textarea, .profile-form:not(.stack) .field > select, .profile-form:not(.stack) .field > input { grid-row: 1; }
  .profile-form:not(.stack) .field > .field-error { grid-row: 3; }
}

.upgrade { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 16px; }
.upgrade-mark svg, .empty-mark svg, .upgrade-mark img, .empty-mark img { width: 64px; height: 64px; display: block; }
.upgrade h2 { font-size: 1.5rem; margin: 10px 0 6px; }
.upgrade p { margin: 4px 0 10px; max-width: 460px; line-height: 1.65; }
.upgrade-why { font-weight: 500; color: var(--accent); }
.perks { list-style: none; padding: 0; margin: 14px 0 26px; text-align: left; display: flex; flex-direction: column; gap: 12px; }
.perks li { display: flex; gap: 12px; align-items: flex-start; }
.perks .icon { color: var(--accent); width: 18px; height: 18px; margin-top: 4px; }
.upgrade .btn.primary { min-width: 200px; margin-bottom: 8px; }
.empty-home { text-align: center; padding: 64px 0; display: flex; flex-direction: column; align-items: center; gap: 14px; }

.res-frame { flex: 1; width: 100%; border: 0; min-height: 0; background: var(--ground); }

/* toast, status line, dialog */
.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  background: var(--text); color: var(--ground); padding: 10px 16px; border-radius: 12px;
  max-width: min(92vw, 420px); font-size: .9rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.status-line { position: fixed; z-index: 70; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: min(92vw, 460px); margin: 0; padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--ground); font-size: .9rem; text-align: center; }
.status-line[hidden] { display: none; }
.dialog { border: 0; border-radius: 20px; padding: 0; max-width: min(92vw, 420px); background: var(--ground); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.22); }
.dialog::backdrop { background: rgba(30, 28, 27, .4); }
.dialog-body { padding: 24px; }
.dialog-body h2 { margin: 0 0 10px; font-size: 1.2rem; }
.dialog-body p { margin: 0 0 20px; color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.res-dialog { width: min(94vw, 760px); max-width: min(94vw, 760px); height: min(86dvh, 760px); }
.res-dialog[open] { display: flex; flex-direction: column; }
.res-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 12px 24px; border-bottom: 1px solid var(--rule); }
.res-dialog-head h2 { margin: 0; font-size: 1.15rem; }
.res-dialog-frame { flex: 1; width: 100%; border: 0; min-height: 0; background: var(--ground); }

/* sign-in */
.app.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.app.no-sidebar .sidebar { display: none; }
.auth-top { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 6px var(--gutter); padding-top: calc(6px + env(safe-area-inset-top)); }
.auth-top .menu-btn { margin-left: -10px; }
.auth-top .res-link { margin-left: auto; }
.auth { max-width: 440px; margin: 0 auto; padding: 24px var(--gutter) 64px; }
/* The sign-in and sign-up splash, matching the site's hero: centered mark, spaced wordmark, tagline. */
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.auth-mark { width: 96px; height: 96px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(60, 40, 30, .08); }
.auth-wordmark { margin: 12px 0 0; font-family: var(--font-body); font-size: .82rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }
.auth-tag { margin: 18px 0 0; text-align: center; font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; }
.auth-sub { margin: 4px 0 32px; text-align: center; font-style: italic; color: var(--text); }
.auth h1 { font-size: 1.75rem; margin: 0 0 16px; outline: none; }
.auth-form .field input, .profile-form input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px;
  border: 1px solid var(--rule-strong); background: var(--surface); font-size: 16px;
}
.auth-form input[aria-invalid="true"], .profile-form input[aria-invalid="true"], .del-form input[aria-invalid="true"] { border-color: var(--accent); }
.field-error { margin: 6px 0 0; color: var(--accent); font-size: .9rem; font-weight: 500; }
.field-error[hidden], .form-error[hidden] { display: none; }
.form-error { margin: 0 0 18px; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent); color: var(--accent); font-weight: 500; }
.btn.wide { width: 100%; margin-top: 8px; }
.auth-switch { margin: 18px 0 0; text-align: center; }
.auth-foot { margin: 36px 0 0; text-align: center; font-size: .88rem; }
.check-email { margin: 0 0 22px; padding: 2px 0 2px 18px; border-left: 2px solid var(--rose); }
.check-email p { margin: 0 0 8px; }
.check-email p:last-child { margin: 0; }
.check-lede { font-weight: 500; font-size: 1.05rem; }
.form-ok { margin: 12px 0 18px; padding: 2px 0 2px 14px; border-left: 2px solid var(--rose); }
.form-ok[hidden] { display: none; }
.profile-form[hidden] { display: none; }
.profile-form input[readonly] { background: transparent; color: var(--muted); }
.stale-note { margin-top: var(--turn-gap); padding: 2px 0 2px 18px; border-left: 2px solid var(--accent); }
.stale-note p { margin: 0 0 12px; font-weight: 500; }
.composer textarea:disabled { opacity: .6; }
.bubble-actions { display: flex; margin-top: 12px; white-space: normal; }
.readonly-note p { font-weight: 400; color: var(--muted); }

/* ---------- the crisis panel: calm and plain, on the ground, with the crimson thread ---------- */
.crisis { max-width: 620px; margin-top: var(--turn-gap); padding: 4px 0 4px 20px; border-left: 2px solid var(--accent); }
.setup-view .crisis, .log-wrap > .crisis:first-child { margin-top: 0; }
.crisis-title { margin: 0 0 10px; font-size: 1.32rem; outline: none; }
/* The heading only takes focus from the app (tabindex -1, never in the tab order), so screen
   readers start here; a ring around it would read as an error, so none is drawn. */
.crisis-title:focus, .crisis-title:focus-visible { outline: none; }
.crisis-message { margin: 0 0 16px; font-size: 1.04rem; line-height: 1.65; color: var(--text); }
.crisis-emergency { margin: 0 0 22px; font-size: 1.04rem; font-weight: 600; line-height: 1.55; }
.crisis-emergency a { color: var(--accent); font-weight: 700; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.crisis-lines { list-style: none; margin: 0; padding: 0; }
.crisis-line { padding: 18px 0; border-top: 1px solid var(--rule); }
.crisis-line:last-child { border-bottom: 1px solid var(--rule); }
.crisis-name { margin: 0 0 4px; font-size: 1.08rem; }
.crisis-for { margin: 0 0 12px; color: var(--muted); font-size: .94rem; line-height: 1.55; }
.crisis-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.crisis-btn {
  background: var(--surface); border-color: var(--rule-strong); color: var(--text);
  font-weight: 600; white-space: normal; text-align: center; max-width: 100%;
}
.crisis-btn:hover { border-color: var(--accent); }
.crisis-btn-label { overflow-wrap: anywhere; }
.crisis-web { margin: 10px 0 0; font-size: .92rem; }
.crisis-web a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
.crisis-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 20px; font-size: .92rem; }
.crisis-res { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.crisis-res .icon { width: 16px; height: 16px; }
@media (max-width: 699.98px) {
  .crisis { padding-left: 14px; }
  .crisis-actions .crisis-btn { flex: 1 1 auto; }
}

/* ---------- deleting the account: steps in the conversation, not a box ---------- */
.del-wrap { align-self: stretch; display: flex; }
.del-card { flex: 1; max-width: 600px; outline: none; padding: 0 0 0 20px; border-left: 2px solid var(--rule-strong); margin-left: 10px; }
.del-card:focus, .del-card:focus-visible { outline: none; }
.del-card .rec-label { display: flex; align-items: center; gap: 8px; }
.del-card .rec-label .icon { width: 16px; height: 16px; color: var(--accent); }
.del-step { margin-left: auto; letter-spacing: .08em; }
.del-h { font-size: 1.12rem; margin: 10px 0 10px; }
.del-list { margin: 0 0 18px; padding-left: 20px; line-height: 1.6; }
.del-list li { margin-bottom: 6px; }
.del-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.del-check { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 4px; cursor: pointer; }
.del-check input { width: 20px; height: 20px; margin: 3px 0 0; flex: none; accent-color: var(--accent-fill); }
.del-demo { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.del-demo select { width: auto; min-width: 200px; }
.del-form .field input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px;
  border: 1px solid var(--rule-strong); background: var(--surface); font-size: 16px;
}
.del-form .hint { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.del-recover { margin: 0 0 8px; font-size: .92rem; }
.del-recover[hidden] { display: none; }
.goodbye { max-width: 520px; margin: 0 auto; padding: 88px var(--gutter) 48px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.goodbye h1 { font-size: 1.6rem; margin: 8px 0 0; outline: none; }
.goodbye p { color: var(--muted); margin: 0 0 10px; line-height: 1.65; }

/* ---------- responsive ---------- */
@media (max-width: 699.98px) {
  :root { --turn-gap: 32px; }
  .app, .app.sb-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: none;
    visibility: hidden;
  }
  .drawer-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.2); visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(30, 28, 27, .35); }
  .scrim[hidden] { display: none; }
  .menu-btn, .drawer-close { display: inline-grid; }
  .collapse-btn { display: none; }
  .seg-opt { font-size: .84rem; padding: 2px 4px; min-height: 40px; }
  .seg { padding: 2px; }
  .seg-thumb { top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / 3); }
  .res-link .res-text { display: none; }
  .res-link { padding: 0; width: 44px; justify-content: center; }
  .composer-note .note-full { display: none; }
  .composer-note .note-short, .composer-note .note-about { display: inline; }
  .composer-note.expanded .note-full { display: block; margin-top: 4px; }
  .composer-note.expanded .note-short { display: none; }
  .composer { padding-top: 10px; }
  .composer-note { margin-top: 4px; }
  .chips-reply { flex-direction: column; align-items: stretch; }
  .chips-reply .chip { width: 100%; }
  .msg { max-width: 90%; }
  .log-wrap { padding-top: 24px; padding-bottom: 44px; }
  .bubble { padding: 13px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: fadein .25s ease !important; }
}

/* profile screen: two sections */
.profile-section h2, .card-section h2 { font-size: 1.2rem; margin: 0 0 14px; }
.section-foot { margin-top: 18px; }
.section-foot p { margin: 0 0 12px; }
.field-label { font-weight: 500; margin: 0 0 4px; }
.behavior-list { list-style: none; margin: 0; padding: 0; }
.behavior-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 2px 0; }
.quiet-remove { color: var(--muted); font-size: .84rem; min-height: 40px; flex: none; }
.quiet-remove:hover { color: var(--accent); }
@media (min-width: 760px) {
  .profile-form:not(.stack) .behaviors-field { display: grid; grid-template-columns: 170px minmax(0, 1fr); column-gap: 24px; }
  .profile-form:not(.stack) .behaviors-field > .field-label { grid-column: 1; grid-row: 1 / span 2; color: var(--muted); font-weight: 400; font-size: .9rem; }
  .profile-form:not(.stack) .behaviors-field > * { grid-column: 2; }
  .profile-form .kv { margin: 0 0 22px; }
}

/* memories */
.memory-lines { margin-top: calc(14px - var(--turn-gap)); display: flex; flex-direction: column; gap: 2px; }
.memory-line { margin: 0; color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.memory-undo { min-height: 32px; font-size: inherit; color: var(--muted); }
.memory-undo:hover { color: var(--accent); }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; margin: 6px 0 8px; font-weight: 500; }
.switch-row input { appearance: none; -webkit-appearance: none; position: relative; width: 40px; height: 24px; margin: 0; border-radius: 999px; background: var(--rule-strong); cursor: pointer; flex: none; transition: background .2s; }
.switch-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); transition: transform .2s; }
.switch-row input:checked { background: var(--accent-fill); }
.switch-row input:checked::after { transform: translateX(16px); }
.switch-row input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-row input:disabled { opacity: .5; cursor: not-allowed; }
.memory-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.memory-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.memory-item input { flex: 1 1 240px; min-width: 0; min-height: 44px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--rule); background: transparent; font-size: 16px; }
.memory-item input:focus { border-color: var(--rule-strong); background: var(--surface); }
.memory-actions { display: inline-flex; gap: 14px; }
