/* Beta 4 housekeeping: shared visual alignment, no navigation ownership. */
@media (min-width: 900px) and (min-height: 540px) {
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) :is(main.main,main.lesson,main.introMain),
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body>main {
  width:auto!important; min-width:0!important; max-width:none!important; box-sizing:border-box!important;
  margin-inline:0!important; padding:0 10px 8px!important; min-height:0!important;
 }
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) main :is(.cwLessonPage,.wrap,.assessmentMain,.modContent,.lesson-content,.introWorkspace,.introBody,.cwLessonOrientation,.content,.workspace):not(dialog *) {
  max-width:none!important; min-width:0!important; box-sizing:border-box!important;
 }
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) main>:is(.cwLessonPage,.wrap,.assessmentMain,.modContent,.lesson-content,.introWorkspace,.introBody,.cwLessonOrientation,.content,.workspace,.top,.controlbar,.gpsPanel,.keySection,#study) {
  width:100%!important; margin-inline:0!important; max-width:none!important; min-width:0!important; box-sizing:border-box!important;
 }
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) main>.lesson-content {padding-inline:0!important;padding-block:5px!important;}
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) main>.wrap{padding-inline:0!important;padding-top:5px!important;}
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) .cwLessonOrientation{width:100%!important;margin-inline:0!important;margin-block:4px 6px!important;padding:6px 10px!important;}
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) main>.introWorkspace{padding-inline:0!important;}
 html.cwLearningSystem:not(.cwTablet) body:not(.cwAcademyHome) .cwHKHeader{
  box-sizing:border-box!important; width:100%!important; max-width:none!important; min-width:0!important;
  margin:0 0 6px!important; padding:0 10px!important; height:56px!important;min-height:56px!important;
  display:flex!important;align-items:center!important;flex-wrap:nowrap!important;gap:6px!important;
  top:0!important;
 }
 html.cwLearningSystem:not(.cwTablet) body .cwHKActions{display:flex!important;align-items:center!important;justify-content:flex-end!important;flex-wrap:nowrap!important;gap:6px!important;margin-left:auto!important;margin-right:0!important;padding-inline:0!important;min-width:0!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader :is(.cwHKPrev,.cwHKNext){box-sizing:border-box!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;flex:0 0 94px!important;width:94px!important;min-width:94px!important;max-width:94px!important;height:36px!important;min-height:36px!important;margin:0!important;padding:0 5px!important;transform:none!important;white-space:nowrap!important;font-size:12px!important;line-height:1!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader .cwHKNext{order:100!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader .cwHKPrev{order:99!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader .cwLessonHeaderBrand{top:50%!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader>.cwHKActions{flex:0 0 auto!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader>div:not(.cwHKActions){min-width:0!important;}
 html.cwLearningSystem:not(.cwTablet) body .cwHKHeader>div:not(.cwHKActions) :is(.title,.sub){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
 /* Use proportional fitting only on the activity body, never on the navigation row. */
 html.cwLearningSystem:not(.cwTablet) body .cwHKFit{zoom:var(--cw-hk-fit,1)!important;width:auto!important;max-width:none!important;}
 html.cwLearningSystem:not(.cwTablet) body :is(.lesson-content,#study,.wrap) .cwHKKeyboard{max-width:100%!important;}
 html.cwLearningSystem.cwMelodyFamily:not(.cwTablet) body main.lesson{overflow:visible!important;}
 html.cwLearningSystem.cwMelodyFamily:not(.cwTablet) body main.lesson>.lesson-content{min-height:0!important;max-height:none!important;overflow:visible!important;}
 html.cwLearningSystem.cwFoundationFamily:not(.cwTablet) body .cwRectanglePracticeWorkspace{height:auto!important;min-height:0!important;grid-template-rows:auto auto!important;overflow:visible!important;}
 html.cwLearningSystem.cwFoundationFamily:not(.cwTablet) body .cwRectanglePracticeWorkspace [data-rectangle-result]{grid-template-rows:auto auto!important;overflow:visible!important;}
 html.cwLearningSystem.cwFoundationFamily:not(.cwTablet) body .cwRectanglePracticeWorkspace :is(.cwRectMatrix,.cwRectSliderReadout){height:auto!important;max-height:none!important;overflow:visible!important;}
 html.cwLearningSystem.cwFoundationFamily:not(.cwTablet) body .cwRectanglePracticeWorkspace .cwRectMatrix table{height:auto!important;}
}
/* A positioned containing block prevents absolutely positioned RF.04 keys
   from escaping the piano; both key layers share the same dimensions. */
 html.cwLearningSystem body .cwMinorSignatureLesson .cwPracticePiano{position:relative!important;isolation:isolate;width:100%!important;max-width:none!important;box-sizing:border-box;}
 html.cwLearningSystem body .cwMinorSignatureLesson .cwPracticePiano>.cwPracticeWhite{position:absolute!important;top:0!important;height:100%!important;transform:none!important;}
 html.cwLearningSystem body .cwMinorSignatureLesson .cwPracticePiano>.cwPracticeBlack{position:absolute!important;top:0!important;height:60%!important;transform:none!important;z-index:2!important;}
/* Common guide envelope; prose remains scrollable and existing section controls remain native. */
@media(min-width:900px) and (min-height:540px){
 html:not(.cwTablet) body :is(.cwUnifiedGuide,.cwGuideSurface.cwGuideDialog,.cwAcademyIntroductionPage){box-sizing:border-box!important;width:calc(100vw - 32px)!important;max-width:none!important;max-height:calc(100dvh - 24px)!important;padding:0 16px 16px!important;}
 html:not(.cwTablet) body :is(.cwUnifiedGuideHeader,.cwGuideSurface>header:not(.cwGuideHero)){box-sizing:border-box!important;min-height:54px!important;padding:8px 0!important;margin:0 0 10px!important;gap:12px!important;align-items:center!important;}
 html:not(.cwTablet) body .cwUnifiedGuideActions{flex-direction:row!important;align-items:center!important;gap:6px!important;}
 html:not(.cwTablet) body .cwUnifiedGuideActions>button{min-width:118px!important;min-height:34px!important;}
 html:not(.cwTablet) body.courseIntroductionPage>main{width:calc(100% - 24px)!important;max-width:none!important;margin-inline:12px!important;box-sizing:border-box!important;}
}
/* The same light-blue primary action palette as the approved later lessons. */
 html body button.cwHKPlay:enabled,html body button.cwHKPlay:enabled:hover,
 html body button.cwHKPlay:enabled:focus-visible,html body select.cwHKChoice:enabled {
  background:#c7e9ff!important;color:#102a40!important;border-color:#83c9ff!important;
 }
 html body button.cwHKPlay:enabled{font-weight:700!important;}
 html body button.cwHKPlay:focus-visible,html body select.cwHKChoice:focus-visible{outline:2px solid #fff!important;outline-offset:2px!important;}
 html body button.cwHKCloseGuide{min-height:34px!important;white-space:nowrap!important;}

/* Beta 4 Mastery fit: compact spacing before a measured proportional fit.
   No keyboard cropping; on very small screens retain accessible scrolling. */
@media (min-width:740px) and (min-height:540px){
 html:is(.cwCreativeMastery,.cwAdvancedCreation,.cwGapMastery,.cwMasteryFamily) body[data-cw-fit-level="1"] :is(.creativeBuilder,.advWorkspace,.gapWorkspace),
 html:is(.cwCreativeMastery,.cwAdvancedCreation,.cwGapMastery,.cwMasteryFamily) body[data-cw-fit-level="2"] :is(.creativeBuilder,.advWorkspace,.gapWorkspace){padding:5px!important;margin-block:3px!important;gap:3px!important}
 html:is(.cwCreativeMastery,.cwAdvancedCreation,.cwGapMastery) body[data-cw-fit-level="2"] .lesson-content{padding-block:3px 6px!important}
 html:is(.cwCreativeMastery,.cwAdvancedCreation,.cwGapMastery,.cwMasteryFamily) body[data-cw-fit-level="2"] :is(.creativeHeading,.advHeading,.creativeVersion,.creativeCompareControls,.creativePhrasePages,.advPlaybackRow,.advTop,.advPaletteHeader,.advPalette,.gapPalette,.gapActions,.creativeActions,.advActions,#testActions){margin-block:2px!important;padding-block:3px!important;row-gap:3px!important}
 html:is(.cwCreativeMastery,.cwAdvancedCreation,.cwGapMastery,.cwMasteryFamily) body[data-cw-fit-level="2"] :is(.creativeActions,.advActions,.gapActions,#testActions,.creativeCompareButtons,.advReviewActions)>button{min-height:28px!important;height:auto!important;padding-block:3px!important;line-height:1.15!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] #creativeTimeline{gap:3px!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] #creativeTimeline>.compositionChoices{padding:4px!important;gap:3px!important;margin:0!important;min-height:0!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] #creativeTimeline>.compositionChoices>button{min-height:34px!important;height:auto!important;padding:3px 4px!important;line-height:1.15!important;gap:2px!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] #creativeTimeline>.compositionChoices>strong{margin:0!important;line-height:1.2!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] .creativeBuilder .creativePalette .creativePaletteHead{min-height:34px!important;margin:0!important;padding:0!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] .creativeBuilder .creativePalette .creativePaletteHead>.creativeTransport{min-height:30px!important;height:auto!important;padding:2px!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] .creativePaletteGroup{padding:3px 4px!important;gap:4px!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] #creativePaletteItems{gap:3px!important}
 html:is(.cwCreativeMastery,.cwAdvancedCreation) body[data-cw-fit-level="2"] :is(.creativeTimeline,.advTimeline) :is(.barHead,.advBarHead){padding:3px!important;line-height:1.2!important;min-height:36px!important;height:auto!important}
 html:is(.cwCreativeMastery,.cwAdvancedCreation) body[data-cw-fit-level="2"] :is(.creativeTimeline,.advTimeline) :is(.barCell,.advTrack,.trackLabel,.advRowLabel){padding:2px!important;min-height:36px!important;height:auto!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] .creativeTimeline button.slot{height:34px!important;min-height:34px!important;padding:2px!important;gap:1px!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] .creativeTimeline .melodyNotes{height:28px!important}
 html.cwCreativeMastery body[data-cw-fit-level="2"] .creativeTimeline .melodyNote{height:22px!important}
 html.cwAdvancedCreation body[data-cw-fit-level="2"] #advChoices>button{min-height:29px!important;padding:4px 6px!important}
 html.cwAdvancedCreation body[data-cw-fit-level="2"] .advWorkspace>.advPaletteHeader{padding:3px!important;margin:2px 0 0!important}
 html.cwAdvancedCreation body[data-cw-fit-level="2"] .advWorkspace>.advPalette{padding:3px!important;margin:0 0 3px!important}
 html:is(.cwCreativeMastery,.cwAdvancedCreation,.cwGapMastery,.cwMasteryFamily) body[data-cw-fit-level="2"] :is(.creativeMelodyLegend,.advLegend,.gapLegend,.compositionKeyboardViewport,.advKeyboardViewport,.gapKeyboardViewport){margin-block:3px!important}
 /* Tablet rules have unusually high specificity; override only their
    Mastery dimensions, keeping touchable controls and the piano geometry. */
 html#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery.cwTablet:is(.cwCreativeMastery,.cwAdvancedCreation) body[data-cw-fit-level="2"] :is(.creativeTimeline,.advTimeline) :is(.barHead,.advBarHead,.barCell,.advTrack,.trackLabel,.advRowLabel){min-height:38px!important;height:auto!important;padding:2px!important}
 html#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery.cwTablet.cwCreativeMastery body[data-cw-fit-level="2"] #creativeTimeline>.compositionChoices>button{min-height:38px!important;padding:3px 4px!important}
}
@media(min-width:950px) and (min-height:540px){
 html#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery.cwTablet.cwCreativeMastery body[data-cw-fit-level="2"] .creativeTimelineReview:has(#creativeTrackFeedback:not([hidden])){display:grid!important;grid-template-columns:minmax(0,1fr) minmax(150px,20%)!important;gap:5px!important;align-items:start!important}
 html#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery.cwTablet.cwCreativeMastery body[data-cw-fit-level="2"] #creativeTrackFeedback{max-height:210px!important;overflow:auto!important;padding:4px!important}
}

/* HK.46–55: preserve the native Pentatonic fixed rail gutter. The shared
   full-width housekeeping envelope must not reset that gutter. */
@media (min-width:900px) and (min-height:540px){
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body{--cw-hk-pent-rail:236px;}
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body>main{
  margin-inline-start:var(--cw-hk-pent-rail)!important;
  margin-inline-end:0!important;
  width:calc(100% - var(--cw-hk-pent-rail))!important;
  max-width:calc(100% - var(--cw-hk-pent-rail))!important;
  min-width:0!important;box-sizing:border-box!important;
 }
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body>main>#study{min-width:0!important;}
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body>main #sticky{top:56px;}
}
@media (min-width:900px) and (max-width:1400px) and (min-height:540px){
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body{--cw-hk-pent-rail:210px;}
}
@media (min-width:900px) and (max-width:1100px) and (min-height:540px){
 html.cwLearningSystem.cwPentatonic:not(.cwTablet) body{--cw-hk-pent-rail:185px;}
}
/* The legacy transport-role style has six repeated attribute selectors.
   Match its priority without touching other transport actions or disabled Play. */
html body button.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay:enabled,
html body button.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay:enabled:hover,
html body button.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay.cwHKPlay:enabled:focus-visible {
 background:#c7e9ff!important;color:#102a40!important;border-color:#83c9ff!important;font-weight:700!important;
}

/* Native WM/RF transport states: do not colour pause, reset or disabled controls. */
html body button:is(.cwIntroReplay,[data-cw-narration="play"],[data-why-transport="play"],[data-side-play]):enabled.cwHKPlay{background-color:#c7e9ff!important;background-image:none!important;color:#102a40!important;border-color:#83c9ff!important;}
/* Prevent browser scroll anchoring from moving the Pentatonic workspace during a route render. */
html.cwPentatonic body>main{overflow-anchor:none;}

/* Beta 4: Mastery selection and review cues. Presentation only.
   Native IDs keep this scoped to the four MA engines and the PM action row.
   Do not change visibility, sizing, playback or navigation. */
html body select:is(#gapTask,#gapMode,#creativeActivity,#creativeMode,#advLesson):enabled,
html.cwLearningSystem.cwMasteryFamily body .compactAssessmentBar .modeControls button.modeBtn.modeBtn.modeBtn.modeBtn.modeBtn.active[data-mode]:enabled {
 background:#c7e9ff!important;color:#102a40!important;border-color:#83c9ff!important;
}
html.cwLearningSystem.cwMasteryFamily body .compactAssessmentBar .modeControls button.modeBtn.modeBtn.modeBtn.modeBtn.modeBtn:not(.active)[data-mode]:enabled {
 border-color:#83a9d0!important;
}
/* Match the existing later-MA violet review action; keep the active feedback
   treatment of the gap/PM engines when a check has already been selected. */
html.cwGapMastery body #gapSticky .gapActions #gapCheck:enabled:not([data-active="true"]),
html.cwPentatonic body #testActions #check:enabled:not([data-active="true"]),
html.cwCreativeMastery body .creativeActions #creativeCheck:enabled,
html.cwAdvancedCreation body .advActions #advReview:enabled {
 background:#b9a8f7!important;color:#10182a!important;border-color:#c6baff!important;
 font-weight:700!important;
}
html body :is(#gapTask,#gapMode,#creativeActivity,#creativeMode,#advLesson,#gapCheck,#creativeCheck,#advReview):focus-visible,
html.cwPentatonic body #testActions #check:focus-visible,
html.cwMasteryFamily body .modeControls button.modeBtn:focus-visible {
 outline:2px solid #fff!important;outline-offset:2px!important;
}

/* Beta 4: primary entry action in introductions. Match the Welcome Start here
   mint accent. Preserve sizing, location, labels and native click handlers.
   Explicit native selectors distinguish the start action from Close guide. */
html body #cwAcademyIntroductionOverlay[data-cw-view-mode="category"] .cwAcademyIntroductionPage:not(.cwAcademyWelcomePage) .cwAcademyExploreLesson.cwAcademyExploreLesson.cwAcademyExploreLesson:enabled,
html body :is(.cwUnifiedGuideHeader,.cwIntroHero,.cwRectangleStandardHeader) :is(button,a):is(.cwAcademyExploreLesson,[aria-label="Start lesson"],[data-cw-minor-start],#startLesson,#makingStart,#advStart,[data-cw-return-tonic-lesson]):is(.cwAcademyExploreLesson,[aria-label="Start lesson"],[data-cw-minor-start],#startLesson,#makingStart,#advStart,[data-cw-return-tonic-lesson]):not(:disabled):not([aria-disabled="true"]),
html body #minorIntroduction button[data-cw-minor-start][data-cw-minor-start][data-cw-minor-start]:enabled,
html body #welcome :is(#pentListeningIntro,#pentMasteryIntro) a.pentStart:not([aria-disabled="true"]),
html.cwPentatonic body #welcome button#start:enabled {
 background:#a5e3d1!important;
 background-image:none!important;
 color:#102a31!important;
 border-color:#a5e3d1!important;
 font-weight:700!important;
}
html body :is(.cwUnifiedGuideHeader,.cwIntroHero,.cwRectangleStandardHeader) :is(.cwAcademyExploreLesson,[aria-label="Start lesson"],[data-cw-minor-start],#startLesson,#makingStart,#advStart,[data-cw-return-tonic-lesson]):focus-visible,
html body #welcome :is(#pentListeningIntro,#pentMasteryIntro) a.pentStart:focus-visible,
html.cwPentatonic body #welcome button#start:focus-visible {
 outline:2px solid #fff!important;outline-offset:2px!important;
}

/* Native Rectangle Play: the triangle is drawn, never substituted by an emoji font. */
html body button[data-cw-rectangle-play][data-cw-no-transport-icon][data-cw-ui] {
 display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:6px!important;
 width:auto!important;min-width:76px!important;max-width:none!important;white-space:nowrap!important;
 font:700 14px/1.2 Arial,sans-serif!important;padding:5px 10px!important;
}
html body button[data-cw-rectangle-play][data-cw-no-transport-icon]::before {
 content:""!important;display:inline-block!important;width:0!important;height:0!important;
 border-top:5px solid transparent!important;border-bottom:5px solid transparent!important;border-left:8px solid currentColor!important;
 background:none!important;mask:none!important;-webkit-mask:none!important;flex:0 0 auto!important;
}
html#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery#cwTabletRecovery.cwTablet body button[data-cw-rectangle-play]:disabled,
html body button[data-cw-rectangle-play]:disabled {
 background:#101824!important;background-image:none!important;color:#8191a6!important;border-color:#53667c!important;box-shadow:none!important;opacity:.65!important;
}
