:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #eeece7;
  --text: #1b1c1f;
  --muted: #6b6d73;
  --line: #dddad3;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1d2025;
    --surface-2: #272a31;
    --text: #eceae6;
    --muted: #9a9ca3;
    --line: #2f333b;
    --accent: #f97316;
    --accent-ink: #1a0d03;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --surface: #1d2025; --surface-2: #272a31; --text: #eceae6; --muted: #9a9ca3;
  --line: #2f333b; --accent: #f97316; --accent-ink: #1a0d03; --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 6px;
  max-width: 560px; margin: 0 auto;
}
.brand { font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.sync { font-size: 13px; color: var(--muted); }
.sync.pending { color: var(--warn); }

main { max-width: 560px; margin: 0 auto; padding: 0 16px 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 16px 4px; font-weight: 600; color: var(--muted);
}
.tabs button.on { color: var(--accent); }

h1 { font-size: 26px; margin: 8px 0 2px; line-height: 1.15; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 10px 0;
}

/* week strip */
.weeks { display: flex; gap: 6px; margin: 10px 0 4px; }
.weeks .w {
  flex: 1; text-align: center; padding: 6px 0; border-radius: 10px; background: var(--surface-2);
  font-size: 13px; color: var(--muted);
}
.weeks .w b { display: block; font-size: 15px; color: var(--text); }
.weeks .w.now { outline: 2px solid var(--accent); outline-offset: -2px; }
.weeks .w.past { opacity: .55; }

/* lift chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 9px 14px; font-weight: 600; min-height: 44px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.done { color: var(--muted); text-decoration: line-through; }

/* sets */
.set {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none;
  padding: 12px 0; text-align: left; min-height: 56px;
}
.set:last-child { border-bottom: 0; }
.set .tick {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.set.ok .tick { background: var(--good); border-color: var(--good); color: var(--surface); }
.set .kg { font-size: 22px; font-weight: 700; }
.set .kg small { font-size: 14px; color: var(--muted); font-weight: 500; }
.set .pct { color: var(--muted); font-size: 14px; }

.amrap { padding-top: 12px; }
.amrap-head { display: flex; justify-content: space-between; align-items: baseline; }
.stepper { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }
.stepper button {
  width: 56px; height: 56px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 26px; font-weight: 700;
}
.stepper .val { font-size: 40px; font-weight: 800; min-width: 64px; text-align: center; }
.stepper .unit { color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); }
.hint.bad { color: var(--bad); font-weight: 600; }
.hint.good { color: var(--good); font-weight: 600; }

.dots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dot {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: none;
  font-weight: 700; color: var(--muted);
}
.dot.ok { background: var(--good); border-color: var(--good); color: var(--surface); }

.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

textarea, input[type=number], input[type=text], input[type=password], select {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px;
  padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 16px; font-weight: 700;
  font-size: 17px; background: var(--accent); color: var(--accent-ink); margin-top: 12px; min-height: 52px;
}
.btn.ghost { background: none; color: var(--muted); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.btn:disabled { opacity: .5; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 8px 0; min-height: 44px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .r { color: var(--muted); font-size: 14px; text-align: right; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.f { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.up { color: var(--good); }
.badge.down { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }

.spark { width: 100%; height: 56px; display: block; margin: 6px 0; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark circle { fill: var(--accent); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  max-width: calc(100% - 32px);
}
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
[hidden] { display: none !important; }
