/* Stride Lab — styles. A teal top bar, a light page, the 3D runner filling
   the left with its buttons around the edge, the stride strip under it, and
   the tabbed panel (cue, runner, run & form, build) on the right. */
:root {
  --bg: #eef7f4;
  --panel: #ffffff;
  --text: #1f2a2a;
  --muted: #5d6b6a;
  --line: #d3e4df;
  --teal: #0f7a6a;
  --teal-dark: #0a5a4e;
  --orange: #ff7a00;
  --blue: #2f7fd8;
  --go: #2fa35a;
  --go-dark: #23824a;
  --good: #1d6b3a;
  --warn: #b45f00;
  --bad: #c0392b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button {
  font: inherit; font-weight: 700; border: 2px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 6px 12px; cursor: pointer; touch-action: manipulation;
}
button.go { background: var(--go); border-color: var(--go-dark); color: #fff; }
button.danger { color: var(--bad); border-color: #f0c4be; }
button.icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 19px; }
button.plain { border: none; background: none; }
input, select { font: inherit; font-size: 16px; border: 2px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; color: var(--text); }
input[type=number] { width: 76px; }
.small { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0; padding: 8px 14px; background: var(--teal); color: #fff; }
.top-left, .top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { background: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.apps-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .6); color: #fff; text-decoration: none; font-weight: 700; }
.apps-link svg { fill: currentColor; }
.topbar button.icon { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .6); }
.update-note { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; background: #fff4d6; border-bottom: 1px solid #f0d58a; font-weight: 600; }

/* segmented buttons */
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: none; border-radius: 0; padding: 6px 12px; background: #fff; color: var(--muted); }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--teal); color: #fff; }
.topbar .seg { border-color: rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .15); }
.topbar .seg button { background: transparent; color: #fff; }
.topbar .seg button + button { border-left-color: rgba(255, 255, 255, .6); }
.topbar .seg button.on { background: #fff; color: var(--teal); }

/* ---------- the lab: stage + side panel ---------- */
.lab { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 30vw, 380px); gap: 10px; padding: 10px; }
.stage { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.view { position: relative; flex: 1; min-height: 320px; border-radius: 16px; overflow: hidden; background: #d6ecff; border: 1px solid var(--line); }
.view canvas { display: block; cursor: grab; }
.view canvas:active { cursor: grabbing; }
.no3d { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; font-weight: 700; background: #fff; }
.hud { position: absolute; z-index: 2; }
.hud button { background: rgba(255, 255, 255, .9); padding: 5px 10px; font-size: 14px; }
.hud button.on { background: var(--teal); border-color: var(--teal-dark); color: #fff; }
.views { top: 10px; left: 10px; display: flex; gap: 4px; flex-wrap: wrap; max-width: calc(100% - 320px); }
.modes { top: 10px; right: 10px; display: flex; gap: 4px; }
.bottom { left: 10px; right: 10px; bottom: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.shows { align-self: stretch; display: flex; gap: 5px; flex-wrap: wrap; pointer-events: auto; }
.shows button { font-size: 13px; padding: 5px 9px; }
.shows button.on { background: #fff3c4; border-color: #e0a800; color: #5a3a00; }
.caption {
  width: min(520px, 92%); text-align: center; pointer-events: none;
  background: rgba(255, 255, 255, .9); border-radius: 14px; padding: 6px 14px; box-shadow: 0 3px 10px rgba(20, 60, 50, .15);
}
.caption:empty, .caption.off { display: none; }
.cap-title { font-weight: 900; color: var(--teal-dark); font-size: 17px; }
.cap-feel { font-size: 14px; color: var(--text); }
.legend { top: 54px; right: 10px; font-size: 12px; font-weight: 700; color: var(--muted); background: rgba(255, 255, 255, .85); border-radius: 999px; padding: 3px 10px; display: flex; align-items: center; gap: 5px; }
.legend span { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.lg-rest { background: #d98c78; }
.lg-work { background: #ff2a10; box-shadow: 0 0 6px #ff3a00; margin-left: 6px; }

.transport { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px; }
.t-btn { width: 46px; height: 46px; padding: 0; font-size: 20px; border-radius: 12px; flex: none; }
.t-btn.small { width: 36px; font-size: 22px; }
.t-btn.play { width: 56px; background: var(--teal); border-color: var(--teal-dark); color: #fff; }
.strip-wrap { flex: 1; min-width: 0; height: 46px; }
.strip { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }
#rate { flex: none; }

/* ---------- side panel ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 2px solid var(--line); flex: none; }
.tabs button { border: none; border-radius: 10px 10px 0 0; background: none; color: var(--muted); padding: 8px 9px; font-size: 14.5px; }
.tabs button.on { background: var(--bg); color: var(--teal-dark); }
.tab { padding: 12px 14px 16px; overflow-y: auto; min-height: 0; flex: 1; }
.tab h2 { margin: 0; font-size: 20px; color: var(--teal-dark); }
.tab h3 { margin: 16px 0 8px; font-size: 15px; color: var(--teal-dark); display: flex; align-items: center; gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.card h3 { margin: 0 0 8px; }
.moment-card { position: relative; min-height: 300px; }
.moment-card .playing-note { visibility: hidden; margin-top: 8px; background: #e6f4f1; color: var(--teal-dark); font-weight: 700; font-size: 14px; border-radius: 10px; padding: 8px 10px; }
.moment-card.playing > :not(.playing-note):not(.moment-head) { opacity: .35; }
.moment-card.playing .playing-note { visibility: visible; }
.working { min-height: 4.6em; }
.cad-now { display: flex; align-items: center; gap: 10px; }
.cad-big { font-size: 15px; color: var(--muted); }
.cad-big b { font-size: 26px; color: var(--teal-dark); }
.cad-vs { margin: 8px 0 4px; font-size: 14px; line-height: 1.4; }
.cad-vs:empty { display: none; }
.cad-vs button { margin-top: 6px; font-size: 13px; padding: 4px 10px; }
.moment-head { display: flex; align-items: center; gap: 8px; }
.m-side { font-size: 12px; font-weight: 900; color: #fff; border-radius: 999px; padding: 2px 8px; flex: none; }
.m-side.R { background: var(--blue); }
.m-side.L { background: var(--orange); }
.m-what { line-height: 1.45; margin: 8px 0; }
.feel { background: #fff7dc; border: 2px solid #f2d27a; border-radius: 12px; padding: 8px 10px; line-height: 1.4; }
.working { margin-top: 8px; line-height: 1.8; }
.chip { display: inline-block; font-size: 13px; font-weight: 800; background: #ffe2dc; color: #a0241a; border-radius: 999px; padding: 1px 9px; margin: 0 2px; white-space: nowrap; }
.nums { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0; font-size: 14.5px; }
.nums dt { color: var(--muted); }
.nums dd { margin: 0; font-weight: 800; text-align: right; }
.nums dd.good { color: var(--good); }
.nums dd.warn { color: var(--warn); }
.nums dd.bad { color: var(--bad); }
.nums .tgt { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); margin: -2px 0 4px; line-height: 1.35; }
.nums .tgt .fix { display: block; color: var(--warn); font-weight: 700; }
.nums .tgt .fix.bad { color: var(--bad); }
.work-list { margin: 0; padding-left: 20px; line-height: 1.45; font-size: 14.5px; }
.work-list li { margin-bottom: 6px; }
.work-list li.ok { list-style: none; margin-left: -20px; color: var(--good); font-weight: 700; }
.work-list li.note { list-style: none; margin-left: -20px; color: var(--muted); font-size: 13px; }
.work-list li.also { list-style: none; margin: 8px 0 4px -20px; color: var(--teal-dark); font-weight: 800; }
.work-list .why { color: var(--muted); font-size: 13px; }
.zones label { font-size: 13px; color: var(--muted); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.zones input { width: 62px; }
.fit-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
.fit-table th { text-align: left; padding: 8px 0 2px; color: var(--teal-dark); }
.work-note { margin: 8px 0 0; }
.also-h { margin-top: 10px; font-weight: 800; color: var(--teal-dark); font-size: 14px; }
#work-also { padding-left: 18px; list-style: disc; }
.fit-table td { padding: 3px 0; border-bottom: 1px solid #edf3f1; }
.fit-table td:last-child { text-align: right; font-weight: 800; }
.fit-big { font-size: 15px; line-height: 1.45; }
.fit-big b { color: var(--teal-dark); }
body:not(.fit-race) .fit-race, body:not(.fit-vo2) .fit-vo2 { display: none; }
.try { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.try-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; font-size: 14px; line-height: 1.35; background: #eef7f4; border-radius: 10px; padding: 6px 8px; }
.try-row button { padding: 4px 10px; font-size: 14px; }
.field { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.field .lbl { width: 84px; font-weight: 700; color: var(--muted); }
.field.check { align-items: flex-start; }
.nudge { width: 36px; height: 36px; padding: 0; font-size: 18px; }
.pace { width: 76px; text-align: center; }
.mini-btn { font-size: 12px; padding: 3px 9px; margin-left: auto; }
.slider { margin: 10px 0 14px; }
.slider-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.slider-top b { color: var(--text); }
.slider-top .val { font-weight: 800; color: var(--teal-dark); white-space: nowrap; }
.slider input[type=range] { width: 100%; accent-color: var(--teal); height: 28px; padding: 0; border: none; }
.slider .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -4px; }
.slider .tip { font-size: 12.5px; color: var(--muted); }
body.mi .met, body.km .imp { display: none; }

/* ---------- dialogs ---------- */
.dialog { max-width: 480px; width: calc(100% - 28px); border: none; border-radius: 18px; padding: 18px 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.dialog.wide { max-width: 760px; }
.dialog::backdrop { background: rgba(10, 40, 35, .45); }
.dialog h2 { margin: 0 0 12px; color: var(--teal-dark); }
.help-body { line-height: 1.5; }
.help-body li { margin-bottom: 6px; }
.dialog-buttons { display: flex; gap: 8px; margin-top: 10px; }
.spacer { flex: 1; }

/* ---------- smaller screens ---------- */
@media (max-width: 980px) {
  .lab { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; align-content: start; overflow-y: auto; }
  .stage, .side { min-height: auto; }
  .view { flex: none; height: min(62vh, 560px); }
  .side { overflow: visible; }
  .tab { overflow: visible; }
}
@media (max-width: 600px) {
  .brand-name, .apps-link span { display: none; }
  .views button[data-view="three"] { display: none; }
  .views { max-width: none; right: 10px; }
  .modes { top: 52px; left: 10px; right: auto; }
  .legend { display: none; }
  .cap-feel { display: none; }
  .shows span { display: none; }
  .shows button { font-size: 17px; padding: 4px 9px; }
  .t-btn { width: 40px; height: 42px; }
  .t-btn.small { width: 30px; }
  #rate { max-width: 92px; font-size: 14px; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .topbar { padding: 4px 10px; }
  .lab { padding: 6px; gap: 6px; }
  .view { flex: none; height: calc(100dvh - 128px); min-height: 200px; }
  .caption, .legend { display: none; }
  .shows span { display: none; }
  .shows button { font-size: 16px; padding: 3px 8px; }
}
@media (pointer: coarse) {
  .hud button { padding: 7px 12px; }
  .views [data-zoom] { display: none; }    /* pinch to zoom */
}
@media (max-width: 1150px) {
  .shows button { font-size: 12.5px; padding: 4px 7px; }
  .modes button, .views button { padding: 5px 8px; font-size: 13.5px; }
}
