/* Six-step lesson geometry contract.
   Every learning step keeps the same two-column frame as the approved step-1 reference. */
body[data-current-view="lesson"] .workbench-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

.landscape-focus-toggle {
  display: none;
}

body:not([data-current-view="lesson"]) .lesson-header-steps,
body:not([data-current-view="lesson"]) .landscape-focus-toggle {
  display: none !important;
}

.lesson-view .editor {
  display: none !important;
}

.lesson-view .workspace,
.lesson-view .context-return-bar + .workspace {
  grid-template-columns: minmax(0, 1fr) !important;
}

.lesson-header-steps {
  width: auto;
  min-width: 0;
  height: 42px;
  margin: 0;
  padding: 0 12px;
  grid-template-columns: 1fr 12px 1fr 12px 1fr 12px 1fr 12px 1fr 12px 1fr 12px 1fr;
  border-radius: 7px;
}

.lesson-view .context-return-bar {
  position: relative;
  box-sizing: border-box;
  height: 56px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 7px max(16px, calc((100% - 1180px) / 2));
}

.phonetic-drawer-toggle {
  position: fixed;
  left: 12px;
  top: 78px;
  z-index: 102;
  min-width: 92px;
  height: 40px;
  border: 1px solid #9bc9bb;
  border-radius: 6px;
  background: #edf7f3;
  color: #176b57;
  font-weight: 800;
  cursor: pointer;
}

.lesson-view .editor#lessonPhoneticDrawer {
  display: none !important;
}

body.phonetic-drawer-open .lesson-view .editor#lessonPhoneticDrawer {
  position: fixed;
  inset: 66px auto 0 0;
  z-index: 110;
  display: block !important;
  width: min(380px, 92vw);
  height: calc(100dvh - 66px);
  overflow-y: auto;
  padding: 54px 18px 20px;
  border-right: 1px solid #cbd9d2;
  background: #f8faf5;
  box-shadow: 12px 0 32px rgba(22, 43, 68, 0.18);
}

body.phonetic-drawer-open .lesson-view .editor#lessonPhoneticDrawer .word-generator {
  display: none;
}

body.phonetic-drawer-open .lesson-view .editor#lessonPhoneticDrawer .editor-tabs,
body.phonetic-drawer-open .lesson-view .editor#lessonPhoneticDrawer .reference-panel {
  display: grid;
}

body.phonetic-drawer-open .lesson-view .editor#lessonPhoneticDrawer .reference-panel:not(.active) {
  display: none;
}

.phonetic-drawer-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid #ccd8d2;
  border-radius: 50%;
  background: #fff;
  color: #40566a;
  font-size: 22px;
  cursor: pointer;
}

.lesson-view .context-return-bar > button,
.lesson-view .context-return-bar > .lesson-header-steps {
  height: 42px;
  min-height: 42px;
}

.lesson-view .context-return-bar + .workspace {
  height: calc(100dvh - 122px);
}

.lesson-view .preview-shell {
  padding: 10px 16px 8px;
  overflow: hidden;
}

.lesson-view .preview-shell .page {
  margin: 0 auto;
  padding: 12px 20px 10px;
  border-top-width: 4px;
}

.lesson-header-steps .step {
  gap: 5px;
}

.lesson-header-steps .step b {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.lesson-header-steps .step strong {
  font-size: 12px;
}

.lesson-header-steps .step small {
  font-size: 9px;
}

@media (max-width: 1100px) {
  .lesson-header-steps {
    grid-template-columns: repeat(7, minmax(46px, 1fr));
    gap: 3px;
    padding-inline: 5px;
  }

  .lesson-header-steps > i {
    display: none;
  }
}

@media (max-width: 680px) {
  .lesson-view .context-return-bar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
    padding-inline: 8px;
  }

  .lesson-view .context-return-bar > button {
    padding-inline: 9px;
    font-size: 12px;
  }

  .lesson-header-steps .step span {
    display: none;
  }

  .lesson-header-steps .step {
    justify-items: center;
  }

  body[data-current-view="lesson"] .workbench-header .lesson-header-steps {
    grid-template-columns: repeat(7, minmax(24px, 1fr));
    gap: 1px;
    padding-inline: 0;
  }

  .lesson-header-steps .step b {
    width: 22px;
    height: 22px;
  }
}

.lesson-view .learning-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr) !important;
  align-items: stretch !important;
  gap: 18px;
}

