/* =========================================================
   Unfurl — design tokens
   Warm sand + deep fern teal + clay. Fraunces for headings, Figtree for UI.
   ========================================================= */
:root {
  --bg: #f5efe6;
  --bg-2: #efe6d9;
  --surface: #fffcf7;
  --surface-2: #f3ebdf;
  --ink: #1c2826;
  --ink-2: #4b5755;      /* 7.0:1 on --bg */
  --line: #ddd1c1;
  --brand: #1d6a60;      /* 6.3:1 with white */
  --brand-strong: #13514a;
  --on-brand: #ffffff;
  --brand-soft: #d9ebe6;
  --tint: #e3efe9;
  --accent: #b5502b;     /* clay, 4.9:1 on white */
  --accent-soft: #f7dccd;
  --accent-ink: #8f3c1d;
  --good: #2f7a4f;
  --danger: #a3332b;
  --focus: #0f5f8a;
  --skin: #ead9c4;
  --skin-line: #cdb69a;
  --hair: #6b4f3a;
  --fig: #1d6a60;
  --fig-far: #8fb9b0;
  --mat: #e2d5c3;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.05), 0 8px 24px -12px rgb(60 40 20 / 0.18);
  --radius: 22px;
  --radius-sm: 14px;
  --font-head: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121a19;
    --bg-2: #18211f;
    --surface: #1b2523;
    --surface-2: #22302d;
    --ink: #eee8de;
    --ink-2: #b6c2be;
    --line: #34423f;
    --brand: #7ccbbd;
    --brand-strong: #a3e0d4;
    --on-brand: #0d1a18;
    --brand-soft: #1f3a35;
    --tint: #1d2f2b;
    --accent: #f0956d;
    --accent-soft: #4a2c1f;
    --accent-ink: #f7b597;
    --good: #7fd09f;
    --danger: #ff8f84;
    --focus: #8fd1ff;
    --skin: #3a4a46;
    --skin-line: #556863;
    --hair: #a68b74;
    --fig: #7ccbbd;
    --fig-far: #3f6560;
    --mat: #2c3a37;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px -14px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121a19;
  --bg-2: #18211f;
  --surface: #1b2523;
  --surface-2: #22302d;
  --ink: #eee8de;
  --ink-2: #b6c2be;
  --line: #34423f;
  --brand: #7ccbbd;
  --brand-strong: #a3e0d4;
  --on-brand: #0d1a18;
  --brand-soft: #1f3a35;
  --tint: #1d2f2b;
  --accent: #f0956d;
  --accent-soft: #4a2c1f;
  --accent-ink: #f7b597;
  --good: #7fd09f;
  --danger: #ff8f84;
  --focus: #8fd1ff;
  --skin: #3a4a46;
  --skin-line: #556863;
  --hair: #a68b74;
  --fig: #7ccbbd;
  --fig-far: #3f6560;
  --mat: #2c3a37;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px -14px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; outline: none; padding-bottom: 32px; }
h1, h2, h3, .h4, .h5 { font-family: var(--font-head); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 1.4rem + 2.4vw, 2.9rem); }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); }
.h4 { font-size: 1.25rem; }
.h5 { font-size: 1.08rem; }
p { margin: 0 0 .75em; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--brand); color: var(--on-brand); padding: 10px 16px; border-radius: 10px; z-index: 100; font-weight: 600; }
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 760px; }
@media (min-width: 700px) { .wrap { padding: 0 28px; } }

.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: .5em; }
.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 40ch; }
.meta { color: var(--ink-2); font-weight: 500; }
.tiny { font-size: .88rem; color: var(--ink-2); }
.hint { font-family: var(--font-body); font-weight: 400; font-size: .88rem; color: var(--ink-2); letter-spacing: 0; text-transform: none; }
.center { text-align: center; }
.center .lede { margin-inline: auto; }
.link { font-weight: 600; text-underline-offset: 3px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
@media (min-width: 700px) { .card { padding: 26px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  border: 1.5px solid transparent; font-weight: 650; text-decoration: none;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: .95rem; }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 1.08rem; }
.btn.block { width: 100%; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--brand); }
.btn-quiet { background: transparent; color: var(--brand); }
.btn-quiet:hover { background: var(--brand-soft); }
.btn-quiet.danger, .btn-danger { color: var(--danger); }
.btn-danger { background: transparent; border-color: var(--danger); }
.btn[disabled], .btn-icon[disabled] { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed='true'] .icon { color: var(--accent); }

