:root {
  --bg: #f4f3f0;
  --card: #ffffff;
  --ink: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #f26b1d;
  --accent-soft: #fde7d8;
  --run: #f26b1d;
  --gym: #2f6fde;
  --extra: #16a36a;
  --done: #16a36a;
  --skip: #d23c3c;
  --star: #f5b400;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416; --card: #1f1f23; --ink: #f4f4f5; --muted: #a1a1aa; --line: #2e2e33;
    --accent-soft: #3a2416; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141416; --card: #1f1f23; --ink: #f4f4f5; --muted: #a1a1aa; --line: #2e2e33;
  --accent-soft: #3a2416; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px; max-width: 640px; margin: 0 auto;
}
.top h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; }
.stars-chip {
  background: var(--card); border-radius: 999px; padding: 4px 12px; font-weight: 600;
  box-shadow: var(--shadow); color: var(--ink);
}
.stars-chip b { color: var(--star); }

main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.pad { padding: 24px 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }

.card {
  background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card.tap { cursor: pointer; }
.card.tap:active { transform: scale(.99); }

.session { display: flex; gap: 12px; align-items: flex-start; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--run); }
.dot.strength { background: var(--gym); }
.dot.extra { background: var(--extra); }
.session .body { flex: 1; min-width: 0; }
.session .t { font-weight: 600; }
.session .meta { color: var(--muted); font-size: 14px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px;
  background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: 1px;
}
.st { font-size: 13px; font-weight: 600; flex: none; }
.st.done { color: var(--done); }
.st.skipped { color: var(--skip); }
.st.dropped { color: var(--muted); }

.hero { padding: 18px; }
.hero .t { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.hero .meta { margin: 2px 0 10px; }
.desc { white-space: pre-line; color: var(--ink); font-size: 15px; }
.ex { list-style: none; padding: 0; margin: 10px 0 0; }
.ex li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.ex li span:last-child { color: var(--muted); white-space: nowrap; }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn {
  border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 600;
  background: var(--line); color: var(--ink);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--skip); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }

.day-h { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 4px 6px; }
.day-h b { font-size: 15px; }
.day-h.today b { color: var(--accent); }
.rest { color: var(--muted); font-size: 14px; padding: 2px 4px 6px; }

.nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.nav button { border: 0; background: var(--card); width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--shadow); font-size: 18px; }
.nav .mid { text-align: center; }
.nav .mid b { display: block; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.focus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
label.f { display: block; font-size: 13px; color: var(--muted); }
select, input, textarea {
  width: 100%; margin-top: 4px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 10px; padding: 9px 10px; font-size: 16px;
}

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal .c {
  background: var(--card); border-radius: 10px; min-height: 54px; padding: 4px; border: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px; box-shadow: var(--shadow);
}
.cal .c.out { opacity: .35; }
.cal .c.today { outline: 2px solid var(--accent); }
.cal .c .n { font-size: 13px; font-weight: 600; }
.cal .dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--run); }
.cal .dots i.strength { background: var(--gym); }
.cal .dots i.extra { background: var(--extra); }
.cal .dots i.done { box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--done); }
.cal .dots i.skipped { opacity: .3; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 13px; color: var(--muted); margin: 10px 0; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.big { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1; white-space: nowrap; flex: none; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--card); border-radius: 14px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 22px; }
.kpi span { font-size: 12px; color: var(--muted); }
.weeks { display: flex; flex-wrap: wrap; gap: 6px; }
.weeks span { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--card); font-size: 12px; color: var(--muted); box-shadow: var(--shadow); }
.weeks span.star { color: var(--star); font-size: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 500; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(86px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(242,107,29,.4);
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabs button { border: 0; background: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 12px; }
.tabs button span { font-size: 18px; }
.tabs button.on { color: var(--accent); }

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 4px 0 2px; font-size: 22px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 500; z-index: 30;
  max-width: calc(100% - 32px);
}
.hint { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }

.offline {
  max-width: 640px; margin: 0 auto 8px; padding: 6px 12px; text-align: center; font-size: 13px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border-radius: 0;
}
input.code { font-size: 28px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
code { font-size: 13px; background: var(--line); border-radius: 6px; padding: 1px 5px; }