.lesson-view .stage-column,
.lesson-view .stage-column > .stage,
.lesson-view .memory-panel {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0 !important;
  height: clamp(360px, calc(100dvh - 220px), 756px) !important;
  max-height: 756px;
}

.lesson-view .stage-column > .stage {
  overflow-x: hidden;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 2vh, 24px) clamp(16px, 2.4vw, 30px) 14px;
}

.lesson-view .stage-column > .stage[hidden] {
  display: none !important;
}

.lesson-view .stage-column > .stage > header {
  flex: 0 0 auto;
  padding-bottom: clamp(9px, 1.4vh, 16px);
}

.lesson-view .stage-column > .stage > .next-button {
  flex: 0 0 auto;
  margin-top: auto;
}

/* Step 1 keeps every teaching element and its action visible in one viewport. */
.lesson-view #stage1 .phoneme-trainer {
  flex: 1 1 auto;
  min-height: 0;
  align-content: center;
  gap: clamp(6px, 1.1vh, 11px);
  padding: clamp(8px, 1.4vh, 14px) 0 8px;
}

.lesson-view #stage1 #wordDisplay { order: 1; }
.lesson-view #stage1 .sound-color-legend { order: 2; }
.lesson-view #stage1 .dual-ipa { order: 3; }
.lesson-view #stage1 #phonemeMeaning { order: 4; }
.lesson-view #stage1 #phonemeTapGrid { order: 5; }
.lesson-view #stage1 .vowel-rule-panel { order: 6; }

.lesson-view #stage1 .word-display {
  font-size: clamp(46px, 6.2vh, 64px);
}

.lesson-view #stage1 .ipa-button {
  padding: 7px 11px;
}

.lesson-view #stage1 .ipa-button strong {
  font-size: 17px;
}

.lesson-view #stage1 .training-current-meaning {
  font-size: clamp(20px, 2.8vh, 28px);
}

.lesson-view #stage1 .phoneme-tap-grid button {
  min-height: 54px;
  padding: 6px 9px;
}

.lesson-view #stage1 .phoneme-tap-grid strong { font-size: 19px; }
.lesson-view #stage1 .phoneme-tap-grid small { font-size: 14px; }

.lesson-view #stage1 .vowel-rule-panel {
  padding-top: 8px;
}

.lesson-view #stage1 .vowel-rule-panel > header {
  margin-bottom: 6px;
}

.lesson-view #stage1 .current-sound-summary {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 6px 9px;
}

.lesson-view #stage1 #currentSoundGroupsStage {
  gap: 4px;
}

.lesson-view #stage1 .current-sound-group {
  grid-template-columns: 56px minmax(0, 1fr);
  margin: 0;
  gap: 6px;
}

.lesson-view #stage1 .current-sound-group h3 {
  padding-top: 7px;
}

.lesson-view #stage1 .current-sound-group button {
  min-width: 60px;
  height: 38px;
  padding: 3px 6px;
}

.lesson-view #stage1 .current-sound-group button strong { font-size: 15px; }
.lesson-view #stage1 .current-sound-group button small { font-size: 10px; }

.lesson-view .memory-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lesson-view .memory-panel > header {
  flex: 0 0 auto;
}

.lesson-view .memory-flip {
  flex: 1 1 auto;
  min-height: 0 !important;
  height: auto !important;
  aspect-ratio: auto !important;
}

.lesson-view .memory-face,
.lesson-view .memory-cover,
.lesson-view .memory-cover img {
  min-height: 0;
  max-height: 100%;
}

@media (min-width: 901px) {
  .lesson-view .memory-panel {
    display: flex;
    flex-direction: column;
  }

  .lesson-view .memory-flip {
    flex: 1 1 auto;
  }
}

@media (max-width: 900px) {
  .lesson-view .learning-grid {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr) !important;
    gap: clamp(6px, 1vw, 10px);
  }

  .lesson-view .stage-column,
  .lesson-view .stage-column > .stage,
  .lesson-view .memory-panel {
    width: auto !important;
    height: clamp(350px, calc(100dvh - 220px), 700px) !important;
    max-height: 700px;
  }
}

