.speaking-page .app { grid-template-rows:calc(var(--topbar) + env(safe-area-inset-top)) minmax(0,1fr) auto; }
.speaking-stage { min-height:0; display:grid; grid-template-rows:minmax(0,1fr) fit-content(70%); width:min(100%,640px); margin:auto; height:100%; text-align:center; }
.speaking-stage .orb-space { min-height:0; max-height:none; width:100%; }
.practice-readout { min-height:0; overflow:auto; padding:0 12px 12px; }
.practice-label { font-size:var(--fs-sm); color:var(--text-3); margin:0 0 8px; }
.practice-readout h1 { font:600 var(--fs-xl)/1.25 var(--font-display); margin:0 0 12px; }
#question { font-size:var(--fs-lg); line-height:1.5; margin:0; }
#status, #hint { font-size:var(--fs-sm); color:var(--text-2); margin:12px 0 0; }
#heard { width:fit-content; max-width:100%; margin:0 auto 4px; padding-left:8px; border-left:2px solid var(--border); text-align:left; font-size:var(--fs-sm); font-style:italic; color:var(--text-2); overflow-wrap:anywhere; }
#status { text-wrap:balance; }
#hint { border-left:2px solid var(--accent); text-align:left; padding-left:12px; }
.speaking-dock { width:min(100%,640px); min-height:184px; justify-self:center; padding:0 0 max(12px,env(safe-area-inset-bottom)); display:grid; grid-template-rows:minmax(44px,auto) 44px minmax(48px,auto) auto; gap:4px; }
#alert { margin:0; font-size:var(--fs-sm); color:var(--warn); text-align:center; }
.primary-actions,.secondary-actions { display:flex; justify-content:center; align-items:center; gap:12px; }
.primary-actions .btn { min-width:120px; }
.speaking-page .btn { border-radius:8px; min-height:44px; box-shadow:none; transform:none; transition:background-color 120ms,color 120ms; }
.speaking-page .btn:hover,.speaking-page .btn:active { transform:none; box-shadow:none; }
.privacy-note,.transcript-note { color:var(--text-3); font-size:var(--fs-xs); text-align:center; margin:8px 0 0; }
.privacy-note { margin-top:4px; line-height:1.5; }
.speaking-page :is(#lessonPicker,#transcript) { inset:0; margin:auto; color:var(--text); background:var(--surface); border:1px solid var(--border-strong); border-radius:12px; width:min(480px,calc(100vw - 32px)); max-height:calc(100dvh - 32px); padding:16px; overflow:auto; }
.speaking-page :is(#lessonPicker,#transcript)::backdrop { background:color-mix(in srgb,var(--bg) 75%,transparent); }
.panel-head { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:12px; }
.panel-head h2 { font-size:var(--fs-lg); margin:0; }
#practiceSelect { display:none; }
#practiceSegments { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; padding:4px; margin:0 0 12px; border-radius:12px; background:var(--surface-2); }
#practiceSegments .btn { padding:0 8px; font-size:var(--fs-sm); color:var(--text-2); }
#practiceSegments .btn[aria-pressed="true"] { background:var(--accent-soft); color:var(--accent); }
#practiceDescription { color:var(--text-2); font-size:var(--fs-sm); line-height:1.5; margin:0 0 12px; }
#scenarioList { display:grid; }
#scenarioList button { min-height:56px; border-bottom:1px solid var(--border); text-align:left; justify-content:space-between; white-space:normal; gap:12px; }
#scenarioList button[aria-pressed="true"] { color:var(--accent); }
#scenarioList button svg { width:20px; height:20px; flex-shrink:0; visibility:hidden; fill:none; stroke:currentColor; stroke-width:1.8; }
#scenarioList button[aria-pressed="true"] svg { visibility:visible; }
.speaking-page .speaking-icon { width:48px; padding:0; flex-shrink:0; }
.speaking-icon svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; }
#talk[aria-pressed="true"] { background:var(--surface-2); color:var(--text); }
/* Results carry the most text: the orb yields space before anything scrolls. */
.speaking-stage:has(#feedback:not([hidden])) { grid-template-rows:minmax(48px,1fr) fit-content(88%); }
#feedback { text-align:left; font-size:var(--fs-md); line-height:1.5; }
#tip { border-top:1px solid var(--border); }
@media(max-width:640px) { .speaking-page { --pad:16px; --topbar:56px; } .speaking-page .brand .name { display:none; } .speaking-stage { grid-template-rows:minmax(0,1fr) fit-content(85%); } .privacy-note { font-size:13px; } }
@media(max-height:600px) { .speaking-page .app { grid-template-rows:48px minmax(0,1fr) auto; } .speaking-stage { grid-template-rows:minmax(0,1fr) fit-content(88%); } .speaking-dock { min-height:156px; grid-template-rows:minmax(44px,auto) 44px minmax(44px,auto); } .privacy-note { display:none; } }
@media(max-height:600px) and (min-height:481px) { .speaking-stage { grid-template-rows:minmax(0,1fr) fit-content(88%); } #question { font-size:var(--fs-md); } #status,#hint { margin-top:8px; } }
@media(max-height:480px) { .speaking-stage { grid-template-columns:32% minmax(0,1fr); grid-template-rows:minmax(0,1fr); align-items:center; } .speaking-stage .orb-space { height:100%; } .practice-readout { max-height:100%; text-align:left; padding:8px; } .practice-label { margin-bottom:4px; } .practice-readout h1 { font-size:var(--fs-lg); margin-bottom:8px; } #question { font-size:var(--fs-md); } #status,#hint { margin-top:8px; } }
@media(prefers-reduced-motion:reduce) { .speaking-page * { transition:none !important; } }
/* Keep the main speaking action clear; occasional controls open above the dock. */
#autoSendControl { display:flex; align-items:center; gap:10px; min-height:44px; color:var(--text); font-size:var(--fs-sm); cursor:pointer; }
#autoSend { width:18px; height:18px; margin:0; flex-shrink:0; accent-color:var(--accent); cursor:pointer; }
#autoSendControl:has(input:focus-visible) { outline:2px solid var(--accent); outline-offset:2px; border-radius:8px; }
.speaking-page .primary-actions .btn { min-width:0; }
.speaking-page .primary-actions .btn-primary { min-width:104px; }
#finish { color:var(--text-3); }
#finish:hover { color:var(--danger); }
@media(max-width:640px) {
  .speaking-page .primary-actions,.speaking-page .secondary-actions { gap:4px; }
  .speaking-page .primary-actions .btn { padding-inline:10px; font-size:var(--fs-sm); }
  .speaking-page .primary-actions .btn-primary { min-width:80px; }
  .secondary-actions { position:relative; }
  .speaking-page #lessonPicker { top:auto; bottom:16px; margin:0 auto; border-radius:16px; max-height:calc(100dvh - 32px); }
}

/* Fixed lesson sheet: six equal rows scroll within a stable frame. */
.speaking-page #lessonPicker { height:min(480px,calc(100dvh - 32px)); overflow:hidden; }
#lessonPicker[open] { display:flex; flex-direction:column; }
#lessonPicker .panel-head,#lessonPicker #practiceSegments { flex-shrink:0; }
#lessonPicker #scenarioList { flex:1; min-height:0; overflow:auto; align-content:start; scrollbar-gutter:stable; }
#lessonPicker #scenarioList button { height:56px; flex-shrink:0; }
/* One fixed dock grid; hidden actions retain their column. */
.speaking-dock { min-height:112px; grid-template-rows:minmax(44px,auto) 56px; }
.speaking-page #changeLesson { min-height:44px; padding:0 12px; border:1px solid var(--border-strong); background:var(--surface-2); font-size:var(--fs-sm); }
.question-row { display:flex; align-items:flex-start; justify-content:center; gap:8px; width:fit-content; max-width:100%; margin-inline:auto; }
.question-row #question { min-width:0; overflow-wrap:anywhere; padding-block:8px; }
#replay { width:44px; height:44px; }
#replay[aria-pressed="true"] { color:var(--accent); }


.question-help { display:flex; justify-content:center; align-items:center; gap:8px; }
.question-help:has(#hintToggle[hidden]):has(#talk[hidden]) { display:none; }
#hintToggle { min-height:44px; padding:0 12px; font-size:var(--fs-sm); }
.speaking-page .speaking-controls { display:grid; grid-template-columns:104px 144px 104px; width:384px; max-width:100%; justify-self:center; gap:16px; align-items:center; }
.speaking-page .speaking-controls :is(.secondary-actions,.primary-actions) { display:contents; }
.speaking-page #talk { width:44px; height:44px; border:1px solid var(--border-strong); background:var(--surface-2); --mic-level:0; box-shadow:0 0 0 calc(var(--mic-level) * 10px) color-mix(in srgb, var(--accent) 35%, transparent); transition:box-shadow 80ms linear, border-color 120ms; }
.speaking-page #talk[data-voice] { border-color:var(--accent); color:var(--accent); }
@media(prefers-reduced-motion:reduce) { .speaking-page #talk { box-shadow:none; } }
/* Desktop: mic shares the first dock column with hang-up, so send stays exactly where Start was. */
.speaking-page .speaking-controls #talk { grid-column:1; grid-row:1; justify-self:start; width:48px; height:56px; }
.speaking-page .speaking-controls:has(#talk:not([hidden])) #finish { width:48px; justify-self:end; }
.speaking-page .speaking-controls #talk:has(#micLabel:not([hidden])) { width:48px; padding:0; flex-direction:column; gap:2px; font-size:11px; line-height:1.1; white-space:nowrap; }
.speaking-page .speaking-controls #talk:has(#micLabel:not([hidden])) svg { width:18px; height:18px; }
.speaking-page .speaking-controls #changeLesson { grid-column:1; grid-row:1; width:104px; height:56px; justify-self:center; }
.speaking-page .speaking-controls :is(#start,#send) { grid-column:2; grid-row:1; width:144px; min-width:144px; height:56px; padding:0 12px; font-size:var(--fs-md); }
.speaking-page .speaking-controls #finish { grid-column:1; grid-row:1; width:104px; justify-self:center; height:56px; min-width:0; padding:0; border-radius:8px; background:var(--danger-solid); color:var(--on-danger); }
.speaking-page .speaking-controls #finish:hover { background:var(--danger-solid-hover); }
.speaking-page .speaking-controls #finish:active { background:var(--danger-solid-press); }
.speaking-page #autoSendControl { grid-column:3; grid-row:1; width:104px; height:56px; padding:0 8px; border:1px solid var(--border-strong); border-radius:8px; background:var(--surface-2); justify-content:center; gap:6px; white-space:nowrap; }
@media(max-width:640px) {
 .speaking-page .speaking-controls { grid-template-columns:80px 96px 80px; width:280px; gap:12px; }
 .speaking-page .speaking-controls :is(#start,#send) { width:96px; min-width:96px; font-size:var(--fs-sm); }
 .speaking-page .speaking-controls #changeLesson { width:80px; padding:0 4px; font-size:13px; }
 .speaking-page .speaking-controls #finish { width:80px; }
 .speaking-page #autoSendControl { width:80px; padding:0 4px; font-size:13px; }
}

.speaking-page #talk:has(#micLabel:not([hidden])) { width:auto; padding:0 10px; gap:6px; font-size:var(--fs-sm); }
@media(max-height:480px) {
 .question-row { margin-inline:0; justify-content:flex-start; }
 .question-help { justify-content:flex-start; }
 /* Phone landscape: keep question, help, status and hint visible without inner scrolling. */
 .practice-label { display:none; }
 .practice-readout h1 { margin-bottom:4px; }
 .question-row #question { padding-block:4px; }
 #status, #hint { margin-top:4px; }
 #feedback { font-size:var(--fs-sm); line-height:1.4; }
 #feedback p { margin:2px 0; }
 .practice-readout { padding-block:0; }
 #dismissTip { min-height:44px; padding-block:0; margin:0; }
}
