:root {
  --bg: #0f1214;
  --panel: #181d20;
  --panel-2: #20272b;
  --line: #2b3338;
  --text: #eef2f3;
  --muted: #8d999f;
  --accent: #c8f04a;
  --accent-ink: #14180a;
  --accent-text: #c8f04a;
  --done: #4fd18b;
  --warn: #ffb547;
  --danger: #ff6b5e;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f2;
    --panel: #ffffff;
    --panel-2: #eef1ec;
    --line: #dde2dc;
    --text: #141a16;
    --muted: #66716a;
    --accent: #b4e021;
    --accent-ink: #141a06;
    --accent-text: #4d6b00;
    --done: #1f9d5c;
    --warn: #c77a00;
    --danger: #d23b2e;
    color-scheme: light;
  }
}

* { 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, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app { min-height: 100dvh; }
.view { padding: calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 110px); max-width: 640px; margin: 0 auto; }

/* ---------- header ---------- */
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.h1 { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; margin: 0 0 16px; }
.h2 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 26px 2px 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.h2 small { font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 13px; }
.sync { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--done); margin-left: 8px; vertical-align: middle; }
.sync.pending { background: var(--warn); }

/* week strip */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 8px; }
.strip button { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 0 8px; text-align: center; }
.strip button.sel { border-color: var(--accent); }
.strip .d { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.strip .n { display: block; font-size: 17px; font-weight: 700; }
.strip .dots { display: flex; justify-content: center; gap: 3px; height: 6px; margin-top: 3px; }
.strip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.strip .dot.gym { background: var(--accent); opacity: .5; }
.strip .dot.gym.done { opacity: 1; }
.strip .dot.done { background: var(--done); }
.strip button.today .d { color: var(--accent-text); }
.strip button.past:not(.sel) { opacity: .7; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.note { padding: 12px 14px; font-size: 15px; color: var(--text); border-left: 0; background: var(--panel-2); border-radius: 12px; margin: 10px 0; }
.note b { color: var(--accent-text); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px; width: 100%; text-align: left;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row .tick {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center;
}
.row .tick svg { width: 16px; height: 16px; stroke-width: 3; opacity: 0; }
.row.done .tick { background: var(--done); border-color: var(--done); color: #fff; }
.row.done .tick svg { opacity: 1; }
.row.part .tick { border-color: var(--accent); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 650; font-size: 16px; }
.row .s { color: var(--muted); font-size: 14px; margin-top: 1px; }
.row .s b { color: var(--text); font-weight: 600; }
.row .chev { color: var(--muted); width: 18px; height: 18px; flex: none; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); margin-left: 6px; vertical-align: 2px; }
.tag.coach { background: var(--accent); color: var(--accent-ink); }
.tag.up { background: color-mix(in srgb, var(--done) 25%, transparent); color: var(--done); }
.tag.warn { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 650; font-size: 15px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { width: 100%; min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.empty { color: var(--muted); padding: 16px 14px; font-size: 15px; }

.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.stat { padding: 14px; border-top: 1px solid var(--line); }
.stat:first-child { border-top: 0; }
.stat .top { display: flex; justify-content: space-between; font-weight: 650; }
.stat .top span:last-child { color: var(--muted); font-weight: 600; }

/* week view */
.wday { padding: 12px 14px; border-top: 1px solid var(--line); }
.wday:first-child { border-top: 0; }
.wday .wh { display: flex; justify-content: space-between; font-weight: 700; }
.wday .wh span:last-child { color: var(--muted); font-weight: 600; font-size: 14px; }
.wday.today .wh span:first-child { color: var(--accent-text); }
.wday ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.wday li { padding: 2px 0; }
.wday li.done { color: var(--text); }
.wday li.done::before { content: "✓ "; color: var(--done); font-weight: 700; }
.wday li.plan::before { content: "○ "; }
.wday li.miss { text-decoration: line-through; }

/* progress */
.spark { width: 84px; height: 30px; flex: none; color: var(--accent-text); }
.spark polyline { stroke-width: 2; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 16px calc(var(--safe-b) + 24px);
  animation: up .25s cubic-bezier(.2, .8, .2, 1); max-width: 640px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet .sh { display: flex; align-items: flex-start; gap: 10px; }
.sheet .sh h2 { flex: 1; margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -.01em; }
.sheet .close { width: 36px; height: 36px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; flex: none; }
.sheet .close svg { width: 18px; height: 18px; }
.sheet .sub { color: var(--muted); margin: 6px 0 0; font-size: 15px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.target { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.target .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.target .big { font-size: 26px; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.target .why { color: var(--muted); font-size: 14px; margin-top: 2px; }
.target.coach { border-color: var(--accent); }

.sets { margin-top: 14px; }
.set { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 17px; }
.set .no { width: 50px; color: var(--muted); font-size: 14px; font-weight: 700; }
.set .v { flex: 1; font-weight: 650; }
.set .vs { font-size: 13px; color: var(--muted); }
.set .x { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.set .x svg { width: 16px; height: 16px; }
.set.hit .v { color: var(--done); }

.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stepper { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; }
.stepper .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stepper .ctl { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 4px; }
.stepper button { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--panel-2); font-size: 24px; font-weight: 600; line-height: 1; }
.stepper input {
  width: 100%; min-width: 0; text-align: center; font-size: 26px; font-weight: 800; background: none; border: 0; padding: 0;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper input:focus { outline: none; }

.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-top: 10px; }
.seg button { flex: 1; padding: 10px 0; border-radius: 9px; font-weight: 650; font-size: 15px; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); }

.timer { text-align: center; margin: 22px 0 10px; }
.timer .clock { font-size: 72px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.timer .of { color: var(--muted); margin-top: 6px; }
.timer.hit .clock { color: var(--done); }

.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
.prose { font-size: 15px; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- tabs, rest timer, toast ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 6px 8px calc(var(--safe-b) + 6px); background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 14px; color: var(--muted); font-size: 11px; font-weight: 650; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--accent-text); }

.rest {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 74px); z-index: 30; max-width: 608px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.rest-label { font-weight: 700; }
.rest-time { flex: 1; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rest-btn { padding: 8px 12px; border-radius: 10px; background: rgba(0, 0, 0, .12); font-weight: 700; }
.rest.over { background: var(--done); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 12px); z-index: 40;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
}

.join { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.join .box { width: 100%; max-width: 380px; }