.btn-icon {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn-icon:hover:not([disabled]) { border-color: var(--brand); color: var(--brand); }
.btn-icon.sm { width: 40px; height: 40px; }
.btn-icon.lg { width: 60px; height: 60px; }
.btn-icon.lg .icon { width: 26px; height: 26px; }
.btn-icon.flip .icon { transform: scaleX(-1); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-head); font-size: 1.45rem; font-weight: 600; }
.nav { display: none; gap: 4px; }
.nav a, .tabbar a { text-decoration: none; color: var(--ink-2); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.nav a { padding: 10px 16px; border-radius: 999px; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current='page'] { color: var(--brand-strong); background: var(--brand-soft); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { flex-direction: column; gap: 2px; font-size: .78rem; padding: 6px 2px; border-radius: 12px; min-height: 52px; justify-content: center; }
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a[aria-current='page'] { color: var(--brand-strong); background: var(--brand-soft); }
body { padding-bottom: 72px; }
@media (min-width: 760px) {
  .nav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 0; }
}
body[data-view='play'] .tabbar, body[data-view='play'] .site-footer, body[data-view='checkin'] .tabbar { display: none; }
body[data-view='play'], body[data-view='checkin'] { padding-bottom: 0; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--ink-2); font-size: .92rem; background: var(--bg-2); }
.site-footer p { max-width: 75ch; }

/* ---------- reminder banner & toast ---------- */
.reminder-banner { background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.banner-inner { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; padding-block: 12px; }
.banner-inner p { margin: 0; display: flex; gap: 10px; align-items: center; font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 14px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { .toast { bottom: 32px; } }

/* ---------- home ---------- */
.hero { display: grid; gap: 24px; padding: 28px 0 24px; align-items: center; }
@media (min-width: 900px) { .hero { grid-template-columns: 1fr 1.05fr; gap: 48px; padding: 48px 0 32px; } }
.today-card {
  position: relative; overflow: hidden;
  background: var(--tint); border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line));
  border-radius: 28px; padding: 24px;
  box-shadow: var(--shadow);
}
.today-card::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%;
  border: 22px solid color-mix(in srgb, var(--brand) 10%, transparent); pointer-events: none;
}
@media (min-width: 700px) { .today-card { padding: 32px; } }
.today-card h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); max-width: 22ch; }
.eyebrow.on-tint { color: var(--brand-strong); }
.mini-moves { list-style: none; padding: 0; margin: 14px 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.mini-moves li { background: var(--surface); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; font-size: .92rem; font-weight: 500; }
.mini-moves li.more { background: transparent; border-style: dashed; color: var(--ink-2); }
.today-card .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.today-card .actions .btn-primary { flex: 1 1 240px; }
.done-note { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--good); }

.intro { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; border-left: 5px solid var(--accent); }
.intro > div { flex: 1 1 380px; }
.intro p { margin-bottom: .5em; max-width: 70ch; }

.week-card { margin-bottom: 40px; }
.week-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; }
.week-sum { color: var(--ink-2); margin: 0; }
.week-sum strong { color: var(--ink); font-size: 1.15rem; }
.week { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 460px; }
.center .week { margin-inline: auto; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wdot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px dashed var(--line); color: var(--on-brand); }
.wday.some .wdot { background: var(--brand-soft); border: 2px solid var(--brand); }
.wday.met .wdot { background: var(--brand); border: 2px solid var(--brand); }
.wday.today .wdot { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.wdot .icon { width: 18px; height: 18px; }
.wlabel { font-size: .78rem; color: var(--ink-2); font-weight: 600; }

.section-head { margin-bottom: 18px; }
.section-head p { color: var(--ink-2); }
.builder { margin-bottom: 40px; scroll-margin-top: 80px; }
.builder-grid { display: grid; gap: 20px; }
@media (min-width: 900px) { .builder-grid { grid-template-columns: minmax(320px, 0.9fr) 1.1fr; align-items: start; } .map-col { position: sticky; top: 84px; } }
.map-col { display: flex; flex-direction: column; align-items: center; background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%); }
.map-status { font-weight: 600; text-align: center; margin: 8px 0 0; min-height: 1.6em; }

