/* The conversation shell (site/js/app/chat/shell.js): rail, header, thread,
   composer and sheets. Quiet and light: white ground, hairline borders, ink
   for the one primary action, the accent only for focus, dots and icons.
   Every color comes from brand.css through tokens.css. */

:root {
  --chat-col: 720px;
  --rail-w: 56px;
  --rail-open: 264px;
  --head-h: 52px;
}

/* Primary actions are ink, not accent (brand palette). */
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:disabled { opacity: .45; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.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; }

body:has(.chat-shell) { background: var(--bg); overflow: hidden; }

.chat-shell { display: flex; height: 100dvh; width: 100%; background: var(--bg); color: var(--text); font-family: var(--font-sans); overflow: hidden; }

/* ---- rail ---- */
.rail { flex: 0 0 var(--rail-w); width: var(--rail-w); display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--bg-subtle); transition: width var(--dur-3) var(--ease-out), flex-basis var(--dur-3) var(--ease-out); overflow: hidden; z-index: 30; }
.rail.open { flex-basis: var(--rail-open); width: var(--rail-open); }
.rail-top { display: flex; align-items: center; gap: 8px; height: var(--head-h); padding: 0 10px; flex: none; }
.rail-brand { display: inline-flex; align-items: center; }
.rail-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer; transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.rail-btn:hover { background: var(--border); color: var(--text); }
.rail-btn.wide { width: auto; padding: 0 10px; gap: 8px; display: inline-flex; font: inherit; font-size: 14px; }
.rail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 10px; animation: chat-fade var(--dur-3) var(--ease-out); }
.rail-new { display: flex; align-items: center; gap: 8px; width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.rail-new:hover { border-color: var(--border-strong); }
.rail-label { margin: 18px 10px 6px; font-size: 12px; color: var(--text-3); }
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.rail-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.rail-item:hover { background: var(--border); color: var(--text); }
.rail-item.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.rail-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.rail-dot.built { background: var(--mark); box-shadow: none; }
.rail-dot.published { background: var(--brand-2); box-shadow: none; }
.rail-foot { flex: none; padding: 10px; position: relative; }
.settings-wrap { position: relative; }
.settings-pop { position: absolute; left: 0; bottom: 44px; min-width: 220px; max-height: 70vh; overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); z-index: 60; animation: chat-pop var(--dur-2) var(--ease-out); }
.settings-item { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.settings-item:hover { background: var(--bg-subtle); }
.settings-item.danger { color: var(--bad); }
.settings-head { padding: 8px 10px 4px; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.rail-scrim { display: none; }

/* ---- main column ---- */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100dvh; position: relative; }
.thread-head { flex: none; height: var(--head-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid transparent; z-index: 5; }
.head-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--text-2); cursor: pointer; }
.head-btn:hover { background: var(--bg-subtle); color: var(--text); }
.menu-btn { display: none; }
.head-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.head-org { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sep { color: var(--text-3); }
.head-period { color: var(--text-2); white-space: nowrap; }
.head-pill { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.head-setup { margin-left: auto; min-width: 0; }
.save-dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 0; padding: 0; background: none; }
.save-dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); transition: background var(--dur-2) var(--ease-out); }
.save-dot.busy i { background: var(--text-3); animation: chat-breathe var(--dur-loop) var(--ease-in-out) infinite; }
.save-dot.warn i { background: var(--mark); }
.save-dot.bad i { background: var(--bad); }
button.save-dot { cursor: pointer; }

.thread-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; overscroll-behavior: contain; overflow-anchor: none; } /* no browser anchoring: a card settling into its receipt shrinks in place instead of the page snapping to compensate */
.thread { max-width: var(--chat-col); margin: 0 auto; padding: 24px 16px 32px; display: flex; flex-direction: column; gap: 14px; }
.thread-page { max-width: 960px; margin: 0 auto; padding: 16px; }
.page-lite .back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; color: var(--brand); }

/* ---- messages ---- */
.thread .msg { border: 0; border-radius: 0; overflow: visible; animation: chat-in var(--dur-3) var(--ease-out) both; max-width: 100%; }
/* A receipt (or a finished stage's one line, whose gold check pops instead)
   replaces its card in place: it never fades in from nothing (that read as a
   flash). A reply that arrives with the message it answers comes a
   beat after it, so the eye reads "you said, then it answered". */
