:root {
  --bg: #F7F7F1; --card: #FFFEFA; --well: #F1F4EC; --sage: #E6EDE4; --line: #DCE3D8;
  --ink: #233D33; --sub: #5C7065; --faint: #8A9A8F;
  --pine: #29473C; --pine-ink: #FFFFFF; --pine-press: #1E372D;
  --amber: #6E4A2A; --amber-bg: #FBF1E1; --amber-line: #EAD7B8;
  --red: #8A1C1C; --red-bg: #FDEDEA; --red-line: #EDC1BB;
  --fig: #3E6350; --fig-2: #AFC1B1; --fig-cue: #C08A4E; --fig-prop: #E3E9DF;
  --focus: #7FA58A; --shadow: 0 1px 2px rgba(30, 55, 45, .04), 0 10px 30px rgba(30, 55, 45, .05);
  --r-card: 22px; --r-ctl: 15px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1512; --card: #17201B; --well: #1C2621; --sage: #22302A; --line: #2B3932;
    --ink: #E6EEE7; --sub: #A2B3A8; --faint: #78897E;
    --pine: #4E7D63; --pine-ink: #FFFFFF; --pine-press: #436D56;
    --amber: #F0CDA0; --amber-bg: #2A2117; --amber-line: #4A3A27;
    --red: #FFB4AB; --red-bg: #2C1513; --red-line: #5A2A25;
    --fig: #A9CDB4; --fig-2: #4C6455; --fig-cue: #E0A868; --fig-prop: #26332C;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
body.locked { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- page ---------- */
#root { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 104px); }
.date { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--faint); }
.large { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: .2px; margin: 2px 0 0; }

/* iOS large-title header */
.nav-large { margin: 4px 4px 18px; }
.nav-meta { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.nav-row .large { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif; letter-spacing: .37px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: linear-gradient(150deg, #5E8A72, var(--pine)); color: #fff; font-size: 15px; font-weight: 600; display: grid; place-items: center; box-shadow: 0 1px 2px rgba(20, 40, 30, .12); }
.avatar:active { opacity: .7; }
.nav-sub { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--sub); font-size: 15px; line-height: 1.3; }
.ring { width: 22px; height: 22px; flex: none; }
.ring circle { fill: none; stroke-width: 3.5; }
.ring .track { stroke: var(--sage); }
.ring .prog { stroke: var(--pine); stroke-linecap: round; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ring .prog { stroke: var(--fig); } }
.tag-demo { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); background: var(--amber-bg); border-radius: 6px; padding: 2px 6px; }
.navbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; height: calc(env(safe-area-inset-top) + 44px); padding-top: env(safe-area-inset-top); display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; color: var(--ink); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-bottom: .5px solid transparent; opacity: 0; pointer-events: none; transition: opacity .18s ease, border-color .18s ease; }
.navbar.show { opacity: 1; border-bottom-color: var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 20px; margin-bottom: 14px; }
.card.quiet { background: var(--well); box-shadow: none; }
.card.amber { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); box-shadow: none; }
.card.red { background: var(--red-bg); border-color: var(--red-line); color: var(--red); box-shadow: none; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 0 0 6px; }
.amber .eyebrow, .red .eyebrow { color: inherit; opacity: .8; }
h2.title { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.2px; margin: 0 0 6px; }
h3.head { font-size: 17px; font-weight: 650; margin: 0 0 4px; }
p { margin: 0 0 10px; }
.sub { color: var(--sub); font-size: 15px; }
.amber .sub, .red .sub { color: inherit; }
.fine { color: var(--faint); font-size: 13px; line-height: 1.4; }
.section-label { font-size: 13px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin: 22px 8px 8px; }

