:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #193b35;
  background: #f3f5f1;
  --line: #d3dcd5;
  --muted: #516b62;
  --green: #186455;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
button { background: white; border: 1px solid var(--line); border-radius: 6px; color: inherit; }
button:disabled, select:disabled { opacity: .45; cursor: default; }
button:enabled:hover { border-color: #4a8270; }
:focus-visible { outline: 3px solid #278a79; outline-offset: 2px; }
main { width: min(94%, 1390px); margin: 0 auto; }
footer a:hover { text-decoration: underline; }
.intro { padding: 21px 0 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.regionSwitch { flex-shrink: 0; align-self: center; border: 1px solid var(--line); }
h1 { font-size: clamp(30px, 3.2vw, 43px); line-height: 1.15; letter-spacing: -.045em; }
.intro p { font-size: 14px; line-height: 1.6; margin-top: 7px; color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(266px, 323px); gap: 15px; align-items: start; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.viewer { overflow: hidden; position: sticky; top: 8px; container: spine-stage / inline-size; }
.viewhead, .viewfoot, .panelhead, .settings, .levelRow, .rowLabel { display: flex; align-items: center; justify-content: space-between; }
.viewhead { min-height: 51px; padding: 8px 13px 8px 16px; }
.selection { display: flex; gap: 9px; align-items: center; }
.selection i { height: 11px; width: 11px; border-radius: 50%; background: #338d7e; }
.selection strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.selection span { font-size: 13px; color: var(--muted); }
.segmented, .cameras, .zooms { display: flex; gap: 3px; align-items: center; }
.segmented { background: #edf2ed; padding: 3px; border-radius: 7px; }
.segmented button, .cameras button, .zooms button { border: 1px solid transparent; font-size: 13px; padding: 5px 8px; background: transparent; white-space: nowrap; }
.segmented button[aria-pressed=true] { background: #245e50; color: white; }
.cameras button[aria-pressed=true] { background: #e4f1e8; color: #145b4b; font-weight: 650; }
.stage { position: relative; background: radial-gradient(ellipse at 50% 35%, #fbfcf8 0%, #eaf0e9 100%); border-block: 1px solid var(--line); }
#spineCanvas { display: block; width: 100%; height: clamp(390px, 61vh, 690px); cursor: grab; touch-action: none; }
#spineCanvas:active { cursor: grabbing; }
.viewfoot { padding: 7px 9px; gap: 3px; flex-wrap: wrap; }
.viewfoot .segmented { background: transparent; padding: 0; }
.viewfoot .segmented button[aria-pressed=true] { background: #e4f1e8; color: #145b4b; }
.zooms { gap: 0; }
#load { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(245px, 88%); padding: 14px 18px; background: #fcfefbf5; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 13px; }
#load progress { display: block; width: 100%; margin-top: 7px; accent-color: var(--green); }
#retry { margin-top: 8px; padding: 5px 10px; }
.panels { display: grid; gap: 10px; min-width: 0; }
.panel, .settings { padding: 15px 16px; }
h2 { font-size: 16px; font-weight: 680; letter-spacing: -.025em; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 12px; }
.presets button { padding: 7px 4px; font-size: 14px; font-weight: 600; }
.presets button[aria-pressed=true] { background: #235f50; color: #fff; border-color: #235f50; }
#curveControls { margin-top: 12px; }
.rowLabel { font-size: 13px; line-height: 1.5; font-weight: 580; }
.rowLabel output { color: var(--green); font-size: 13px; font-variant-numeric: tabular-nums; }
.check { font-size: 13px; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { margin: 0; accent-color: var(--green); width: 15px; height: 15px; }
#curveControls .check { margin-top: 7px; }
.levelRow { gap: 4px; margin: 12px 0 13px; }
.levelRow select { min-width: 0; flex: 1; color: #174f42; font-size: 14px; border: 1px solid #b7cfc0; background: #edf4ed; border-radius: 6px; padding: 6px 7px; height: 34px; }
.levelRow button { width: 32px; height: 34px; font-size: 16px; }
.linkButton { padding: 4px 0 4px 5px; color: var(--green); background: transparent; border-color: transparent; font-size: 13px; }
.sliderRow + .sliderRow { margin-top: 10px; }
input[type=range] { display: block; width: 100%; height: 18px; margin: 2px 0 0; cursor: pointer; accent-color: var(--green); }
.limits { display: flex; align-items: baseline; justify-content: space-between; font-size: 11px; line-height: 1.25; color: var(--muted); }
details { margin-top: 13px; border-top: 1px solid #e2e9e2; padding-top: 9px; }
summary { width: fit-content; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--green); }
#secondaryControls { margin-top: 11px; }
.pelvicTargets { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 3px; margin: 12px 0 9px; }
.pelvicTargets button { padding: 6px 1px; font-size: 13px; }
.pelvicTargets button[aria-pressed=true] { background: #235f50; color: #fff; border-color: #235f50; }
.motionGuide { font-size: 12px; line-height: 1.65; color: var(--muted); margin: 0 0 12px; }
.examples { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.examples button { padding: 5px 8px; font-size: 13px; }
#pelvicSecondary { margin-top: 11px; }
.stage.xray { background: #101819; }
.switches { display: flex; align-items: center; gap: 6px; }
#planes { display: flex; gap: 10px; font-size: 12px; }
#planes label { display: flex; align-items: center; gap: 3px; white-space: nowrap; cursor: pointer; }
#planes input { accent-color: var(--green); margin: 0; }
#planeGrid { display: grid; grid-auto-columns: minmax(0,1fr); grid-auto-flow: column; gap: 1px; background: #ced8cf; }
#planeGrid figure { margin: 0; min-width: 0; background: radial-gradient(ellipse at 50% 35%, #fbfcf8, #eaf0e9); }
#planeGrid figcaption { padding: 6px 9px; font-size: 13px; font-weight: 650; min-height: 28px; background: #f1f5ef; color: #36594d; }
#planeGrid canvas { display: block; width: 100%; height: clamp(360px,55vh,605px); touch-action: none; cursor: grab; }
#planeGrid canvas:active { cursor: grabbing; }
.xray #planeGrid { background: #45504d; }
.xray #planeGrid figure { background: #101819; }
.xray #planeGrid figcaption { background: #202c29; color: #e1ede4; }
#relations { margin: 11px 0 0; font-size: 13px; line-height: 1.6; }
#relations dt { font-weight: 650; margin-top: 7px; }
#relations dd { margin: 0; color: var(--muted); }
#landmarkMotion { margin-block: 8px 3px; font-size: 12px; line-height: 1.6; color: var(--green); }
#landmarkMotion:empty { display: none; }
#sources { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 6px; }
#sources a { color: var(--green); font-size: 11px; }
@media (min-width: 646px) {
  @container spine-stage (max-width: 899px) {
    #planeGrid[data-count="3"] { grid-auto-flow: row; grid-template-columns: repeat(2,minmax(0,1fr)); }
    #planeGrid[data-count="3"] #plane-top { grid-column: 1 / -1; }
    #planeGrid[data-count="3"] canvas { height: clamp(210px, 31vh, 273px); }
  }
}
.settings { padding-block: 9px; }
.note, footer { font-size: 12px; line-height: 1.65; color: var(--muted); }
.note { padding-inline: 2px; }
footer { display: flex; justify-content: space-between; flex-wrap: wrap; margin: 15px 1px 20px; gap: 2px 13px; }
footer a { color: inherit; }
@media (max-width: 790px) and (min-width: 646px) {
  .workspace { grid-template-columns: minmax(0,1fr) 254px; gap: 8px; }
  .viewfoot { flex-wrap: wrap; justify-content: center; }
  .panel, .settings { padding-inline: 13px; }
  .segmented button { padding-inline: 5px; }
}
@media (max-width: 645px) {
  main { width: 95%; }
  .intro { padding: 14px 3px 11px; align-items: flex-start; flex-direction: column; gap: 7px; }
  .regionSwitch { align-self: start; }
  .switches { gap: 3px; }
  .switches .segmented { padding: 2px; }
  .switches .segmented button { font-size: 12px; padding-inline: 4px; }
  .selection { gap: 4px; }
  .selection span { display: none; }
  #planeGrid { grid-auto-flow: row; grid-template-columns: repeat(2,minmax(0,1fr)); }
  #planeGrid[data-count="1"] { grid-template-columns: 1fr; }
  #planeGrid[data-count="3"] #plane-top { grid-column: 1 / -1; }
  #planeGrid figcaption { min-height: 17px; padding: 1px 6px; font-size: 11px; }
  #planeGrid canvas { height: clamp(212px,34svh,300px); }
  #planeGrid[data-count="3"] canvas { height: clamp(115px,17svh,183px); }
  h1 { font-size: 30px; }
  .intro p { font-size: 13px; margin-top: 4px; }
  .workspace { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .viewer { top: 0; z-index: 2; }
  .viewhead { min-height: 38px; padding: 4px 7px 4px 11px; }
  .selection strong { font-size: 16px; }
  .segmented button { padding: 3px 7px; }
  #spineCanvas { height: clamp(222px, 37svh, 360px); }
  .viewfoot { padding: 4px 5px; }
  .cameras, .viewfoot .segmented { gap: 0; }
  .cameras button, .zooms button, .viewfoot .segmented button { font-size: 12px; padding: 5px 4px; }
  .panels { gap: 7px; }
  .panel, .settings { padding: 12px 14px; }
  .presets { margin-top: 8px; }
  .presets button { padding-block: 8px; }
  .levelRow { margin-block: 9px 11px; }
  .note { padding-inline: 3px; }
}
@media (max-height: 580px) { .viewer { position: relative; top: auto; } }
