/* Compact phone layout. Tablet and desktop retain their existing layout. */
@media(max-width:760px){
 :root{--classora-dock-height:62px;--classora-mobile-nav-height:62px;--classora-dock-clearance:calc(78px + env(safe-area-inset-bottom,0px))}
 body :is(#platformLobby,.modal,.classora-curriculum-modal,.hub-dialog,.subject-lab-modal) :is(button,.button,.btn){box-sizing:border-box;min-width:0;max-width:100%;min-height:40px;padding:8px 11px;font-size:13px;line-height:1.35;white-space:normal;overflow-wrap:anywhere}
 body :is(#authGate,#authPanel) button{min-height:42px;padding:9px 12px;font-size:14px}
 body :is(.modal,.classora-curriculum-modal,.hub-dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea){box-sizing:border-box;min-width:0;max-width:100%;font-size:16px;padding:9px 10px}
 body :is(.modalbox,.settings-modalbox,.classora-curriculum-body,.cm-studio,.learning-hub,.hub-dialog-body){min-width:0;max-width:100%;box-sizing:border-box}
 #platformLobby{padding-inline:10px!important}
 #platformLobby :is(.student-dash-action-grid,.tw-actions,.hub-card-grid,.hub-curriculum-subjects){grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}
 #platformLobby :is(.student-dash-action,.tw-action,.hub-curriculum-subject,.hub-topic-card,.hub-card){min-height:0!important;padding:12px!important;border-radius:14px!important;gap:8px!important}
 #platformLobby :is(.hub-curriculum-subject,.student-dash-action,.tw-action) :is(h3,strong,b){font-size:15px!important;line-height:1.4!important}
 #platformLobby :is(.hub-curriculum-subject,.student-dash-action,.tw-action) :is(p,small){font-size:12px!important;line-height:1.5!important}
 #platformLobby :is(.student-dash-hero,.tw-hero,.classora-mix-hero){padding:18px 14px!important;gap:12px!important}
 #platformLobby :is(.student-dash-hero,.tw-hero,.classora-mix-hero) h1{font-size:clamp(23px,6vw,30px)!important;line-height:1.3!important}
 body .classora-curriculum-modal :is(.classora-curriculum-head,.curriculum-toolbar){padding:10px!important;gap:8px!important;flex-wrap:wrap}
 body .classora-curriculum-modal .classora-curriculum-body{padding:12px!important;padding-bottom:calc(var(--classora-dock-clearance) + 12px)!important}
 body .classora-curriculum-modal :is(.cm-heading,.cm-lab,.cm-controls,.cm-explain,.cm-practice,.curriculum-panel){padding:14px!important;border-radius:16px!important}
 body .classora-curriculum-modal .cm-heading h1{font-size:24px!important;line-height:1.35!important}
 body .classora-curriculum-modal :is(.cm-scene-tools,.cm-assessment,.cl130-actions,.cl-workbench-actions,.curriculum-controls){gap:7px!important;flex-wrap:wrap}
 body .classora-curriculum-modal :is(.cm-scene-tools,.cm-assessment,.cl130-actions) button{min-height:40px!important;padding:8px 10px!important;font-size:13px!important;flex:1 1 auto}
 body .classora-curriculum-modal :is(.cm-layout,.curriculum-topic-workspace){gap:12px!important}
 body .classora-curriculum-modal :is(.cm-scene,.cg-model){min-height:0!important}
 body .classora-curriculum-modal :is(.cm-scene,.cg-model)>svg{width:100%;height:auto;max-height:310px}
 body .cl130-tools,body .cl130-home{padding:12px!important;margin-block:12px!important}
 body .cl130-home-row b{font-size:17px}
 body :is(#settingsModal,#classModal,#examModal,#supportModal,#adminPanelModal) .modalbox{width:calc(100% - 16px)!important;margin-inline:auto;padding-inline:12px!important;border-radius:18px!important}
 body :is(.settings-grid,.class-actions,.exam-actions,.admin-actions){gap:8px!important}
 body #settingsModal .settings-grid>button{padding:10px!important;min-height:44px!important;font-size:13px!important}
 body #chatModal :is(.chat-toolbar,.chat-compose,.chat-person-actions) button{min-width:40px!important;min-height:40px!important;padding:8px!important}
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav{min-height:62px!important;padding:5px!important;gap:2px!important;border-radius:17px!important}
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button,
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav #classoraMobileLobbyBtn{min-height:50px!important;padding:5px 2px!important;gap:3px!important;font-size:10px!important}
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button svg{width:20px!important;height:20px!important}
 #classoraMathCalculator .cm-calc-tab{width:58px;min-height:88px;padding:8px 10px 8px 5px;gap:5px;transform:translateX(9px) rotate(-3deg);border-radius:16px 0 0 16px}
 #classoraMathCalculator .cm-mini-display{width:42px;min-height:20px;font-size:8px;border-width:2px}
 #classoraMathCalculator .cm-mini-keys{width:39px;gap:3px}
 #classoraMathCalculator .cm-mini-keys i{height:5px}
 #classoraMathCalculator .cm-calc-caption{font-size:9px}
 #classoraMathCalculator .cm-calc-panel{box-sizing:border-box;position:fixed;width:min(296px,calc(100vw - 28px));right:12px;top:auto;bottom:calc(80px + env(safe-area-inset-bottom,0px));max-height:calc(100dvh - 102px - env(safe-area-inset-bottom,0px));padding:11px;border-radius:20px;transform:none;overflow:auto;scrollbar-width:thin}
 #classoraMathCalculator .cm-calc-panel header{margin:0 0 7px;padding:0;min-height:32px}
 #classoraMathCalculator .cm-calc-close{width:32px;min-width:32px;min-height:32px;padding:2px;font-size:22px}
 #classoraMathCalculator .cm-calc-lcd{box-sizing:border-box;min-height:72px;padding:6px 9px;border-width:3px;border-radius:10px}
 #classoraMathCalculator .cm-lcd-brand{font-size:12px}
 #classoraMathCalculator .cm-calc-expression{min-height:20px;max-height:38px;font-size:15px;padding:2px 0;margin:0}
 #classoraMathCalculator .cm-calc-lcd output{font-size:22px;min-height:25px;line-height:1.2}
 #classoraMathCalculator .cm-calc-modes{margin:7px 0;gap:6px}
 #classoraMathCalculator .cm-calc-modes button{min-height:30px;padding:4px 9px;font-size:11px}
 #classoraMathCalculator .cm-calc-keyboard{gap:5px}
 #classoraMathCalculator .cm-calc-keyboard button{min-height:36px;padding:3px;font-size:16px;border-radius:7px}
 #classoraMathCalculator .cm-calc-keyboard .scientific{min-height:32px;font-size:11px}
 #classoraMathCalculator .cm-calc-tip{font-size:10px;line-height:1.35;margin:7px 0 0}
 #classoraMathCalculator .cm-calc-history{max-height:110px;overflow:auto;margin-top:8px;gap:5px}
 html[data-learn-large=true] body :is(.modal,.classora-curriculum-modal,#platformLobby) button{font-size:16px!important}
}
/* A sideways phone uses two calculator columns instead of a tall overlay. */
@media(max-width:960px) and (max-height:500px) and (orientation:landscape){
 #classoraMathCalculator .cm-calc-panel{box-sizing:border-box;display:grid;grid-template-columns:135px minmax(0,1fr);grid-template-rows:auto auto 1fr auto;gap:6px 10px;width:min(490px,calc(100vw - 32px));max-height:calc(100dvh - 90px);top:8px;bottom:auto;right:12px;padding:10px;transform:none;overflow:auto}
 #classoraMathCalculator .cm-calc-panel header{grid-column:1;margin:0}
 #classoraMathCalculator .cm-calc-lcd{grid-column:1;min-height:65px;padding:5px 7px;border-width:3px}
 #classoraMathCalculator .cm-calc-modes{grid-column:1;margin:0;align-self:start;gap:5px;flex-wrap:wrap}
 #classoraMathCalculator .cm-calc-keyboard{grid-column:2;grid-row:1 / span 4;grid-template-columns:repeat(6,minmax(0,1fr));gap:5px;align-self:start}
 #classoraMathCalculator .cm-calc-keyboard button,#classoraMathCalculator .cm-calc-keyboard .scientific{grid-column:auto;min-height:36px;font-size:12px;padding:3px}
 #classoraMathCalculator .cm-calc-tip{grid-column:1;margin:0;font-size:10px;line-height:1.3}
 #classoraMathCalculator .cm-calc-history{grid-column:1 / -1;max-height:80px;overflow:auto}
}

@media(max-width:760px){
 #offlineHome{padding:16px!important} .offline-unit{padding:12px!important}.offline-unit>div{gap:8px!important}.offline-unit button,#offlineExam button{font-size:13px;min-height:40px;padding:8px 11px}
 body .subject-lab-page .sl-button{min-height:40px!important;padding:8px 11px!important;font-size:13px!important}body .subject-lab-page .sl-main{padding:14px!important}
}

/* v132: compact phone navigation and grade names; full calculator stays within the viewport. */
@media(max-width:600px){
 body #platformLobby{padding-inline:8px!important}
 body #platformLobby .learning-hub .hub-grade-tabs{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;width:100%;gap:4px!important;padding:4px!important}
 body #platformLobby .learning-hub .hub-grade-button{box-sizing:border-box;min-width:0!important;width:100%!important;height:auto!important;min-height:40px!important;padding:5px 2px!important;font-size:clamp(10px,2.9vw,12px)!important;line-height:1.25!important;white-space:normal!important;overflow-wrap:anywhere}
 body #platformLobby .learning-hub .hub-subject-tabs{gap:5px!important}
 body #platformLobby .learning-hub .hub-subject-tabs button{min-width:0!important;min-height:40px!important;padding:7px 9px!important;font-size:12px!important}
 body #platformLobby .hub-curriculum-head{gap:8px!important;padding:9px!important}
 body #platformLobby .hub-curriculum-head :is(h1,h2){font-size:clamp(20px,5vw,25px)!important}
 body #platformLobby .hub-curriculum-subject-main{padding:10px!important;min-height:0!important}
 body #platformLobby .hub-curriculum-subject-main :is(b,strong,h3){font-size:clamp(13px,3.5vw,15px)!important;line-height:1.35!important}
 body #platformLobby .hub-curriculum-subject-main :is(p,small){font-size:11px!important}
 body #platformLobby :is(.hub-topic-chip,.hub-topic-card,.hub-card){min-width:0!important;overflow-wrap:anywhere;white-space:normal}
 body #platformLobby .hub-topic-chip{padding:7px 8px!important;font-size:11px!important}
 body .classora-curriculum-modal .curriculum-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}
 body .classora-curriculum-modal :is(.curriculum-grade-card,.curriculum-subject-card){min-width:0!important;min-height:84px!important;padding:10px 8px!important;border-radius:13px!important}
 body .classora-curriculum-modal :is(.curriculum-grade-card,.curriculum-subject-card) svg{width:24px!important;height:24px!important;margin-bottom:6px!important}
 body .classora-curriculum-modal :is(.curriculum-grade-card,.curriculum-subject-card,.curriculum-topic-card) b{font-size:clamp(12px,3.3vw,15px)!important;line-height:1.3!important;overflow-wrap:anywhere}
 body .classora-curriculum-modal :is(.curriculum-grade-card,.curriculum-subject-card,.curriculum-topic-card) small{font-size:10px!important;line-height:1.35!important}
 body .classora-curriculum-modal .curriculum-topic-card{min-width:0!important;min-height:85px!important;padding:10px!important}
 body :is(.ca-grade-tabs,.ca-subject-tabs){gap:5px!important}
 body .ca-grade-chip{min-width:0!important;min-height:40px!important;padding:6px 6px!important;font-size:12px!important;white-space:normal!important;line-height:1.25!important}
 body .ca-subject-chip{min-width:0!important;min-height:40px!important;padding:6px 8px!important;font-size:12px!important}
 body :is(.classora-curriculum-modal,.subject-lab-modal,.hub-dialog) :is(.classora-curriculum-back,.classora-curriculum-close,.curriculum-filter-row button,.cl130-actions button){padding:7px 9px!important;min-height:40px!important;font-size:12px!important}
 body .classora-curriculum-modal .classora-curriculum-body{padding-inline:9px!important}
 body .classora-curriculum-modal .cm-heading h1{font-size:clamp(20px,5vw,25px)!important}
 body #classoraMathCalculator{filter:none!important;top:32%;right:0}
 body #classoraMathCalculator .cm-calc-panel{
  position:fixed!important;left:50%!important;right:auto!important;top:max(8px,env(safe-area-inset-top,0px))!important;bottom:auto!important;
  transform:translateX(-50%)!important;animation:none!important;
  box-sizing:border-box!important;width:min(292px,calc(100vw - 20px))!important;
  max-width:calc(100vw - 20px)!important;max-height:calc(100dvh - 88px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))!important;
  min-width:0!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;
  padding:10px!important;border-radius:17px!important;scrollbar-width:thin
 }
 body #classoraMathCalculator .cm-calc-panel header{min-height:26px!important;margin-bottom:6px!important}
 body #classoraMathCalculator .cm-calc-lcd{min-height:65px!important;padding:6px 8px!important;border-width:3px!important}
 body #classoraMathCalculator .cm-calc-expression{font-size:14px!important;max-height:30px}
 body #classoraMathCalculator .cm-calc-lcd output{font-size:22px!important;min-height:23px!important}
 body #classoraMathCalculator .cm-calc-modes{margin:6px 0!important;gap:6px!important}
 body #classoraMathCalculator .cm-calc-modes button{min-height:30px!important;padding:4px 7px!important}
 body #classoraMathCalculator .cm-calc-keyboard{grid-template-columns:repeat(20,minmax(0,1fr))!important;gap:4px!important;min-width:0}
 body #classoraMathCalculator .cm-calc-keyboard button{min-width:0!important;min-height:34px!important;padding:3px 0!important;font-size:15px!important}
 body #classoraMathCalculator .cm-calc-keyboard .scientific{min-height:31px!important;font-size:11px!important}
 body #classoraMathCalculator .cm-calc-tip{margin-top:7px!important;font-size:10px!important}
 body #classoraMathCalculator .cm-calc-history{max-height:95px!important}
 body #classoraMathCalculator .cm-calc-tab{width:58px!important;min-height:86px!important}
}
@media(max-width:960px) and (max-height:500px) and (orientation:landscape){
 body #classoraMathCalculator{filter:none!important}
 body #classoraMathCalculator .cm-calc-panel{
  position:fixed!important;left:50%!important;right:auto!important;top:max(6px,env(safe-area-inset-top,0px))!important;bottom:auto!important;
  transform:translateX(-50%)!important;animation:none!important;
  width:min(490px,calc(100vw - 20px))!important;max-height:calc(100dvh - 14px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))!important;
 }
}