@media (max-height: 760px) {
  .lesson-view .stage-column > .stage > header {
    gap: 8px;
    padding-bottom: 5px;
  }
  .lesson-view .stage > header > span { font-size: 18px; }
  .lesson-view .stage h2 { font-size: 16px; }
  .lesson-view .stage header p { margin-top: 2px; font-size: 10px; line-height: 1.25; }
  .lesson-view #stage1 .phoneme-trainer { gap: 3px; padding: 3px 0; }
  .lesson-view #stage1 .word-display { font-size: 38px; line-height: 38px; }
  .lesson-view #stage1 .dual-ipa { gap: 6px; }
  .lesson-view #stage1 .ipa-button { min-height: 34px; padding: 4px 8px; }
  .lesson-view #stage1 .ipa-button strong { font-size: 15px; }
  .lesson-view #stage1 .training-current-meaning { font-size: 20px; line-height: 1.1; }
  .lesson-view #stage1 .phoneme-tap-grid button { min-height: 44px; }
  .lesson-view #stage1 .vowel-rule-panel { padding-top: 4px; }
  .lesson-view #stage1 .vowel-rule-panel > header { margin-bottom: 3px; }
  .lesson-view #stage1 .current-sound-summary { padding: 3px 6px; }
  .lesson-view #stage1 #currentSoundGroupsStage { gap: 1px; }
  .lesson-view #stage1 .current-sound-group { grid-template-columns: 52px minmax(0, 1fr); gap: 4px; }
  .lesson-view #stage1 .current-sound-group h3 { padding-top: 5px; font-size: 11px; }
  .lesson-view #stage1 .current-sound-group button { height: 30px; min-width: 60px; padding: 1px 6px; }
  .lesson-view #stage1 .current-sound-group button strong { font-size: 14px; }
  .lesson-view #stage1 .current-sound-group button small { font-size: 9px; }
  .lesson-view .stage-column > .stage > .next-button { min-height: 38px; padding-block: 8px; }
  .lesson-view .dictation-levels { gap: 7px; padding-top: 7px; }
  .lesson-view .dictation-levels i { width: 28px; }
  .lesson-view .assembly-practice,
  .lesson-view .letter-assembly,
  .lesson-view .manual-dictation {
    flex: 1 1 auto;
    min-height: 0;
    align-content: center;
    gap: 9px;
    padding: 6px 0;
  }
  .lesson-view .assembly-sound { width: 40px; height: 40px; }
  .lesson-view .assembly-slots { min-height: 48px; }
  .lesson-view .assembly-slot { height: 44px; min-width: 44px; font-size: 21px; }
  .lesson-view .letter-slots .assembly-slot { height: 40px; }
  .lesson-view .assembly-bank { gap: 6px; }
  .lesson-view .assembly-bank button { height: 38px; min-width: 58px; font-size: 17px; }
  .lesson-view .manual-dictation input { height: 48px; font-size: 30px; }
  .lesson-view .soft-keyboard { gap: 4px; padding: 6px 8px; }
  .lesson-view .soft-key-row { gap: 4px; }
  .lesson-view .soft-key-row button { width: 42px; height: 32px; font-size: 16px; }
  .lesson-view .soft-key-row .soft-key-action { width: 58px; font-size: 11px; }
  .lesson-view .soft-key-row .soft-key-symbol { width: 36px; font-size: 17px; }
  .lesson-view .mnemonic-study {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 6px 0;
  }
  .lesson-view .mnemonic-study-map {
    grid-template-columns: 78px minmax(150px, 1fr);
    min-height: 0;
    gap: 18px;
    padding: 4px 0;
  }
  .lesson-view .mnemonic-study-map .branches { min-height: 0; }
  .lesson-view .mnemonic-study-story { padding: 8px; border-top: 0; border-left: 1px solid var(--line); }
  .lesson-view .mnemonic-study-story > span { margin-bottom: 6px; padding: 3px 6px; }
  .lesson-view .mnemonic-study-story p { font-size: 14px; line-height: 1.55; }
  .lesson-view .mnemonic-narration { min-height: 30px; margin-top: 6px; }
}

