/* Humanual. Look and layout follow the Plainspoken prototype: tabs across the
   top, form on the left and the result card on the right, Lexend headings,
   Atkinson Hyperlegible body text, and mono labels. */
:root {
  --bg: #e9eeec;              /* ground */
  --surface: #fbfcfb;
  --surface-2: #dfe6e3;       /* sunk */
  --text: #18221f;
  --muted: #56655f;
  --line: #c9d3cf;
  --accent: #34539e;
  --accent-ink: #ffffff;
  --accent-soft: #dce3f4;
  --focus: #34539e;
  --danger: #a23a2e;
  --crisis-bg: #f5dad5;
  --crisis-line: #e2b2a6;
  --low: #2e7351; --low-bg: #d8ede1;
  --med: #8a5a00; --med-bg: #f6e7c4;
  --high: #a23a2e; --high-bg: #f5dad5;

  --junie: #5f7a5c;
  --junie-2: #d9a650;
  --otis: #4f6578;
  --otis-2: #d1a63a;
  /* Topic tiles on the start screen, one soft hue each. */
  --sage: #2e7351; --sage-bg: #d8ede1;
  --gold: #8a5a00; --gold-bg: #f6e7c4;
  --plum: #6b4a80; --plum-bg: #ebe1f1;
  --teal: #2b6b70; --teal-bg: #d6ecec;

  --user-bubble: #dce3f4;
  --radius: 10px;
  --font: "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
  --f-display: "Lexend", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121816;
    --surface: #1b2320;
    --surface-2: #232d29;
    --text: #e3eae7;
    --muted: #9aa9a3;
    --line: #33403b;
    --accent: #9fb4ec;
    --accent-ink: #101626;
    --accent-soft: #27304a;
    --focus: #9fb4ec;
    --danger: #f0a193;
    --crisis-bg: #3a2420;
    --crisis-line: #6e3b31;
    --low: #8fd3ae; --low-bg: #1e3a2b;
    --med: #edc46e; --med-bg: #3d3016;
    --high: #f0a193; --high-bg: #442420;
    --junie: #7f9c79;
    --otis: #6f879b;
    --sage: #8fd3ae; --sage-bg: #1e3a2b;
    --gold: #edc46e; --gold-bg: #3d3016;
    --plum: #cdb3e0; --plum-bg: #352a40;
    --teal: #8fd0d4; --teal-bg: #1b3a3c;
    --user-bubble: #27304a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.2; text-wrap: balance; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.fineprint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.center { text-align: center; }
.label {
  font-family: var(--f-mono); font-size: 11.5px; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.brand { font-family: var(--f-display); font-weight: 600; letter-spacing: -.01em; color: var(--text); margin: 0; font-size: 22px; }
.brand span { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 9px 16px; cursor: pointer; font-family: var(--f-display); font-weight: 500; font-size: 15px;
  text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; justify-content: flex-start; }
.btn.big { padding: 13px 22px; font-size: 17px; width: 100%; }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.linkback { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 15px; }
.linkback:hover { text-decoration: underline; text-underline-offset: 3px; }
.fineprint-link { font-size: inherit; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* Form bits */
.field { display: grid; gap: 5px; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-weight: 700; font-size: 15px; padding: 0; margin-bottom: 2px; }
.field small { color: var(--muted); font-size: 14px; margin-top: -2px; }
input:not([type=radio]):not([type=checkbox]), textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 9px 11px; resize: vertical;
}
.check { display: flex; gap: 10px; align-items: center; margin: 0 0 18px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span {
  display: block; height: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: var(--surface); font-size: 15px; color: var(--muted);
}
.segmented strong { display: block; color: var(--text); font-size: 16px; font-family: var(--f-display); font-weight: 500; }
.segmented.three { grid-template-columns: 1fr 1fr 1fr; }
.segmented input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Small segmented controls look like Plainspoken's joined toggle buttons. */
.segmented.small { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented.small label + label span { border-left: 1px solid var(--line); }
.segmented.small span { border: 0; border-radius: 0; padding: 5px 12px; background: transparent; }
.segmented.small strong { font-size: 14px; color: inherit; }
.segmented.small input:checked + span { background: var(--accent); color: var(--accent-ink); }

/* Avatars: placeholder until the illustrated portraits exist */
.avatar {
  --c1: var(--junie); --c2: var(--junie-2);
  width: 40px; height: 40px; border-radius: 50%; flex: none; position: relative;
  background: var(--c1); color: #fff; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 600; font-size: 17px; box-shadow: inset 0 -5px 0 var(--c2);
}
.avatar[data-coach=otis] { --c1: var(--otis); --c2: var(--otis-2); }
.avatar.xl { width: 64px; height: 64px; font-size: 26px; box-shadow: inset 0 -8px 0 var(--c2); }
.avatar.sm { width: 30px; height: 30px; font-size: 14px; box-shadow: inset 0 -4px 0 var(--c2); }

/* Coach picker */
.coach-pick { display: grid; gap: 10px; }
.coach-card { position: relative; cursor: pointer; display: block; }
.coach-card input { position: absolute; opacity: 0; inset: 0; }
.coach-body {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
}
.coach-card input:checked + .coach-body { border-color: var(--accent); background: var(--accent-soft); }
.coach-card input:focus-visible + .coach-body { outline: 3px solid var(--focus); outline-offset: 2px; }
.coach-text { display: grid; gap: 2px; }
.coach-name { font-family: var(--f-display); font-weight: 600; }
.coach-line { font-size: 15px; }
.coach-best { font-size: 14px; color: var(--muted); }
.coach-pick.compact .coach-best { display: none; }

/* Sign-in and welcome */
.onboarding {
  min-height: 100%; display: grid; place-items: start center;
  padding: calc(32px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.onboard-card { width: min(560px, 100%); }
.onboard-card h1 { font-size: clamp(26px, 5vw, 32px); margin: 10px 0 12px; }
.lede { font-size: 18px; color: var(--muted); margin: 0 0 20px; }
.notice {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 12px 14px; border-radius: 8px; margin-bottom: 24px; font-size: 15px;
}

/* ---------- App frame: header, tabs, then one tool at a time ---------- */
/* The safe-area padding keeps the installed app clear of a phone's notch,
   rounded corners, and home bar (index.html sets viewport-fit=cover). */
.app {
  display: flex; flex-direction: column; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* Shown only while the device is offline (app.js). */
.offline-bar { flex: none; margin: 0; padding: 6px 16px; text-align: center; font-size: 14px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.top, .panel, .chat-panel { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: 16px; }
/* One quiet row: brand, the three tools, then settings. */
.top {
  flex: none; display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 8px 28px; padding-block: 12px;
}
.top .brand { font-size: 22px; }
.brand-home { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.brand-home:hover span { text-decoration: underline; text-underline-offset: 3px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.top-right .btn { white-space: nowrap; }
.crisis-btn { color: var(--danger); }
.crisis-btn svg { width: 16px; height: 16px; }
/* A short, dismissable line under the header: "Added 10 replies." */
.flash {
  margin: 0; padding: 8px 16px; text-align: center; font-size: 15px;
  background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--line);
}
.top-right .sync-status { font-size: 13px; color: var(--muted); }
.app > .top { border-bottom: 1px solid var(--line); max-width: none; padding-inline: max(16px, calc((100% - 1048px) / 2)); }

.tabs { display: flex; gap: 4px; overflow-x: auto; }
.view-btn {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-family: var(--f-display); font-size: 15px; color: var(--muted); white-space: nowrap;
}
.view-btn:hover { color: var(--text); background: var(--surface-2); }
.view-btn[aria-current=page] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

.main { flex: 1; min-height: 0; min-width: 0; }
#scripts-view, #translate-view, #journal-view { overflow-y: auto; }

/* Scripts and Journal: form on the left, result card on the right */
.panel {
  display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px; align-items: start;
  padding-block: 22px 40px;
}
.intro { display: grid; gap: 14px; align-content: start; }
.intro h2 { margin: 0; font-size: 22px; }
.intro > p { margin: 0; }
.tool-form .field:last-of-type { margin-bottom: 12px; }
.tool-form .chips { margin: -4px 0 14px; }
.tool-form [data-replies-note] { margin-top: 10px; }
.more { margin-bottom: 14px; }
.more summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.more .field { margin: 8px 0 0; }
.tool-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status { margin: 0; font-size: 14px; color: var(--muted); }
.status.err { color: var(--danger); }

/* ---------- Coach chat: conversation list beside the chat card ---------- */
.chat-panel {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; padding-block: 16px; height: 100%;
}
.sidebar { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; min-height: 24px; }
.convo-list { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; min-height: 0; }
.convo-item { display: flex; align-items: center; gap: 8px; border-radius: 8px; padding: 0 4px 0 10px; }
.convo-item:hover, .convo-item[aria-current=true] { background: var(--surface); }
.convo-item[aria-current=true] { box-shadow: inset 3px 0 0 var(--accent); }
.convo-item button.open {
  flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 8px 0; cursor: pointer; display: grid;
}
.convo-item .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.convo-item .meta { font-size: 12px; color: var(--muted); }
.convo-item .del { opacity: 0; width: 32px; height: 32px; }
.convo-item:hover .del, .convo-item .del:focus-visible, .convo-item[aria-current=true] .del { opacity: 1; }
.convo-item .del svg { width: 16px; height: 16px; }
/* No conversations yet: no list to show, so the chat takes the full width. */
.chat-panel.no-history { grid-template-columns: minmax(0, 1fr); }
.chat-panel.no-history .sidebar, .chat-panel.no-history #open-sidebar { display: none; }

.chat-card {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; }
.topbar-coach { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 600; min-width: 0; white-space: nowrap; }
.topbar-coach > span { overflow: hidden; text-overflow: ellipsis; }
.topbar-coach .sub { font-family: var(--font); font-weight: 400; color: var(--muted); font-size: 14px; }
/* The coach's name never shrinks to "O…": the topic menu gives way first. */
.topbar-coach .coach-name { flex: none; }
.topic-select { min-width: 0; }
.topbar-coach .coach-switch { flex: none; display: inline-flex; align-items: center; gap: 6px; font-family: var(--font); font-weight: 400; }
.topbar-coach .coach-switch > span { overflow: visible; }
.coach-switch .icon-wrap svg { width: 16px; height: 16px; display: block; }
/* Where the conversation changed coach. */
.handoff {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); text-align: center;
}
.handoff::before, .handoff::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
/* Topic dropdown and New chat, so the topics are one tap away mid-conversation. */
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topic-select {
  width: auto; max-width: 180px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px;
  padding: 6px 28px 6px 10px; font-size: 14px; color: var(--text); cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356655f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
}
.only-mobile { display: none; }

.crisis-banner {
  padding: 12px 14px; border-radius: 8px; font-size: 15px;
  background: var(--crisis-bg); border: 1px solid var(--crisis-line);
}
.chat-card .crisis-banner { margin: 12px 16px 0; }
.crisis-banner strong { display: block; margin-bottom: 2px; }
.crisis-banner a { color: inherit; font-weight: 700; }

/* position: relative holds the screen-reader announcer (.sr-only, absolute)
   inside the scroller. Without it the announcer sat below the start screen's
   content, outside any clipping, and made the whole page taller than a phone. */
.scroller { flex: 1; overflow-y: auto; min-height: 0; position: relative; }

/* Start screen */
.start { max-width: 680px; margin: 0 auto; padding: 32px 20px 24px; }
.start-head { text-align: center; display: grid; justify-items: center; gap: 4px; margin-bottom: 20px; }
.start-head h2 { margin: 0; font-size: 22px; }
.start-head p { margin: 0; }
/* Compact rows: icon beside the name, one short line under it. */
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode-card {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr);
  column-gap: 12px; align-items: center;
}
.mode-card:hover { border-color: var(--accent); }
.mode-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-card[aria-pressed="true"] .icon { background: var(--accent); color: var(--accent-ink); }
.mode-card .icon { grid-row: span 2; width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.mode-card .icon svg { width: 18px; height: 18px; }
.mode-card strong { font-family: var(--f-display); font-weight: 500; font-size: 15px; }
.mode-card span:not(.icon) { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.start-settings { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center; margin-top: 20px; }

/* Messages */
.messages { list-style: none; margin: 0 auto; padding: 20px 20px 8px; max-width: 760px; display: grid; gap: 18px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); border-radius: 12px 12px 4px 12px;
  padding: 9px 13px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.coach .body { flex: 1; min-width: 0; }
.msg.coach .who { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 3px 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 17px; margin: 16px 0 6px; }
.md blockquote { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.msg-actions { margin-top: 6px; display: flex; gap: 4px; }
.msg-actions button {
  border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; display: inline-flex; gap: 6px; align-items: center;
}
.msg-actions button:hover { background: var(--surface-2); color: var(--text); }
.msg-actions svg { width: 15px; height: 15px; }
.msg .error { color: var(--danger); font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.msg .error + .fineprint { margin-top: 6px; }
.msg.unsent .md > p:first-child { margin: 0 0 8px; }
.crisis-ask { margin: 0 0 10px; font-size: 16px; }
.crisis-ask-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg .error button { margin-left: 8px; }
.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Composer */
.composer-wrap { padding: 8px 16px 12px; border-top: 1px solid var(--line); }
.composer-tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
/* "I'm already overstimulated": a chip that stays on until switched off. */
.toggle-chip { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13.5px; color: var(--muted); user-select: none; }
.toggle-chip input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.toggle-chip:has(input:checked) { color: var(--text); font-weight: 700; }
.tool-form .toggle-chip { margin: -4px 0 12px; }
/* With it on, the page itself gets quieter: fewer suggestions, less to read. */
body.calm .chips.quiet, body.calm #start-sub:not(.picked), body.calm .mode-card span:not(.icon) { display: none; }
.chips { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px;
  font-size: 13.5px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
/* Example ideas: there if you want them, not competing with the form. */
.chips.quiet .chip { border-color: transparent; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.chips.quiet .chip:hover { color: var(--text); border-color: var(--accent); }
.composer {
  display: flex; gap: 8px; align-items: flex-end; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 5px 5px 5px 13px;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea { border: 0; background: none; padding: 8px 0; resize: none; max-height: 40vh; outline: none; line-height: 1.45; }
.send-btn {
  width: 40px; height: 40px; border-radius: 9px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.send-btn:disabled { opacity: .4; cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }

/* Settings sheet */
.sheet {
  border: 0; padding: 0; border-radius: 14px; width: min(620px, calc(100% - 32px)); max-height: calc(100dvh - 32px);
  background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.sheet::backdrop { background: rgba(10, 16, 14, .45); }
.sheet form, .sheet-body { padding: 20px 22px 22px; }
.sheet.narrow { width: min(460px, calc(100% - 32px)); }
#install-guest-note { margin: 8px 0 0; }
.install-steps { margin: 6px 0 0; padding-left: 22px; font-size: 15px; }
.install-steps li + li { margin-top: 4px; }
.sheet-body p { margin: 0 0 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.sheet .muted { font-size: 15px; margin: 6px 0 18px; }
.sheet-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.sheet-actions.stack { flex-direction: column; margin: 16px 0 10px; }

/* Crisis help */
.crisis-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 16px; }
#crisis-sheet .crisis-actions { margin: 8px 0 6px; }
#crisis-sheet .crisis-actions .btn { font-size: 14.5px; }
#crisis-sheet .muted { margin: 0 0 14px; }
.help-head { font-size: 16px; margin: 16px 0 0; }
.quick-exit { width: 100%; margin: 4px 0 6px; border-color: var(--danger); color: var(--danger); }
.quick-exit-note { margin: 0 0 14px; }
.crisis-banner [data-open-help] { display: block; margin-top: 6px; font-weight: 700; color: inherit; text-decoration: underline; }

/* Getting more replies */
.packs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 16px; }
.pack {
  display: grid; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
}
.pack:hover, .pack.picked { border-color: var(--accent); background: var(--accent-soft); }
.pack strong { font-family: var(--f-display); font-weight: 600; font-size: 17px; }
.pack span { color: var(--muted); font-size: 14px; }
.custom-row { display: flex; gap: 8px; }
.custom-row input { flex: 1; }
.custom-pack .field { margin-bottom: 4px; }
.plan-offer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 15px; }
.plan-offer p { margin: 0 0 10px; }
.warning-lede { font-size: 16px; }
.replies-summary p { margin: 0; font-size: 15px; }
.replies-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* What the coach remembers */
.memory-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; max-height: 280px; overflow-y: auto; }
.memory-list li {
  display: flex; align-items: flex-start; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 6px 7px 12px; font-size: 15px;
}
.memory-list li span { flex: 1; min-width: 0; padding-top: 2px; }
.memory-list .icon-btn { width: 30px; height: 30px; }
.memory-list .icon-btn svg { width: 15px; height: 15px; }
.sheet .memory .muted { margin: 4px 0 0; }

/* Account (top of Settings) */
.account-actions { display: flex; gap: 6px; }
.sheet-account {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.sheet-account span { overflow-wrap: anywhere; }
.dev-signin { margin-top: 8px; }
/* One box: sign in or make an account, or try it as a guest. Clerk's own card
   chrome is switched off (appearance classes in app.js) so this box is the card. */
.signin-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 20px 20px; }
.signin-box .hm-clerk-cardbox, .signin-box .hm-clerk-card { box-shadow: none !important; border: 0 !important; background: transparent !important; }
.signin-box .hm-clerk-root { width: 100%; max-width: 400px; margin: 0 auto; }
.signin-box .hm-clerk-cardbox { width: 100% !important; max-width: none !important; }
.signin-box .hm-clerk-footer { background: transparent !important; }
.guest-option { max-width: 400px; margin: 0 auto; padding: 0 2.5rem; text-align: center; }
.guest-option .btn { width: 100%; }
.guest-option p { margin: 10px 0 0; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin: 4px 0 14px !important; }
.or-line::before, .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.guest-option .guest-clear { margin: 12px 0 0; }
.linkback.danger { color: var(--danger); font-size: 14px; }
.optional { font-weight: 400; color: var(--muted); }
#clerk-mount { display: flex; justify-content: center; margin-top: 8px; }

/* "Get me ready" setup */
.practice-setup { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.practice-setup h3 { margin: 6px 0 4px; font-size: 20px; }
.practice-setup > .muted { margin: 0 0 6px; font-size: 15px; }
.step { font-weight: 700; margin: 16px 0 8px; display: block; }
.channel-pick.three { grid-template-columns: repeat(3, 1fr); }
.situations { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.situation {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 9px 12px; cursor: pointer; font-size: 15px;
}
.situation:hover { border-color: var(--accent); background: var(--accent-soft); }
.situation[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.ready-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
.ready-actions .muted { margin: 0; }

.channel-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.channel-pick label { position: relative; cursor: pointer; }
.channel-pick input { position: absolute; opacity: 0; inset: 0; }
.channel-pick span {
  display: grid; justify-items: center; gap: 4px; padding: 9px 6px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-weight: 700; text-align: center; background: var(--bg);
}
.channel-pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.channel-pick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Result cards (scripts and journal replies) */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; display: grid; gap: 16px;
  /* A long word or link inside wraps instead of pushing the card past a phone screen. */
  min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.card > * { min-width: 0; }
@media (prefers-reduced-motion: no-preference) { .card { animation: fade .25s ease-out; } @keyframes fade { from { opacity: .4; } to { opacity: 1; } } }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 14px; }
.card-head h3 { margin: 0; font-size: 19px; }
.card-head .by { font-size: 13px; color: var(--muted); margin-top: 3px; }
.meters { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.low { background: var(--low-bg); color: var(--low); }
.pill.medium { background: var(--med-bg); color: var(--med); }
.pill.high { background: var(--high-bg); color: var(--high); }
.tag { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.norm { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; font-size: 15px; }
.norm strong { font-family: var(--f-display); font-weight: 500; }
.row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 4px 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.row .k { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
.row p { margin: 0; }
.say { margin: 0; font-size: 17px; }
.say::before { content: "\201C"; }
.say::after { content: "\201D"; }
.pair { display: grid; gap: 2px; }
.pair + .pair { margin-top: 10px; }
.pair .if { color: var(--muted); font-size: 14px; }
.ready { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 16px; margin: 0; font-family: inherit; }
.entry-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.pending-reply { display: flex; align-items: center; gap: 12px; }
.pending-reply p { margin: 0; }
ul.plain { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }

/* Saved scripts and past journal entries */
.saved { display: grid; gap: 8px; }
.saved h3 { margin: 0; }
.saved .muted { margin: 0; }
.saved-list { display: grid; gap: 6px; }
.saved-item { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px 0 12px; }
.saved-item[aria-current=true] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.saved-item button.open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 9px 0; cursor: pointer; display: grid; }
.saved-item .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 15px; }
.saved-item .meta { font-size: 13px; color: var(--muted); }

/* ---------- Narrow screens ---------- */
@media (max-width: 760px) {
  /* Brand and settings on one line, the three tools on the next. */
  .top { grid-template-columns: 1fr auto; padding-block: 10px 8px; }
  .top .tabs { grid-row: 2; grid-column: 1 / -1; }
  .top-right .sync-status, .hide-narrow { display: none; }
  .view-btn { flex: 1; }
  /* 16px: iPhones zoom the page in when a smaller text box or menu is tapped. */
  .topic-select { max-width: 130px; font-size: 16px; padding-block: 5px; }
  .topbar-actions { gap: 6px; flex: none; }
  .topbar-actions .btn.small { padding: 6px 8px; }
  .topbar-coach .sub { display: none; }
  .top .brand { font-size: 20px; }
  .top-right { gap: 6px; }
  .top-right .btn.small { padding-inline: 9px; font-size: 14px; }
  .composer-tools { justify-content: flex-start; }
  .pack { padding: 10px; }
  .pack strong { font-size: 15px; }
  .panel { grid-template-columns: 1fr; padding-block: 16px 32px; }
  .chat-panel { grid-template-columns: 1fr; padding: 10px 10px 8px; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 20; padding: 16px 12px;
    background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(10, 16, 14, .45); z-index: 10; }
  .topbar { padding: 8px 10px; min-height: 50px; }
  .start { padding: 20px 14px; }
  .messages { padding: 16px 14px 8px; }
  .msg.coach .avatar { display: none; }
  .msg.user .bubble { max-width: 92%; }
  .mode-grid { grid-template-columns: 1fr; }
  .composer-wrap { padding: 8px 10px 10px; }
  .row { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Public demo (/demo) */
.demobar {
  flex: none; background: var(--accent); color: var(--accent-ink); font-size: 14px; line-height: 1.4;
  padding: 7px 16px; text-align: center;
}
.demobar a { color: inherit; font-weight: 700; white-space: nowrap; }
body.demo { display: flex; flex-direction: column; height: 100dvh; }
body.demo .app { height: auto; flex: 1; min-height: 0; }
.demo-samples { margin-top: 24px; }
.demo-samples h3 { margin: 0 0 10px; font-size: 18px; }
.sample-list { display: grid; gap: 8px; }
.sample {
  display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line);
  background: var(--bg); border-radius: var(--radius); padding: 10px 14px; cursor: pointer;
}
.sample:hover { border-color: var(--accent); }
.sample-text { display: grid; gap: 2px; min-width: 0; }
.sample-text strong { font-family: var(--f-display); font-weight: 500; }
.sample-text .meta { font-size: 13px; color: var(--muted); }
.chip.next { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-color: var(--accent); }

/* Terms, privacy, and refunds (/legal) */
.legal .brand a { color: inherit; text-decoration: none; }
.legal h2 { font-size: 22px; margin: 32px 0 8px; }
.legal p, .legal li { font-size: 16px; }
.legal section { scroll-margin-top: 16px; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: 15px; }
.legal-link { color: inherit; }

/* ---------- A warmer first screen ---------- */
/* Two soft washes of the coaches' colours behind the sign-in and welcome
   pages: calm, low contrast, and gone by the time the form starts. */
.onboarding {
  background:
    radial-gradient(55% 38% at 12% -4%, color-mix(in srgb, var(--junie) 26%, transparent), transparent 72%),
    radial-gradient(48% 34% at 94% 2%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 72%),
    radial-gradient(40% 30% at 70% 30%, color-mix(in srgb, var(--junie-2) 10%, transparent), transparent 70%),
    var(--bg);
}
.onboard-card h1::before {
  content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; margin-bottom: 14px;
  background: linear-gradient(90deg, var(--junie-2), var(--junie) 55%, var(--accent));
}
/* Meet the coaches: their colours, their names, one line each. */
.coach-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 20px; }
.coach-chip {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 82%, transparent);
}
.coach-chip[data-coach=junie] { border-color: color-mix(in srgb, var(--junie) 45%, var(--line)); }
.coach-chip[data-coach=otis] { border-color: color-mix(in srgb, var(--otis) 55%, var(--line)); }
.coach-chip strong { display: block; font-family: var(--f-display); font-weight: 600; font-size: 15px; }
.coach-chip .line { font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.signin-box { border-top: 4px solid var(--accent); }
@media (max-width: 480px) {
  .coach-strip { grid-template-columns: 1fr; gap: 8px; }
  .coach-chip { padding: 10px 12px; }
}

/* Start screen: the coach says hello, and each topic has its own colour. */
.start-head .avatar.xl { margin-bottom: 6px; }
.mode-card[data-mode=everyday] .icon { background: var(--sage-bg); color: var(--sage); }
.mode-card[data-mode=workplace] .icon { background: var(--accent-soft); color: var(--accent); }
.mode-card[data-mode=networking] .icon { background: var(--gold-bg); color: var(--gold); }
.mode-card[data-mode=reply] .icon { background: var(--plum-bg); color: var(--plum); }
.mode-card[data-mode=practice] .icon { background: var(--teal-bg); color: var(--teal); }
.mode-card[data-mode=everyday]:hover { border-color: var(--sage); }
.mode-card[data-mode=networking]:hover { border-color: var(--gold); }
.mode-card[data-mode=reply]:hover { border-color: var(--plum); }
.mode-card[data-mode=practice]:hover { border-color: var(--teal); }
.mode-card[aria-pressed="true"] .icon { background: var(--accent); color: var(--accent-ink); }

/* "Start my day": the once-a-day morning card above the topics */
.morning {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start;
  margin: 0 0 22px; padding: 18px 18px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--gold-bg), var(--accent-soft));
  border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
}
.morning[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .morning { animation: morning-in .4s ease-out; } @keyframes morning-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } } }
.morning-sun { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--gold); box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold) 14%, transparent); }
.morning-sun svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.morning-sun circle, .morning-sun .moon path { fill: currentColor; fill-opacity: .25; }
.morning-body { display: grid; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.morning-body p { margin: 0; }
.morning-kicker { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.morning h3 { margin: 0; font-size: 20px; }
.morning-boost { font-size: 16.5px; line-height: 1.5; }
.morning-one { background: var(--surface); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.morning-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.morning-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
@media (max-width: 480px) { .morning { grid-template-columns: 1fr; } .morning-sun { width: 36px; height: 36px; } }

