:root {
  --bg: #f4f1ea;
  --bg2: #ece7dd;
  --surface: #fffdf8;
  --ink: #22302d;
  --ink-soft: #4a5a56;
  --muted: #78867f;
  --line: #ded7ca;
  --accent: #0d6f5a;
  --accent-soft: #e3efe9;
  --accent-ink: #095243;
  --warn: #8a5a12;
  --warn-soft: #f7eedd;
  --fig-ink: #2b3a37;
  --fig-ink-far: #a9b5ae;
  --fig-accent: #0d6f5a;
  --fig-ground: rgba(13, 111, 90, .10);
  --fig-dark: 0;
  --radius: 16px;
  --fs: 17px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #111715;
  --bg2: #202927;
  --surface: #19211f;
  --ink: #e8efeb;
  --ink-soft: #bcc9c4;
  --muted: #8b9a94;
  --line: #2b3835;
  --accent: #57c3a4;
  --accent-soft: #1c2b27;
  --accent-ink: #8fe0c7;
  --warn: #e0b678;
  --warn-soft: #2a2317;
  --fig-ink: #d2ded9;
  --fig-ink-far: #4c5a56;
  --fig-accent: #57c3a4;
  --fig-ground: rgba(87, 195, 164, .12);
  --fig-dark: 1;
  color-scheme: dark;
}
html[data-big="1"] { --fs: 20px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.75em; }
h2 { font-size: 1.3em; }
h3 { font-size: 1.08em; }
p { margin: 0 0 .8em; }
a { color: var(--accent-ink); }
.hide { display: none !important; }

.wrap { max-width: 680px; margin: 0 auto; padding: 18px 18px 96px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px 6px; max-width: 680px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.12em; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 180deg, var(--ink) 0 50%, var(--surface) 50% 100%);
  border: 1.5px solid var(--ink); position: relative; flex: none;
}
.brand .mark::before, .brand .mark::after {
  content: ""; position: absolute; left: 50%; width: 13px; height: 13px; border-radius: 50%; transform: translateX(-50%);
}
.brand .mark::before { top: 0; background: var(--ink); }
.brand .mark::after { bottom: 0; background: var(--surface); }
.who { font-size: .88em; color: var(--muted); }
.whobtn {
  font: inherit; font-size: 1em; cursor: pointer;
  background: var(--bg2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; min-height: 40px;
}
.whobtn:active { background: var(--accent-soft); }

/* ---------- cards / buttons ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 0 0 14px;
}
.card.tight { padding: 14px 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 12px 20px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .btn.primary { color: #06211a; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 42px; padding: 8px 14px; font-size: .92em; font-weight: 500; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; font: inherit;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
}
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95em; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%;
  min-height: auto; height: 30px; padding: 0; border: 0; background: transparent;
  accent-color: var(--accent); cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: var(--bg2);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -10px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.22);
}
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--bg2); }
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface); background: var(--accent);
}

/* voice chooser */
.vlist { border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.vrow {
  display: flex; align-items: stretch; gap: 0;
  border-top: 1px solid var(--line); background: var(--surface);
}
.vrow:first-child { border-top: 0; }
.vrow.on { background: var(--accent-soft); }
.vrow .vpick {
  flex: 1; min-width: 0; text-align: left; font: inherit; cursor: pointer;
  background: none; border: 0; color: inherit; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 1px;
}
.vrow .vpick b { font-weight: 600; }
.vrow.on .vpick b { color: var(--accent-ink); }
.vrow .vpick b::before { content: "○  "; color: var(--muted); font-weight: 400; }
.vrow.on .vpick b::before { content: "●  "; color: var(--accent); }
.vrow .vpick span { color: var(--muted); font-size: .8em; padding-left: 1.4em; }
.vrow .vhear {
  flex: 0 0 auto; font: inherit; font-size: .85em; cursor: pointer;
  background: none; border: 0; border-left: 1px solid var(--line);
  color: var(--accent-ink); padding: 0 16px; font-weight: 600;
}
.vrow .vhear:active { background: var(--bg2); }

/* three-way segmented choice */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.seg button {
  font: inherit; text-align: center; cursor: pointer; padding: 10px 6px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; gap: 2px; min-height: 68px; justify-content: center;
}
.seg button b { font-weight: 600; font-size: .95em; }
.seg button span { color: var(--muted); font-size: .74em; line-height: 1.25; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); }
.seg button.on b { color: var(--accent-ink); }
.hint { color: var(--muted); font-size: .88em; margin-top: 6px; }
.err { color: #a4302c; font-weight: 600; margin-top: 10px; }
html[data-theme="dark"] .err { color: #ff9c95; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 8px 0 4px; }
.hero .sub { color: var(--muted); margin-top: -.2em; }
.streak {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px;
}
.stat {
  background: var(--accent-soft); border-radius: 12px; padding: 10px 8px; text-align: center;
}
.stat b { display: block; font-family: var(--serif); font-size: 1.5em; line-height: 1.1; color: var(--accent-ink); }
.stat span { font-size: .8em; color: var(--muted); }

.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.pick .btn { flex-direction: column; gap: 2px; min-height: 84px; }
.pick .btn b { font-family: var(--serif); font-size: 1.35em; font-weight: 600; }
.pick .btn small { color: var(--muted); font-weight: 500; font-size: .8em; }
.pick .btn.sel { border-color: var(--accent); background: var(--accent-soft); }

.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle:first-of-type { border-top: 0; }
.toggle .lab { flex: 1; }
.toggle .lab b { display: block; font-weight: 600; }
.toggle .lab span { color: var(--muted); font-size: .86em; }
.sw {
  width: 56px; height: 32px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--bg2); position: relative; flex: none; cursor: pointer; transition: .18s;
}
.sw::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--line); transition: .18s;
}
.sw[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.sw[aria-checked="true"]::after { left: 27px; border-color: transparent; }

/* ---------- figure ---------- */
.fig-wrap { position: relative; background: var(--bg2); border-radius: var(--radius); overflow: hidden; }
canvas.fig { display: block; width: 100%; height: 320px; touch-action: pan-y; cursor: grab; }
canvas.fig:active { cursor: grabbing; }
.fig-hint {
  position: absolute; right: 10px; bottom: 8px; font-size: .74em; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 3px 8px; border-radius: 8px;
}
.fig-view { position: absolute; left: 10px; bottom: 8px; display: flex; gap: 6px; }
.fig-view button {
  font: inherit; font-size: .74em; padding: 4px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--ink-soft);
}

