/* Shared PULSE controls: native semantics, explicit state and 48 px targets. */
.pulse-row { display:flex !important; flex-direction:row !important; align-items:center !important;
  justify-content:space-between; gap:12px; min-height:48px; margin:8px 0; }
.pulse-row .control-label { flex-shrink:0; }
.pulse-row input[type=checkbox]:not([hidden]) { appearance:none; -webkit-appearance:none; width:64px; height:48px;
  flex:0 0 64px; border:2px solid #668781; border-radius:24px; background:#e5ebe6; position:relative; margin:0; cursor:pointer; }
.pulse-row input[type=checkbox]:not([hidden])::after { content:'关'; position:absolute; left:4px; top:5px;
  width:34px; height:34px; border-radius:50%; background:white; color:#35534d; text-align:center; line-height:34px; font-size:14px; }
.pulse-row input[type=checkbox]:checked { background:#227a70; }
.pulse-row input[type=checkbox]:checked::after { content:'开'; left:22px; }
.pulse-row select { appearance:none; -webkit-appearance:none; min-height:48px; max-width:65%; padding:8px 28px 8px 12px;
  border:2px solid #7aaca0; border-radius:12px; background:#f4faf4; color:#174e48; font:inherit;
  background-image:linear-gradient(45deg,transparent 50%,#227a70 50%),linear-gradient(135deg,#227a70 50%,transparent 50%);
  background-position:calc(100% - 16px) 21px,calc(100% - 10px) 21px; background-size:6px 6px; background-repeat:no-repeat; }
.pulse-stepper { display:flex; align-items:center; gap:8px; }
.pulse-stepper button { min-width:48px; min-height:48px; padding:6px; margin:0; width:48px; }
.pulse-stepper output { width:52px; text-align:center; font-size:16px; }
.settings-tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.settings-tabs button { flex:1; min-width:60px; min-height:48px; margin:0; padding:6px 10px; font-size:16px; }
.settings-tabs [aria-pressed=true] { background:#227a70; color:white; }
.settings-page[hidden] { display:none !important; }
.settings-page > button { min-height:48px; margin:6px 0; }
#settings .sheet { width:min(650px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); padding:20px; overflow:auto; }
#settings .display-settings { display:block; }
#settings .settings-page label { display:flex; width:100%; }
#settings .settings-page h2 { font-size:20px; margin:8px 0; }
#settings .timing-control { display:flex; align-items:center; gap:4px; }
#settings .timing-control > output { display:none; }
#settings .settings-page p { font-size:14px; margin:8px 0; }
#settings .settings-page fieldset { border:0; padding:0; margin:0; }
#settings .settings-page fieldset label { margin:4px 0; }
#settings.pulse-settings { width:min(620px,calc(100vw - 24px)); padding:20px; max-height:calc(100dvh - 24px); }
#settings.pulse-settings > h2,#settings.pulse-settings > .eyebrow { display:none; }
#settings .settings-page button { min-height:48px; }
.pulse-topbar { position:fixed; top:0; left:0; right:0; height:64px; z-index:45; display:flex;
  align-items:center; gap:24px; padding:8px 24px; background:#fffcf3ed; color:#216c65; }
.pulse-topbar a { color:inherit; text-decoration:none; font-size:17px; }
.pulse-topbar b { font-size:24px; letter-spacing:2px; }
.pulse-topbar button { margin-left:auto; min-height:48px; }
body:not([data-state=position]) .pulse-topbar { display:none; }
#audio-gate { margin:8px 0; text-align:center; }
#audio-gate button { min-height:48px; background:#216f65; color:white; border:0; border-radius:12px; padding:10px 18px; font-size:18px; }
#audio-gate p { font-size:13px; line-height:1.45; margin:6px 0 0; color:#4d635b; }
#audio-banner { position:fixed; bottom:8px; left:50%; transform:translateX(-50%); z-index:46;
  min-height:48px; width:max-content; max-width:calc(100vw - 16px); padding:8px 14px; border:1px solid #92c2ac;
  border-radius:12px; background:#fff9e8ee; color:#235b51; font-size:14px; }
#audio-gate[hidden],#audio-banner[hidden] { display:none; }
[data-scene=fingers] .course-controls > label { flex-direction:row; justify-content:space-between; align-items:center; }
[data-scene=fingers] #position { padding-top:72px; }
@media(max-width:600px) {
 .pulse-topbar { height:60px; padding:6px 12px; gap:12px; }
 .pulse-topbar a { font-size:14px; }
 .pulse-topbar b { font-size:20px; }
 #settings .sheet,#settings.pulse-settings { padding:16px; }
 #settings .sheet h1 { font-size:26px; margin:0 0 12px; }
 .pulse-row { gap:8px; font-size:14px; }
 .pulse-row select { font-size:14px; }
 #settings .settings-page { min-height:280px; }
}
/* Start workspaces reserve the header and keep the primary actions in view. */
body[data-state=position]:not([data-scene=fingers]) #position { padding-top:72px; }
body[data-state=position]:not([data-scene=fingers]) .position-sheet { max-height:calc(100dvh - 88px); }
.pulse-row:has(> input[type=checkbox]) > input { order:2; }
#settings .pulse-row select { width:auto; min-width:85px; }
@media(max-width:600px) {
 [data-scene=fingers] #position { justify-content:flex-start; padding:68px 10px 8px; gap:6px; }
 [data-scene=fingers] .preview-image { height:30dvh; min-height:30vh; }
 [data-scene=fingers] #start-progress { width:75px; height:75px; }
 [data-scene=fingers] #start-progress strong { font-size:14px; }
 [data-scene=fingers] #start-preview #hand-quality { padding:2px 8px; margin-top:2px; font-size:12px; }
 [data-scene=fingers] #start-preview #hand-quality summary { min-height:24px; }
 [data-scene=fingers] #position .sheet { padding:10px 12px; }
 [data-scene=fingers] .preset-picker h2 { font-size:20px; margin-bottom:6px; }
 [data-scene=fingers] .preset-card { min-height:62px; padding:6px 8px; }
 [data-scene=fingers] .preset-card strong { font-size:17px; }
 [data-scene=fingers] .preset-card small { font-size:11px; }
 [data-scene=fingers] .preset-card span { font-size:12px; }
 [data-scene=fingers] #custom-course { margin-top:4px; min-height:48px; padding:6px 10px; }
 [data-scene=fingers] #audio-gate { margin:4px 0; }
 [data-scene=fingers] #audio-gate p { font-size:12px; margin:4px 0; }
 [data-scene=fingers] .course-controls { display:flex; flex-direction:column; align-items:stretch; gap:0; margin:0; }
 [data-scene=fingers] .course-controls > label { margin:2px 0; font-size:14px; }
 [data-scene=fingers] #position-camera { width:54px; flex-basis:54px; }
 [data-scene=fingers] .preview-image .pulse-row { font-size:12px; gap:4px; }
 [data-scene=fingers] #position #position-layout,[data-scene=fingers] #position #skip-range { margin:2px 2px 0 0; }
}
/* Neck ready view has a smaller stage; the exercise stage retains its original size. */
body:has(#coach):not(.playing) header { padding-top:12px; padding-bottom:8px; }
body:has(#coach):not(.playing) main { padding-top:4px; }
body:has(#coach):not(.playing) .intro { margin-bottom:12px; }
body:has(#coach):not(.playing) .playfield { height:290px; min-height:0; }
body:has(#coach):not(.playing) #controls { display:grid; grid-template-columns:1fr 1fr; gap:8px 20px; }
body:has(#coach):not(.playing) #controls > .pulse-row { grid-column:1; margin:4px 0; }
body:has(#coach):not(.playing) #modes { grid-column:1; grid-row:2; }
body:has(#coach):not(.playing) #controls .actions { grid-column:2; grid-row:2; margin:0; }
body:has(#coach):not(.playing) #audio-gate { grid-column:2; grid-row:1; margin:4px 0; }
body:has(#coach):not(.playing) #footnote { grid-column:1 / -1; margin:0; }
@media(max-width:600px) {
 body:has(#coach):not(.playing) header { padding:10px 16px; height:64px; }
 body:has(#coach):not(.playing) header .tag { display:none; }
 body:has(#coach):not(.playing) main { padding:0 14px 8px; }
 body:has(#coach):not(.playing) .intro { margin:0 0 8px; }
 body:has(#coach):not(.playing) .intro h1 { margin:0; font-size:24px; }
 body:has(#coach):not(.playing) .intro h1 span,
 body:has(#coach):not(.playing) .intro > .eyebrow,
 body:has(#coach):not(.playing) #introNote { display:none; }
 body:has(#coach):not(.playing) .playfield { height:230px; }
 body:has(#coach):not(.playing) .instruction { top:48px; }
 body:has(#coach):not(.playing) .instruction h2 { font-size:20px; }
 body:has(#coach):not(.playing) .indicator { top:58px; }
 body:has(#coach):not(.playing) #controls { display:flex; flex-direction:column; gap:4px; }
 body:has(#coach):not(.playing) #modes { gap:6px; }
 body:has(#coach):not(.playing) #modes button { padding:8px 12px; min-height:56px; }
 body:has(#coach):not(.playing) #controls .actions { gap:6px; }
 body:has(#coach):not(.playing) #controls .actions button { min-height:48px; padding:8px 12px; }
 body:has(#coach):not(.playing) #audio-gate { order:2; }
 body:has(#coach):not(.playing) #footnote { order:3; font-size:11px; }
}
body:has(#coach):not(.playing) .indicator { width:150px; top:42px; }
body:has(#coach):not(.playing) .indicator svg { width:120px; height:120px; }
body:has(#coach):not(.playing) #guideDeviation { display:none; }
@media(max-width:600px) {
 body:has(#coach):not(.playing) .indicator { width:90px; top:48px; right:10px; }
 body:has(#coach):not(.playing) .indicator svg { width:80px; height:80px; }
 body:has(#coach):not(.playing) .indicator b { font-size:14px; }
 body:has(#coach):not(.playing) .indicator #angle { display:none; }
 body:has(#coach):not(.playing) .instruction { width:150px; }
 body:has(#coach):not(.playing) .instruction h2 { font-size:18px; }
 body:has(#coach):not(.playing) #hint { display:none; }
 body:has(#coach):not(.playing) .coachLabel { left:20px; bottom:30px; transform:none; }
 body:has(#coach):not(.playing) .coachLabel span { display:none; }
}
#position button,#controls button { min-height:48px; min-width:48px; }
body:has(#coach) header button { min-height:48px; min-width:48px; }
.settings-tabs button { transition:none; }
@media(max-width:380px) {
 [data-scene=fingers] #position:has(.course-editor) .sheet { padding-top:6px; padding-bottom:6px; }
}
.course-editor > label:has([name=muted]) {
 grid-column:span 2; display:flex; flex-direction:row; align-items:center;
}

/* R3: preview, sound gate, checks and actions each occupy their own flow row. */
body:not([data-scene=fingers]) #position .position-sheet {
 display:grid; grid-template-columns:minmax(0, 1.5fr) minmax(0, 1fr);
 gap:8px 24px; height:auto; overflow:auto; padding:20px;
}
body:not([data-scene=fingers]) #position .position-sheet > * {
 position:static !important; width:auto; margin:0; grid-column:2;
}
body:not([data-scene=fingers]) #position .position-sheet > .eyebrow { grid-column:1; grid-row:1; }
body:not([data-scene=fingers]) #position #position-title { grid-column:1; grid-row:2; font-size:28px; }
body:not([data-scene=fingers]) #position #position-note { grid-column:1; grid-row:3; }
body:not([data-scene=fingers]) #position #position-preview {
 position:relative !important; grid-column:1; grid-row:4 / 11; min-height:300px;
}
body:not([data-scene=fingers]) #position .station-checks { grid-row:1 / 3; }
body:not([data-scene=fingers]) #position #audio-gate { grid-row:3 / 5; }
body:not([data-scene=fingers]) #position #range-list { grid-row:6; grid-template-columns:1fr 1fr; font-size:13px; gap:4px; }
body:not([data-scene=fingers]) #position #calibration-ring { grid-row:7; width:70px; height:70px; justify-self:center; }
body:not([data-scene=fingers]) #position #start-button { grid-row:8; }
body:not([data-scene=fingers]) #position #position-layout { grid-row:9; }
body:not([data-scene=fingers]) #position #skip-range { grid-row:10; }
body:not([data-scene=fingers]) #position .sim-label { grid-column:1 / -1; grid-row:11; font-size:11px; }
body[data-state=position] #position-preview > :is(.camera,.skeleton-window) {
 position:absolute !important; inset:0 !important; width:100% !important; height:100% !important;
 margin:0; border-radius:16px;
}
@media(orientation:portrait) {
 [data-scene=fingers] .preview-image { height:30dvh; min-height:30vh; }
 [data-scene=fingers] #start-preview { flex-shrink:0; }
 [data-scene=fingers] #position { overflow-y:auto; scroll-padding-top:68px; }
 [data-scene=fingers] #position .sheet { flex-shrink:0; }
 body:not([data-scene=fingers]) #position .position-sheet {
  display:flex; flex-direction:column; gap:6px; padding:12px; max-height:calc(100dvh - 80px);
 }
 body:not([data-scene=fingers]) #position .position-sheet > * { flex-shrink:0; }
 body:not([data-scene=fingers]) #position .eyebrow { order:0; font-size:11px; }
 body:not([data-scene=fingers]) #position #position-title { order:1; font-size:23px; }
 body:not([data-scene=fingers]) #position #position-note { order:2; font-size:12px; }
 body:not([data-scene=fingers]) #position .station-checks { order:3; }
 body:not([data-scene=fingers]) #position #position-preview { order:4; min-height:180px; height:24dvh; }
 body:not([data-scene=fingers]) #position #audio-gate { order:5; }
 body:not([data-scene=fingers]) #position .pulse-row { order:6; }
 body:not([data-scene=fingers]) #position #range-list { order:7; }
 body:not([data-scene=fingers]) #position #calibration-ring { order:8; align-self:center; }
 body:not([data-scene=fingers]) #position #start-button { order:9; }
 body:not([data-scene=fingers]) #position #position-layout { order:10; }
 body:not([data-scene=fingers]) #position #skip-range { order:11; }
 body:not([data-scene=fingers]) #position .sim-label { order:12; }
}
@media(orientation:portrait) {
 body[data-scene=fingers]:has(#audio-banner:not([hidden])) #toolbar { bottom:64px; }
}
/* Keep neck actions above the persistent unlock banner while audio is locked. */
body.playing:has(#coach):has(#audio-banner:not([hidden])) .playfield {
 height:calc(100dvh - 410px); min-height:280px; max-height:490px;
}
@media(orientation:portrait) {
 body:has(#audio-banner:not([hidden])) #hud :is(.meter,.combo) { bottom:64px; }
 body:not([data-scene=fingers]):has(#audio-banner:not([hidden])) #toolbar { bottom:112px; }
 body[data-scene=fingers]:has(#audio-banner:not([hidden])) #hand-quality { bottom:120px; }
}
@media(min-width:701px) {
 body.playing:has(#coach):has(#audio-banner:not([hidden])) .indicator { width:170px; }
 body.playing:has(#coach):has(#audio-banner:not([hidden])) .indicator svg { width:140px; height:140px; }
}

/* Solid cards and a separate dimmed layer keep stage text behind settings. */
#settings.screen { background:rgba(32,24,44,.60); backdrop-filter:blur(8px); z-index:80; }
#settings.screen > .sheet,#settings.pulse-settings { background:#fffaf4; color:#3a2340; opacity:1; box-shadow:0 24px 80px #30233355; }
#settings.pulse-settings::backdrop { background:rgba(32,24,44,.60); backdrop-filter:blur(8px); }
#settings .pulse-row .control-label { flex-shrink:1; }
