
#lesson-header{display:none}
@media(min-width:1000px) and (orientation:landscape){
  body{background:#244d43}
  #lesson-header{position:fixed;inset:0 0 auto;height:64px;z-index:140;display:flex;align-items:center;gap:20px;padding:0 26px;background:#21262F;color:#bccbc2;font:13px "Segoe UI",sans-serif;box-sizing:border-box}
  #lesson-header #home-link{position:static!important;transform:none!important;margin:0;padding:0;background:none;border:0;box-shadow:none;color:#eef0e5;font-size:22px;text-decoration:none}
  #stage{background:#244d43!important}
  #board-toolbar{position:fixed!important;top:12px!important;bottom:auto!important;left:auto!important;right:20px!important;transform:none!important;display:flex!important;flex-direction:row!important;align-items:center;gap:5px;padding:0!important;width:auto!important;max-height:44px;background:transparent!important;border:0!important;box-shadow:none!important;z-index:150}
  #board-toolbar .tb-sep{width:1px;height:20px}
  #board-toolbar .tb-btn{width:34px;height:36px;margin:0}
  #board-toolbar #tb-grade{width:85px!important;background:#2e383c!important}
  #chat-panel,#chat-panel:has(#sample-chips:not([hidden])),#chat-panel:has(#chat-log:not(:empty)){
    position:fixed!important;left:80%!important;right:0!important;top:64px!important;bottom:0!important;width:20%!important;max-width:none!important;max-height:none!important;height:calc(100dvh - 64px)!important;
    transform:none!important;border:0!important;border-left:1px solid #30463b!important;border-radius:0!important;box-shadow:none!important;background:#0C1A16!important;padding:18px 14px!important;display:flex;flex-direction:column;gap:12px;box-sizing:border-box;color:#dce6dc
  }
  #chat-panel[hidden]{display:none!important}
  #conversation-title{font:600 15px "Segoe UI",sans-serif;color:#dce6dc;margin:0;padding:0 0 14px;border-bottom:1px solid #293d33}
  #teacher-subtitles{position:static!important;order:0;flex:none;font:15px/1.7 "Segoe UI",sans-serif!important;text-shadow:none!important;color:#e0e9dd!important}
  #teacher-subtitles > div{height:auto!important;min-height:1.7em;white-space:normal!important;overflow:visible!important}
  #teacher-subtitles .subtitle-previous{color:#91a698;opacity:.65}
  #chat-log{flex:1;min-height:0;max-height:none!important;overflow:auto;margin:0;font-size:13px}
  /* Keep the flex spacer even when all problem messages are hidden. */
  #chat-panel #chat-log{display:block!important}
  #sample-chips{margin:0;flex:none;display:flex;flex-wrap:wrap;gap:5px}
  #sample-chips button{font-size:11px;padding:6px!important}
  #chat-input-row{flex:none;display:flex;flex-wrap:wrap;gap:5px;padding:8px!important;background:#14271f!important;border:1px solid #425b49;border-radius:10px}
  #chat-input{flex:1 0 100%!important;width:100%!important;box-sizing:border-box;min-width:0;min-height:54px;border:0!important;background:transparent!important;color:#e0e9dd!important;font:14px "Segoe UI",sans-serif!important}
  #chat-panel #chat-send{margin-left:auto;background:#a8bea0;color:#284332}
  #chat-controls{flex:none;flex-wrap:wrap;gap:4px!important;margin-top:0!important}
  #chat-controls #speed-ctl{width:100%;max-width:none}
  #chat-controls #voice-ctl{flex-wrap:wrap;gap:1px}
  #chat-controls #voice-ctl button{font-size:10px;padding:0 4px}
  #tb-chat{display:none}
}
@media(max-width:999px){#conversation-title{display:none}}

@media(min-width:1000px) and (orientation:landscape){
  #lesson-header #home-link{width:auto!important;min-width:95px;height:auto!important;white-space:nowrap!important;font-family:Comfortaa,"Segoe UI",sans-serif!important}
  #board-toolbar #tb-chat{display:none!important}
  #stage{background-color:#244d43!important;background-image:linear-gradient(#d8e6d005 1px,transparent 1px),linear-gradient(90deg,#d8e6d005 1px,transparent 1px)!important;background-size:64px 64px!important}
  #sample-chips{order:2}
  #chat-log{order:1}
  #chat-input-row{order:3}
  #chat-controls{order:4}
}

@media(min-width:1000px) and (orientation:landscape){
 #lesson-header{right:20%;width:80%;padding:0 20px}
 #lesson-header>span{display:none}
 #board-toolbar{left:145px!important;right:auto!important;max-width:calc(80vw - 160px);overflow:visible}
 #board-toolbar .tb-btn svg{display:block;width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.6}
 #board-toolbar .tb-btn{background:transparent;border:0;box-shadow:none;color:#c1cbc5}
 #board-toolbar .tb-active{background:#ffffff12;color:#f1ead6}
 #chat-panel,#chat-panel:has(#sample-chips:not([hidden])),#chat-panel:has(#chat-log:not(:empty)){top:0!important;height:100dvh!important}
}

@media(min-width:1000px) and (orientation:landscape){
 #lesson-header #home-link{display:inline-flex!important;align-items:center;gap:10px}
 #lesson-header #home-link img{display:block;width:36px;height:36px;object-fit:contain}
 #board-toolbar{left:190px!important;max-width:calc(80vw - 205px)}
}

@media(min-width:1000px) and (orientation:landscape){
 #chat-panel #sample-chips{display:flex!important;flex-wrap:nowrap!important;gap:12px!important;overflow-x:auto;scrollbar-width:thin;padding:3px 0 7px!important;max-width:100%;flex-shrink:0}
 #chat-panel #sample-chips[hidden]{display:none!important}
 #chat-panel #sample-chips button{flex:0 0 auto;white-space:nowrap;font-size:11px!important;padding:3px 0!important}
 #chat-panel #chat-input-row{position:relative;display:grid!important;grid-template-columns:28px 28px minmax(0,1fr) 34px;gap:4px!important;align-items:center;padding:9px!important;min-height:90px}
 #chat-panel #chat-input{grid-column:1/-1;grid-row:1;min-height:35px!important;height:35px!important;padding:3px 4px!important;font-size:13px!important}
 #chat-panel #chat-img{grid-column:1;grid-row:2;width:28px;height:28px}
 #chat-panel #chat-mic{grid-column:2;grid-row:2;width:28px;height:28px}
 #chat-panel #chat-send{grid-column:4;grid-row:2;width:32px;height:32px}
 #chat-panel #chat-controls{gap:5px!important;padding-top:8px!important;display:flex;align-items:center;flex-wrap:wrap}
 #chat-controls #speed-ctl{width:auto!important;max-width:100%;flex:1;gap:5px;height:27px}
 #chat-controls #speed-range{width:55px;min-width:30px}
 #chat-controls #voice-ctl{margin-left:auto;gap:0!important}
 #chat-controls #voice-ctl button{width:28px!important;padding:5px!important;height:28px}
 #chat-controls #voice-ctl button::after{display:none!important}
 #chat-panel #chat-controls #speed-val{font-size:10px}
}

#lesson-problem{display:none}
@media(min-width:1000px) and (orientation:landscape){
 #lesson-problem:not([hidden]){display:grid;gap:10px;flex:0 1 auto;max-height:35dvh;overflow:auto;padding:0 0 14px;border-bottom:1px solid #293d33;order:-2}
 #conversation-title{order:-3}
 #lesson-problem img{width:100%;height:auto;object-fit:contain;border-radius:3px}
 #lesson-problem img[hidden]{display:none}
 #lesson-problem p{color:#d2dfd1;font:13px/1.7 "Segoe UI",sans-serif;white-space:pre-wrap}
 .lesson-problem-label{font:600 11px "Segoe UI",sans-serif;color:#9caf9f}
}

#chat-panel #chat-log a{color:#F2DFA0;text-decoration-color:#F2DFA080;text-underline-offset:3px}#chat-panel #chat-log a:hover{color:#FFF0BE;text-decoration-color:currentColor}

@media(min-width:1000px) and (orientation:landscape){
 #chat-panel #chat-input-row{
  border:0!important;background:transparent!important;border-radius:0!important;
  min-height:0!important;padding:0!important;row-gap:3px!important;
 }
 #chat-panel #chat-input{
  border:1px solid #425b49!important;border-radius:8px!important;
  background:#14271f!important;padding:8px 10px!important;min-height:38px!important;height:38px!important;
 }
 #chat-panel #chat-img,#chat-panel #chat-mic{height:28px!important}
 #chat-panel #chat-send{width:30px!important;height:30px!important}
 #chat-panel #chat-controls{padding-top:5px!important;margin-top:0!important;border-top:0!important;gap:4px!important}
 #chat-panel #voice-ctl button{font-size:0!important;width:28px!important;height:28px!important;overflow:hidden;flex-shrink:0}
 #chat-panel #voice-ctl button svg{width:16px!important;height:16px!important;flex-shrink:0}
}

