:root {
  --bg: #ffffff; --bg2: #f5f5f5; --bg3: #e5e5ea; --text: #1d1d1f; --text2: #6e6e73;
  --border: rgba(60, 60, 67, .18); --danger: #d70015; --go: #248a3d; --go-bg: rgba(52, 199, 89, .18); --stop-bg: rgba(255, 59, 48, .16);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --control: 48px; --r-card: 28px; --r-group: 20px; --r-pill: 999px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --bg2: #1c1c1e; --bg3: #2c2c2e; --text: #f5f5f7; --text2: #98989d; --border: rgba(84, 84, 88, .6); --danger: #ff453a; --go: #30d158; --go-bg: rgba(48, 209, 88, .2); --stop-bg: rgba(255, 69, 58, .2); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
main { max-width: 560px; margin: 0 auto; padding: var(--s5) var(--s4) calc(var(--control) + var(--s7) + env(safe-area-inset-bottom)); }
header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: 0 0 var(--s4); }
h1 { font-family: var(--display); font-size: 34px; line-height: 41px; letter-spacing: -.022em; margin: 0; }
h2 { font-size: 13px; line-height: 18px; font-weight: 400; text-transform: uppercase; color: var(--text2); margin: var(--s5) var(--s4) var(--s2); }
section[hidden], [hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.big { font-family: var(--display); font-size: clamp(34px, 12vw, 52px); white-space: nowrap; line-height: 1; font-weight: 700; letter-spacing: -.035em; text-align: center; margin: var(--s5) 0; }
.sub { color: var(--text2); font-size: 15px; line-height: 20px; text-align: center; margin: var(--s2) 0; }
svg.face { display: block; width: min(320px, 80vw); height: auto; margin: 0 auto; }
.face .rim { fill: var(--bg2); }
.face .tick { stroke: var(--text2); stroke-linecap: round; }
.face .hand { stroke: var(--text); stroke-linecap: round; }
.face .sec { stroke: var(--accent); stroke-linecap: round; }
.face .hub { fill: var(--accent); }
.face text { fill: var(--text); font: 300 14px var(--font); text-anchor: middle; dominant-baseline: central; }
.group { background: var(--bg2); border-radius: var(--r-group); margin: var(--s2) 0 var(--s4); overflow: hidden; }
.row { display: flex; align-items: center; gap: var(--s3); min-height: var(--s7); padding: var(--s3) var(--s4); }
.row + .row { border-top: .5px solid var(--border); }
.row.tap { cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .label { font-size: 17px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; line-height: 18px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { font-size: 28px; font-weight: 300; white-space: nowrap; }
.row .time.xl { font-size: 48px; font-weight: 200; line-height: 1.05; }
.row.off .time, .row.off .meta { color: var(--text2); }
.row.best .label, .row.best .num { color: var(--go); }
.row.worst .label, .row.worst .num { color: var(--danger); }
.controls { display: flex; gap: var(--s3); justify-content: space-between; margin: var(--s4) 0; }
.controls.center { justify-content: center; flex-wrap: wrap; }
button, input, select { font: inherit; font-size: 17px; height: var(--control); border-radius: var(--r-pill); border: 0; }
button { padding: 0 var(--s5); background: var(--bg2); color: var(--text); cursor: pointer; min-width: 120px; }
button.primary { background: var(--accent); color: #fff; }
button.go { background: var(--go-bg); color: var(--go); }
button.stop { background: var(--stop-bg); color: var(--danger); }
button.danger { color: var(--danger); }
button.link { background: none; color: var(--accent); min-width: 0; padding: 0 var(--s2); }
button.icon { min-width: 0; padding: 0 var(--s4); height: 32px; font-size: 15px; }
button:disabled { opacity: .4; cursor: default; }
input, select { padding: 0 var(--s4); background: var(--bg2); color: var(--text); min-width: 0; width: 100%; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.form { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.form > * { flex: 1 1 120px; }
/* iOS switch */
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; padding: 0; border-radius: 31px; background: var(--bg3); position: relative; cursor: pointer; transition: background .2s; }
input.switch::before { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .2s; }
input.switch:checked { background: #34c759; }
input.switch:checked::before { transform: translateX(20px); }
/* day chips */
.days { display: flex; gap: var(--s1); justify-content: space-between; margin: var(--s2) 0 var(--s4); }
.days button { min-width: 0; flex: 1; height: 40px; padding: 0; font-size: 15px; }
.days button[aria-pressed="true"] { background: var(--accent); color: #fff; }
/* sheets */
dialog { border: 0; padding: var(--s5) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); width: 100%; max-width: 560px; margin: auto auto 0; border-radius: var(--r-card) var(--r-card) 0 0; background: var(--bg); color: var(--text); }
@media (min-width: 600px) { dialog { margin: auto; border-radius: var(--r-card); } }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog header { margin-bottom: var(--s4); }
dialog h1 { font-size: 17px; line-height: 22px; font-weight: 600; }
dialog label { display: block; font-size: 13px; color: var(--text2); margin: var(--s3) var(--s4) var(--s1); }
dialog .row label { margin: 0; font-size: 17px; color: var(--text); }
input[type="time"].wheel { font-size: 48px; font-weight: 200; height: 72px; text-align: center; background: var(--bg2); }
/* full screen views */
.full { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); padding: var(--s5); background: var(--bg); text-align: center; }
.full .when { font-size: min(24vw, 120px); font-weight: 200; line-height: 1; }
.full .what { font-size: 22px; line-height: 28px; color: var(--text2); }
.full .controls { width: min(100%, 360px); flex-direction: column; }
.full .controls button { width: 100%; }
#stand { background: #000; color: #fff; cursor: pointer; user-select: none; }
#stand .when { font-size: min(30vw, 50vh); font-weight: 200; }
#stand .what { color: #98989d; font-size: 17px; white-space: nowrap; }
#stand.night { color: #ff3b30; }
#stand.night .what { color: #8a1f1a; }
/* timers */
.ring { flex: none; width: 56px; height: 56px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .track { stroke: var(--bg3); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .3s linear; }
.stack { display: flex; flex-direction: column; gap: var(--s1); }
.stack button { height: 28px; font-size: 13px; padding: 0 var(--s3); }
.pick { display: flex; gap: var(--s2); align-items: center; }
.pick select { text-align: center; font-size: 22px; height: 56px; }
.pick span { color: var(--text2); font-size: 15px; }
.toast { position: fixed; left: 50%; top: calc(var(--s4) + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 20; background: var(--text); color: var(--bg); padding: var(--s3) var(--s5); border-radius: var(--r-pill); font-size: 15px; white-space: nowrap; }
nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--s4) + env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: var(--s1); border-radius: var(--r-pill); width: min(calc(100% - 2 * var(--s4)), 528px);
  background: color-mix(in srgb, var(--bg2) 80%, transparent); backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%); border: .5px solid var(--border);
}
nav button { flex: 1 1 auto; min-width: 0; height: 40px; padding: 0 var(--s2); background: transparent; color: var(--text2); font-size: clamp(12px, 3.6vw, 14px); letter-spacing: -.01em; }
nav button[aria-current="page"] { background: var(--bg); color: var(--accent); }
.empty { color: var(--text2); text-align: center; padding: var(--s5); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
