.lesson-chat-button{position:fixed;right:16px;bottom:calc(92px + env(safe-area-inset-bottom,0px));z-index:65;width:54px;height:54px;min-height:54px;padding:0;display:grid;place-items:center;border:0;border-radius:var(--radius-round);background:var(--legacy-hex-173d91);color:var(--palette-white);box-shadow:var(--shadow-lesson-chat-16);font:24px/1 system-ui;cursor:pointer}
.lesson-chat-button[hidden],.lesson-chat-panel[hidden]{display:none!important}
.lesson-chat-panel{position:fixed;right:14px;bottom:calc(158px + env(safe-area-inset-bottom,0px));z-index:66;width:min(390px,calc(100vw - 28px));height:min(510px,calc(100dvh - 210px));display:flex;flex-direction:column;background:var(--palette-white);border:1px solid var(--legacy-hex-ccd7ed);border-radius:var(--radius-20px);box-shadow:var(--shadow-lesson-chat-17);overflow:hidden;font:15px system-ui;color:var(--legacy-hex-193256)}
.lesson-chat-head{display:flex;align-items:center;gap:12px;padding:14px 16px;background:var(--legacy-hex-173d91);color:var(--palette-white)}.lesson-chat-head div{flex:1;min-width:0}.lesson-chat-head small{display:block;margin-top:4px;overflow-wrap:anywhere}.lesson-chat-head button{border:0;background:var(--palette-clear);color:var(--palette-white);font-size:22px;padding:8px;cursor:pointer}
.lesson-chat-messages{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:14px;min-height:0}.lesson-chat-message{padding:10px 12px;background:var(--legacy-hex-edf2fc);border-radius:var(--radius-btn);margin-bottom:12px;overflow-wrap:anywhere}.lesson-chat-message.user{background:var(--legacy-hex-e6f5ef);margin-left:28px}.lesson-chat-message p{white-space:pre-wrap;line-height:1.6;margin:5px 0 0}.lesson-chat-status{margin:0;padding:0 14px 10px;font-size:13px;color:var(--legacy-hex-536580);overflow-wrap:anywhere}.lesson-chat-form{display:flex;gap:8px;padding:12px;border-top:1px solid var(--legacy-hex-dde5f3)}.lesson-chat-form textarea{flex:1;min-width:0;resize:none;font:16px system-ui;border:1px solid var(--legacy-hex-bdcce4);border-radius:var(--radius-btn);padding:10px}.lesson-chat-form button{border:0;border-radius:var(--radius-btn);background:var(--legacy-hex-173d91);color:var(--palette-white);padding:10px 14px;font:600 15px system-ui}.lesson-chat-form button:disabled{opacity:.5}
body.drawer-open .lesson-chat-button,body.drawer-open .lesson-chat-panel,body.drawer-open .lesson-selection-prompt{visibility:hidden}
.lesson-selection-prompt{position:fixed;z-index:67;width:min(310px,calc(100vw - 24px));padding:12px;background:var(--legacy-hex-fffffff2);border:1px solid var(--legacy-hex-ccd7ed);border-radius:var(--radius-14px);box-shadow:var(--shadow-lesson-chat-18);backdrop-filter:blur(12px);font:14px system-ui;color:var(--legacy-hex-193256)}
.lesson-selection-prompt[hidden]{display:none!important}
.lesson-selection-prompt form{display:grid;gap:8px}.lesson-selection-prompt label{font-weight:700}.lesson-selection-prompt textarea{width:100%;min-height:66px;resize:none;padding:9px 10px;border:1px solid var(--legacy-hex-bdcce4);border-radius:var(--radius-10px);font:16px/1.4 system-ui}.lesson-selection-prompt form>div{display:flex;justify-content:flex-end;gap:8px}.lesson-selection-prompt button{min-height:40px;padding:7px 12px;border:0;border-radius:var(--radius-10px);background:var(--legacy-hex-173d91);color:var(--palette-white);font:600 14px system-ui}.lesson-selection-prompt #lessonSelectionClose{width:40px;padding:0;background:var(--legacy-hex-edf2fc);color:var(--legacy-hex-193256);font-size:20px}
@media(min-width:701px){.lesson-chat-button{bottom:24px}.lesson-chat-panel{bottom:86px;height:min(540px,calc(100dvh - 110px))}}
@media(max-height:650px){.lesson-chat-panel{top:max(calc(var(--safe-t,env(safe-area-inset-top,0px)) + 10px),20px);bottom:calc(82px + env(safe-area-inset-bottom,0px));height:auto;max-height:none}}

/* Keep iOS focus at the current zoom and fit the keyboard's visual viewport. */
body.studio-enabled #lessonChatInput,body.studio-enabled #lessonSelectionInput{font-size:16px}
.lesson-chat-panel[aria-busy=true] .lesson-chat-status{display:flex;align-items:center;gap:8px}
.lesson-chat-panel[aria-busy=true] .lesson-chat-status::before{content:"";flex:none;width:16px;height:16px;border:2px solid var(--line-dark);border-top-color:var(--accent);border-radius:var(--radius-round);animation:hsk-chat-spin .85s linear infinite;will-change:transform}
@keyframes hsk-chat-spin{to{transform:rotate(360deg)}}
@media(max-width:700px),(pointer:coarse){
 .lesson-chat-panel{top:calc(var(--chat-view-top,0px) + env(safe-area-inset-top,0px) + 8px);bottom:auto;height:calc(var(--chat-view-height,100dvh) - env(safe-area-inset-top,0px) - 16px);max-height:min(560px,65dvh);right:max(10px,env(safe-area-inset-right,0px));width:calc(100% - max(10px,env(safe-area-inset-right,0px)) - max(10px,env(safe-area-inset-left,0px)))}
}
@media(prefers-reduced-motion:reduce){.lesson-chat-panel[aria-busy=true] .lesson-chat-status::before{animation-duration:2s}}
