:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --fg: #14201d;
  --muted: #5a6b66;
  --accent: #0f766e;
  --accent-fg: #ffffff;
  --line: #d5dfdb;
  --warn-bg: #fff4dc;
  --warn-fg: #7a4a00;
  --bad: #b91c1c;
  --good: #15803d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513;
    --card: #17211e;
    --fg: #e8f0ed;
    --muted: #94a8a1;
    --accent: #2dd4bf;
    --accent-fg: #06201c;
    --line: #2a3833;
    --warn-bg: #3a2c0c;
    --warn-fg: #fbd38d;
    --bad: #f87171;
    --good: #4ade80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 12px 0 4px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none; }
.stack > * + * { margin-top: 12px; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 4px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .small { flex: 0 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

label { display: block; font-weight: 600; font-size: 0.9rem; }
input, select {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  padding: 8px 12px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, nav a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  color: var(--accent-fg);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 12px;
  cursor: pointer;
}
.btn.secondary { color: var(--accent); background: transparent; }
.btn.round { width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 50%; font-size: 1.6rem; }
.btn.small { width: auto; min-height: 40px; padding: 6px 12px; }
.icon-btn { background: none; border: none; color: var(--bad); font-size: 1.3rem; cursor: pointer; min-width: 44px; min-height: 44px; }

.error { color: var(--bad); font-weight: 600; }
.warning { background: var(--warn-bg); color: var(--warn-fg); padding: 10px 12px; border-radius: 12px; text-align: left; }

nav#tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav#tabs[hidden] { display: none; }
nav#tabs a {
  padding: 16px 4px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}
nav#tabs a[aria-current] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

.dots { display: flex; gap: 8px; margin: 8px 0; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--accent); }
.dot.on { background: var(--accent); }
.dot.bonus { border-style: dashed; }
.big { font-size: 2rem; font-weight: 800; line-height: 1.1; }

.timer { font-size: 4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stepper { display: flex; justify-content: center; align-items: center; gap: 20px; }
.value { font-size: 2.5rem; font-weight: 800; min-width: 3ch; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg); border: 1px solid var(--accent); border-radius: 999px; padding: 6px 12px; font-size: 0.9rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
details { text-align: left; }
summary { cursor: pointer; font-weight: 700; padding: 8px 0; }

.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .plan { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 6 4; }
.chart .trend { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linejoin: round; }
.chart .pt { fill: var(--accent); opacity: 0.45; }

.fig { width: 100%; max-width: 360px; height: auto; }
.fig-ground { stroke: var(--line); stroke-width: 3; }
.fig-prop { stroke: var(--muted); stroke-width: 4; fill: none; stroke-linecap: round; }
.fig-limb { stroke: var(--fg); stroke-width: 6; stroke-linecap: round; }
.fig-head { fill: var(--fg); }
.figure { display: flex; justify-content: center; }
.preview-row { display: flex; gap: 8px; }
.preview-row .fig { width: 50%; }

#toasts {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  justify-self: center;
  max-width: 560px;
  padding: 10px 16px;
  color: var(--accent-fg);
  background: var(--accent);
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.warning:empty { display: none; }
