/* The clinic's palette (its style guide via its report template): purple primary, teal accent, burgundy sparingly,
   soft tints for surfaces. Text pairs checked for WCAG AA. */
:root {
  --bg: #f7f6fa;
  --surface: #ffffff;
  --ink: #23212b;
  --muted: #5d5867;
  --line: #e3dfea;
  --primary: #36275c;
  --primary-ink: #ffffff;
  --primary-soft: #f1eef7;
  --accent: #297D7C;
  --accent-text: #1f6362;
  --accent-ink: #ffffff;
  --accent-soft: #E6F1F1;
  --berry: #823046;
  --berry-soft: #F6EBEE;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --partly: #7a4fa0;
  --partly-soft: #f1eaf8;
  --declined: #5f5a66;
  --declined-soft: #eeedf0;
  --danger: #a3242f;
  --danger-soft: #fbe7e9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 18, 30, .06), 0 4px 16px rgba(20, 18, 30, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17141f; --surface: #221d2d; --ink: #eeeaf5; --muted: #b3aac2; --line: #3a3347;
    --primary: #b9a8e6; --primary-ink: #1b1430; --primary-soft: #2c2440;
    --accent: #7cc2b4; --accent-text: #8fd0c3; --accent-ink: #10201d; --accent-soft: #1d3330;
    --berry: #e3a0b4; --berry-soft: #3a1f29; --warn: #f0c46a; --warn-soft: #3a2f16;
    --partly: #c8a6ea; --partly-soft: #2e2540; --declined: #b9b5c0; --declined-soft: #2b2a31; --danger: #f08a93; --danger-soft: #3d1c20;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 Calibri, Carlito, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--primary); font-weight: 700; }
.band img { display: block; width: 100%; height: 8px; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--primary); }
/* The clinic's full-resolution logo (1133 x 726) scaled down: crisp at 48 px tall, true proportions. */
.brand .logo { display: block; height: 48px; width: auto; max-width: none; }
.welcome-logo { text-align: center; margin: 0 0 8px; }
.welcome-logo img { height: 110px; width: auto; max-width: 100%; }
.welcome { text-align: center; color: var(--primary); font-size: 18px; margin: 0 0 16px; }
.site-foot { max-width: 1240px; margin: 0 auto; padding: 8px 16px 28px; color: var(--muted); font-size: 13px; text-align: center; }
.site-foot span { display: inline-block; margin: 0 8px; }
.site-foot .foot-lead { color: var(--berry); font-weight: 700; }
.site-foot .powered { font-size: 12px; margin-top: 6px; }
.step { color: var(--muted); font-size: 14px; }
.app { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.narrow { max-width: 640px; margin: 0 auto; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label.field input, label.field select, textarea, .text-in { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); font-weight: 400; min-height: 44px; width: 100%; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 18px; min-height: 44px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.quiet { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 10px 12px; margin: 12px 0 0; }
.ok { color: var(--accent-text); }

/* Conversation + form panel */
.talk { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .talk { grid-template-columns: 1fr; } }
.convo { display: flex; flex-direction: column; gap: 14px; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.live { background: var(--accent); box-shadow: 0 0 0 4px rgba(41, 125, 124, .2); }
.transcript { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.bubble { border-radius: 14px; padding: 10px 14px; max-width: 92%; }
.bubble.assistant { background: var(--accent-soft); align-self: flex-start; }
.bubble.parent { background: var(--primary-soft); border: 1px solid var(--line); align-self: flex-end; }
.bubble.server { background: var(--warn-soft); color: var(--warn); align-self: flex-start; font-weight: 600; }
.bubble.server.stop { background: var(--danger-soft); color: var(--danger); }
.bubble .who { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.typed { display: flex; gap: 8px; }
.typed input { flex: 1; }
.cards { display: flex; flex-direction: column; gap: 12px; }
.tick-card, .wrap-card { border: 2px solid var(--accent); }
.tick-card h3, .wrap-card h3 { margin: 0 0 10px; font-size: 16px; }
.ticks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tick { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 44px; cursor: pointer; }
.tick input { width: 20px; height: 20px; }

.panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-width: 900px) { .panel { position: static; max-height: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.meter { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 6px 0 14px; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.sec { border-top: 1px solid var(--line); padding: 10px 0; }
.sec summary { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; font-weight: 700; font-size: 14px; list-style: none; min-height: 32px; align-items: center; }
.sec summary::-webkit-details-marker { display: none; }
.sec .count { font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sec .count.done { color: var(--accent-text); }
.badge { display: inline-block; font-size: 12px; color: var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 2px 6px; margin: 4px 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 14px; }
.item .q { flex: 1; }
.item button.q { text-align: left; background: none; border: 0; padding: 0; cursor: pointer; }
.item .quote { display: none; margin-top: 4px; font-style: italic; color: var(--muted); }
.item.open-quote .quote { display: block; }
.chip { flex: none; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.chip.answered { background: var(--accent-soft); color: var(--accent-text); }
.chip.partly { background: var(--partly-soft); color: var(--partly); }
.chip.declined { background: var(--declined-soft); color: var(--declined); }
.chip.on_form, .chip.skipped { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.open { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.chip.to_type { background: var(--warn-soft); color: var(--warn); }
.item div.q { flex: 1; display: flex; flex-direction: column; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.editor { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; font-style: normal; color: var(--ink); }

.form-item { border-top: 1px solid var(--line); padding: 14px 0; }
.form-item .sec-name { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.choice-row label { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; display: flex; gap: 6px; align-items: center; min-height: 40px; cursor: pointer; }
.downloads { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.downloads a { text-decoration: none; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* v7.1: presence, one transcript, chapters, review */
.preparing { margin-left: 12px; color: var(--primary); font-weight: 700; font-size: 16px; }
.brand { display: flex; align-items: center; }
.group-block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.group-block h2 { font-size: 16px; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; }
.dob-row { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 8px; }
.dob-row label.field { font-weight: 400; font-size: 12px; color: var(--muted); }
.presence { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; min-height: 28px; }
.orb { width: 14px; height: 14px; border-radius: 50%; background: var(--line); flex: none; transition: background .2s, box-shadow .2s; }
.orb.listening { background: var(--accent); box-shadow: 0 0 0 5px rgba(41, 125, 124, .18); }
.orb.speaking { background: var(--primary); box-shadow: 0 0 0 6px rgba(54, 39, 92, .16); animation: pulse 1.2s ease-in-out infinite; }
.orb.thinking { background: var(--primary-soft); border: 2px solid var(--primary); }
.orb.paused, .orb.connecting { background: var(--muted); }
.orb.reconnecting { background: var(--berry); animation: pulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .orb { animation: none !important; } }
@keyframes pulse { 50% { transform: scale(1.25); } }
.bubble .words { white-space: pre-wrap; }
.bubble.parent.live .words { color: var(--muted); font-style: italic; }
.transcript { max-height: 52vh; }
.chapters { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 12px; }
.chapter-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chapter-title { font-weight: 600; }
.chapter.later .chapter-title { color: var(--muted); }
.chapter.now .chapter-title { color: var(--primary); }
.pill { font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.pill.done { background: var(--accent-soft); color: var(--accent-text); }
.pill.now { background: var(--primary); color: var(--primary-ink); }
.pill.later { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.bar { height: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.chapter-pill { display: none; }
@media (max-width: 900px) {
  .chapter-pill { display: block; position: sticky; top: 0; z-index: 5; width: 100%; margin: 0 0 12px; border: 1px solid var(--line); background: var(--surface); color: var(--primary); font-weight: 700; border-radius: 999px; padding: 10px 14px; min-height: 44px; text-align: left; box-shadow: var(--shadow); cursor: pointer; }
}
.review-chapter { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.review-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px 16px; margin: 0; }
.review-list dt { color: var(--muted); font-size: 14px; }
.review-list dd { margin: 0; }
@media (max-width: 640px) { .review-list { grid-template-columns: 1fr; } .review-list dd { margin-bottom: 8px; } }
details.followups { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
details.followups summary { cursor: pointer; font-weight: 700; color: var(--primary); min-height: 32px; display: flex; align-items: center; }