/* ---------- buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border-radius: var(--r-ctl); font-weight: 650; font-size: 17px; padding: 12px 18px; transition: transform .12s ease, background .12s ease; }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--pine); color: var(--pine-ink); }
.btn-primary:active { background: var(--pine-press); }
.btn-primary:disabled { opacity: .4; }
.btn-soft { background: var(--sage); color: var(--ink); }
.btn-red { background: var(--red); color: var(--red-bg); }
.btn-plain { color: var(--sub); min-height: 44px; font-weight: 600; font-size: 15px; }
.btn + .btn { margin-top: 10px; }
.link { color: var(--pine); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; font-size: 15px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .link { color: var(--fig); } }
.row-btns { display: flex; gap: 10px; margin-top: 10px; }
.row-btns > * { flex: 1; margin: 0 !important; }

/* ---------- list rows ---------- */
.list { margin: 14px -4px 16px; display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--well); border-radius: 16px; padding: 8px 12px 8px 8px; min-height: 60px; }
.thumb { width: 64px; height: 40px; flex: none; border-radius: 10px; background: var(--card); display: grid; place-items: center; overflow: hidden; }
.thumb .fig { width: 64px; height: 36px; }
.item .name { font-weight: 600; font-size: 16px; line-height: 1.25; }
.item .amt { color: var(--sub); font-size: 14px; }
.item .tag { margin-left: auto; font-size: 12px; font-weight: 650; color: var(--sub); white-space: nowrap; }
.item .tag.ok { color: var(--fig); }

.rows { margin: 4px 0 0; padding: 0; list-style: none; }
.rows li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.rows li:last-child { border-bottom: 0; }
.rows .k { color: var(--sub); }
.dots { margin: 6px 0 0; padding-left: 20px; }
.dots li { margin: 6px 0; font-size: 15px; }

/* ---------- choices ---------- */
.choices { display: grid; gap: 10px; margin: 18px 0 8px; }
.choice { text-align: left; min-height: 56px; padding: 14px 16px; border-radius: var(--r-ctl); background: var(--card); border: 1.5px solid var(--line); font-size: 17px; font-weight: 550; display: flex; align-items: center; gap: 10px; }
.choice[aria-pressed="true"] { border-color: var(--pine); background: var(--sage); }
.choice .hint { display: block; font-size: 14px; font-weight: 400; color: var(--sub); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0 6px; }
.days .choice { padding: 0; justify-content: center; min-height: 46px; font-size: 15px; }
.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 18px 0 6px; }
.scale .choice { justify-content: center; padding: 0; font-variant-numeric: tabular-nums; font-size: 19px; }
.scale-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--sub); }
.field { width: 100%; min-height: 52px; padding: 13px 15px; border-radius: var(--r-ctl); border: 1.5px solid var(--line); background: var(--card); font-size: 17px; }
textarea.field { min-height: 96px; resize: vertical; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; font-size: 15px; }
.toggle:last-child { border-bottom: 0; }
.box { width: 26px; height: 26px; flex: none; border-radius: 8px; border: 1.5px solid var(--faint); display: grid; place-items: center; }
.toggle[aria-checked="true"] .box { background: var(--pine); border-color: var(--pine); }
.toggle[aria-checked="true"] .box::after { content: ""; width: 7px; height: 12px; border: solid var(--pine-ink); border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

/* ---------- figures ---------- */
.fig { width: 100%; height: auto; display: block; }
.fig polyline, .fig line, .fig path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig-near, .fig-body { stroke: var(--fig); stroke-width: 6; }
.fig-far { stroke: var(--fig-2); stroke-width: 6; }
.fig-head { fill: var(--fig); }
.fig-ground { stroke: var(--line); stroke-width: 2; }
.fig-prop { fill: var(--fig-prop); stroke: var(--fig-2); stroke-width: 2; }
.fig-cue { stroke: var(--fig-cue); stroke-width: 2.5; fill: none; }
.stage { background: var(--well); border-radius: var(--r-card); padding: 22px 18px 14px; margin: 6px 0 18px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px); border-top: .5px solid var(--line); padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); }
.tabbar-in { display: flex; justify-content: space-around; max-width: 560px; margin: 0 auto; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 50px; padding-top: 4px; font-size: 11px; font-weight: 600; color: var(--faint); }
.tab[aria-current="page"] { color: var(--pine); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tab[aria-current="page"] { color: var(--fig); } }
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- full-screen flows and sheets ---------- */
#overlay { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.flow { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 8px) 20px calc(env(safe-area-inset-bottom) + 20px); }
.flow.anim { animation: rise .22s ease-out; }
.flow-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 48px; }
.flow-bar > :first-child { justify-self: start; } .flow-bar > :last-child { justify-self: end; }
.flow-bar .count { font-size: 15px; font-weight: 600; color: var(--sub); }
.progress { height: 4px; border-radius: 4px; background: var(--sage); overflow: hidden; margin: 4px 0 14px; }
.progress > i { display: block; height: 100%; background: var(--pine); border-radius: 4px; transition: width .2s ease; }
.flow-body { flex: 1; }
.flow-body .large { font-size: 30px; margin-bottom: 8px; }
.flow-foot { padding-top: 16px; }
.dose { display: inline-block; background: var(--sage); border-radius: 99px; padding: 6px 12px; font-weight: 650; font-size: 15px; margin: 4px 0 14px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 14px; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; margin: 0 0 12px; font-size: 17px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%; background: var(--sage); color: var(--ink); font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.timer { font-variant-numeric: tabular-nums; }
.stopline { font-size: 15px; color: var(--sub); background: var(--well); border-radius: 14px; padding: 12px 14px; margin: 0 0 6px; }
.split { display: flex; gap: 10px; margin-top: 10px; }
.split > .btn { margin: 0; }
.btn-stop { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-line); }