/* v138: iPhone bottom navigation — compact, no negative safe-area offset.
   iOS can clip fixed content outside the visible viewport. Keep all five
   buttons INSIDE it, not in the home-indicator area. */
@media (max-width:760px) and (orientation:portrait){
 body.classora-dock-enabled{
  --classora-dock-height:70px;
  --classora-mobile-nav-height:70px;
  --classora-dock-clearance:80px;
 }
 body.classora-dock-enabled #platformLobby.platform-lobby:not(.hidden){
  height:100dvh!important;
  min-height:100dvh!important;
  max-height:100dvh!important;
  box-sizing:border-box!important;
  padding-bottom:var(--classora-dock-clearance)!important;
  scroll-padding-bottom:var(--classora-dock-clearance)!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav{
  position:fixed!important;
  /* Never push the dock below the visible viewport on iOS. */
  inset:auto auto 0 50%!important;
  inset-block-start:auto!important;
  inset-block-end:0!important;
  top:auto!important;
  right:auto!important;
  bottom:0!important;
  left:50%!important;
  transform:translateX(-50%)!important;
  display:grid!important;
  grid-template-columns:repeat(5,minmax(0,1fr))!important;
  grid-template-rows:52px!important;
  align-items:start!important;
  align-content:start!important;
  justify-items:stretch!important;
  width:min(480px,calc(100vw - 12px))!important;
  max-width:calc(100vw - 12px)!important;
  height:70px!important;
  min-height:70px!important;
  max-height:70px!important;
  padding:6px 5px 11px!important;
  margin:0!important;
  gap:3px!important;
  box-sizing:border-box!important;
  border:1px solid rgba(138,221,197,.32)!important;
  border-bottom:0!important;
  border-radius:19px 19px 0 0!important;
  background:linear-gradient(160deg,rgba(20,54,70,.98),rgba(8,30,43,.99))!important;
  box-shadow:0 -7px 28px rgba(0,0,0,.22),inset 0 1px rgba(255,255,255,.11)!important;
  -webkit-backdrop-filter:blur(14px)!important;
  backdrop-filter:blur(14px)!important;
  overflow:hidden!important;
  isolation:isolate!important;
  z-index:2147483646!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav::before,
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav::after{
  content:none!important;display:none!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button,
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav #classoraMobileLobbyBtn{
  position:relative!important;
  display:flex!important;
  flex-direction:column!important;
  align-items:center!important;
  justify-content:center!important;
  flex:1 1 0!important;
  min-width:0!important;
  width:100%!important;
  height:52px!important;
  min-height:52px!important;
  max-height:52px!important;
  padding:4px 2px!important;
  margin:0!important;
  gap:3px!important;
  box-sizing:border-box!important;
  border:1px solid transparent!important;
  border-radius:13px!important;
  background:transparent!important;
  color:#cde2e9!important;
  box-shadow:none!important;
  font:800 11px/1.2 "Tajawal","Inter",system-ui,sans-serif!important;
  white-space:nowrap!important;
  touch-action:manipulation!important;
  -webkit-tap-highlight-color:transparent!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button.is-active{
  color:#a3f7d2!important;
  background:rgba(49,207,148,.17)!important;
  border-color:rgba(91,230,175,.29)!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button svg{
  display:block!important;
  width:21px!important;
  height:21px!important;
  flex:0 0 auto!important;
  stroke:currentColor!important;
  fill:none!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button span{
  display:block!important;
  min-width:0!important;
  max-width:100%!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
  white-space:nowrap!important;
  line-height:1.2!important;
 }
}
@media (max-width:350px) and (orientation:portrait){
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav{
  width:calc(100vw - 6px)!important;
  max-width:calc(100vw - 6px)!important;
  gap:1px!important;
  padding-inline:3px!important;
 }
 body.classora-dock-enabled.classora-authenticated #classoraMobilePageNav button{
  font-size:10px!important;
 }
}