#lesson-more{display:contents}#lesson-more summary{display:none}.tool-label{display:none}
@media(min-width:1000px) and (orientation:landscape){
 #board-toolbar #tb-draw,#board-toolbar #tb-ask{width:auto!important;display:inline-flex;gap:7px;padding:8px 11px;align-items:center}
 .tool-label{display:inline;font:13px "Segoe UI",sans-serif}
 #lesson-more{display:block;position:relative}
 #lesson-more summary{display:block;color:#d9e2da;cursor:pointer;padding:10px;font:13px "Segoe UI",sans-serif;list-style:none}
 #lesson-more summary::-webkit-details-marker{display:none}
 #lesson-more[open]{background:#26332e;border-radius:8px}
 #lesson-more[open]> .tb-btn,#lesson-more[open]>#rail-replies{display:flex!important;margin:6px 10px!important}
 #lesson-more:not([open])> :not(summary){display:none!important}
 #lesson-more[open]{position:absolute;left:calc(100% - 52px);top:0;width:115px;padding-bottom:8px;box-shadow:0 8px 24px #0004}
 #board-toolbar #rail-replies{flex-direction:row!important;gap:6px;align-items:center}
 #board-toolbar .tb-sep{display:none}
}

@media(max-width:999px) and (orientation:portrait){
 html,body{width:100%;height:100%;overflow:hidden;overscroll-behavior:none;touch-action:pan-x pan-y}
 #lesson-header{position:fixed;inset:0 0 auto;display:flex;align-items:center;height:52px;padding:0 12px;z-index:140;background:#21262F}
 #lesson-header>span{display:none}
 #lesson-header #home-link{position:static!important;display:inline-flex!important;align-items:center;gap:7px;width:auto!important;height:auto!important;transform:none!important;background:transparent!important;border:0!important;box-shadow:none!important;color:#e6e9de;font:700 16px "Segoe UI",sans-serif!important}
 #lesson-header #home-link img{width:28px;height:28px}
 #board-toolbar{position:fixed!important;left:auto!important;right:8px!important;top:7px!important;bottom:auto!important;transform:none!important;width:auto!important;height:38px!important;display:flex!important;flex-direction:row!important;gap:4px;padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;z-index:145}
 #board-toolbar> :not(#tb-grade-toggle):not(#tb-ask):not(#lesson-more){display:none!important}
 #board-toolbar #tb-ask{display:flex;width:36px;height:36px}
 #board-toolbar #tb-grade-toggle{display:block;width:42px;height:34px;font-size:10px}
 #tb-menu,#rotate-hint{display:none!important}
 #lesson-more{display:block;position:relative}
 #lesson-more summary{display:block;list-style:none;padding:8px;color:#dce5da;font:12px "Segoe UI",sans-serif}
 #lesson-more:not([open])> :not(summary){display:none!important}
 #lesson-more[open]{position:absolute;right:0;top:0;width:115px;background:#26332e;border-radius:8px;padding-bottom:6px}
 #lesson-more[open]>.tb-btn,#lesson-more[open]>#rail-replies{display:flex!important;margin:4px 8px}
 #rail-replies{flex-direction:row!important}
 #chat-panel,#chat-panel:has(#sample-chips:not([hidden])),#chat-panel:has(#chat-log:not(:empty)){
 position:fixed!important;left:0!important;right:0!important;top:var(--stage-bottom)!important;bottom:auto!important;width:100%!important;height:max(180px,calc(var(--lesson-viewport-height,100dvh) - var(--stage-bottom)))!important;max-height:none!important;transform:none!important;box-sizing:border-box;padding:12px 14px calc(8px + env(safe-area-inset-bottom))!important;border:0!important;border-radius:0!important;background:#0C1A16!important;display:flex;flex-direction:column;gap:8px}
 #chat-panel[hidden]{display:none!important}
 #teacher-subtitles{position:static!important;flex:none;font:14px/1.5 "Segoe UI",sans-serif!important;text-shadow:none!important}
 #teacher-subtitles>div{white-space:normal!important;height:auto!important;max-height:3em;overflow:hidden}
 #chat-log{flex:1;min-height:0;max-height:none!important;overflow:auto;font-size:13px}
 #chat-panel #chat-log{display:block!important}
 #sample-chips{flex:none;display:flex!important;flex-wrap:nowrap!important;overflow-x:auto;gap:12px;scrollbar-width:none}
 #sample-chips[hidden]{display:none!important}
 #sample-chips button{white-space:nowrap;flex:none;font-size:11px;padding:4px 0!important}
 #chat-input-row{flex:none;display:flex;gap:5px;padding:5px!important;border:1px solid #425b49!important;border-radius:9px;background:#14271f!important}
 #chat-input{min-width:0!important;flex:1!important;width:0!important;height:40px!important;padding:5px!important;font-size:16px!important;background:transparent!important;border:0!important}
 #chat-panel #chat-img,#chat-panel #chat-mic,#chat-panel #chat-send{flex:none;width:34px!important;height:40px!important}
 #chat-controls{flex:none;flex-wrap:nowrap!important;gap:8px!important;padding-top:3px!important;margin:0!important;border:0!important}
 #chat-controls #speed-ctl{flex:1;max-width:none;width:auto;min-width:0;gap:4px}
 #chat-controls #speed-range{width:55px;min-width:30px}
 #chat-controls #voice-ctl{position:static!important;display:flex!important;gap:2px}
 #chat-controls #voice-ctl button{width:28px!important;height:30px!important;padding:5px!important;font-size:0!important}
 #chat-controls #voice-ctl button::after{display:none!important}
 #chat-controls #voice-ctl button svg{width:16px;height:16px}
 #voice-ctl #vc-conv{box-shadow:none!important;position:static!important}
}