/* body map */
.bodymap { width: 100%; max-width: 400px; height: auto; display: block; overflow: visible; }
.pip-skin line { stroke: var(--skin); stroke-linecap: round; }
.pip-skin circle, .pip-skin rect, .pip-skin path, .pip-skin ellipse { fill: var(--skin); }
.pip-hair { fill: var(--hair); }
.pip-line { fill: none; stroke: var(--skin-line); stroke-width: 2; stroke-linecap: round; }
.pip-shadow { fill: var(--mat); }
.zone { cursor: pointer; outline: none; }
.zone .hit > * { fill: color-mix(in srgb, var(--accent) 8%, transparent); stroke: var(--skin-line); stroke-width: 2; stroke-dasharray: 5 5; transition: fill .2s, stroke .2s; }
.zone .pulse > * { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; }
.zone .leader { stroke: var(--skin-line); stroke-width: 1.5; stroke-dasharray: 2 4; }
.zone .dot { fill: var(--skin-line); }
.zone .zlabel { font-family: var(--font-body); font-size: 15px; font-weight: 600; fill: var(--ink-2); }
.zone:hover .hit > * { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); }
.zone:hover .zlabel { fill: var(--ink); }
.zone[aria-pressed='true'] .hit > * { fill: var(--accent); stroke: var(--accent-ink); stroke-dasharray: none; fill-opacity: .9; }
.zone[aria-pressed='true'] .zlabel { fill: var(--accent-ink); font-weight: 700; }
.zone[aria-pressed='true'] .leader { stroke: var(--accent); stroke-dasharray: none; }
.zone[aria-pressed='true'] .dot { fill: var(--accent); }
.zone:focus-visible .hit > * { stroke: var(--focus); stroke-width: 3.5; stroke-dasharray: none; }
.zone:focus-visible .zlabel { fill: var(--focus); text-decoration: underline; }
.zone.pop[aria-pressed='true'] .pulse > * { animation: pulse .6s ease-out; }
@keyframes pulse { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(1.5); } }

/* form pills */
.options { display: flex; flex-direction: column; gap: 4px; }
.field { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.field legend { font-weight: 700; margin-bottom: 10px; padding: 0; font-size: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill label, .chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: .96rem; cursor: pointer; transition: all .15s; user-select: none;
}
.pill label:hover, .chip:hover { border-color: var(--brand); }
.pill input:checked + label, .chip[aria-pressed='true'] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.pill input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.pill .pill-check { display: none; width: 16px; height: 16px; }
.pill input:checked + label .pill-check { display: inline-block; }
fieldset[disabled] .pill label, .pill input:disabled + label { opacity: .5; cursor: not-allowed; }
.form-actions { margin-top: 6px; }
.form-actions .btn { width: 100%; }

.quick { margin-bottom: 32px; }
.quick-grid { display: grid; gap: 16px; margin: 12px 0; }
@media (min-width: 640px) { .quick-grid { grid-template-columns: 1fr 1fr; } }
.quick-grid > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px; }
.quick-grid .tiny { margin: 0; }
.qtitle { font-weight: 700; margin: 2px 0 10px; }

.safety { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); font-size: .92rem; max-width: 75ch; margin: 24px 0; }
.safety .icon { margin-top: 2px; color: var(--accent); }

/* ---------- page heads ---------- */
.page-head { padding: 28px 0 16px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 18px; font-weight: 600; text-decoration: none; padding: 6px 8px 6px 2px; }
.back-link + .page-head { padding-top: 8px; }

/* ---------- preview ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; padding: 12px 14px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; }
@media (max-width: 560px) {
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar .stepper { grid-column: 1 / -1; justify-content: center; margin: 0; }
  .toolbar .btn { padding: 0 10px; }
}
.stepper-val { font-weight: 700; min-width: 4.5ch; text-align: center; }
.move-list { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 10px; }
.move-row { display: grid; grid-template-columns: 76px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.thumb-wrap { background: var(--surface-2); border-radius: 12px; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; }
.thumb { width: 100%; height: 100%; }
.move-info h2 { margin: 0 0 2px; }
.move-info .num { color: var(--ink-2); font-family: var(--font-body); font-weight: 600; }
.move-info p { margin: 0; }
.dose { font-weight: 600; color: var(--brand-strong); }
.type-tag { color: var(--ink-2); font-weight: 500; }
.badge { font-family: var(--font-body); font-size: .72rem; background: var(--accent-soft); color: var(--accent-ink); padding: 2px 8px; border-radius: 99px; vertical-align: middle; font-weight: 700; }
.row-actions { display: flex; gap: 6px; }
@media (max-width: 480px) {
  .move-row { grid-template-columns: 60px 1fr; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
.sticky-cta { position: sticky; bottom: 80px; padding: 12px 0; z-index: 5; }
@media (min-width: 760px) { .sticky-cta { bottom: 12px; } }
.sticky-cta .btn { box-shadow: 0 10px 30px -10px rgb(29 106 96 / .55); }

/* figure */
.figure .fig-mat { fill: var(--mat); }
.figure .fig-far polyline { stroke: var(--fig-far); }
.figure .fig-body polyline, .figure .fig-near polyline { stroke: var(--fig); }
.figure .fig-body circle { fill: var(--fig); }
.figure .fig-prop path { stroke: var(--skin-line); stroke-width: 4; fill: none; stroke-linecap: round; }