/* Phones in landscape keep the approved two-column geometry in a shorter frame. */
@media (orientation: landscape) and (max-height: 620px) {
  body[data-current-view="lesson"] .workbench-header,
  body[data-current-view="lesson"] .phonetic-drawer-toggle {
    display: none !important;
  }

  body[data-current-view="lesson"] .landscape-focus-toggle {
    position: fixed;
    top: 6px;
    left: 8px;
    z-index: 140;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    height: 34px;
    padding: 3px 7px 3px 4px;
    border: 1px solid rgba(159, 184, 174, 0.72);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.94);
    color: #14243a;
    box-shadow: 0 3px 10px rgba(30, 58, 48, 0.16);
    cursor: pointer;
  }

  .landscape-focus-toggle img {
    width: 27px;
    height: 27px;
    border-radius: 5px;
    object-fit: cover;
  }

  .landscape-focus-toggle span,
  .landscape-focus-toggle strong,
  .landscape-focus-toggle small {
    display: block;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .landscape-focus-toggle strong {
    font-size: 10px;
    line-height: 1.1;
  }

  .landscape-focus-toggle small {
    margin-top: 2px;
    color: #718078;
    font-size: 7px;
    line-height: 1;
  }

  body[data-current-view="lesson"] .context-return-bar,
  body[data-current-view="lesson"] .pretest-warning:not([hidden]) {
    display: none;
  }

  body[data-current-view="lesson"].landscape-menu-open .workbench-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 135;
    display: flex !important;
  }

  body[data-current-view="lesson"].landscape-menu-open .phonetic-drawer-toggle {
    display: block !important;
    top: 68px;
    z-index: 138;
  }

  body[data-current-view="lesson"].landscape-menu-open .landscape-focus-toggle {
    top: 72px;
    left: auto;
    right: 8px;
    z-index: 141;
  }

  body[data-current-view="lesson"] .app-shell,
  body[data-current-view="lesson"] .lesson-view {
    height: 100dvh;
    min-height: 0;
  }

  .lesson-view .context-return-bar {
    height: 42px;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 2px 8px;
  }

  .lesson-view .context-return-bar > button {
    display: none;
  }

  .lesson-view .context-return-bar > .lesson-header-steps,
  .lesson-header-steps {
    width: 100%;
    height: 38px;
    min-height: 38px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .lesson-header-steps::-webkit-scrollbar {
    display: none;
  }

  .lesson-header-steps .step {
    min-width: 0;
  }

  .lesson-view .context-return-bar + .workspace {
    height: 100dvh;
    min-height: 0;
  }

  .lesson-view .preview-shell {
    min-height: 0;
    padding: 5px 8px 6px;
  }

  .lesson-view .preview-shell .page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 6px 10px;
  }

  .lesson-view .pretest-warning:not([hidden]) {
    flex: 0 0 auto;
    min-height: 30px;
    margin-bottom: 4px;
    padding: 4px 10px;
    font-size: 12px;
  }

  .lesson-view .pretest-warning span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .lesson-view .learning-grid {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    gap: 8px;
  }

  .lesson-view .stage-column,
  .lesson-view .stage-column > .stage,
  .lesson-view .memory-panel {
    height: 100% !important;
    min-height: 0 !important;
    max-height: none;
  }

  .lesson-view .stage-column > .stage {
    overflow-y: auto;
    padding: 7px 10px 6px;
    scrollbar-width: thin;
  }

  .lesson-view .memory-panel {
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .lesson-view .stage-column > .stage > .next-button {
    position: sticky;
    bottom: 0;
    z-index: 2;
  }
}