@media(max-width:999px) and (orientation:portrait){
 #board-toolbar{visibility:visible!important;opacity:1!important;overflow:visible!important}
 #board-toolbar #tb-grade-toggle,#board-toolbar #tb-ask,#board-toolbar #lesson-more{visibility:visible!important;opacity:1!important;transform:none!important;pointer-events:auto!important}
 #board-toolbar #lesson-more[open]>.tb-btn,#board-toolbar #lesson-more[open]>#rail-replies{visibility:visible!important;opacity:1!important;transform:none!important;pointer-events:auto!important}
 #chat-panel #chat-mic.recording{transform:none!important;box-shadow:none!important;background:#ad5266!important}
}

#chat-mic {
 position:static!important;inset:auto!important;transform:none!important;
 flex:0 0 34px!important;width:34px!important;height:40px!important;
 margin:0!important;padding:7px!important;border:0!important;border-radius:8px!important;
 background:transparent!important;color:#dce6dc!important;box-shadow:none!important;
}
#chat-mic svg{width:20px!important;height:20px!important}
#chat-mic.recording{background:#874453!important;transform:none!important;animation:none!important}
#chat-mic::before{content:none!important}

@media(max-width:999px) and (orientation:portrait){
 #chat-panel #chat-input-row{
  display:grid!important;grid-template-columns:48px 48px 48px minmax(0,1fr);
  gap:8px 14px!important;padding:8px!important;
 }
 #chat-panel #chat-input{grid-column:1/-1;grid-row:1;width:100%!important;min-height:40px}
 #chat-panel #chat-send{grid-column:1;grid-row:2;margin:0!important}
 #chat-panel #chat-img{grid-column:2;grid-row:2}
 #chat-panel #chat-mic{grid-column:3;grid-row:2}
 #chat-panel #chat-send,#chat-panel #chat-img,#chat-panel #chat-mic{
  width:48px!important;height:48px!important;flex-basis:48px!important;
  padding:11px!important;border-radius:10px!important;
 }
 #chat-panel #chat-send svg,#chat-panel #chat-img svg,#chat-panel #chat-mic svg{width:26px!important;height:26px!important}
}

@media(max-width:999px) and (orientation:portrait){
 #chat-panel #chat-input-row{
  grid-template-columns:minmax(0,1fr) 48px 20px 48px minmax(0,1fr) 48px;
  column-gap:0!important;row-gap:8px!important;position:relative;
 }
 #chat-panel #chat-input{
  grid-column:1/6;grid-row:1;min-width:0;width:100%!important;height:48px!important;
  padding:9px!important;
 }
 #chat-panel #chat-send{grid-column:6;grid-row:1}
 #chat-panel #chat-img{grid-column:2;grid-row:2}
 #chat-panel #chat-mic{grid-column:4;grid-row:2}
 #chat-panel #chat-img{transform:translateX(24px)}
 #chat-panel #chat-mic{transform:translateX(24px)!important}
}

@media(min-width:1000px) and (orientation:landscape){
 #lesson-header{justify-content:center;gap:24px}
 #lesson-header #board-toolbar{position:relative!important;left:auto!important;right:auto!important;top:auto!important;max-width:none;flex:none}
}
