:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #5b6875;
  --border: #d9e0e6;
  --accent: #1f7a6d;
  --accent-text: #ffffff;
  --danger: #b4372f;
  --notice-bg: #fff4dc;
  --notice-text: #5a4100;
  --ph-contract: #d1495b;
  --ph-hold: #d1495b;
  --ph-release: #e89a6b;
  --ph-rest: #8fa3b3;
  --ph-move: #3a7ca5;
  --ph-breathe: #4f9d8a;
  --ring-track: #e3e8ec;
  --radius: 16px;
  --tap: 52px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --surface: #18232e;
    --text: #e8eef3;
    --muted: #9aaab8;
    --border: #2a3846;
    --accent: #3fb5a3;
    --accent-text: #06231f;
    --danger: #ef6f66;
    --notice-bg: #3a2f12;
    --notice-text: #f6e2b0;
    --ph-contract: #ef6f7e;
    --ph-hold: #ef6f7e;
    --ph-release: #f2ad83;
    --ph-rest: #6f8496;
    --ph-move: #64a6cf;
    --ph-breathe: #6cc2ad;
    --ring-track: #24323f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1 { font-size: 1.6rem; margin: 8px 0 0; }
h2 { font-size: 1.15rem; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

button {
  font: inherit;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
}
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); min-height: 44px; padding: 8px 0; text-align: left; }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.hero button.primary { min-height: 64px; font-size: 1.15rem; }
.notice { background: var(--notice-bg); color: var(--notice-text); border-radius: 12px; padding: 12px 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > button { flex: 1 1 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.toggles { display: flex; gap: 10px; }
.toggles button { flex: 1; }
ol, ul { margin: 0; padding-left: 1.2rem; }
li + li { margin-top: 6px; }

/* --- session --- */
.session { flex: 1; justify-content: space-between; }
.session-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.session-head .name { font-weight: 600; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1; justify-content: center; }
.dial { width: min(78vw, 320px); aspect-ratio: 1; position: relative; }
.dial svg { width: 100%; height: 100%; display: block; }
.dial .track { fill: none; stroke: var(--ring-track); stroke-width: 6; }
.dial .ring { fill: none; stroke: var(--phase, var(--accent)); stroke-width: 6; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.dial .blob { fill: var(--phase, var(--accent)); opacity: 0.85; }
.dial .count { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(3rem, 16vw, 4.5rem); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.phase-label { font-size: clamp(1.6rem, 8vw, 2.2rem); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; text-align: center; color: var(--phase, var(--text)); }
.phase-hint { text-align: center; min-height: 1.4em; color: var(--muted); }
.meta { text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls .wide { grid-column: 1 / -1; min-height: 64px; font-size: 1.1rem; }

.ph-contract { --phase: var(--ph-contract); }
.ph-hold { --phase: var(--ph-hold); }
.ph-release { --phase: var(--ph-release); }
.ph-rest, .ph-setRest, .ph-sideSwitch { --phase: var(--ph-rest); }
.ph-move, .ph-stretch, .ph-preview { --phase: var(--ph-move); }
.ph-breathe { --phase: var(--ph-breathe); }

.overlay {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10;
}
.overlay .card { width: 100%; max-width: 520px; max-height: 90dvh; overflow: auto; }

.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rating button { padding: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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