/* Approved single-screen learning layout: content first, navigation hidden. */
body[data-current-view="lesson"] .pretest-warning,
body[data-current-view="lesson"] .context-return-bar,
body[data-current-view="lesson"] .stage > header,
body[data-current-view="lesson"] .dictation-levels,
body[data-current-view="lesson"] .memory-panel > header {
  display: none !important;
}
body[data-current-view="lesson"] .preview-shell .page {
  height: 100%;
  min-height: 0;
  padding: 8px 14px;
}
body[data-current-view="lesson"] .learning-grid {
  height: 100%;
  min-height: 0;
  gap: 12px;
}
body[data-current-view="lesson"] .stage-column > .stage,
body[data-current-view="lesson"] .memory-panel {
  overflow: hidden !important;
  min-height: 0 !important;
}
body[data-current-view="lesson"] .stage-column > .stage {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-content: start;
  padding: 10px 12px;
}
body[data-current-view="lesson"] .overview-stage {
  display: flex !important;
  position: relative;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  padding-top: 6px !important;
}
body[data-current-view="lesson"] .overview-stage .lesson-group-tracker {
  flex: 0 0 auto;
  margin-bottom: 12px;
}
body[data-current-view="lesson"] .overview-stage .overview-top {
  position: static;
  order: -1;
  display: flex;
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  padding: 0 8px;
  text-align: right;
}
body[data-current-view="lesson"] .overview-stage .overview-word {
  flex: 0 0 auto;
  min-height: 0;
  margin-block: 2px 4px;
}
body[data-current-view="lesson"] .overview-stage .accent-grid {
  flex: 0 0 auto;
  width: min(560px, 82%);
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-self: center;
  margin-inline: auto;
  margin-bottom: 4px;
}
body[data-current-view="lesson"] .overview-stage .accent-card {
  width: 100%;
  min-width: 0;
}
body[data-current-view="lesson"] .overview-stage .overview-meaning {
  flex: 0 0 auto;
  width: min(650px, 100%);
  box-sizing: border-box;
  align-self: center;
  margin: 0 0 8px;
  padding: 10px 18px;
  justify-items: center;
  text-align: center;
  border: 1px solid #bedcd3;
  border-radius: 6px;
  background: #f1faf7;
}
body[data-current-view="lesson"] .overview-stage .overview-meaning span {
  font-size: 14px;
}
body[data-current-view="lesson"] .overview-stage .overview-meaning strong {
  font-size: 30px;
  line-height: 1.35;
}
body[data-current-view="lesson"] .overview-stage .read-aloud {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 12px 14px 10px;
}
body[data-current-view="lesson"] .overview-stage .practice-copy {
  margin-bottom: 4px;
}
body[data-current-view="lesson"] .overview-stage .practice-button {
  min-height: 48px;
  margin-top: 8px;
}
body[data-current-view="lesson"] .overview-stage .practice-feedback {
  margin: 8px 0 0;
}
body[data-current-view="lesson"] .overview-stage .practice-feedback:empty {
  display: none;
}
body[data-current-view="lesson"] #stage3,
body[data-current-view="lesson"] #stage4,
body[data-current-view="lesson"] #stage5,
body[data-current-view="lesson"] #stage6 {
  display: flex !important;
  flex-direction: column;
  justify-content: flex-start;
}
body[data-current-view="lesson"] #stage3 .assembly-practice,
body[data-current-view="lesson"] #stage4 .mnemonic-study,
body[data-current-view="lesson"] #stage5 .letter-assembly,
body[data-current-view="lesson"] #stage6 .manual-dictation {
  flex: 0 0 auto;
  min-height: 0;
  margin-top: 8px;
}
body[data-current-view="lesson"] #stage4 .mnemonic-study {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
body[data-current-view="lesson"] #stage4 .mnemonic-study-map,
body[data-current-view="lesson"] #stage4 .mnemonic-study-story {
  height: auto;
  min-height: 0;
}
body[data-current-view="lesson"] #stage4 .next-button {
  display: block !important;
  visibility: visible !important;
  position: relative;
  z-index: 3;
}
body[data-current-view="lesson"] #stage3 .next-button,
body[data-current-view="lesson"] #stage4 .next-button,
body[data-current-view="lesson"] #stage5 .next-button,
body[data-current-view="lesson"] #stage6 .check-button {
  flex: 0 0 auto;
  margin-top: 10px;
}
body[data-current-view="lesson"] #stage1 {
  display: flex !important;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
}
body[data-current-view="lesson"] #stage1 .phoneme-trainer {
  flex: 0 0 auto;
  min-height: 0;
  padding: 8px 0 4px;
  gap: 8px;
}
body[data-current-view="lesson"] #stage1 .phoneme-tap-grid {
  margin-top: 2px;
}
body[data-current-view="lesson"] #stage1 .vowel-rule-panel {
  margin-top: 4px;
  padding-top: 6px;
}
body[data-current-view="lesson"] #stage1 .current-sound-summary {
  padding-block: 4px;
}
body[data-current-view="lesson"] #stage1 > .next-button {
  flex: 0 0 auto;
  align-self: center;
  width: min(360px, 82%);
  min-height: 48px;
  margin: 10px auto 0;
}
/* Every learning step is vertically centered as one compact content group. */
body[data-current-view="lesson"] .stage-column > .stage:not([hidden]) {
  justify-content: center;
}
body[data-current-view="lesson"] .overview-stage:not([hidden]) {
  justify-content: center !important;
}
body[data-current-view="lesson"] #stage1:not([hidden]),
body[data-current-view="lesson"] #stage2:not([hidden]),
body[data-current-view="lesson"] #stage2:not([hidden]),
body[data-current-view="lesson"] #stage3:not([hidden]),
body[data-current-view="lesson"] #stage4:not([hidden]),
body[data-current-view="lesson"] #stage5:not([hidden]),
body[data-current-view="lesson"] #stage6:not([hidden]) {
  justify-content: center !important;
}
body[data-current-view="lesson"] #stage2:not([hidden]) {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  justify-content: center !important;
}
body[data-current-view="lesson"] #stage2 .blend-overview,
body[data-current-view="lesson"] #stage2 .syllable-summary,
body[data-current-view="lesson"] #stage2 .syllable-board,
body[data-current-view="lesson"] #stage2 .next-button {
  flex: 0 0 auto;
}
body[data-current-view="lesson"] #stage2 .next-button {
  align-self: center;
  margin-top: 12px;
}
body[data-current-view="lesson"] .memory-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* The word overview always opens as a focused single-column page. */
body[data-current-view="lesson"][data-lesson-step="0"] .learning-grid {
  grid-template-columns: minmax(0, 1fr) !important;
}
body[data-current-view="lesson"][data-lesson-step="0"] .stage-column {
  width: 100% !important;
  max-width: 980px !important;
  margin-inline: auto;
  justify-self: center;
}
body[data-current-view="lesson"][data-lesson-step="0"] .memory-panel {
  display: none !important;
}
/* Hidden stages must never be revived by the flex layout overrides above. */
body[data-current-view="lesson"] .stage[hidden],
body[data-current-view="lesson"] [hidden] {
  display: none !important;
}
body[data-current-view="lesson"] #stage0[hidden],
body[data-current-view="lesson"] #stage1[hidden],
body[data-current-view="lesson"] #stage2[hidden],
body[data-current-view="lesson"] #stage3[hidden],
body[data-current-view="lesson"] #stage4[hidden],
body[data-current-view="lesson"] #stage5[hidden],
body[data-current-view="lesson"] #stage6[hidden] {
  display: none !important;
}
body[data-current-view="lesson"] .overview-word {
  gap: 12px;
  align-items: center;
}
body[data-current-view="lesson"] .overview-meaning,
body[data-current-view="lesson"] .training-current-meaning,
body[data-current-view="lesson"] .blend-meaning {
  font-size: 1.35em;
}
body[data-current-view="lesson"] .dual-ipa,
body[data-current-view="lesson"] .accent-grid {
  gap: 6px;
}
body[data-current-view="lesson"] .ipa-button,
body[data-current-view="lesson"] .accent-card {
  min-height: 38px;
  padding-block: 4px;
}
body[data-current-view="lesson"] .mnemonic-study {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
body[data-current-view="lesson"] .mnemonic-study-map,
body[data-current-view="lesson"] .mnemonic-study-story {
  min-height: 0;
}
body[data-current-view="lesson"] .mnemonic-study-story p {
  font-size: clamp(16px, 1.45vw, 22px);
  line-height: 1.55;
}
body[data-current-view="lesson"] .memory-panel {
  padding: 12px;
}
body[data-current-view="lesson"] .memory-flip,
body[data-current-view="lesson"] .memory-flip-inner,
body[data-current-view="lesson"] .memory-face {
  height: 100%;
  min-height: 0;
}
body[data-current-view="lesson"] .manual-dictation {
  min-height: 0;
  gap: 10px;
}
body[data-current-view="lesson"] .manual-dictation > .assembly-sound {
  display: inline-grid;
  vertical-align: middle;
  margin-right: 12px;
}
body[data-current-view="lesson"] .manual-dictation > .training-current-meaning {
  display: inline-block;
  vertical-align: middle;
}
body[data-current-view="lesson"] .soft-key-row button {
  font-size: 24px;
}
body[data-current-view="lesson"] #stage5 .letter-slots .assembly-slot {
  font-size: 30px;
  font-weight: 900;
}
body[data-current-view="lesson"] #stage5 .letter-bank button {
  font-size: 25px;
  font-weight: 900;
}
body[data-current-view="lesson"] #stage5 .letter-slots .assembly-slot:not(.empty),
body[data-current-view="lesson"] #stage5 .letter-bank button {
  opacity: 1;
}
body[data-current-view="lesson"] #stage6 .manual-dictation input {
  font-size: clamp(40px, 4.5vw, 56px);
}

