/* Lumi V3 — 5. sınıf ders bazında ekran optimizasyonu.
   Yalnız bu sınıfın tahta sınıflarına kapsamlı kurallar. Orijinal ders dosyalarına dokunulmaz. */

/* 0) Hareketi azalt (prefers-reduced-motion) kullanan cihazlarda ders kabuğu `transition-duration:.01ms`
   ile geçiş başlatıyor; 5. sınıf okunabilirlik koruyucusu (grade5-readable-min) yazı boyutunu geçişin
   BAŞLANGIÇ değerinden okuyup 28 px'e kadar şişiriyor (tahta içi taşma). Geçişi kapatmak yazıyı doğru boyutta tutar.
   Yalnız hareket-azaltma açıkken; normal hareket etkilenmez. */
@media (prefers-reduced-motion: reduce) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board *,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board *::before,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board *::after { transition: none !important; }
}

/* Help is part of the scene's natural flow. The older compact help styles
   capped the model at 165px and allowed the tools to shrink beneath it. */
@media (max-width:900px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy).am-support-open {
    height:auto !important; min-height:0 !important; max-height:none !important;
    grid-template-rows:repeat(7,auto) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy).am-support-open :is(.am-workspace,.am-support) {
    height:auto !important; min-height:0 !important; max-height:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy).am-support-open .am-support {
    grid-template-columns:minmax(0,1fr) minmax(0,1.4fr) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy).am-support-open .am-support > header {
    grid-column:1/-1 !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy).am-support-open .am-small-step > div {
    display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy).am-support-open .am-small-step button {
    white-space:normal !important; overflow-wrap:break-word !important; padding:4px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support) :is(.tci-workspace,.tci-tools,.tci-support) {
    height:auto !important; min-height:min-content !important; max-height:none !important;
    flex-shrink:0 !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support) :is(.tci-choice-grid,.tci-small-step) {
    min-width:0 !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support) .tci-small-step button {
    white-space:normal !important; overflow-wrap:break-word !important; padding:5px !important;
  }
}

@media (max-width:599px) and (orientation:portrait) {
  /* The support card repeats this same hint in its first paragraph. Avoid
     displaying it twice while leaving answer/status feedback in the card. */
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support) > .tci-message.tci-hint {
    display:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support) .tci-local-footer:not(:has(button:not([hidden]))) {
    display:none !important;
  }
  /* Focus the small screen on the alternate model. Closing support restores
     the primary model and all its controls without changing their state. */
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]):has(.tci-support) .tci-workspace {
    display:none !important;
  }
}

/* At the narrowest phone width, keep the two verdict targets in separate
   rows, including after the help panel closes and touch-size styles persist. */
@media (max-width:359px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]) .tci-choice-grid {
    grid-template-columns:minmax(0,1fr) !important;
  }
}

