:root {
  --bg: #0b0e11;
  --surface: #14191f;
  --raised: #1b222a;
  --line: #2a333d;
  --line-soft: rgba(42, 51, 61, .68);
  --text: #f4f7f8;
  --muted: #9aa6b2;
  --mint: #72ddb3;
  --mint-ink: #092018;
  --danger: #ffb4a9;
  --radius: 15px;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4; }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .38; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { width: 100%; max-width: 430px; min-height: 100vh; margin: 0 auto; padding: 0 18px 116px; }
body.rest-active .app-shell { padding-bottom: 192px; }
body.rest-active.toast-visible .app-shell { padding-bottom: 244px; }
.app-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line-soft); }
.wordmark { min-height: 48px; padding: 0; border: 0; background: none; font-size: 15px; font-weight: 780; letter-spacing: -.02em; }
.save-state { max-width: 158px; color: var(--muted); font-size: 12px; text-align: right; }
.save-state.saved { color: var(--mint); }
main { padding-top: 25px; }

.kicker { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: break-word; }
h1 { margin: 0; font-size: clamp(29px, 8vw, 36px); line-height: 1.04; letter-spacing: -.045em; }
h2 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: -.025em; }
h3 { margin: 0; font-size: 16px; line-height: 1.2; letter-spacing: -.015em; }
.lede { max-width: 34ch; margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.text-button { min-height: 48px; padding: 0 3px; border: 0; background: transparent; color: var(--mint); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.primary, .secondary, .danger-button {
  min-height: 50px; padding: 0 16px; border-radius: 12px; font-weight: 760;
}
.primary { border: 0; background: var(--mint); color: var(--mint-ink); }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.accent-outline { border-color: rgba(114, 221, 179, .62); color: var(--mint); }
.danger-button { border: 1px solid rgba(255, 180, 169, .28); background: transparent; color: var(--danger); }
.full { width: 100%; }
.primary:active, .secondary:active { transform: translateY(1px); }

.start-card { margin-top: 27px; padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.start-card h2 { font-size: 24px; }
.start-meta { display: flex; gap: 18px; margin: 12px 0 21px; color: var(--muted); font-size: 14px; }
.movement-preview { margin: 0 0 22px; padding: 0; list-style: none; counter-reset: movement; }
.movement-preview li { display: flex; min-height: 47px; align-items: center; gap: 12px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.movement-preview li::before { counter-increment: movement; content: counter(movement, decimal-leading-zero); color: #697583; font-size: 11px; font-variant-numeric: tabular-nums; }
.recent-line { margin-top: 20px; color: var(--muted); font-size: 13px; }

.session-head { margin-bottom: 24px; }
.session-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.session-meta { display: flex; gap: 10px; align-items: center; margin: 11px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.dot::before { content: "·"; margin-right: 10px; }
.progress-track { height: 3px; margin-top: 18px; overflow: hidden; border-radius: 99px; background: var(--raised); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--mint); transition: width .2s ease; }

.exercise-card { position: relative; margin: 0 -4px; padding: 22px 4px 18px; border-top: 1px solid var(--line); }
.exercise-card.superset { padding-left: 13px; border-left: 2px solid var(--mint); }
.exercise-card.superset + .exercise-card { padding-left: 13px; border-left: 2px solid rgba(114,221,179,.32); }
.exercise-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.exercise-head .subline { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.pair-cue { margin: 7px 0 0; color: var(--mint); font-size: 12px; font-weight: 680; }
.more-button { flex: 0 0 auto; min-width: 48px; min-height: 48px; margin: -12px -4px 0 0; padding: 0 4px; border: 0; background: transparent; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.note { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13px; }

.set-table { margin-top: 17px; }
.set-head, .set-row { display: grid; grid-template-columns: 30px minmax(70px,.9fr) minmax(65px,1fr) minmax(58px,.72fr) 50px; column-gap: 7px; align-items: center; }
.set-head { min-height: 27px; color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: .06em; text-transform: uppercase; }
.set-head span:nth-child(n+3) { text-align: center; }
.set-row { min-height: 62px; border-top: 1px solid var(--line-soft); }
.set-row.done .set-index { color: var(--mint); }
.set-variant-note { margin: 8px 0 -1px 30px; color: var(--mint); font-size: 10px; font-weight: 720; letter-spacing: .02em; }
.set-index { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.warmup-mark { color: var(--mint); font-weight: 780; }
.previous-cell { overflow: hidden; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.set-input-wrap { position: relative; min-width: 0; }
.set-input {
  width: 100%; height: 48px; padding: 2px 4px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text);
  font-size: 16px; font-weight: 680; text-align: center; font-variant-numeric: tabular-nums;
}
.set-input:hover, .set-input:focus { border-color: var(--line); background: var(--raised); }
.set-input[aria-invalid="true"] { border-color: var(--danger); }
.unit-hint { position: absolute; right: 4px; bottom: 2px; color: var(--muted); font-size: 9px; pointer-events: none; text-transform: uppercase; }
.done-button { justify-self: end; width: 48px; height: 48px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 12px; font-weight: 780; }
.set-row.done .done-button { border-color: rgba(114,221,179,.48); background: rgba(114,221,179,.12); color: var(--mint); }
.set-actions { display: flex; gap: 4px; margin-top: 8px; }
.set-actions button { min-height: 48px; padding: 0 11px; border: 0; background: transparent; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.set-actions button:first-child { margin-left: 30px; }
.exercise-history { margin-top: 13px; }
.exact-attempt { padding: 11px 12px; border-radius: 11px; background: var(--surface); color: var(--muted); font-size: 12px; }
.exact-attempt strong { color: var(--text); font-weight: 700; }
.related-attempts { margin-top: 7px; }
.related-attempts summary { min-height: 48px; display: flex; align-items: center; color: var(--muted); cursor: pointer; font-size: 12px; }
.related-attempts ul { margin: -4px 0 8px; padding: 0 0 0 16px; color: var(--muted); font-size: 12px; }
.add-exercise { width: 100%; min-height: 54px; margin: 8px 0 15px; border: 1px dashed #3b4652; border-radius: 13px; background: transparent; color: var(--muted); font-weight: 680; }
.finish-button { width: 100%; min-height: 56px; margin-top: 5px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-weight: 760; }

.routine-form { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.field-stack { display: block; margin-bottom: 15px; }
.field-label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.routine-form input, .sheet textarea, .sheet select {
  width: 100%; min-height: 50px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--raised); color: var(--text);
}
.sheet textarea { resize: vertical; }
.routine-number-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.routine-list { margin: 24px 0 0; padding: 0; list-style: none; }
.routine-item { min-height: 72px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.routine-main { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; min-height: 52px; }
.routine-number { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.routine-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.routine-item button { min-width: 48px; min-height: 48px; padding: 0; border: 0; background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }
.routine-defaults { margin: 8px 0 0 30px; border-top: 1px solid var(--line-soft); }
.routine-default-row { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 8px; min-height: 55px; align-items: center; color: var(--muted); font-size: 11px; }
.routine-default-row + .routine-default-row { border-top: 1px solid rgba(42,51,61,.42); }
.routine-default-row label { position: relative; min-width: 0; }
.routine-set-input { width: 100%; height: 48px; padding: 2px 4px 11px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text); font-size: 16px; font-weight: 680; text-align: center; font-variant-numeric: tabular-nums; }
.routine-set-input:hover, .routine-set-input:focus { border-color: var(--line); background: var(--raised); }
.routine-set-input[aria-invalid="true"] { border-color: var(--danger); }
.routine-default-row small { position: absolute; right: 4px; bottom: 3px; color: var(--muted); font-size: 8px; pointer-events: none; }
.routine-raw-unit { color: var(--text); font-size: 12px; }
.routine-item .set-actions { margin: 0 0 0 45px; }
.routine-item .set-actions button:first-child { margin-left: 0; }
.pair-label { color: var(--mint); }

.history-list { display: grid; gap: 12px; }
.history-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.history-card summary { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; cursor: pointer; list-style: none; }
.history-card summary::-webkit-details-marker { display: none; }
.history-card summary::after { content: "Open"; color: var(--mint); font-size: 12px; font-weight: 700; }
.history-card[open] summary::after { content: "Close"; }
.history-date { margin: 0; font-weight: 740; }
.history-summary { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.history-detail { padding: 0 16px 16px; border-top: 1px solid var(--line-soft); }
.history-exercise { padding-top: 14px; }
.history-exercise + .history-exercise { margin-top: 13px; border-top: 1px solid var(--line-soft); }
.history-sets { margin: 7px 0 0; color: var(--text); font-size: 13px; font-weight: 630; font-variant-numeric: tabular-nums; }
.history-actions { display: flex; gap: 8px; margin-top: 15px; }
.history-actions button { flex: 1; }
.by-exercise { margin-top: 35px; }
.by-exercise > h2 { margin-bottom: 14px; }
.movement-history { margin-top: 10px; }
.comparison-label { margin: 15px 0 7px; color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.comparison-label.related { padding-top: 14px; border-top: 1px solid var(--line-soft); }
.comparison-row { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid rgba(42,51,61,.42); font-size: 12px; }
.comparison-row time { color: var(--muted); }
.comparison-row strong { color: var(--text); font-weight: 630; font-variant-numeric: tabular-nums; }
.empty { padding: 30px 18px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

.summary-hero { padding: 21px; border: 1px solid rgba(114,221,179,.28); border-radius: 18px; background: linear-gradient(145deg, rgba(114,221,179,.09), var(--surface) 44%); }
.summary-hero > button + button { margin-top: 8px; }
.summary-numbers { display: grid; grid-template-columns: repeat(3, 1fr); margin: 24px 0; }
.summary-numbers div + div { border-left: 1px solid var(--line); padding-left: 14px; }
.summary-numbers strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.summary-numbers span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.tab-bar { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 430px; margin: auto; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(11,14,17,.96); backdrop-filter: blur(12px); }
.tab-bar button { min-height: 53px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.tab-bar button[aria-current="page"] { background: var(--surface); color: var(--mint); }

.rest-bar { position: fixed; z-index: 24; right: 12px; bottom: 79px; left: 12px; width: calc(100% - 24px); max-width: 406px; min-height: 62px; margin: auto; padding: 8px 9px 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgba(114,221,179,.32); border-radius: 14px; background: var(--raised); box-shadow: 0 16px 40px rgba(0,0,0,.45); }
.rest-label { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
#restTime { display: block; font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rest-actions { display: flex; gap: 2px; }
.rest-actions button { min-width: 48px; min-height: 48px; padding: 0 8px; border: 0; background: transparent; color: var(--mint); font-size: 12px; font-weight: 700; }

.toast { position: fixed; z-index: 50; right: 18px; bottom: 91px; left: 18px; width: calc(100% - 36px); max-width: 394px; min-height: 50px; margin: auto; padding: 8px 9px 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); box-shadow: 0 16px 40px rgba(0,0,0,.5); font-size: 13px; }
body.rest-active.toast-visible .toast { bottom: 153px; }
body.keyboard-open .tab-bar,
body.keyboard-open .rest-bar { display: none; }
body.keyboard-open .app-shell { padding-bottom: 36px; }
.toast button { min-height: 48px; padding: 0 8px; border: 0; background: transparent; color: var(--mint); font-weight: 760; text-decoration: underline; text-underline-offset: 4px; }

dialog { color: var(--text); }
.sheet-dialog { width: min(430px, 100%); max-width: 430px; max-height: min(86vh, 760px); margin: auto 0 0; padding: 0; border: 0; border-radius: 20px 20px 0 0; background: var(--raised); }
.sheet-dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(2px); }
.sheet { padding: 9px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 18px; border-radius: 99px; background: #586572; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.sheet-copy { margin: 10px 0 20px; color: var(--muted); }
.sheet-section { margin: 22px 0; padding-top: 20px; border-top: 1px solid var(--line); }
.button-grid, .scope-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scope-actions { margin-top: 9px; }
.sheet .secondary.full, .sheet .danger-button.full { margin-top: 8px; }
.movement-list { margin: 0; padding: 0; border: 0; }
.movement-list button { display: flex; width: 100%; min-height: 62px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; }
.movement-list button span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.movement-list button::after { content: "Add"; color: var(--mint); font-size: 12px; font-weight: 760; }
.timer-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.timer-choices button { min-height: 58px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 760; font-variant-numeric: tabular-nums; }
.timer-choices button.current { border-color: var(--mint); color: var(--mint); }

@media (min-width: 431px) {
  body { background: linear-gradient(90deg, #090c0f, var(--bg) 28%, var(--bg) 72%, #090c0f); }
  .app-shell { min-height: 900px; box-shadow: 0 0 0 1px rgba(42,51,61,.45), 0 30px 90px rgba(0,0,0,.34); }
  .sheet-dialog { margin-left: calc(50% - 215px); }
}
@media (max-width: 360px) {
  .set-head, .set-row { grid-template-columns: 24px 58px minmax(58px,1fr) minmax(52px,.72fr) 46px; column-gap: 4px; }
  .previous-cell { font-size: 10px; }
  .scope-actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