body[data-current-view="lesson"] #stage7 .manual-dictation {
  gap: 10px;
}
body[data-current-view="lesson"] #stage7 .manual-dictation-prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  white-space: nowrap;
}
body[data-current-view="lesson"] #stage7 .manual-dictation-prompt .assembly-sound {
  width: 38px;
  height: 38px;
  margin: 0;
}
body[data-current-view="lesson"] #stage7 .manual-dictation > .soft-keyboard {
  width: min(620px, calc(100% - 24px));
  gap: 4px;
  padding: 6px 8px;
}
body[data-current-view="lesson"] #stage7 .soft-keyboard .soft-key-row button {
  width: 42px;
  height: 40px;
  min-width: 0;
  font-size: 20px;
  white-space: nowrap;
}
body[data-current-view="lesson"] #stage7 .soft-keyboard .soft-key-row {
  gap: 4px;
}
body[data-current-view="lesson"] #stage7 .soft-keyboard .soft-key-row .soft-key-action {
  width: 58px;
  padding-inline: 4px;
  font-size: 14px;
}
body[data-current-view="lesson"] #stage7 .soft-keyboard .soft-key-row .soft-key-symbol {
  width: 36px;
}

/* Seven-step flow: steps 0-4 are focused single-column study surfaces. */
body[data-current-view="lesson"][data-lesson-step="0"] .learning-grid,
body[data-current-view="lesson"][data-lesson-step="1"] .learning-grid,
body[data-current-view="lesson"][data-lesson-step="2"] .learning-grid,
body[data-current-view="lesson"][data-lesson-step="3"] .learning-grid,
body[data-current-view="lesson"][data-lesson-step="4"] .learning-grid {
  grid-template-columns: minmax(0, 1fr) !important;
}
body[data-current-view="lesson"][data-lesson-step="0"] .stage-column,
body[data-current-view="lesson"][data-lesson-step="1"] .stage-column,
body[data-current-view="lesson"][data-lesson-step="2"] .stage-column,
body[data-current-view="lesson"][data-lesson-step="3"] .stage-column,
body[data-current-view="lesson"][data-lesson-step="4"] .stage-column {
  width: 100% !important;
  max-width: 980px !important;
  margin-inline: auto;
  justify-self: center;
}
body[data-current-view="lesson"][data-lesson-step="0"] .memory-panel,
body[data-current-view="lesson"][data-lesson-step="1"] .memory-panel,
body[data-current-view="lesson"][data-lesson-step="2"] .memory-panel,
body[data-current-view="lesson"][data-lesson-step="3"] .memory-panel,
body[data-current-view="lesson"][data-lesson-step="4"] .memory-panel {
  display: none !important;
}
body[data-current-view="lesson"][data-lesson-step="5"] .stage-column,
body[data-current-view="lesson"][data-lesson-step="6"] .stage-column,
body[data-current-view="lesson"][data-lesson-step="7"] .stage-column {
  width: auto !important;
  max-width: none !important;
}
body[data-current-view="lesson"] #stage7[hidden] {
  display: none !important;
}