.urgent h1 { font-size: 32px; line-height: 1.15; margin: 8px 0 12px; color: var(--red); }
.urgent p, .urgent li { font-size: 18px; }

.mark { width: 64px; height: 64px; border-radius: 18px; background: var(--sage); display: grid; place-items: center; margin: 24px 0 22px; color: var(--fig); }
.chart { width: 100%; height: 140px; display: block; margin-top: 8px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--fig); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--card); stroke: var(--fig); stroke-width: 2; }
.chart text { fill: var(--faint); font-size: 11px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.cal span { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-size: 13px; color: var(--faint); background: var(--well); font-variant-numeric: tabular-nums; }
.cal .done { background: var(--sage); color: var(--ink); font-weight: 650; }
.cal .stop { background: var(--amber-bg); color: var(--amber); font-weight: 650; }
.cal .now { box-shadow: inset 0 0 0 2px var(--pine); color: var(--ink); font-weight: 700; }
.pre { white-space: pre-wrap; font-size: 15px; line-height: 1.5; background: var(--well); border-radius: 16px; padding: 16px; margin: 0 0 14px; user-select: text; -webkit-user-select: text; }
.phase { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.phase:last-child { border-bottom: 0; }
.phase .n { width: 30px; height: 30px; border-radius: 10px; background: var(--sage); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.phase.on .n { background: var(--pine); color: var(--pine-ink); }
.phase h3 { margin: 2px 0 2px; font-size: 16px; }
.phase p { margin: 0; font-size: 14px; color: var(--sub); }
.toast { margin: 12px 0 0; font-size: 15px; color: var(--fig); font-weight: 600; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* tap-to-play figure */
button.stage { display: block; width: 100%; text-align: center; cursor: pointer; }
.fig-box { display: block; }
.stage-hint { display: block; font-size: 13px; color: var(--faint); margin-top: 4px; }
/* on/off switch, iOS style */
.switch { margin-left: auto; flex: none; width: 51px; height: 31px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s ease; }
.switch span { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.18); transition: transform .15s ease; }
.switch[aria-checked="true"] { background: var(--pine); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

/* figure body */
:root { --f-shirt: #6E957C; --f-pants: #2B473B; --f-skin: #E0BC9E; --f-hair: #4A3426; --f-shoe: #8C9A90; --f-mat: #D5E0D2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --f-shirt: #7FA98D; --f-pants: #4F7A64; --f-skin: #D2AD8E; --f-hair: #2E211A; --f-shoe: #9AA89E; --f-mat: #2A3A31; }
}
.fig .f-shirt { fill: var(--f-shirt); } .fig .f-pants { fill: var(--f-pants); } .fig .f-skin { fill: var(--f-skin); }
.fig .f-hair { fill: var(--f-hair); } .fig .f-shoe { fill: var(--f-shoe); } .fig .fig-mat { fill: var(--f-mat); }
.f-far { opacity: .45; }

/* sign-in forms */
.lbl { display: block; font-size: 15px; font-weight: 600; margin: 16px 2px 6px; }
.form-err { color: var(--red); background: var(--red-bg); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin: 12px 0 0; }
.learn-good { color: var(--fig) !important; font-weight: 600; }
.learn-poor, .learn-resting { color: var(--amber) !important; font-weight: 600; }
.code-box { font: 600 24px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em; text-align: center; background: var(--card); border: 1.5px dashed var(--fig-2); border-radius: 16px; padding: 20px 12px; margin: 18px 0; user-select: all; -webkit-user-select: all; }
.code-field { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; text-transform: uppercase; }
