:root {
  --bg: #f4f5f7; --card: #ffffff; --card2: #eef0f3; --text: #15181d; --muted: #5d6573;
  --line: #dde1e7; --accent: #0f8a5f; --accent-ink: #ffffff; --accent-soft: #dff3ea;
  --warn: #9a5b00; --warn-soft: #fff1d6; --danger: #b42318; --danger-soft: #fde7e5;
  --radius: 16px; --tap: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013; --card: #181b20; --card2: #22262d; --text: #eceef2; --muted: #9ba3b0;
    --line: #2c3139; --accent: #3ccf8e; --accent-ink: #062b1b; --accent-soft: #143728;
    --warn: #f3b44c; --warn-soft: #3a2c10; --danger: #ff7b6e; --danger-soft: #3d1714;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --card: #181b20; --card2: #22262d; --text: #eceef2; --muted: #9ba3b0;
  --line: #2c3139; --accent: #3ccf8e; --accent-ink: #062b1b; --accent-soft: #143728;
  --warn: #f3b44c; --warn-soft: #3a2c10; --danger: #ff7b6e; --danger-soft: #3d1714;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
main { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 24px; }
h1 { font-size: 26px; margin: 4px 0 2px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 12px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card.hero { border: 2px solid var(--accent); }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.danger { background: var(--danger-soft); border-color: var(--danger); }
.pill { display: inline-block; white-space: nowrap; font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }

button, .btn {
  font: inherit; font-weight: 600; min-height: var(--tap); padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  touch-action: manipulation; user-select: none;
}
button:active { transform: scale(.98); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
button.block { width: 100%; }
button.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .45; }
.btns { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chips button { min-height: 46px; min-width: 56px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: left;
  min-height: 78px; display: block; width: 100%; font-weight: 400; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tile .v small { font-size: 13px; font-weight: 500; color: var(--muted); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; min-height: 48px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
label.f { display: block; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.check { display: flex; gap: 12px; align-items: center; min-height: var(--tap); padding: 4px 0; cursor: pointer; }
.check input { width: 26px; height: 26px; min-height: 0; accent-color: var(--accent); flex: none; }

.list > * { border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 0; min-height: var(--tap); }
.li .grow p { margin: 0; }

/* meals checklist */
.meal { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; margin: 6px 0;
  min-height: 60px; font-weight: 500; }
.meal .box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.meal.on .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bar { height: 10px; border-radius: 99px; background: var(--card2); overflow: hidden; margin: 4px 0 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* workout */
.ex { padding: 14px; }
.ex.blocked { opacity: .7; }
.setrow { display: grid; grid-template-columns: 26px 1fr 1fr 56px; gap: 8px; align-items: center; margin: 8px 0; }
.setrow .n { color: var(--muted); font-weight: 700; text-align: center; }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; background: var(--card2); border-radius: 12px; border: 1px solid var(--line); }
.stepper button { min-height: 50px; padding: 0; border: 0; background: transparent; font-size: 22px; border-radius: 12px; }
.stepper input { border: 0; background: transparent; text-align: center; padding: 0; min-height: 50px; font-size: 18px; font-weight: 700; }
.stepper .u { display: none; }
.done-btn { min-height: 52px; width: 56px; padding: 0; font-size: 22px; }
.done-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* bottom nav */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
nav.tabs button { border: 0; border-radius: 0; background: transparent; min-height: 62px; flex-direction: column; gap: 2px;
  font-size: 12px; color: var(--muted); font-weight: 600; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--accent); }

/* rest timer bar */
#restbar { position: fixed; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--text); color: var(--bg); border-radius: 16px; padding: 8px 8px 8px 16px; display: none;
  align-items: center; gap: 8px; max-width: 536px; margin: 0 auto; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
#restbar.show { display: flex; }
#restbar .t { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; flex: 1; }
#restbar button { min-height: 46px; background: transparent; color: inherit; border-color: currentColor; }
#restbar.over { background: var(--accent); color: var(--accent-ink); }

/* sheet */
#sheet { position: fixed; inset: 0; z-index: 40; display: none; }
#sheet.show { display: block; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
#sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--card);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.big-num { font-size: 44px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.bigstep { display: grid; grid-template-columns: 72px 1fr 72px; gap: 10px; align-items: center; margin: 10px 0; }
.bigstep button { min-height: 64px; font-size: 28px; }
.bigstep input { text-align: center; font-size: 30px; font-weight: 800; min-height: 64px; }

/* run timer */
.timer { text-align: center; padding: 18px 8px; border-radius: 20px; }
.timer.jog { background: var(--accent); color: var(--accent-ink); }
.timer.walk { background: var(--card2); }
.timer .phase { font-size: 22px; font-weight: 700; }
.timer .clock { font-size: 72px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.seg { display: flex; background: var(--card2); border-radius: 14px; padding: 4px; gap: 4px; margin: 8px 0 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; background: transparent; border-radius: 10px; font-size: 15px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

.chart { width: 100%; height: auto; display: block; }
.toast { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: var(--text);
  color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; font-weight: 600; font-size: 14px; max-width: 90vw; }
table.g { width: 100%; border-collapse: collapse; font-size: 14px; }
.gitem { padding: 10px 0; border-top: 1px solid var(--line); }
.gitem:first-child { border-top: 0; }
.gitem .row input { min-height: 44px; }
.price { max-width: 110px; }
a { color: var(--accent); }
.hidden { display: none !important; }