/* ---------- player ---------- */
body.playing { overflow: hidden; }
.player {
  position: fixed; inset: 0; z-index: 50;
  background:
    radial-gradient(120% 70% at 50% 22%, color-mix(in srgb, var(--accent) 8%, var(--bg)) 0%, var(--bg) 62%);
  display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.player-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px 4px; }
.player-top .ttl { flex: 1; font-size: .86em; color: var(--muted); }
.bar { height: 5px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin: 0 16px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s linear; }
.player-mid { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; padding: 0 16px; }
.player-mid canvas.fig { height: min(50vh, 440px); }
.player-mid .fig-wrap { background: transparent; }
.now { text-align: center; margin: 10px 0 4px; }
.now .nm { font-family: var(--serif); font-size: 1.7em; line-height: 1.15; }
.now .cn { color: var(--muted); font-size: .9em; }
.cue {
  text-align: center; font-size: 1.18em; font-weight: 600; min-height: 1.6em;
  color: var(--accent-ink); margin: 6px 0 2px;
}
.breathe {
  text-align: center; color: var(--muted); font-size: .82em;
  letter-spacing: .18em; text-transform: uppercase; min-height: 1.4em;
}
.counts { display: flex; justify-content: center; gap: 8px; margin: 10px 0 2px; }
.counts i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block;
  transition: background .3s ease, transform .3s ease;
}
.counts i.on { background: var(--accent); transform: scale(1.25); }
.player-bot { padding: 8px 16px 16px; display: flex; gap: 10px; align-items: center; }
.player-bot .btn { flex: 1; }
.player-bot .btn.icon { flex: 0 0 64px; min-width: 64px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list button.row {
  display: flex; width: 100%; align-items: center; gap: 12px; text-align: left;
  background: none; border: 0; font: inherit; color: inherit; padding: 14px 2px; cursor: pointer;
}
.row .num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: .88em;
}
.row .txt { flex: 1; min-width: 0; }
.row .txt b { display: block; font-weight: 600; }
.row .txt span { color: var(--muted); font-size: .85em; }
.row .chev { color: var(--muted); flex: none; }
.pill {
  display: inline-block; font-size: .74em; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; vertical-align: 2px;
}
.pill.grey { background: var(--bg2); color: var(--muted); }

.note {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 14px; border-radius: 0 12px 12px 0; margin: 0 0 14px;
}
.note.caution { border-color: var(--warn); background: var(--warn-soft); }
.note h3 { margin-bottom: .25em; font-size: 1em; }
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
ul.tick { list-style: none; padding: 0; margin: 0 0 .8em; }
ul.tick li { padding-left: 22px; position: relative; margin-bottom: .4em; }
ul.tick li::before { content: "—"; position: absolute; left: 0; color: var(--accent); }
ol.steps { padding-left: 1.3em; margin: 0 0 .8em; }
ol.steps li { margin-bottom: .5em; }

/* ---------- calendar ---------- */
.cal {
  display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column;
  grid-auto-columns: 1fr; gap: 4px; max-width: 400px;
}
.callab { max-width: 400px; }
.cal i { aspect-ratio: 1; border-radius: 3px; background: var(--bg2); display: block; }
.cal i.l1 { background: color-mix(in srgb, var(--accent) 32%, var(--bg2)); }
.cal i.l2 { background: color-mix(in srgb, var(--accent) 62%, var(--bg2)); }
.cal i.l3 { background: var(--accent); }
.cal i.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.callab { display: flex; justify-content: space-between; color: var(--muted); font-size: .78em; margin-top: 8px; }

.people { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.person { background: var(--bg2); border-radius: 12px; padding: 12px; text-align: center; }
.person b { display: block; font-family: var(--serif); font-size: 1.05em; }
.person .big { display: block; font-size: 1.7em; line-height: 1.15; font-family: var(--serif); color: var(--accent-ink); margin-top: 4px; }
.person span { color: var(--muted); font-size: .8em; }

/* ---------- nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  display: flex; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; background: none; border: 0; font: inherit; font-size: .74em; color: var(--muted);
  padding: 6px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.nav button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav button.on { color: var(--accent-ink); font-weight: 600; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (min-width: 720px) {
  canvas.fig { height: 380px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .sw, .sw::after, .bar i { transition: none; }
}