.thread .msg:has(> .msg-receipt), .intake-thread .msg[data-type="intake_stage"][data-state="settled"] { animation: none; }
.thread .msg-user + .msg-system { animation-delay: 120ms; }
.thread .msg.msg-still { animation: none; } /* already there when the thread opened (shell.js) */
.intake-thread .msg[data-id="ix-typing"] { animation-delay: 300ms; }
.thread .msg-text { margin: 0; padding: 0; font-family: var(--font-sans); font-size: 15px; line-height: 1.55; white-space: pre-line; }
.thread .msg-system { align-self: stretch; }
.thread .msg-user { align-self: flex-end; max-width: 82%; }
.thread .bubble { font-size: 15px; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; white-space: pre-line; }
.thread .msg-user .bubble { padding: 9px 14px; border-radius: 18px 18px 6px 18px; background: var(--bg-subtle); border: 1px solid var(--border); }
.thread .msg-line { margin: 0; font-size: 15px; line-height: 1.55; }
.thread .msg-line.question { font-weight: 500; }
.thread .msg-receipt { margin: 0; font-size: 14px; color: var(--text-3); }
.thread .msg-receipt::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--brand-2); vertical-align: middle; }
.thread .msg-error { margin: 6px 0 0; color: var(--bad); font-size: 13px; }
.thread .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thread .chip { height: 34px; padding: 0 14px; font-size: 14px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out); }
.thread .chip:hover { background: var(--bg-subtle); border-color: var(--text-3); }
.thread .link, .sheet .link { border: 0; padding: 0; background: none; color: var(--brand); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.thread .link:hover { text-decoration-color: currentColor; }
.thread .muted { color: var(--text-3); }

.notice-card { display: flex; align-items: baseline; gap: 10px; color: var(--text-2); }
.notice-card .msg-line { font-size: 14px; }
/* The link sits in the sentence: its tap area grows by padding, not by a taller line. */
.thread .notice-card .link { display: inline; min-height: 0; padding-block: 12px; margin-block: -12px; }
.notice-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mark); flex: none; transform: translateY(-2px); }

/* files */
.card-files { display: flex; flex-direction: column; gap: 10px; }
.file-pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.file-pill { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); font-size: 13px; color: var(--text-2); }
.file-pill.bad { border-color: var(--bad-soft); color: var(--bad); }
.file-pill-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.file-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.file-dot.a { background: var(--brand-2); }
.file-dot.e { background: var(--mark); }
.file-dot.r { background: var(--text-3); }
.see-read { align-self: flex-start; }

/* progress */
.progress-inline { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.pi-bar { height: 4px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.pi-bar > span { display: block; height: 100%; background: var(--brand-2); border-radius: inherit; transform-origin: left center; transition: transform 1s linear; }
.pi-caption { font-size: 14px; color: var(--text-2); }
.pi-stop { align-self: flex-start; }

/* schedule card */
.sched-card { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); overflow: hidden; }
.sched-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sched-title { font-weight: 600; font-size: 15px; }
.sched-state { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--bg-subtle); color: var(--text-2); }
.sched-state.pub { background: var(--brand-soft); color: var(--brand); }
.sched-days { display: flex; flex-direction: column; }
.sched-card .sched-day { margin: 0; display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.sched-card .sched-day:last-child { border-bottom: 0; }
.sched-date { display: flex; flex-direction: column; font-size: 12px; color: var(--text-3); line-height: 1.2; }
.sched-date span { font-size: 18px; color: var(--text); font-weight: 600; }
.sched-items { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sched-item { min-width: 0; }
.si-top { display: flex; align-items: baseline; gap: 10px; font-size: 14px; min-width: 0; }
.si-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-time { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.si-count { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-2); }
.si-count.short { color: var(--bad); font-weight: 600; }
.si-people { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.si-chip { font-size: 12.5px; padding: 2px 8px; border-radius: 6px; background: var(--bg-subtle); color: var(--text); }
.si-chip.open { background: var(--bad-soft); color: var(--bad); }
.sched-more { font-size: 12.5px; color: var(--text-3); }
.sched-foot { display: flex; gap: 18px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); }
/* The change beats inside the schedule card (motion.js playChange): the
   person who is out turns coral and struck through, the replacement holds a
   teal highlight for ~2 s. Color only, no tags or weight change, so no chip
   changes size and nothing beside it shifts. The words are on the result
   card below. */
.si-chip { transition: background-color var(--dur-3) var(--ease-out), color var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out); }
.si-chip[data-out] { background: color-mix(in srgb, var(--coral) 12%, var(--surface)); color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; box-shadow: inset 0 0 0 1px var(--coral); }
.si-chip[data-moved] { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand-2); }

