:root {
  --bg: #121417;
  --card: #1c1f24;
  --card-2: #252a31;
  --text: #f1f2f4;
  --muted: #9aa1ab;
  --line: #2e343c;
  --accent: #ff7a45;
  --accent-text: #1a0d06;
  --good: #3ecf8e;
  --easy: #5aa9ff;
  --hard: #ff5d6c;
  --radius: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --card-2: #eceef1;
    --text: #15171a;
    --muted: #5f6670;
    --line: #dde0e5;
    --accent: #e85d24;
    --accent-text: #ffffff;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); }
.loading { color: var(--muted); padding-top: 40vh; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--card-2);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-height: 48px;
  touch-action: manipulation;
}
button:active, .btn:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.big { width: 100%; min-height: 64px; font-size: 20px; font-weight: 700; }
.ghost { background: transparent; color: var(--muted); padding: 8px 10px; min-height: 40px; }
.link { background: transparent; color: var(--accent); padding: 8px 0; min-height: 40px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.banner { background: var(--card-2); border-radius: 12px; padding: 10px 14px; font-size: 14px; color: var(--muted); }
.banner.warn { color: var(--text); border-left: 4px solid var(--accent); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; min-height: 48px; }
.topbar .title { font-weight: 700; text-align: center; flex: 1; font-size: 15px; }

.exlist { list-style: none; padding: 0; margin: 8px 0 0; }
.exlist li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.exlist li:first-child { border-top: 0; }

/* workout */
.media {
  border-radius: var(--radius);
  background: var(--card);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media img, .media video { width: 100%; height: 100%; object-fit: contain; }
.media .placeholder { font-size: 64px; font-weight: 800; color: var(--line); }
.exname { margin-top: 16px; }
.dots { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--card-2); }
.dot.done { background: var(--accent); }
.setline { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; font-weight: 600; }
.cues { margin: 0; padding-left: 20px; }
.cues li { margin: 4px 0; }
.why { white-space: pre-line; font-size: 15px; }

.panel { margin-top: 20px; }
.counter { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
.counter button { width: 64px; height: 64px; font-size: 30px; border-radius: 50%; }
.counter .value { font-size: 56px; font-weight: 800; min-width: 120px; text-align: center; font-variant-numeric: tabular-nums; }
.counter .unit { font-size: 18px; color: var(--muted); font-weight: 600; }
.ratings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ratings button { min-height: 64px; font-weight: 700; flex-direction: column; gap: 0; }
.ratings .r-easy { background: color-mix(in srgb, var(--easy) 22%, var(--card)); }
.ratings .r-good { background: color-mix(in srgb, var(--good) 22%, var(--card)); }
.ratings .r-hard { background: color-mix(in srgb, var(--hard) 22%, var(--card)); }
.ratings small { font-weight: 400; font-size: 12px; color: var(--muted); }

.timer { font-size: 88px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; margin: 8px 0 14px; }
.timer.reached { color: var(--good); }
.bar { height: 8px; background: var(--card-2); border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.25s linear; }

.rest {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; gap: 16px; text-align: center;
}
.rest .timer { font-size: 110px; }
.rest .row { width: 100%; max-width: 400px; }
.rest .row button { flex: 1; }

.hist-day { padding: 12px 0; border-top: 1px solid var(--line); }
.hist-day:first-child { border-top: 0; }
.hist-ex { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; padding: 2px 0; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); }