/* Dar dikey ekranda sabit 390px eski pano, bu iki araç ailesinin normal
   akıştaki alt kontrollerini kırpıyordu. İçeriğin gerçek yüksekliğini V3
   sığdırıcısına ver; metin/araçlar üst üste binmeden kendi satırlarında kalsın. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .am-opening),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .am-copy),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .tci-scene[data-phase="22"]),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .tci-scene[data-phase="23"]) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy) {
    height:auto !important; min-height:0 !important; max-height:none !important;
    grid-template-rows:auto auto auto auto auto auto auto !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy) .am-workspace {
    height:auto !important; min-height:0 !important; max-height:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy) .am-local-footer:not(:has(button:not([hidden]))) {
    display:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-opening,.am-copy) input[type="range"] {
    height:var(--lc-range-height,44px) !important; min-height:var(--lc-range-height,44px) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]) {
    height:auto !important; min-height:0 !important; max-height:none !important;
    grid-template-rows:auto auto auto auto auto auto auto !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]) :is(.tci-workspace,.tci-tools) {
    height:auto !important; min-height:min-content !important; max-height:none !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]) .tci-drawing {
    min-height:0 !important; height:100% !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.tci-scene[data-phase="22"],.tci-scene[data-phase="23"]) .tci-tools {
    padding-block:5px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .teaching-area:has(:is(.am-opening,.am-copy,.tci-scene[data-phase="22"],.tci-scene[data-phase="23"])) #lesson-footer:empty {
    display:none !important;
  }
}

/* Long evidence answers need one readable row each on portrait phones/tablets. */
@media (max-width:900px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> :is(.family-twin-distribution,.family-evidence-bridge)),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge) :is(main,.g5dvt-visual,.g5dvt-visual-stage) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge) :is(.g5dvt-choices,.g5dvt-multi) {
    grid-template-columns:minmax(0,1fr) !important; gap:4px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge) :is(.g5dvt-choices,.g5dvt-multi) button {
    display:flex !important; align-items:center !important; gap:6px !important;
    height:auto !important; min-height:44px !important; padding:6px !important;
    text-align:left !important; white-space:normal !important; line-height:1.2 !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge) :is(.g5dvt-choices,.g5dvt-multi) button span {
    min-width:0 !important; overflow-wrap:break-word !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-bridge .g5dvt-multi button i {
    flex:0 0 16px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge) :is(.g5dvt-twins,.g5dvt-evidence) {
    flex:0 0 auto !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    height:auto !important; min-height:0 !important; gap:4px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-twin-distribution,.family-evidence-bridge) :is(.balance-mark,.evidence-bridge) {
    position:static !important; transform:none !important; inset:auto !important; clip-path:none !important;
    grid-column:1/-1 !important; grid-row:1 !important; width:auto !important; height:auto !important;
    min-height:0 !important; padding:3px !important; border:0 !important; border-radius:8px !important;
    background:#e5f3ee !important; color:#174b54 !important; font-size:12px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-bridge .evidence-bridge :is(i,b) {
    position:static !important; transform:none !important; color:inherit !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-bridge .evidence-bridge i { display:none !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-twin-distribution .twin .g5dvt-dots {
    height:160px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-bridge .g5dvt-bars {
    justify-content:space-around !important; gap:8px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-bridge .g5dvt-bars .bar-slot {
    flex:1 1 0 !important; min-width:0 !important; max-width:44px !important; width:auto !important;
  }
}

/* Critical phone probability tools: keep the model and its actions full width.
   The shared fit engine bounds these long tasks with an internal scroll area. */

  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.g5pe-shell.family-wheel-builder,.g5pe-shell.family-evidence-builder,.g5ps-shell.family-spectrum-slider,.g5ps-shell.family-jar-spectrum,.g5ps-shell.family-cube-spectrum,.g5ps-shell.family-spectrum-studio) > main {
    display:flex !important; flex-direction:column !important; height:auto !important; min-height:0 !important; max-height:none !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-wheel-builder,.family-evidence-builder,.family-spectrum-slider,.family-jar-spectrum,.family-cube-spectrum,.family-spectrum-studio) :is(.g5pe-visual,.g5pe-visual-stage,.g5ps-visual,.g5ps-visual-stage,.g5pe-panel,.g5ps-panel) {
    height:auto !important; min-height:0 !important; max-height:none !important; min-width:0 !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-wheel-builder .g5pe-wheel-workshop,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-spectrum-studio .g5ps-wheel-workshop {
    grid-template-columns:minmax(0,1fr) !important; min-width:0 !important; height:auto !important; min-height:0 !important; max-height:none !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-builder .g5pe-builder {
    grid-template-columns:minmax(0,1fr) 40px minmax(0,1fr) !important; min-width:0 !important; width:100% !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-evidence-builder .g5pe-builder > section { min-width:0 !important; padding:4px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-jar-spectrum,.family-cube-spectrum) :is(.g5ps-jar-spectrum,.g5ps-cube-spectrum) {
    grid-template-columns:minmax(0,1fr) !important; height:auto !important; min-height:0 !important; max-height:none !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-spectrum-slider,.family-jar-spectrum,.family-cube-spectrum) .g5ps-spectrum { width:100% !important; min-width:0 !important; padding:10px 24px 45px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-spectrum-slider,.family-jar-spectrum,.family-cube-spectrum) .g5ps-rail { margin-inline:0 !important; width:100% !important; min-width:0 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-spectrum-slider,.family-jar-spectrum,.family-cube-spectrum) .g5ps-rail button { width:44px !important; max-width:44px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.family-spectrum-slider,.family-jar-spectrum,.family-cube-spectrum) .g5ps-rail button b { max-width:44px !important; white-space:normal !important; overflow-wrap:break-word !important; }


/* 19 Oct critical mobile layout: the degree/place/construct tool controls
   follow the drawing in normal flow. Their heights must not be clipped by
   the legacy grade-5 390px board normalizer; fitStage clears those inline caps. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> :is(.am-degree,.am-place,.am-construct)),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-degree,.am-place,.am-construct),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-degree,.am-place,.am-construct) .am-workspace {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-degree,.am-place,.am-construct) {
    grid-template-rows:repeat(7,auto) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-degree,.am-place,.am-construct) .am-tools {
    height:auto !important; min-height:min-content !important; max-height:none !important;
    flex-shrink:0 !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-degree,.am-place,.am-construct) input[type="range"] {
    height:var(--lc-range-height,44px) !important; min-height:var(--lc-range-height,44px) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] :is(.am-degree,.am-place,.am-construct) .am-local-footer:not(:has(button:not([hidden]))) {
    display:none !important;
  }
}
/* Lines journey keeps the model beside its tools; the tools determine the
   row height instead of being clipped by a percentage-height workspace. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .lj-scene),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-scene,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-workspace,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-tools {
    height:auto !important; min-height:0 !important; max-height:none !important;
    aspect-ratio:auto !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-scene {
    grid-template-rows:repeat(6,auto) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-drawing {
    height:auto !important; min-height:180px !important; max-height:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-svg {
    height:auto !important; min-height:180px !important; max-height:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-tools { justify-content:flex-start !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .lj-tools button { flex-shrink:0 !important; }
}
/* The parallel-construction step has two sliders and four tool buttons. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .gp-parallel),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel :is(.gp-workspace,.gp-tools) {
    height:auto !important; min-height:0 !important; max-height:none !important;
    aspect-ratio:auto !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel {
    grid-template-rows:repeat(6,auto) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel .gp-tools { justify-content:flex-start !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel .gp-tools button { flex-shrink:0 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel .gp-drawing {
    height:auto !important; min-height:180px !important; max-height:none !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .gp-parallel .gp-svg { min-height:180px !important; }
}
/* Earlier triangle-construction tool families need the same natural-height
   treatment as the existing final proof task (22/23). */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .tci-scene:is([data-phase="4"],[data-phase="5"],[data-phase="10"],[data-phase="11"],[data-phase="13"],[data-phase="14"],[data-phase="16"],[data-phase="17"])),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="4"],[data-phase="5"],[data-phase="10"],[data-phase="11"],[data-phase="13"],[data-phase="14"],[data-phase="16"],[data-phase="17"]),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="4"],[data-phase="5"],[data-phase="10"],[data-phase="11"],[data-phase="13"],[data-phase="14"],[data-phase="16"],[data-phase="17"]) :is(.tci-workspace,.tci-tools) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="4"],[data-phase="5"],[data-phase="10"],[data-phase="11"],[data-phase="13"],[data-phase="14"],[data-phase="16"],[data-phase="17"]) {
    grid-template-rows:repeat(7,auto) !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="4"],[data-phase="5"],[data-phase="10"],[data-phase="11"],[data-phase="13"],[data-phase="14"],[data-phase="16"],[data-phase="17"]) .tci-tools { justify-content:flex-start !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="4"],[data-phase="5"],[data-phase="10"],[data-phase="11"],[data-phase="13"],[data-phase="14"],[data-phase="16"],[data-phase="17"]) .tci-drawing { min-height:180px !important; height:auto !important; }
}
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .tri-identity),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity :is(.tri-workspace,.tri-tools) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity { grid-template-rows:repeat(7,auto) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools { justify-content:flex-start !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-drawing { height:auto !important; min-height:180px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-choice-grid { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-choice-grid button { white-space:normal !important; overflow-wrap:break-word !important; padding:5px !important; }
}
/* The angle bridge has enough tools to exceed a 390px board on small phones.
   Keep the tools in natural flow inside the shared bounded scroll board. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-angles,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-angles :is(.tri-workspace,.tri-tools) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-angles { grid-template-rows:repeat(7,auto) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-angles .tri-tools { justify-content:flex-start !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-angles .tri-drawing { height:auto !important; min-height:180px !important; }
}
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="7"],[data-phase="8"]),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="7"],[data-phase="8"]) :is(.tci-workspace,.tci-tools) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important; overflow:visible !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="7"],[data-phase="8"]) { grid-template-rows:repeat(7,auto) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="7"],[data-phase="8"]) .tci-tools { justify-content:flex-start !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tci-scene:is([data-phase="7"],[data-phase="8"]) .tci-drawing { height:auto !important; min-height:180px !important; }
}
/* Names pinned near the right edge of the score table must remain wholly
   within the visual even after the shared 44px touch minimum is applied. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .g5t1a-shell.family-truth .g5t1a-scene-actions button[data-g5t1a-scene-choice] {
    left:clamp(28px,var(--x),calc(100% - 28px)) !important;
  }
}
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] #teaching-board:has(> .family-relevance-pack),
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack,
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack :is(main,.g5srs-visual,.g5srs-visual-stage) {
    height:auto !important; min-height:0 !important; max-height:none !important; aspect-ratio:auto !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:5px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi button {
    display:flex !important; min-width:0 !important; white-space:normal !important; overflow-wrap:break-word !important; padding:5px !important; gap:3px !important;
  }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi button i { flex:0 0 14px !important; width:14px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi button span { min-width:0 !important; }
}
/* Decimal comparison uses four table columns; intrinsic min-content widths
   must not push the thousandths column or the third answer slot offstage. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-decimal-lens .g5t4a-visual-stage { min-width:0 !important; grid-template-columns:minmax(0,1fr) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-decimal-lens :is(.g5t4a-place-lens,.g5t4a-order-source,.g5t4a-order-track) { min-width:0 !important; width:100% !important; box-sizing:border-box !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-decimal-lens .g5t4a-place-lens > div { grid-template-columns:60px repeat(3,minmax(0,1fr)) !important; gap:3px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-decimal-lens .g5t4a-place-lens header { grid-template-columns:repeat(3,minmax(0,1fr)) !important; padding-left:63px !important; gap:3px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-decimal-lens .g5t4a-order-track { grid-template-columns:repeat(3,minmax(0,1fr)) !important; gap:4px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-decimal-lens .g5t4a-order-track button { min-width:0 !important; white-space:normal !important; padding:3px !important; }
}
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-visual-stage { min-width:0 !important; grid-template-columns:minmax(0,1fr) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack :is(.g5srs-pack,.g5srs-multi) { min-width:0 !important; max-width:100% !important; width:100% !important; box-sizing:border-box !important; }
}
/* The desktop split panel also needs bounded labels and wrapping choices;
   its content column can be narrower than a phone despite a wide viewport. */
@media (min-width:600px) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-visual-stage { min-width:0 !important; grid-template-columns:minmax(0,1fr) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-pack { min-width:0 !important; max-width:100% !important; width:100% !important; box-sizing:border-box !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .g5t1a-shell.family-truth .g5t1a-scene-actions button[data-g5t1a-scene-choice] { left:clamp(40px,var(--x),calc(100% - 40px)) !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi { grid-template-columns:repeat(2,minmax(0,1fr)) !important; min-width:0 !important; width:100% !important; box-sizing:border-box !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi button { min-width:0 !important; white-space:normal !important; overflow-wrap:break-word !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .family-relevance-pack .g5srs-multi button span { min-width:0 !important; }
}
/* On compact phones the passport and tools need stacked rows. A narrow
   side panel creates a height/touch-size feedback loop in the fit engine. */
@media (max-width:599px) and (orientation:portrait) {
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-workspace { grid-template-columns:minmax(0,1fr) !important; gap:4px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-drawing { height:120px !important; min-height:120px !important; max-height:120px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-svg { height:120px !important; min-height:0 !important; max-height:120px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:4px !important; padding:5px !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools > p { grid-column:1/-1 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools > :nth-child(4) { grid-column:1 !important; grid-row:3 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools > :nth-child(6) { grid-column:2 !important; grid-row:3 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools > :nth-child(5) { grid-column:1 !important; grid-row:4 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools > :nth-child(7) { grid-column:2 !important; grid-row:4 !important; }
  #app:not(#lumi-z) .lesson-shell[data-grade="5"] .tri-identity .tri-tools > :last-child { grid-column:1/-1 !important; }
}