.quality-card, .explain-card { display: flex; flex-direction: column; gap: 8px; }
.q-lines { margin: 0; padding-left: 18px; font-size: 14px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }

/* publish */
.publish-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.publish-card.quiet { opacity: .8; }
.publish-card.done { border-color: color-mix(in srgb, var(--brand-2) 40%, var(--border)); background: var(--brand-soft); }
.publish-card.pending { justify-content: flex-start; }
.pc-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pc-line { font-size: 15px; }
.publish-card .btn-publish { min-width: 112px; height: 40px; border-radius: 12px; }
.publish-card .btn-undo { margin-left: auto; }
/* Open slots: the reason leads; publishing as it is is a quiet link under it. */
.publish-card.has-open { flex-direction: column; align-items: stretch; gap: 8px; }
.pc-why { margin: 0; font-size: 15px; line-height: 1.45; }
.publish-card.has-open .pc-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.publish-card.has-open .pc-row .btn-publish { min-width: 112px; height: 40px; border-radius: 12px; font-size: inherit; }
.pc-also { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.publish-card.has-open .btn-publish { min-width: 0; height: auto; border-radius: 0; font-size: 14px; }
/* The roster in words: a count and one pill per person. */
.people-card { display: grid; gap: 8px; }
.people-card .pc-head { margin: 0; font-size: 14px; color: var(--text-2); }
.people-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.person-pill { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 14px; max-width: 100%; }
.person-pill b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-pill span { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.person-pill.is-new { border-color: var(--teal, var(--brand)); }
.person-pill.more { color: var(--text-2); }
.publish-card .undo-ring { position: relative; width: 26px; height: 26px; display: inline-grid; place-items: center; flex: none; }
.publish-card .undo-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.publish-card .undo-ring circle { fill: none; stroke: var(--brand-2); stroke-width: 2; stroke-dasharray: 50.3; stroke-dashoffset: 0; animation: chat-ring var(--ms, 10000ms) linear forwards; }
.publish-card .undo-ring b { font-size: 11px; font-variant-numeric: tabular-nums; }

/* invite */
.invite-card { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.invite-card .input { flex: 1 1 220px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row .input { flex: 1; min-width: 0; }

/* ---- composer ---- */
.composer-dock { flex: none; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 0%, transparent), var(--bg) 28%); }
.composer { position: relative; max-width: var(--chat-col); margin: 0 auto; }
.composer-box { display: flex; align-items: flex-end; gap: 4px; padding: 6px; border: 1px solid var(--border-strong); border-radius: 22px; background: var(--surface); box-shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 8px 28px rgba(24, 24, 27, .06); transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.composer-box:focus-within { border-color: var(--text-3); }
.composer.over .composer-box { border-color: var(--brand-2); box-shadow: 0 0 0 4px var(--brand-soft); }
.composer textarea { flex: 1; min-width: 0; min-height: 36px; max-height: 200px; resize: none; border: 0; outline: none; background: transparent; padding: 8px 6px; font: inherit; font-size: 15px; line-height: 1.45; color: var(--text); }
.composer textarea:focus-visible { outline: none; box-shadow: none; }
.composer-box:has(textarea:focus-visible) { border-color: var(--text-3); box-shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 8px 28px rgba(24, 24, 27, .08); }
.composer textarea::placeholder { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* one line: an empty box never wraps taller than a typed one, so the first key press never makes it jump */
.composer-btn { width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), opacity var(--dur-1); }
.composer-btn:hover { background: var(--bg-subtle); color: var(--text); }
.composer-btn.send { background: var(--primary); color: #fff; }
.composer-btn.send:hover:not(:disabled) { background: var(--primary-hover); }
.composer-btn.send:disabled { background: var(--border); color: var(--text-3); cursor: default; }
.composer-voice { display: inline-flex; position: relative; }
.composer-voice .ix-voice { position: static; display: inline-flex; }
.composer-voice .ix-voice-btn { width: 36px; height: 36px; min-height: 0; padding: 0; gap: 0; display: inline-flex; align-items: center; justify-content: center; line-height: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); font-size: 0; box-shadow: none; }
.composer-voice .ix-voice-btn:hover { background: var(--bg-subtle); color: var(--text); }
.composer-voice .ix-voice-btn.ix-on { color: var(--bad); background: var(--bad-soft); }
.composer-voice .ix-voice-live, .composer-voice .ix-voice-err { position: absolute; right: 0; bottom: 44px; width: max-content; max-width: 260px; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; box-shadow: var(--shadow); }
.composer-note { max-width: var(--chat-col); margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--text-3); }
.drop-veil { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(2px); pointer-events: none; animation: chat-fade var(--dur-2) var(--ease-out); }
.drop-veil span { padding: 18px 26px; border: 2px dashed var(--brand-2); border-radius: 18px; background: var(--surface); font-size: 16px; color: var(--text); }

/* ---- sheets ---- */
.sheet-drawer { width: min(480px, 100vw); }
.sheet-drawer:has(.sheet[data-sheet="schedule"]), .sheet-drawer:has(.sheet[data-sheet="roster"]), .sheet-drawer:has(.sheet[data-sheet="period"]), .sheet-drawer:has(.sheet[data-sheet="mapping"]) { width: min(980px, 100vw); }
.sheet { min-width: 0; }
.sheet .page, .sheet .page.wide, .sheet .page.narrow { max-width: none; padding: 0; margin: 0; }
.sheet .page-head h1 { display: none; }
.sheet .page-head { margin-bottom: 12px; }
.sched-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.sched-sheet-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.data-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.preview-sheet { display: flex; flex-direction: column; gap: 18px; }
.preview-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.preview-rows { margin: 0 0 8px; padding-left: 18px; font-size: 14px; color: var(--text-2); }
.setup-sheet { display: flex; flex-direction: column; gap: 12px; }
.setup-sheet .composer { position: sticky; bottom: 0; }

/* ---- skeleton ---- */
.chat-skel { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; }
.composer-skel { max-width: var(--chat-col); margin: 0 auto; }
.composer-skel-fill { flex: 1; min-height: 36px; }
.composer-skel .composer-btn.send { background: var(--border); }

/* ---- motion ---- */
@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes chat-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes chat-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes chat-breathe { 50% { opacity: .45; } }
@keyframes chat-ring { to { stroke-dashoffset: 50.3; } }
@media (prefers-reduced-motion: reduce) {
  .thread .msg, .rail-body, .settings-pop, .drop-veil { animation: none; }
  .rail { transition: none; }
}

/* ---- phones ---- */
@media (max-width: 899px) {
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail-open); transform: translateX(-100%); transition: transform var(--dur-3) var(--ease-out); box-shadow: var(--shadow); }
  .rail.open { transform: none; }
  .rail-is-open .rail-scrim { display: block; position: fixed; inset: 0; background: rgba(24, 24, 27, .24); z-index: 25; animation: chat-fade var(--dur-2) var(--ease-out); }
  .thread-head .menu-btn { display: inline-grid !important; margin-left: -6px; } /* app.css hides the old .menu-btn with !important */
  .thread-head { padding: 0 12px; }
  .head-btn, .rail-btn, .composer-btn, .composer-voice .ix-voice-btn { width: 44px; height: 44px; }
  .composer textarea { min-height: 44px; padding: 11px 6px; }
  .composer-skel-fill { min-height: 44px; }
  .thread .chip { height: 44px; padding: 0 16px; }
  .thread .link { min-height: 44px; display: inline-flex; align-items: center; }
  .thread { padding: 16px 16px 24px; }
  .thread .msg-user { max-width: 90%; }
  .head-period { font-size: 14px; }
  .head-setup .sp-label { display: none; }
  .composer-dock { padding: 6px 12px calc(8px + env(safe-area-inset-bottom)); }
  .composer-note { display: none; }
  .sched-card .sched-day { grid-template-columns: 40px 1fr; padding: 10px 12px; }
  .publish-card { flex-wrap: wrap; }
  .pc-also .btn-publish { min-height: 44px; display: inline-flex; align-items: center; }
  .progress-inline .pi-caption { min-height: 3em; } /* room for the longest caption: it updates every second and must not resize the card */
  .sheet-drawer { width: 100vw; }
  /* A phone sheet comes up from the composer's side and goes back down. */
  .drawer.sheet-drawer { animation-name: sheet-up; }
  .drawer-overlay.closing .drawer.sheet-drawer { animation-name: sheet-down; }
}
@keyframes sheet-down { to { transform: translateY(40px); opacity: 0; } }

