:root {
  color-scheme: light dark;
  --bg: light-dark(#f3f3f0, #15171a);
  --card: light-dark(#ffffff, #202328);
  --line: light-dark(#d5d5cf, #363a41);
  --text: light-dark(#191b1e, #f0f0ec);
  --muted: light-dark(#5d6168, #a3a8b0);
  --accent: #f5c430;
  --on-accent: #191b1e;
  --data: light-dark(#9a7200, #bd8f0c);
  --danger: light-dark(#b3261e, #ff8a80);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  max-width: 560px; margin: 0 auto;
  /* keep clear of the Dynamic Island; #tabs does the same for the home indicator */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--bg); color: var(--text);
  font: 17px/1.4 system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; touch-action: manipulation;
}
main { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px 24px; }
h1 { font-size: 1.7rem; line-height: 1.15; margin: 4px 0 12px; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.num, input { font-variant-numeric: tabular-nums; }

button, input, select {
  font: inherit; color: inherit; min-height: 48px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 0 14px;
}
button { cursor: pointer; font-weight: 600; user-select: none; -webkit-user-select: none; }
button:active { opacity: .7; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h2:focus { outline: none; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.danger { color: var(--danger); }
.wide { display: block; width: 100%; min-height: 56px; margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }

#tabs { display: flex; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; min-height: 56px; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: .9rem; padding: 0; border-top: 3px solid transparent; }
#tabs button[aria-current] { color: var(--text); border-top-color: var(--accent); }

dialog { width: 100%; max-width: 560px; margin: auto auto 0; padding: 0; border: 0; border-radius: 18px 18px 0 0; background: var(--bg); color: var(--text); max-height: 88dvh; }
dialog::backdrop { background: rgb(0 0 0 / .55); }
.sheet { padding: 4px 16px calc(env(safe-area-inset-bottom) + 20px); }
.toast { position: fixed; inset: calc(env(safe-area-inset-top) + 12px) 16px auto; z-index: 9; padding: 14px 16px; border-radius: var(--radius); background: var(--text); color: var(--bg); text-align: center; }

#dock:not(:empty) { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--card); }
#dock p { margin: 4px 0; }
#dock button, #dock input { background-color: var(--bg); }
#dock .primary { background: var(--accent); }
#dock .log { min-height: 56px; min-width: 50%; }
#dock .row input { min-height: 56px; }

.stepper { display: flex; gap: 8px; margin: 8px 0; }
.stepper button { width: 76px; min-height: 56px; font-size: 1.7rem; padding: 0; }
.stepper label { flex: 1; min-width: 0; position: relative; }
.stepper input { width: 100%; height: 100%; text-align: center; font-size: 1.7rem; font-weight: 700; padding: 0 44px; }
.stepper span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .88rem; pointer-events: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.choices { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.choices button { flex: 1 0 auto; padding: 0 6px; font-size: .85rem; }
.choices [aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.current { border-color: var(--accent); }
.card-head { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 52px; padding: 10px 14px; line-height: 1.25; border: 0; background: none; text-align: left; }
.grow { flex: 1; min-width: 0; }
.count { color: var(--muted); }
.count.done { background: var(--accent); color: var(--on-accent); border-radius: 8px; padding: 1px 8px; }
.card-body { padding: 0 14px 4px; }
.card-body p { margin: 0 0 6px; }
.sets { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; }
.sets:empty { display: none; }
.set { background: var(--bg); text-align: left; }

.countdown { font-size: 5rem; font-weight: 800; line-height: 1; text-align: center; letter-spacing: -.02em; }
progress { display: block; width: 100%; height: 8px; margin: 12px 0; appearance: none; border: 0; border-radius: 4px; overflow: hidden; background: var(--line); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
#dock .next { text-wrap: balance; text-align: center; margin: 0 0 12px; }
.timer-buttons button { min-height: 60px; font-size: 1.1rem; }

summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 56px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ''; width: 9px; height: 9px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); margin: 0 4px 4px; }
[open] > summary::after { transform: rotate(225deg); margin: 4px 4px 0; }
details .card-body { padding-bottom: 14px; }
h3 { font-size: 1rem; margin: 14px 0 4px; }

.stats > div { display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); padding: 10px 14px; }
.stats b { font-size: 1.35rem; }
.readout { min-height: 1.4em; }
.chart { display: block; width: 100%; touch-action: pan-y; }
.chart text { fill: var(--muted); font-size: 12px; }
.grid { stroke: var(--line); }
.cross { stroke: var(--muted); }
.line { fill: none; stroke: var(--data); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--data); stroke: var(--bg); stroke-width: 2; }
table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: .92rem; }
th, td { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
th:last-child, td:last-child { text-align: right; }

.item { gap: 6px; margin-bottom: 8px; }
.left { text-align: left; }
.icon { width: 48px; padding: 0; flex: none; }
:disabled { opacity: .35; }
.field { display: block; flex: 1; min-width: 0; margin: 10px 0; color: var(--muted); font-size: .88rem; }
.field input { display: block; width: 100%; margin-top: 4px; color: var(--text); font-size: 1.06rem; }
.check { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.check input { width: 26px; height: 26px; min-height: 0; accent-color: var(--accent); }

.alarm {
  position: fixed; inset: 0; z-index: 10; width: 100%; border: 0; border-radius: 0;
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: var(--accent); color: var(--on-accent); animation: flash 1s steps(1) infinite;
}
.alarm b { font-size: 4.5rem; line-height: 1; font-weight: 800; }
.alarm span { font-size: 1.3rem; text-wrap: balance; }
/* One flash a second: noticeable across a room, and under the limit for photosensitivity. */
@keyframes flash { 50% { background: #15171a; color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } }

.reminder { background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 14px 14px; margin-bottom: 16px; }
