/* teaching-chat-panel 1.1.1; all selectors are confined to an attached panel. */
.teaching-chat-panel-host{display:flex!important;flex:1;flex-direction:column;min-width:0;min-height:0;overflow:hidden}
.teaching-chat-panel{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;overflow:hidden;container-type:size;line-height:1.6;color:#223044}
.teaching-chat-panel>.teaching-chat-panel__top{flex:0 1 auto;min-height:0;max-height:42%;overflow:auto;overscroll-behavior:contain;padding-bottom:5px}
.teaching-chat-panel .teaching-chat-panel__heading{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px}
.teaching-chat-panel .teaching-chat-panel__heading>h2{font-size:21px;line-height:1.5;margin:0;flex:0 0 auto}
.teaching-chat-panel .teaching-chat-panel__navigation{display:flex;align-items:center;flex:1;min-width:150px;flex-wrap:wrap;gap:5px}
.teaching-chat-panel .teaching-chat-panel__navigation>select{flex:1;min-width:60px;width:auto;margin:0;padding:5px;font-size:12px}
.teaching-chat-panel .teaching-chat-panel__navigation>button{font-size:12px;padding:5px 8px}
.teaching-chat-panel .teaching-chat-panel__actions{font-size:12px;margin:4px 0;max-height:none;overflow:visible}
.teaching-chat-panel .teaching-chat-panel__actions button{font-size:12px;padding:5px 9px;min-height:30px;line-height:1.5}
.teaching-chat-panel .teaching-chat-panel__actions>p{margin:2px 0;max-height:2.8em;overflow:auto;line-height:1.4}
.teaching-chat-panel .teaching-chat-panel__source{flex:none;margin:3px 0;font-size:12px}
.teaching-chat-panel .teaching-chat-panel__source>summary{cursor:pointer;color:#3456a6;width:fit-content;padding:3px 0}
.teaching-chat-panel .teaching-chat-panel__source[open]{max-height:18dvh;overflow:auto;overscroll-behavior:contain}
.teaching-chat-panel .teaching-chat-panel__source>div{max-height:none;overflow:visible}
.teaching-chat-panel .teaching-chat-panel__messages{flex:1 1 0;min-height:64px;max-height:none;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding:10px 1px;border-top:1px solid #edf0f5;overflow-wrap:anywhere}
.teaching-chat-panel .teaching-chat-panel__messages>.bubble{flex-shrink:0;font-size:20px;line-height:1.85}
.teaching-chat-panel .teaching-chat-panel__footer{flex:0 0 auto;min-width:0;position:relative;background:#fff}
.teaching-chat-panel .teaching-chat-panel__composer{flex:none;gap:5px;padding-top:7px;background:#fff}
.teaching-chat-panel .teaching-chat-panel__composer>.chat-tools{display:flex;align-items:center;flex-wrap:wrap;gap:4px}
.teaching-chat-panel .teaching-chat-panel__composer>.chat-tools button,.teaching-chat-panel .teaching-chat-panel__composer>.chat-tools summary{font-size:12px;padding:5px 7px;line-height:1.5}
.teaching-chat-panel .teaching-chat-panel__composer .chat-entry{align-items:stretch;gap:7px}
.teaching-chat-panel .teaching-chat-panel__composer .chat-entry textarea{height:60px;min-height:0;resize:none;font-size:16px;line-height:1.6;margin:0}
.teaching-chat-panel .teaching-chat-panel__composer.composer-expanded .chat-entry textarea{height:clamp(92px,12dvh,144px);font-size:18px;line-height:1.7}
.teaching-chat-panel .teaching-chat-panel__composer .chat-entry button{font-size:13px;padding:7px 10px}
.teaching-chat-panel .teaching-chat-panel__composer>p{margin:0;font-size:11px;max-height:34px;overflow:auto}
.teaching-chat-panel .teaching-chat-panel__composer .tool-popover{max-height:min(45dvh,280px);max-width:calc(100vw - 38px)}
@media(max-width:600px){
 .teaching-chat-panel .teaching-chat-panel__heading>h2{font-size:19px}
 .teaching-chat-panel .teaching-chat-panel__messages>.bubble{font-size:19px}
 .teaching-chat-panel .teaching-chat-panel__actions button{padding:4px 7px;font-size:11px}
 .teaching-chat-panel .teaching-chat-panel__composer>.chat-tools button,.teaching-chat-panel .teaching-chat-panel__composer>.chat-tools summary{font-size:11px;padding:4px 6px}
}
@media(max-height:650px){
 .teaching-chat-panel>.teaching-chat-panel__top{max-height:48%}
 .teaching-chat-panel .teaching-chat-panel__messages{min-height:40px;padding-block:5px}
 .teaching-chat-panel .teaching-chat-panel__composer .chat-entry textarea{height:48px}
 .teaching-chat-panel .teaching-chat-panel__composer.composer-expanded .chat-entry textarea{height:92px}
 .teaching-chat-panel .teaching-chat-panel__composer>.chat-tools button,.teaching-chat-panel .teaching-chat-panel__composer>.chat-tools summary{font-size:11px;padding:3px 5px}
}

/* Layout primitives are owned here so another subject need not load an English stylesheet. */
.teaching-chat-panel .teaching-chat-panel__messages{display:flex;flex-direction:column;gap:11px}
.teaching-chat-panel .teaching-chat-panel__messages>.bubble{max-width:92%;border-radius:12px;padding:10px 12px;white-space:pre-wrap;background:#f0f2f6;align-self:flex-start}
.teaching-chat-panel .teaching-chat-panel__messages>.bubble.child{background:#e1ebff;align-self:flex-end}
.teaching-chat-panel .teaching-chat-panel__messages img{max-width:100%;max-height:250px;object-fit:contain}
.teaching-chat-panel .teaching-chat-panel__composer{display:flex;flex-direction:column;border-top:1px solid #e4e9f1}
.teaching-chat-panel .teaching-chat-panel__composer .chat-entry{display:flex}
.teaching-chat-panel .teaching-chat-panel__composer .chat-entry textarea{flex:1;min-width:0;box-sizing:border-box}
.teaching-chat-panel .teaching-chat-panel__composer .chat-entry button{flex:none;align-self:flex-end}
.teaching-chat-panel .teaching-chat-panel__composer .chat-tools select{width:auto;max-width:110px;margin:0;padding:4px;font-size:12px}
.teaching-chat-panel .teaching-chat-panel__composer .chat-tools details{position:relative;margin:0}
.teaching-chat-panel .teaching-chat-panel__composer .tool-popover{position:absolute;z-index:4;bottom:calc(100% + 8px);right:0;left:auto;display:flex;flex-direction:column;gap:6px;width:max-content;padding:9px;border:1px solid #dce3ef;border-radius:10px;background:#fff;box-shadow:0 7px 24px #1e3b6926;overflow:auto}
.teaching-chat-panel .teaching-chat-panel__composer>p:empty{display:none}

@media(max-width:350px){
 .teaching-chat-panel .teaching-chat-panel__heading{gap:4px;flex-wrap:nowrap}
 .teaching-chat-panel .teaching-chat-panel__heading>h2{font-size:16px}
 .teaching-chat-panel .teaching-chat-panel__navigation{min-width:145px;gap:3px}
 .teaching-chat-panel .teaching-chat-panel__navigation>button{font-size:10px;padding:4px}
 .teaching-chat-panel .teaching-chat-panel__navigation>select{font-size:10px;padding:4px;min-width:50px}
}

/* Four-subject workspace: one placement contract, no learning state or action rules. */
.teaching-workspace .teaching-workspace__header{display:flex;align-items:center;gap:12px;flex-wrap:wrap;flex:0 0 auto;min-width:0;margin-bottom:7px}
.teaching-workspace .teaching-workspace__header>h1{font-size:21px;line-height:1.5;margin:0;flex:1;min-width:0}
.teaching-workspace .teaching-workspace__header>.row:empty{display:none}
.teaching-workspace .teaching-workspace__voice{margin-left:auto;display:flex;align-items:center;flex:none}
.teaching-workspace .teaching-workspace__voice:empty{display:none}
.teaching-workspace .teaching-workspace__voice button{background:#2859bd;color:#fff;border:1px solid #2859bd;border-radius:9px;padding:10px 16px;font-size:15px;font-weight:600;min-height:42px;white-space:nowrap}
.teaching-workspace .teaching-workspace__voice button:disabled{opacity:.5;cursor:not-allowed}
.teaching-workspace .teaching-workspace__voice button:focus-visible{outline:3px solid #7da6ff;outline-offset:3px}
.teaching-workspace .teaching-workspace__actions{display:flex;flex-wrap:wrap;align-items:center;gap:7px;flex:0 0 auto;padding:10px;border:1px solid #dce5f3;border-radius:10px;background:#f6f8fc;max-height:210px;overflow:auto}
.teaching-workspace .teaching-workspace__actions:empty{display:none}
.teaching-workspace .teaching-workspace__action-item{display:contents}
.teaching-workspace .teaching-workspace__actions [hidden],.teaching-workspace .teaching-workspace__actions .hidden{display:none!important}
.teaching-workspace .teaching-workspace__actions button{min-height:36px;padding:7px 11px;font-size:13px}
.teaching-workspace .teaching-workspace__actions .study-actions{width:100%;margin:0;border:0;padding:0;background:transparent}
.teaching-workspace .teaching-workspace__actions #childStudyActions{flex-basis:100%;max-height:none;margin:0;padding:0;border:0;background:transparent}
.teaching-workspace .teaching-workspace__actions .study-actions-buttons{display:flex;flex-wrap:wrap;gap:7px}
.teaching-workspace .teaching-workspace__tutor{display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}
.teaching-workspace .teaching-workspace__messages{flex:1 1 0;min-height:120px;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;border-top:1px solid #edf0f5}
.teaching-workspace .teaching-workspace__messages>.bubble{font-size:20px;line-height:1.85;overflow-wrap:anywhere}
.teaching-workspace .teaching-workspace__composer{flex:0 0 auto;padding-top:8px;border-top:1px solid #e4e9f1;min-width:0}
.teaching-workspace .teaching-workspace__composer .chat-tools{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
.teaching-workspace .teaching-workspace__composer .chat-tools button,.teaching-workspace .teaching-workspace__composer .chat-tools summary{font-size:13px;min-height:32px;padding:6px 9px}
.teaching-workspace .teaching-workspace__composer .chat-entry{min-width:0;align-items:flex-end}
.teaching-workspace .teaching-workspace__composer .chat-entry textarea{min-height:62px;max-height:150px;font-size:17px;line-height:1.65}
.teaching-workspace .teaching-workspace__composer .chat-entry button[type=submit]{min-height:40px}
.teaching-workspace #childTaskContext:empty{display:none}
.teaching-workspace #childTaskContext{flex:0 0 auto}
.teaching-workspace .teaching-workspace__composer .math-edit-wrap{min-width:0}
@media(max-width:720px){
 .teaching-workspace .teaching-workspace__header{gap:8px}
 .teaching-workspace .teaching-workspace__header>h1{font-size:18px}
 .teaching-workspace .teaching-workspace__voice button{padding:9px 12px;font-size:14px;min-height:40px}
 .teaching-workspace .teaching-workspace__actions{max-height:200px;padding:8px;gap:6px}
 .teaching-workspace .teaching-workspace__tutor{min-height:75dvh;overflow:visible}
 .teaching-workspace .teaching-workspace__messages{height:46dvh;max-height:60dvh;flex:auto;font-size:19px}
 .teaching-workspace .teaching-workspace__messages>.bubble{font-size:19px}
 .teaching-workspace .teaching-workspace__composer .chat-entry{flex-wrap:wrap}
 .teaching-workspace .teaching-workspace__composer .chat-entry textarea{width:100%}
}

/* Keep mobile worksheet controls reachable without a scroll trap inside the paper card. */
.teaching-workspace #childQuestionPicker{flex-shrink:0;min-height:max-content}
@media(max-width:720px){
 .teaching-workspace.child-focus-layout .teaching-workspace__paper{height:auto;min-height:0;overflow:visible}
 .teaching-workspace.child-focus-layout #childPaperContent{flex:0 0 auto;overflow:visible}
 .teaching-workspace.child-focus-layout .child-paper .image-wrap{height:42dvh;min-height:240px;max-height:none;flex:0 0 auto}
 .teaching-workspace .teaching-workspace__actions{max-height:none;overflow:visible}
 .teaching-workspace .teaching-workspace__actions .study-actions-buttons button{flex:1 1 calc(50% - 7px)}
 .teaching-workspace .teaching-workspace__composer .chat-entry textarea,.teaching-workspace .teaching-workspace__composer .chat-entry>.math-edit-wrap{flex-basis:100%;width:100%}
 .teaching-workspace .teaching-workspace__composer .chat-entry>button[type=submit]{margin-left:auto}
}

/* One compact action row leaves the worksheet enough space on laptop screens. */
.teaching-workspace .teaching-workspace__actions #childStudyActions{display:contents}
.teaching-workspace .teaching-workspace__actions #childStudyActions .study-actions-buttons{display:contents}
.teaching-workspace .teaching-workspace__actions #childStudyActions .study-actions-title{order:-1;flex-basis:100%;margin:0;font-size:13px}
.teaching-workspace .teaching-workspace__actions #childStudyActions>p,.teaching-workspace .teaching-workspace__actions #childStudyActions>details{order:2;flex-basis:100%;margin:0;font-size:12px}
.teaching-workspace .teaching-workspace__actions .teaching-workspace__action-item>button{flex:1 1 auto}
@media(max-width:720px){
 .teaching-workspace .teaching-chat-panel__composer .chat-entry{flex-wrap:wrap}
 .teaching-workspace .teaching-chat-panel__composer .chat-entry textarea{flex-basis:100%;width:100%}
 .teaching-workspace .teaching-chat-panel__composer .english-send-buttons{margin-left:auto}
}

/* On very short handsets keep sending accessible alongside the compact text field. */
@media(max-width:350px) and (max-height:550px){
 .teaching-workspace .teaching-chat-panel__composer .chat-entry{flex-wrap:nowrap}
 .teaching-workspace .teaching-chat-panel__composer .chat-entry textarea{flex-basis:auto;width:auto}
 .teaching-workspace .teaching-chat-panel__composer .english-send-buttons{margin-left:0}
}


/* Mobile history reading is opt-in; desktop and original composer tools stay intact. */
.teaching-history-toggle{display:none}
@media(max-width:720px){
 .teaching-workspace .teaching-history-toggle{display:block;align-self:flex-start;flex:none;min-height:44px;margin:6px 0;padding:8px 12px;font-size:14px}
 .teaching-workspace .teaching-history-toggle[hidden]{display:none!important}
 /* Override subject ID sizing only while reading, including the English mounted shell. */
 .teaching-workspace.teaching-history-open,
 .teaching-workspace.teaching-history-open .teaching-workspace__tutor,
 .teaching-workspace.teaching-history-open .teaching-chat-panel-host,
 .teaching-workspace.teaching-history-open .teaching-chat-panel{
   height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;container-type:normal;
 }
 .teaching-workspace.teaching-history-open .teaching-chat-panel__top{
   flex:0 0 auto;max-height:none;overflow:visible;
 }
 .teaching-workspace.teaching-history-open .teaching-workspace__messages,
 .teaching-workspace.teaching-history-open .teaching-chat-panel__messages{
   flex:0 0 auto!important;height:auto!important;min-height:0!important;max-height:none!important;
   overflow:visible!important;overscroll-behavior:auto;scrollbar-gutter:auto;
 }
 .teaching-workspace.teaching-history-open .messages>details{min-width:0;overflow-wrap:anywhere}
}
