.walk-page {
  --surface: #fcfaf6;
  --rust: #973e30;
  --teal: #496664;
  --stage: #181b20;
  line-height: 1.6;
}
:where(.walk-page) button {
  background: #fffdf9;
  border: 1px solid #cfc7bb;
  border-radius: 5px;
  color: var(--ink);
  padding: 6px 11px;
  font-size: .83rem;
  cursor: pointer;
}
:where(.walk-page) button:hover:not(:disabled) { filter: brightness(.94); }
:where(.walk-page) button:disabled { opacity: .48; cursor: default; }
.walk-page input { accent-color: var(--rust); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.page-head { padding: 32px 0 24px; }
.page-head .walk-kicker { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.walk-kicker span { margin-inline: 3px; }
.walk-page h1, .walk-page h2, .walk-page h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
.page-head h1 { font-size: var(--title-size); line-height: 1.3; letter-spacing: -.035em; }
.page-head p { max-width: 66ch; margin: 9px 0 0; color: var(--muted); font-size: 15px; }
.viewer { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stage { position: relative; isolation: isolate; color: #f8f5ee; height: clamp(330px, 55vh, 625px); background: #171a20 var(--live-poster, url('./media/live-poster.webp')) center / contain no-repeat; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: -1; touch-action: none; }
.stage-label, .ball-status { position: absolute; top: 13px; left: 14px; padding: 4px 7px; color: #ece5da; background: #181b20e6; border-radius: 5px; font-size: .76rem; pointer-events: none; }
.ball-status { left: auto; right: 14px; color: #ffd5a2; }
.start { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; width: max-content; max-width: calc(100% - 24px); text-align: center; }
.start button { color: #2f221b; background: #efcfb5; border-color: #efcfb5; font-weight: 650; padding: 8px 18px; }
.start small { max-width: 38ch; color: #f0eae1; text-shadow: 0 1px 8px black; font-size: .74rem; }
.load-progress { width: min(240px, calc(100vw - 72px)); display: grid; gap: 4px; padding: 7px 10px; border-radius: 6px; background: #181b20e6; }
.load-progress progress { width: 100%; height: .7rem; accent-color: #efcfb5; }
.load-progress small { font-variant-numeric: tabular-nums; }
.viewer-dialog { padding: 0; border: 0; margin: 0; max-width: none; max-height: none; width: 100%; height: 100%; background: var(--stage); }
body:has(.viewer-dialog[open]) { overflow: hidden; }
.viewer-dialog::backdrop { background: var(--stage); }
:is(.viewer:fullscreen, .viewer-dialog .viewer) { width: 100%; height: 100%; border: 0; border-radius: 0; display: flex; flex-direction: column; }
:is(.viewer:fullscreen, .viewer-dialog .viewer) .stage { flex: 1; min-height: 0; height: auto; }
:is(.viewer:fullscreen, .viewer-dialog .viewer) .toolbar { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
#full-screen { margin-left: auto; white-space: nowrap; }

.stage-controls { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }
.stage-controls button, .replay-transport button { background: #272b32; border-color: #555c66; color: #f8f5ee; }
.stage-controls button.push:not(:disabled) { border-color: #b38a78; }
.stage:has(.start:not([hidden])) .stage-controls { visibility: hidden; }
.stage :focus-visible, .replay-stage :focus-visible { outline-color: #efcfb5; }
.toolbar, .under-viewer { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.toolbar { padding: 9px 12px; }
.view-controls, .display-controls, .legend { display: flex; align-items: center; gap: 6px; }
.display-controls { flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; }
.display-controls label { display: flex; align-items: center; gap: 4px; }
.under-viewer, .small-note, figcaption { color: var(--muted); font-size: .82rem; }
.under-viewer p { margin: 7px 0; }
.legend span { width: 56px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #d1a39c, #bd6157, #cc261f, #990609); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; border-block: 1px solid var(--line); padding: 9px 0; margin: 4px 0 7px; }
.metrics dt { color: var(--muted); font-size: .77rem; }
.metrics dd { margin: 0; font-variant-numeric: tabular-nums; font-size: clamp(1rem, 2.1vw, 1.35rem); }
.small-note { margin: 5px 0; }
.small-note:empty { display: none; }

.contents { display: flex; flex-wrap: wrap; gap: 7px 23px; margin: 27px 0 0; font-size: .88rem; color: var(--rust); }
.chapter { border-top: 1px solid var(--line); padding: 28px 0 0; margin: 46px 0 0; scroll-margin-top: 18px; }
.walk-page h2 { font-size: clamp(1.66rem, 3.5vw, 2.25rem); letter-spacing: -.032em; line-height: 1.16; }
.walk-page h3 { font-size: clamp(1.19rem, 2.4vw, 1.45rem); line-height: 1.2; letter-spacing: -.02em; }
.lede { max-width: 71ch; margin: 12px 0 23px; font-size: clamp(.94rem, 1.6vw, 1.02rem); }
figure { margin: 0; }
figcaption { margin: 8px 0 0; }
.gait-frames { padding: 0; margin: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.gait-frames li { position: relative; min-width: 0; overflow: hidden; background: var(--stage); }
.gait-frames img { width: 100%; height: auto; aspect-ratio: 1 / 1.02; object-fit: contain; display: block; }
.gait-frames span { position: absolute; top: 5px; left: 8px; color: #efd4be; font-size: .75rem; font-variant-numeric: tabular-nums; }
.gait-frames li:first-child { border-radius: 7px 0 0 7px; }
.gait-frames li:last-child { border-radius: 0 7px 7px 0; }
.muscle-spread { display: grid; grid-template-columns: minmax(0, .93fr) minmax(0, 1.07fr); align-items: center; gap: clamp(22px, 5vw, 63px); margin-top: 27px; }
.ankle-figure img { display: block; width: 100%; height: auto; }
.muscle-copy { max-width: 54ch; }
.muscle-copy p { margin: 9px 0 0; }

.loop-figure { --loop-gap: clamp(22px, 4vw, 46px); margin: 0 0 28px; padding: 12px 0 15px; border-block: 1px solid var(--line); }
.loop-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--loop-gap); }
.loop-buttons button { position: relative; display: grid; align-content: start; min-width: 0; background: var(--surface); border-color: var(--line); padding: 0 0 10px; text-align: left; }
.loop-buttons button:hover:not(:disabled) { filter: none; border-color: #b99180; }
.loop-buttons button[aria-pressed=true] { border-color: #b77969; box-shadow: inset 0 -2px var(--rust); }
.loop-buttons button:not(:last-child)::after { position: absolute; left: calc(100% + 1px); top: 36%; width: var(--loop-gap); color: #786d61; content: '→' / ''; text-align: center; font: 1.2rem var(--serif); pointer-events: none; }
.loop-buttons img { display: block; width: 100%; height: auto; border-radius: 4px 4px 0 0; }
.loop-label { display: block; margin: 9px 11px 0; font-weight: 640; line-height: 1.3; }
.loop-step { color: var(--rust); margin-right: .25em; font-variant-numeric: tabular-nums; font-weight: 500; }
.loop-summary { display: block; margin: 4px 11px 0; color: var(--muted); font-size: .76rem; line-height: 1.3; }
.loop-feedback { position: relative; display: flex; justify-content: center; margin: 0 calc((100% - 2 * var(--loop-gap)) / 6) 12px; padding-top: 14px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 6px 6px; color: var(--muted); font-size: .77rem; text-align: center; }
.loop-feedback::before { content: ''; position: absolute; width: 6px; height: 6px; left: -4px; top: 1px; border-top: 1px solid #8d7c6d; border-left: 1px solid #8d7c6d; transform: rotate(45deg); }
.loop-feedback > span { background: var(--paper); margin: 0 8px -1em; padding: 0 .55em; }
.loop-feedback span[aria-hidden] { color: var(--rust); font-size: 1.05em; }
#loop-detail { max-width: 77ch; min-height: 1.65em; margin-top: 20px; font-size: .92rem; }
.training-steps { list-style: none; padding: 0; margin: 15px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 3vw, 37px); counter-reset: steps; }
.training-steps li { border-top: 1px solid var(--line); padding-top: 9px; counter-increment: steps; }
.training-steps li::before { content: '0' counter(steps); font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--rust); margin-right: .55em; }
.training-steps p, .applications p { margin: 4px 0 0; }
.reading-note { max-width: 74ch; margin: 14px 0 0; color: var(--muted); font-size: .9rem; }

.replay-card { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.replay-stage { min-width: 0; background: #171a20; color: #f6eee4; position: relative; display: flex; flex-direction: column; justify-content: space-between; }
.replay-stage video { width: 100%; display: block; aspect-ratio: 8 / 5; object-fit: contain; background: #171a20; }
.replay-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px 4px; }
.segments { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.segments button { font-size: .77rem; padding: 5px 8px; }
.segments button[aria-pressed=true] { color: #7e3026; background: #f4e6e0; border-color: #c69488; }
.replay-top .segments button { background: #272b32; color: #ede6da; border-color: #53545b; }
.replay-top .segments button[aria-pressed=true] { background: #393238; color: #f9eee4; border-color: #b38a78; }
.timecode { color: #ece7df; font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.replay-transport { display: flex; gap: 8px; align-items: center; padding: 8px 10px 10px; }
.replay-transport input { min-width: 38px; flex: 1; accent-color: #efcfb5; }
.replay-transport button { white-space: nowrap; font-size: .76rem; padding: 5px 8px; }
.push-flag { position: absolute; top: 49px; right: 10px; border-radius: 4px; background: #181b20ed; color: #f1cfb6; border: 1px solid #b38a78; padding: 3px 7px; font-size: .73rem; pointer-events: none; }
.trace { min-width: 0; padding: clamp(14px, 2.4vw, 25px); display: grid; align-content: center; gap: 9px; }
.trace-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; }
.trace-meta, .trace-note { color: var(--muted); font-size: .79rem; margin: 0; }
.trace-meta { font-variant-numeric: tabular-nums; }
.plot { height: clamp(165px, 18vw, 225px); min-width: 0; }
#trace-chart { display: block; width: 100%; height: 100%; }
.trace-readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding-top: 6px; margin: 0; border-top: 1px solid var(--line); }
.trace-readout dt { font-size: .76rem; display: flex; align-items: center; gap: 6px; }
.trace-readout dd { font: 400 1.42rem/1.2 var(--serif); font-variant-numeric: tabular-nums; margin: 2px 0 0; color: var(--teal); }
.trace-readout div:last-child dd, #replay-error { color: var(--rust); }
.swatch { width: 13px; height: 0; border-top: 2px solid var(--rust); }
.swatch.steady { border-color: var(--teal); border-top-style: dashed; }

.applications { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 3vw, 37px); margin: 0; padding: 0; }
.applications li { min-width: 0; }
.applications img { display: block; width: 100%; height: auto; border-radius: 5px; }
.applications h3 { margin-top: 10px; }
.resource-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 18px 0 0; }
.resource-link { position: relative; display: grid; align-content: start; gap: 10px; height: 100%; padding: 15px 16px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-decoration: none; }
.resource-link:hover { border-color: #b79587; color: var(--ink); }
.resource-link:hover h3, .resource-link:focus-visible h3 { text-decoration: underline; text-underline-offset: .18em; }
.resource-mark { display: block; background: #f2ebe0; border-radius: 5px; }
.resource-type { display: block; margin-bottom: 3px; color: var(--muted); font-size: .74rem; }
.resource-copy p { margin-top: 5px; color: var(--muted); font-size: .84rem; }
.resource-arrow { position: absolute; right: 13px; top: 10px; color: var(--rust); font-size: .95rem; }
.resource-notes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); font-size: .84rem; }
.resource-notes dt { color: var(--muted); font-size: .74rem; }
.resource-notes dd { margin: 2px 0 0; }
.resource-notes a { white-space: nowrap; }
.walk-credits { margin: 44px 0 0; padding: 11px 0 25px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.walk-credits p { margin: 7px 0 0; }

@media (max-width: 700px) {
  .page-head { padding-block: 23px 19px; }
  .stage { height: clamp(310px, 58svh, 440px); }
  .chapter { margin-top: 36px; padding-top: 22px; }
  .muscle-spread, .replay-card, .training-steps, .applications { grid-template-columns: minmax(0, 1fr); }
  .ankle-figure { max-width: 480px; }
  .applications { gap: 24px; }
  .applications img { max-width: 440px; }
  .resource-list, .resource-notes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .loop-buttons { grid-template-columns: minmax(0, 1fr); gap: 19px; }
  .loop-buttons button { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); grid-template-rows: auto auto; align-content: center; min-height: 74px; padding-bottom: 0; }
  .loop-buttons img { grid-row: 1 / 3; height: 100%; object-fit: contain; border-radius: 4px 0 0 4px; background: #f2ebe0; }
  .loop-label { align-self: end; margin-top: 6px; }
  .loop-summary { align-self: start; margin-bottom: 6px; }
  .loop-buttons button:not(:last-child)::after { content: '↓' / ''; left: 0; top: 100%; width: 100%; }
  .loop-feedback { display: block; margin: 10px 0 0; padding-top: 0; border: 0; text-align: left; }
  .loop-feedback::before { display: none; }
  .loop-feedback > span { margin: 0; padding: 0; }
  #loop-detail { margin-top: 7px; min-height: 4.9em; }
  .resource-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .resource-link { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 12px; padding: 11px 32px 11px 11px; }
}
@media (max-width: 360px) {
  .under-viewer { gap: 0 12px; }
  .ball-status { top: 39px; left: 14px; right: auto; }
  .under-viewer p { margin: 4px 0; }
  .replay-transport { flex-wrap: wrap; }
  .replay-transport input { order: 3; flex-basis: 100%; }
  .replay-transport button.ghost { margin-left: auto; }
}