/* ---------- check-in ---------- */
.feelings { display: grid; gap: 10px; margin: 8px 0 20px; }
@media (min-width: 640px) { .feelings { grid-template-columns: 1fr 1fr; } .feelings .feeling:last-child { grid-column: 1 / -1; } }
.feeling {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; text-align: left;
  padding: 16px 18px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; min-height: 72px; transition: border-color .15s, transform .1s;
}
.feeling:hover { border-color: var(--brand); transform: translateY(-1px); }
.f-emoji { grid-row: span 2; font-size: 1.7rem; align-self: center; }
.f-label { font-weight: 700; font-size: 1.05rem; }
.f-effect { color: var(--ink-2); font-size: .9rem; }
.checkin-foot { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; color: var(--ink-2); max-width: 46ch; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }

/* ---------- player ---------- */
.player { padding-bottom: 24px; }
.player-top { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding-top: 14px; padding-bottom: 10px; }
.ptitle { min-width: 0; text-align: center; }
.ptitle .eyebrow { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcount { margin: 0; font-weight: 700; }
.premain { margin: 0; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.segbar { list-style: none; padding: 0; margin: 0 0 10px; display: flex; gap: 4px; }
.segbar li { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.segbar li span { display: block; height: 100%; width: 0; background: var(--brand); }
.segbar li.done span { width: 100% !important; }
.tailored { display: flex; gap: 8px; align-items: center; background: var(--brand-soft); color: var(--brand-strong); padding: 8px 14px; border-radius: 12px; font-size: .92rem; font-weight: 600; }
.player-grid { display: grid; gap: 16px; }
@media (min-width: 860px) { .player-grid { grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; padding-top: 12px; } }
.figure-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 8px; box-shadow: var(--shadow); }
.figure-wrap svg { display: block; width: 100%; height: auto; max-height: 42vh; }
@media (min-width: 860px) {
  .figure-wrap svg { max-height: 52vh; }
  .controls-wrap { position: static; background: none; }
}
.phase-chip { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; padding: 4px 14px; border-radius: 99px; margin: 0; font-size: .9rem; white-space: nowrap; }
.phase-chip[hidden] { display: none; }
.panel h1 { font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.3rem); margin-bottom: 4px; outline: none; }
.panel .dose { font-size: 1.05rem; }
.timer { position: relative; width: 150px; height: 150px; margin: 10px 0 14px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.ring { fill: none; stroke: var(--brand); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.ring.prep { stroke: var(--accent); }
.timer-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#tval { font-family: var(--font-head); font-size: 2.3rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
#tlabel { font-size: .85rem; color: var(--ink-2); font-weight: 600; margin-top: 4px; }
@media (max-width: 859px) {
  .panel { display: grid; grid-template-columns: 1fr auto; column-gap: 16px; align-items: center; }
  .panel > *:not(.timer) { grid-column: 1 / -1; }
  .panel h1 { grid-column: 1; grid-row: 1; }
  .panel .dose { grid-column: 1; grid-row: 2; align-self: start; }
  .panel .timer { grid-column: 2; grid-row: 1 / span 2; width: 112px; height: 112px; margin: 0; }
  #tval { font-size: 1.7rem; }
}
.steps { padding-left: 1.3em; margin: 0 0 12px; }
.steps li { margin-bottom: 6px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.disclosure { background: none; border: 1.5px solid var(--line); border-radius: 999px; min-height: 40px; padding: 0 16px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: var(--brand-strong); justify-self: start; }
.disclosure[aria-expanded='true'] { background: var(--brand-soft); border-color: var(--brand); }
.easier { background: var(--brand-soft); border-radius: 14px; padding: 12px 16px; margin-top: 10px; }
.easier p { margin: 0; }
.pain-note { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: .9rem; margin-top: 14px; }
.controls-wrap { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 18px 16px calc(12px + env(safe-area-inset-bottom)); margin-top: 8px; }
.controls { display: flex; justify-content: center; align-items: center; gap: 22px; }
.btn-play { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; cursor: pointer; box-shadow: 0 12px 30px -12px rgb(29 106 96 / .7); }
.btn-play .icon { width: 34px; height: 34px; }
.btn-play:hover { background: var(--brand-strong); }
.btn-play.is-paused { background: var(--accent); }
.controls-2 { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 10px; }
.kbd-hint { text-align: center; margin: 4px 0 0; display: none; }
body[data-view='play'] .site-header { display: none; }
@media (max-width: 859px) {
  .figure-wrap svg { max-height: 30vh; }
  .controls-wrap { padding-top: 14px; }
  .controls { gap: 18px; }
  .btn-play { width: 68px; height: 68px; }
  .btn-play .icon { width: 28px; height: 28px; }
  .btn-icon.lg { width: 52px; height: 52px; }
  .controls-2 { flex-wrap: nowrap; margin-top: 6px; }
  .controls-2 .btn.sm { padding: 0 10px; font-size: .88rem; min-height: 40px; }
}
@media (hover: hover) and (min-width: 760px) { .kbd-hint { display: block; } }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 24px; max-width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 60px -20px rgb(0 0 0 / .4); }
dialog::backdrop { background: rgb(20 25 24 / .45); }
.dialog-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ---------- done ---------- */
.done { padding-top: 16px; }
.done-art { width: 120px; margin: 24px auto 0; }
.done-bg { fill: var(--tint); }
.done-frond { fill: none; stroke: var(--brand); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 1.6s ease-out .2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h1 { max-width: 22ch; margin-inline: auto; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 18px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 10px; text-align: center; }
.stats dt { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.stats dd { margin: 2px 0 0; font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; overflow-wrap: break-word; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr 1fr; } .stats div:last-child { grid-column: 1 / -1; } }
.done .card { margin-bottom: 14px; }
.week-msg { font-weight: 600; }
.feedback .pills { margin: 10px 0; }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }

/* ---------- progress ---------- */
.progress-grid { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .progress-grid { grid-template-columns: 1fr 1.2fr; } }
.goal-line strong { color: var(--brand-strong); }
.goal-ring { position: relative; width: 120px; height: 120px; margin: 8px 0; }
.goal-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.goal-ring .ring-bg, .goal-ring .ring { stroke-width: 10; }
.goal-ring span { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 38px; gap: 1px; font-size: 1.1rem; color: var(--ink-2); }
.goal-ring strong { font-family: var(--font-head); font-size: 1.9rem; color: var(--ink); }
.goal-form { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.goal-form label, .inline-field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
select, input[type='time'] { min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 12px; font-weight: 500; }
select:hover, input[type='time']:hover { border-color: var(--brand); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; }
.cal-dow, .cal { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow li { font-size: .78rem; color: var(--ink-2); font-weight: 700; padding-bottom: 4px; }
.cal-day { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; font-weight: 600; font-size: .92rem; color: var(--ink-2); max-height: 56px; }
.cal-day i { position: absolute; bottom: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.cal-day.some { background: var(--brand-soft); color: var(--ink); }
.cal-day.met { background: var(--brand); color: var(--on-brand); }
.cal-day.met i { background: var(--on-brand); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-legend { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-left: 8px; }
.swatch.some { background: var(--brand-soft); border: 1px solid var(--brand); margin-left: 0; }
.swatch.met { background: var(--brand); }
.month-sum { margin-top: 8px; font-weight: 600; }
.stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-n { font-family: var(--font-head); font-size: 2.2rem; font-weight: 600; line-height: 1.1; }
.stat-n.small { font-size: 1.5rem; }
.stat-l { color: var(--ink-2); font-size: .92rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .qtitle { margin: 0; }
.list-row .tiny { margin: 0; }
.empty { color: var(--ink-2); display: flex; gap: 8px; align-items: center; }

/* ---------- saved ---------- */
.routine-cards { list-style: none; padding: 0; margin: 10px 0 28px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.routine-card { display: flex; flex-direction: column; padding: 20px; }
.routine-card .meta { font-size: .92rem; margin-bottom: 6px; }
.routine-card .tiny { margin-bottom: 4px; }
.card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 12px; align-items: center; }
.card-actions [data-action='fav'] { margin-left: auto; }

/* ---------- settings ---------- */
.settings-sec { margin-bottom: 16px; }
.settings-sec h2 { display: flex; gap: 10px; align-items: center; }
.settings-sec h2 .icon { color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.stack[disabled] { opacity: .55; }
.callout { background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px; margin-top: 16px; font-size: .96rem; }
.callout.warn { background: var(--accent-soft); }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s; }
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--focus); outline-offset: 2px; }
.inline-field select, .inline-field input { max-width: 280px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .done-frond { stroke-dashoffset: 0; }
}

/* copy-text dialog (used instead of file downloads) */
.text-dialog textarea { width: 100%; margin-top: 6px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); padding: 10px; font: 0.82rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.text-dialog { width: min(560px, calc(100vw - 32px)); max-width: none; }

body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 25; background: var(--bg); }
