:root {
  --ground: #f3f6f5;
  --surface: #ffffff;
  --ink: #0e1f1d;
  --muted: #5b6f6d;
  --hair: #d9e2e0;
  --accent: #0d8a80;
  --accent-soft: #e2f1ef;
  --good: #2f9e6f;
  --good-soft: #e4f4ec;
  --warn: #c67a12;
  --warn-soft: #fbf1e2;
  --danger: #c0392b;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(14, 31, 29, .06), 0 10px 30px rgba(14, 31, 29, .07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--ground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
}

/* screens */
.screen { display: none; flex-direction: column; gap: 22px; flex: 1; }
.screen.active { display: flex; }

.eyebrow {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

h1 { font-size: 27px; line-height: 1.12; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 21px; line-height: 1.2; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; }
.lede { color: var(--muted); font-size: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* buttons */
.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 17px 22px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -.01em;
  transition: background .15s ease, transform .08s ease, opacity .15s ease;
  text-align: center;
  width: 100%;
}
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0b7a71; }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--hair); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { width: auto; flex: 1; }

.spacer { flex: 1; }

/* ear selection */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  background: var(--surface);
  border: 2px solid var(--hair);
  border-radius: var(--radius);
  padding: 24px 16px;
  cursor: pointer;
  text-align: center;
  font-weight: 650;
  font-size: 18px;
  color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* notes */
.note {
  font-size: 14px; color: var(--muted); line-height: 1.5;
  padding: 15px 17px; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 12px 12px 0;
}
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note b { color: var(--ink); font-weight: 700; }
.note ul { margin: 8px 0 0; padding-left: 18px; }
.note li { margin: 3px 0; }

/* running step */
.step-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.step-count { font-size: 13px; font-weight: 650; color: var(--muted); letter-spacing: .04em; font-variant-numeric: tabular-nums; }

.posture-wrap { display: flex; justify-content: center; padding: 4px 0; }
.posture { width: 200px; height: 150px; }
.posture .bed { stroke: var(--hair); stroke-width: 4; stroke-linecap: round; }
.posture .body { stroke: var(--accent); stroke-width: 7; stroke-linecap: round; fill: none; }
.posture .head { fill: var(--accent); }
.posture .arrow { stroke: var(--warn); stroke-width: 3.5; fill: none; stroke-linecap: round; }

.instruction { font-size: 19px; line-height: 1.4; }
.instruction .dir { color: var(--accent); font-weight: 700; }

/* status pill */
.pill {
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 600; color: var(--muted);
  padding: 13px 15px; border-radius: 12px; background: var(--ground);
}
.pill.wait { background: var(--accent-soft); color: var(--accent); }
.pill.hold { background: var(--good-soft); color: var(--good); }
.pill .pill-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }

/* hold timer ring */
.timer { display: none; flex-direction: column; align-items: center; gap: 6px; }
.timer.on { display: flex; }
.timer svg { width: 128px; height: 128px; transform: rotate(-90deg); }
.timer .track { fill: none; stroke: var(--hair); stroke-width: 10; }
.timer .prog { fill: none; stroke: var(--good); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .95s linear; }
.timer .count {
  position: absolute; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink);
}
.timer-holder { position: relative; display: flex; align-items: center; justify-content: center; }

/* mini bubble level (assistive) */
.level-mini { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.level-mini canvas { width: 56px; height: 56px; flex: none; }

.foot-note { font-size: 12.5px; color: var(--muted); text-align: center; }
a { color: var(--accent); }

/* the plan (overview) */
.plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.plan li { display: flex; align-items: center; gap: 15px; }
.plan .pn {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
}
.plan b { font-size: 17px; font-weight: 650; }
.plan small { display: block; font-size: 13.5px; color: var(--muted); }

/* subtle text-only controls during the run */
.run-controls { display: flex; justify-content: center; gap: 28px; }
.linkbtn {
  background: none; border: none; font: inherit; cursor: pointer;
  color: var(--muted); font-size: 15px; padding: 10px 8px;
  text-decoration: underline; text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--ink); }
.linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
