@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(/fonts/barlow-400.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(/fonts/barlow-500.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(/fonts/barlow-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url(/fonts/barlow-700.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(/fonts/barlowc-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 800; font-display: swap; src: url(/fonts/barlowc-800.woff2) format('woff2'); }

/* ---------- tokens ---------- */
:root {
  --bg: #f5f5f2;
  --surface: #ebebe6;
  --ink: #0f1012;
  --ink-2: #66655f;
  --ink-3: #a3a29b;
  --line: #e0dfd9;
  --accent: #d4f34a;
  --on-accent: #0f1012;
  --fig: #0f1012;
  --prop: #d6d5ce;
  --floor: #c9c8c0;
  --danger: #c4372f;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --r: 4px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d0f; --surface: #18191c; --ink: #f2f2ee; --ink-2: #9b9a94; --ink-3: #5c5b57; --line: #222327;
    --fig: #f2f2ee; --prop: #2a2b2f; --floor: #34353a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0d0f; --surface: #18191c; --ink: #f2f2ee; --ink-2: #9b9a94; --ink-3: #5c5b57; --line: #222327;
  --fig: #f2f2ee; --prop: #2a2b2f; --floor: #34353a; color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
main { max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 20px calc(96px + env(safe-area-inset-bottom)); }
body.in-workout main { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
p, ul, ol, h1 { margin: 0; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button:disabled { opacity: .3; pointer-events: none; }

.ic { width: 22px; height: 22px; flex: none; display: block; }
.ic.faint { color: var(--ink-3); width: 18px; height: 18px; }
.grow { flex: 1; min-width: 0; }

/* ---------- type ---------- */
.title { font: 800 40px/1 var(--display); text-transform: uppercase; letter-spacing: -.005em; }
.title.xl { font-size: 72px; }
.sub { color: var(--ink-2); font-size: 15px; margin-top: 8px; }
.eyebrow { color: var(--ink-2); font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.caption { color: var(--ink-3); font-size: 13px; margin-top: 10px; }

/* ---------- layout ---------- */
.head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; margin-bottom: 8px; }
.date { font-size: 15px; font-weight: 500; color: var(--ink-2); }
.icon-link, .back { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 -11px; color: var(--ink); }
.sec { margin-top: 40px; }
.sec.tight { margin-top: 32px; }
.head + .sec { margin-top: 12px; }

/* ---------- buttons ---------- */
.primary, .secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 56px; padding: 0 20px; border: 0; border-radius: var(--r); cursor: pointer;
  font: 700 17px/1 var(--body);
}
.primary { background: var(--accent); color: var(--on-accent); margin-top: 28px; }
.primary.soft { background: var(--ink); color: var(--bg); }
.secondary { height: 48px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 15px; }
.quiet { display: block; width: 100%; margin-top: 6px; padding: 14px; border: 0; background: none; color: var(--ink-2); font-size: 15px; font-weight: 500; cursor: pointer; }
.quiet.danger { color: var(--danger); margin-top: 32px; }
.text { background: none; border: 0; padding: 10px 0; cursor: pointer; font-size: 15px; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.text .ic { width: 16px; height: 16px; }
.text.strong { font-weight: 700; }
.sq {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--r); background: transparent; color: var(--ink-3);
}
.sq .ic { width: 22px; height: 22px; }
.primary:active, .secondary:active, .sq:active { transform: scale(.98); }

/* ---------- week ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { display: flex; flex-direction: column; gap: 8px; }
.day i { height: 6px; border-radius: 1px; background: var(--line); }
.day.on i { background: var(--accent); }
.day span { font-size: 12px; font-weight: 600; color: var(--ink-3); text-align: center; }
.day.today span { color: var(--ink); }
.week-meta { margin-top: 14px; font-size: 15px; color: var(--ink-2); display: flex; align-items: center; flex-wrap: wrap; }
.week-meta b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.sep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); margin: 0 10px; }

/* ---------- today ---------- */
.ex-names { color: var(--ink-2); font-size: 15px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.notice { display: flex; align-items: center; gap: 12px; margin-top: 32px; padding: 16px 0; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); }
.notice b { color: var(--ink); font-weight: 600; display: block; }
.notice .ic:first-child { color: var(--ink); }

/* ---------- figures ---------- */
.fig { width: 100%; height: 100%; display: block; cursor: pointer; }
.fig .floor { stroke: var(--floor); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.fig .prop { fill: var(--prop); }
.fig .prop-line { stroke: var(--prop); stroke-width: var(--psw, 5px); stroke-linecap: round; vector-effect: non-scaling-stroke; }
.thumb .fig { --psw: 2px; }
.fig .near *, .fig .far * { fill: none; stroke: var(--fig); stroke-width: var(--sw, 7px); stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.thumb .fig { --sw: 2.6px; }
.fig .near circle { fill: var(--fig); stroke-width: 0; }
.fig .far { opacity: .22; }
.fig .weight { fill: var(--accent); stroke: var(--fig); stroke-width: 1.2; }
.fig .towel { stroke: var(--fig); stroke-width: 1.5; fill: none; stroke-dasharray: 3 3; }
.fig .slider { fill: var(--accent); }
.fig.paused { opacity: .5; }
.stage { position: relative; display: block; aspect-ratio: 220 / 120; background: var(--surface); border-radius: var(--r); overflow: hidden; margin: 4px 0 24px; }
.stage > span { position: absolute; inset: 0; display: block; }

/* ---------- workout ---------- */
.wo-head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.clock { font: 600 17px/1 var(--display); letter-spacing: .04em; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.steps { display: flex; gap: 4px; margin: 4px 0 16px; }
.steps button { flex: 1; height: 20px; padding: 8px 0; border: 0; background: none; cursor: pointer; }
.steps button::before { content: ''; display: block; height: 3px; border-radius: 1px; background: var(--line); }
.steps button.done::before { background: var(--ink-3); }
.steps button.cur::before { background: var(--ink); }
.ex-title .title { font-size: 36px; }
.ex-meta { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.ex-links { display: flex; gap: 18px; }
.ex-links .text { color: var(--ink); font-size: 14px; padding: 6px 0; }
.ex-title .sub { margin-top: 6px; }
.stage.short { aspect-ratio: 2.3; margin: 18px 0 8px; }
.sets { margin-top: 12px; }
.set { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.set-n { width: 18px; font: 600 15px/1 var(--display); color: var(--ink-3); }
.cell { flex: 1; min-width: 0; display: flex; align-items: center; height: 52px; padding: 0 14px; border-radius: var(--r); background: var(--surface); }
.cell input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); outline: none; font: 800 26px/1 var(--display); font-variant-numeric: tabular-nums; padding: 0; }
.cell input::placeholder { color: var(--ink-3); }
.cell span { font-size: 13px; color: var(--ink-3); }
.cell:focus-within { box-shadow: inset 0 0 0 1.5px var(--ink); }
.set.done .cell { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.set.done .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.set.done .set-n { color: var(--ink); }
.set.running .sq[data-act="watch"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.add { color: var(--ink-2); font-weight: 500; margin-top: 4px; }
.wo-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 8px;
  max-width: 520px; margin: 0 auto; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--bg);
}
.wo-nav .primary { margin: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; line-height: 56px; text-align: center; }
.wo-nav .ghost { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: var(--r); background: none; cursor: pointer; }

/* rest */
.rest {
  position: fixed; left: 20px; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; z-index: 20;
  background: var(--ink); color: var(--bg); border-radius: var(--r); overflow: hidden; animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.rest-line { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); transform-origin: left; transition: transform .25s linear; }
.rest-inner { display: flex; align-items: center; gap: 18px; padding: 12px 16px 14px; }
.rest-inner .grow { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.rest-time { font: 800 34px/1 var(--display); font-variant-numeric: tabular-nums; }
.rest-next { font-size: 14px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest .text { color: inherit; }
.rest.go { background: var(--accent); color: var(--on-accent); }

/* ---------- done ---------- */
.finished { padding-top: 48px; }
.done-mark { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); margin-bottom: 24px; }
.done-mark .ic { width: 28px; height: 28px; stroke-width: 2.4; }
.plain { list-style: none; padding: 0; }
.plain li { padding: 12px 0; border-top: 1px solid var(--line); font-size: 15px; }
.plain li:first-child { border-top: 0; padding-top: 0; }

/* ---------- lists ---------- */
.list { list-style: none; padding: 0; border-top: 1px solid var(--line); }
.list li > a, .list li > div { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list b { display: block; font-weight: 600; font-size: 16px; }
.list small { display: block; color: var(--ink-2); font-size: 14px; margin-top: 1px; }
.list .val { font: 600 16px/1 var(--display); letter-spacing: .02em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.thumb { width: 60px; height: 40px; flex: none; display: block; border-radius: var(--r); background: var(--surface); overflow: hidden; }

/* ---------- exercise detail ---------- */
.head + .stage { margin-top: 0; }
.steps-list { padding-left: 20px; }
.steps-list li { padding: 6px 0 6px 6px; }
.steps-list li::marker { color: var(--ink-3); font-weight: 600; }
.avoid { margin-top: 18px; font-size: 15px; color: var(--ink-2); }
.avoid b { color: var(--ink); font-weight: 600; }
.ext { margin-top: 14px; }
.level { display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.level b { display: block; font-weight: 600; }
.level small { display: block; color: var(--ink-2); font-size: 14px; }
.level .sq { color: var(--ink); }
.level .sq.hot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- progress ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 12px; }
.stats div { display: flex; flex-direction: column; gap: 6px; }
.stats b { font: 800 48px/.9 var(--display); font-variant-numeric: tabular-nums; }
.stats span { font-size: 14px; color: var(--ink-2); }
.heat { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heat i { display: block; aspect-ratio: 1; border-radius: 1px; background: var(--line); }
.heat i.on { background: var(--accent); }

/* ---------- settings ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line); }
.sec.tight > .setting:first-child { border-top: 1px solid var(--line); }
.setting > span { font-weight: 500; }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--surface); border-radius: var(--r); }
.seg button { border: 0; background: transparent; min-width: 42px; height: 34px; padding: 0 8px; border-radius: 3px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 6px 0 4px; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: grid; place-items: center; height: 42px; border-radius: var(--r); background: var(--surface); font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.days input:checked + span { background: var(--ink); color: var(--bg); }
.days input:focus-visible + span { outline: 2px solid var(--ink); }
.time { font: 600 17px/1 var(--body); background: var(--surface); color: var(--ink); border: 0; border-radius: var(--r); padding: 8px 10px; }
.sec .secondary { margin-top: 14px; }
.inline { display: flex; gap: 8px; }
.inline .secondary { margin-top: 0; }
.inline input + .secondary { width: auto; flex: none; padding: 0 22px; }
.inline input { flex: 1; min-width: 0; height: 48px; border: 0; border-radius: var(--r); background: var(--surface); color: var(--ink); padding: 0 14px; font: inherit; font-size: 16px; }
.status { margin-left: 6px; font-size: 13px; color: var(--ink-3); }
.status.ok { color: var(--ink); }
.status.error { color: var(--danger); }

/* ---------- nav + toast ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 8px;
  background: var(--bg); border-top: 1px solid var(--line); padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
}
.nav:empty { display: none; }
.nav a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--ink-3); font-size: 12px; font-weight: 600; }
.nav a.on { color: var(--ink); }
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: 14px; font-weight: 600; white-space: nowrap;
}

@media (max-width: 360px) {
  main { padding-left: 16px; padding-right: 16px; }
  .title { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