.ipa-choice-practice {
  display: grid;
  align-content: center;
  gap: 12px;
  width: min(100%, 650px);
  margin: 0 auto;
  padding: 8px 0;
}
.ipa-choice-word {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.ipa-choice-word strong {
  color: var(--navy);
  font-size: 54px;
  line-height: 1;
}
.ipa-choice-slots {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-inline: 24px;
}
.ipa-choice-slots::before,
.ipa-choice-slots::after {
  content: "/";
  color: #334155;
  font-size: 36px;
  font-weight: 800;
}
.ipa-choice-slot {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-bottom: 3px solid #25364b;
  color: #17253a;
  font-size: 24px;
  font-weight: 850;
}
.ipa-choice-bank {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 12px;
}
.ipa-choice-bank button {
  min-height: 70px;
  border: 1px solid #d5dde5;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font-size: 22px;
  font-weight: 800;
}
.ipa-choice-bank button.correct { border-color: #258c74; background: #e7f5ee; }
.ipa-choice-bank button.wrong { border-color: #d74e45; background: #fff0ee; }
#ipaChoiceFeedback { min-height: 24px; margin: 0; text-align: center; }
#stage2 > .next-button { width: min(360px, 82%); min-height: 48px; margin-inline: auto; }
body[data-current-view="lesson"] #stage2:not([hidden]) {
  gap: 12px;
  padding-block: 14px;
}

@media (max-width: 700px) {
  .ipa-choice-bank { grid-template-columns: repeat(2, minmax(88px, 1fr)); }
  .ipa-choice-practice { padding: 12px; }
  .ipa-choice-slot { width: 48px; height: 54px; font-size: 26px; }
  .ipa-choice-slots::before, .ipa-choice-slots::after { font-size: 40px; }
}
body[data-current-view="lesson"] .soft-key-row .soft-key-action {
  font-size: 15px;
}
body[data-current-view="lesson"] .soft-key-row .soft-key-case {
  width: 72px;
  color: #526478;
}
body[data-current-view="lesson"] #manualWordInput {
  caret-color: var(--blue);
  user-select: text;
  cursor: text;
}
body[data-current-view="lesson"] .landscape-focus-toggle {
  position: static;
  z-index: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 116px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: #edf2ef;
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  box-shadow: 3px 3px 7px #cbd5d0, -3px -3px 7px #fff;
}
body[data-current-view="lesson"] .landscape-focus-toggle img,
body[data-current-view="lesson"] .landscape-focus-toggle span,
body[data-current-view="lesson"] .landscape-focus-toggle strong,
body[data-current-view="lesson"] .landscape-focus-toggle small {
  display: none !important;
}
body[data-current-view="lesson"] .landscape-focus-toggle::before {
  content: none;
}
body[data-current-view="lesson"].landscape-menu-open .landscape-focus-toggle::before {
  content: none;
}
body[data-current-view="lesson"] .context-return-bar {
  display: none !important;
}
body[data-current-view="lesson"] .phonetic-drawer-toggle {
  position: absolute !important;
  top: 12px;
  left: max(72px, calc((100% - 980px) / 2));
  z-index: 12;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: #edf2ef;
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  box-shadow: 3px 3px 7px #cbd5d0, -3px -3px 7px #fff;
}
body[data-current-view="lesson"] .phonetic-drawer-toggle:hover {
  background: #e7f4ee;
}
body[data-current-view="lesson"] .context-return-bar > button {
  display: none !important;
}
body[data-current-view="lesson"] .workbench-header .lesson-header-steps {
  flex: 1 1 900px;
  width: auto;
  max-width: 1050px;
}
body[data-current-view="lesson"].landscape-menu-open .workbench-header .header-brand-group {
  width: 100%;
  gap: 10px;
}
body[data-current-view="lesson"].landscape-menu-open .workbench-header .header-tools {
  display: none !important;
}
body[data-current-view="lesson"].landscape-menu-open .workbench-header .brand {
  display: none !important;
}
body[data-current-view="lesson"].landscape-menu-open .workbench-header .lesson-header-steps {
  display: grid !important;
  min-width: 0;
}
body[data-current-view="lesson"] .landscape-focus-toggle {
  white-space: nowrap;
}
body[data-current-view="lesson"] .landscape-focus-toggle::after {
  content: "  ▸";
  display: inline-block;
  margin-left: 4px;
}

@media (orientation: landscape) {
  body[data-current-view="lesson"] .preview-shell {
    padding-inline: clamp(14px, 3vw, 42px);
  }
  body[data-current-view="lesson"] .learning-grid {
    padding-inline: clamp(4px, 1.4vw, 18px);
  }
  body[data-current-view="lesson"] .overview-word {
    width: min(100%, 760px);
    margin-inline: auto;
    justify-content: center;
  }
  body[data-current-view="lesson"] .overview-word h1 {
    max-width: 100%;
    margin-inline: auto;
    font-size: clamp(42px, 6vw, 76px);
    line-height: .98;
    text-align: center;
    overflow-wrap: anywhere;
  }
  body[data-current-view="lesson"] .overview-word .main-sound {
    flex: 0 0 auto;
  }
}

@media (orientation: landscape) and (max-width: 900px) {
  body[data-current-view="lesson"] .learning-grid {
    gap: 8px;
  }
  body[data-current-view="lesson"] .stage-column > .stage,
  body[data-current-view="lesson"] .memory-panel {
    padding-inline: 10px;
  }
  body[data-current-view="lesson"] .overview-word h1 {
    font-size: clamp(34px, 5.5vw, 58px);
  }
}

/* Whole-word playback stays immediately after the word. */
body[data-current-view="lesson"] .overview-stage .overview-word {
  width: fit-content !important;
  max-width: calc(100% - 24px);
  margin-inline: auto !important;
  justify-content: center;
  gap: 14px;
}
body[data-current-view="lesson"] .overview-stage .overview-word h1 {
  flex: 0 1 auto;
  width: auto;
  margin: 0 !important;
}
body[data-current-view="lesson"] .overview-stage .overview-word .main-sound {
  position: static;
  flex: 0 0 auto;
  margin: 0;
}
body[data-current-view="lesson"] #phoneticDrawerToggle {
  display: none !important;
  visibility: hidden !important;
}
body[data-current-view="lesson"] #wordCard {
  position: relative;
}