/* Toasts sit under the header, away from the composer. */
body:has(.chat-shell) .toasts { top: calc(var(--head-h) + 8px); bottom: auto; }
body:has(.chat-shell) .toast { background: var(--primary); color: #fff; border-radius: 12px; }
/* Under the header, a toast drops in from above and leaves back up. */
body:has(.chat-shell) .toast { animation-name: toast-drop; }
body:has(.chat-shell) .toast.leaving { animation-name: toast-out; }
@keyframes toast-drop { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.thread .privacy-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-subtle); font-size: 14px; }
.solve-dock { max-width: var(--chat-col); margin: 0 auto 8px; }

/* ---- the setup interview's progress rail at the right (desktop) ---- */
.setup-aside { display: none; }
@media (min-width: 1100px) {
  .chat-shell.has-setup-rail .setup-aside { display: flex; flex-direction: column; flex: 0 0 280px; width: 280px; height: 100dvh; overflow-y: auto; border-left: 1px solid var(--border); background: var(--bg-subtle); padding: calc(var(--head-h) + 8px) 20px 24px; }
  .chat-shell.has-setup-rail .head-setup { display: none; }
  .chat-shell.has-setup-rail .head-right { margin-left: auto; }
}

/* ---- guest (the interview before an account) ---- */
.head-right { margin-left: auto; display: flex; align-items: center; }
.head-setup + .head-right { margin-left: 8px; }
.head-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; text-decoration: none; }
.head-link:hover { background: var(--bg-subtle); color: var(--text); }
/* The sample week's way out to the real setup: always in view. */
.head-start { white-space: nowrap; }
@media (max-width: 640px) {
  .thread-head:has(.head-start) .head-pill, .thread-head:has(.head-start) .head-sep, .thread-head:has(.head-start) .head-period { display: none; }
}
.account-card { display: flex; flex-direction: column; gap: 10px; max-width: 420px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.account-card .ac-field { display: block; }
.account-card .input { width: 100%; height: 42px; }
.account-card .ac-submit { align-self: flex-start; height: 42px; padding: 0 18px; border-radius: 12px; }
.composer textarea:disabled { cursor: not-allowed; }
@media (max-width: 899px) {
  .head-link { min-height: 44px; }
  .account-card .input, .account-card .ac-submit { height: 44px; }
  .sheet .warnings summary { min-height: 44px; }
}

/* In the conversation the sentence is the card: the kind of change is read
   from the words, so its picker stays out of the way (say it again to fix). */
.thread .verb-pick { display: none; }
.thread .il-head:not(:has(.icon-btn)) { display: none; }
/* Call around in the conversation: Call, Text, Yes and No. "Asked" is a
   bookkeeping tap the thread does not need. */
.thread .call-btns .ask-check { display: none; }

/* The short wait while a question in the person's own words is answered (chat/ask.js). */
.msg[data-id="asking"] .bubble { color: var(--text-3); }
.msg[data-id="asking"] .bubble::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: var(--brand); vertical-align: middle; animation: ask-breathe var(--dur-loop, 1.6s) ease-in-out infinite; }
@keyframes ask-breathe { 50% { opacity: .25; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .msg[data-id="asking"] .bubble::after { animation: none; } }

/* "How did it do?" under a freshly built schedule (cards/schedule.js RateRow). */
.rate-row { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.rate-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; }
.rate-btn:hover, .rate-btn:focus-visible { color: var(--brand); border-color: var(--border); background: var(--surface); }
.rate-why { margin-left: auto; display: flex; gap: 10px; align-items: center; flex: 1 1 220px; min-width: 0; }
.rate-why .input { flex: 1; min-width: 0; height: 32px; font-size: 13px; }
.sched-foot { flex-wrap: wrap; align-items: center; }
@media (max-width: 640px), (pointer: coarse) { .rate-btn { width: 44px; height: 44px; } .rate-why .input { height: 44px; } }

/* Export sheet (pages/export.js): format, their columns, a short preview, one main button. */
.export-sheet { display: flex; flex-direction: column; gap: 14px; }
.export-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.export-changed { font-size: 14px; }
.export-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.export-header-row { display: flex; gap: 8px; }
.export-header-row .input { flex: 1; min-width: 0; }
.export-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; align-items: end; }
.export-col { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
.export-col span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-col .select { width: 100%; }
.export-col .select.blank { color: var(--text-3); }
.export-warn { color: color-mix(in srgb, var(--warn) 60%, var(--text)); margin: 6px 0 0; }
.export-warn ul { margin: 4px 0 0; padding-left: 18px; }
.export-notes p { margin: 0; }
.export-preview { border: 1px solid var(--border); border-radius: 10px; }
.export-preview .table { font-size: 12.5px; }
.export-preview .table td, .export-preview .table th { white-space: nowrap; }
.export-preview p { margin: 6px 8px; }
.export-actions { display: flex; gap: 8px; }
.pc-links { display: inline-flex; flex-wrap: wrap; gap: 4px 16px; }
.pc-links .link { min-width: 44px; }
