:root {
  --bg: #0e1116;
  --card: #181c24;
  --card2: #20252f;
  --line: #2c323e;
  --text: #eef1f5;
  --muted: #9aa3b2;
  --accent: #c6f432;
  --accent-ink: #12160a;
  --run: #2fd27a;
  --walk: #3b9cff;
  --warm: #ffb02e;
  --danger: #ff5d5d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { 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, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

#view {
  max-width: 560px; margin: 0 auto;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 90px);
}

/* ---------- tabs ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: rgba(14,17,22,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
#tabs button {
  flex: 1; background: none; border: 0; padding: 8px 0 10px;
  color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#tabs button .ti { font-size: 18px; line-height: 1.2; }
#tabs button.on { color: var(--accent); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: 18px; padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.hero { padding: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 99px; background: var(--card2); color: var(--muted);
}
.pill.accent { background: var(--accent); color: var(--accent-ink); }
.pill.run { background: rgba(47,210,122,.15); color: var(--run); }
.pill.warn { background: rgba(255,176,46,.15); color: var(--warm); }

.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.topbar h1 { font-size: 28px; }
.countdown { text-align: right; }
.countdown b { font-size: 28px; display: block; line-height: 1; color: var(--accent); }

.wo-title { font-size: 26px; font-weight: 800; margin: 8px 0 4px; }
.wo-sub { color: var(--muted); }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px;
  background: var(--card2); font-weight: 700; font-size: 17px; text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); font-size: 20px; padding: 18px; }
.btn.ghost { background: none; border: 1px solid var(--line); }
.btn.danger { background: rgba(255,93,93,.14); color: var(--danger); }
.btn.sm { padding: 10px 14px; font-size: 15px; width: auto; display: inline-block; }
.btns { display: flex; gap: 8px; }
.btns > .btn { flex: 1; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }

/* week strip on Today */
.wk-list { list-style: none; margin: 0; padding: 0; }
.wk-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-top: 1px solid var(--line);
}
.wk-item:first-child { border-top: 0; }
.wk-item .day { width: 44px; text-align: center; font-size: 12px; color: var(--muted); }
.wk-item .day b { display: block; font-size: 18px; color: var(--text); }
.wk-item .what { flex: 1; min-width: 0; }
.wk-item .what div:first-child { font-weight: 600; }
.wk-item.today .day b { color: var(--accent); }
.status { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; border: 2px solid var(--line); flex: none; }
.status.done { background: var(--run); border-color: var(--run); color: #062; font-weight: 900; }
.status.skip { border-style: dashed; color: var(--muted); }
.status.missed { border-color: var(--warm); color: var(--warm); }
.tap { background: none; border: 0; width: 100%; text-align: left; padding: 0; color: inherit; }
.card.tap { background: var(--card); border: 1px solid var(--line); padding: 16px; }

/* plan screen */
.week-card h3 { font-size: 17px; }
.week-card.current { border-color: var(--accent); }
.week-card.past { opacity: .75; }
.progress { height: 8px; background: var(--card2); border-radius: 9px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }

/* log */
.log-item { display: flex; gap: 12px; align-items: flex-start; }
.log-item .feel { font-size: 26px; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 22px; }

/* forms */
label.f { display: block; margin-top: 12px; font-size: 14px; color: var(--muted); }
label.f input, label.f select, label.f textarea {
  display: block; width: 100%; margin-top: 5px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card2); font-size: 17px;
}
textarea { resize: vertical; min-height: 70px; }
.feel-pick { display: flex; justify-content: space-between; margin-top: 6px; }
.feel-pick button {
  font-size: 30px; background: var(--card2); border: 2px solid transparent; border-radius: 14px;
  width: 19%; padding: 6px 0;
}
.feel-pick button.on { border-color: var(--accent); background: rgba(198,244,50,.12); }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.switch:first-of-type { border-top: 0; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.daypick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 6px; }
.daypick button {
  background: var(--card2); border: 2px solid transparent; border-radius: 10px; padding: 7px 0;
  font-size: 12px; color: var(--muted);
}
.daypick button b { display: block; font-size: 16px; color: var(--text); }
.daypick button.on { border-color: var(--accent); }
.daypick button.today b { color: var(--accent); }

/* ---------- bottom sheet ---------- */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  padding: 10px 18px calc(var(--safe-b) + 18px);
  max-width: 560px; margin: 0 auto;
  animation: up .18s ease-out;
}
#sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--safe-b) + 84px); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; max-width: 90vw;
}

/* ---------- timer ---------- */
#timer {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 18px calc(var(--safe-b) + 16px);
  transition: background .3s;
}
#timer[hidden] { display: none; }
#timer.ph-run { background: #0b2a1a; }
#timer.ph-walk { background: #0b1d33; }
#timer.ph-warmup, #timer.ph-cooldown { background: #2a1e07; }
#timer.paused { background: #1a1a1a; }
.t-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 15px; }
.t-main { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-height: 0; }
.t-phase { font-size: clamp(56px, 19vw, 120px); font-weight: 900; letter-spacing: .02em; line-height: 1; }
.ph-run .t-phase { color: var(--run); }
.ph-walk .t-phase { color: var(--walk); }
.ph-warmup .t-phase, .ph-cooldown .t-phase { color: var(--warm); font-size: clamp(44px, 14vw, 96px); }
.paused .t-phase { color: var(--muted); }
.t-clock { font-size: clamp(84px, 30vw, 190px); font-weight: 800; line-height: 1; margin: 6px 0; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.t-rep { font-size: 22px; font-weight: 700; }
.t-next { font-size: 18px; color: var(--muted); margin-top: 10px; }
.t-goal { font-size: 17px; color: var(--muted); margin-top: 8px; }
.t-bar { height: 10px; background: rgba(255,255,255,.1); border-radius: 9px; overflow: hidden; margin: 12px 0 6px; }
.t-bar i { display: block; height: 100%; background: var(--text); opacity: .85; }
.t-totals { display: flex; justify-content: space-between; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.t-ctrl { display: flex; gap: 10px; margin-top: 14px; }
.t-ctrl .btn { flex: 1; width: auto; padding: 20px 10px; font-size: 18px; background: rgba(255,255,255,.1); }
.t-ctrl .btn.big { flex: 2; background: var(--text); color: var(--bg); font-size: 22px; }
.t-ctrl .btn.finish { flex: 2; background: var(--accent); color: var(--accent-ink); }
.t-warn { background: rgba(255,176,46,.15); color: var(--warm); border-radius: 12px; padding: 8px 12px; font-size: 14px; margin-top: 8px; text-align: center; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
a { color: var(--accent); }
