/* Loaded after feature styles: a phone cannot inherit a desktop minimum width.
   Documents keep their own pan/zoom surface; page layout never hides overflow
   as a substitute for fitting controls and text. */
.group-mobile-section { display:none; }
@media (max-width:900px) {
  html body :is(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), select, textarea) {
    font-size:16px; box-sizing:border-box; max-width:100%;
  }
  html body :is(.section-heading,.nb-library-heading,.lecture-library-heading,.study-heading) {
    flex-wrap:wrap; gap:10px;
  }
  /* The seven day columns must not also size the schedule action buttons. */
  html body .study-week-strip > .study-plan-action {
    grid-column:1 / -1; width:100%; min-width:0; margin:8px 0 0;
    white-space:normal; overflow-wrap:normal; word-break:normal;
  }
  /* Keep audio parts readable and wrap whole controls onto the next row. */
  html body .lecture-inline > :is(button,.lecture-import) {
    flex:1 1 128px; min-width:0; max-width:100%; min-height:44px;
    white-space:normal; overflow-wrap:normal; word-break:normal; line-height:1.4;
  }
  html body :is(.design-panel,.lecture-library,.group-home,.profile-card,.device-panel) {
    min-width:0; overflow-wrap:anywhere;
  }
  html body :is(.material-actions,.video-actions,.video-utilities,.device-controls,.challenge-footer,.group-invite-actions) > * {
    min-width:0; max-width:100%; white-space:normal;
  }
  html body :is(.material-actions,.video-actions,.video-utilities,.device-controls,.challenge-footer,.group-invite-actions) :is(button,a),
  html body :is(.challenge-tabs,.quiz-support,.approval-actions,.nb-library-heading,.group-home-tabs) button {
    min-height:44px;
  }
  html body .device-controls label { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; }
  html body .device-controls select { width:100%; }
  html body .app-sidebar { top:var(--app-viewport-top,0px); }
  html body.mobile-keyboard-open.app-authenticated .page-shell { padding-bottom:16px; }
  html body.mobile-keyboard-open .toast { bottom:12px; }
  html body .group-library-search { display:grid; grid-template-columns:minmax(0,1fr) auto; }
  html body .group-library-search input { min-width:0; width:100%; }
  html body :is(.group-file-row,.group-share-item) { box-sizing:border-box; min-width:0; overflow-wrap:anywhere; }
  html body :is(.group-file-row,.group-share-item) > span { min-width:0; }
  html body :is(.group-file-row,.group-share-item) > svg { flex-shrink:0; }
  html body .group-email-list li { overflow-wrap:anywhere; min-width:0; align-items:center; }
  html body .group-email-list button { flex:none; min-width:44px; min-height:44px; }
  html body .group-chat { min-height:0; }
  html body .group-messages { min-height:0; }
  html body :is(.group-message details,.group-session-list,.group-study-actions,.group-recording-bar) button { min-height:44px; }
}
@media (max-width:600px) {
  html body .materials-view .material-grid,
  html body .quiz-dialog .quiz-config,
  html body .quiz-dialog .quiz-config:has(#quiz-request-count),
  html body .challenge-fields { grid-template-columns:minmax(0,1fr); }
  html body .materials-view .library-layout { display:block; }
  html body .library-layout > .material-search { position:static; width:100%; }
  html body .group-room-head { gap:6px; padding:calc(4px + env(safe-area-inset-top)) 10px 4px; }
  html body .group-room-head h2 { font-size:16px; line-height:1.25; max-height:2.5em; overflow:hidden; }
  html body .group-room-head .group-action { min-width:44px; width:44px; min-height:44px; padding:8px; flex:none; font-size:22px; }
  html body .group-room-head .group-action span { display:none; }
  html body .group-room-head .group-avatar { width:30px; height:30px; }
  html body .group-composer { padding:8px 10px calc(8px + env(safe-area-inset-bottom)); }
  html body.mobile-keyboard-open .group-composer { padding-bottom:8px; }
  html body.mobile-keyboard-open .group-mobile-section { display:none; }
  html body .group-section-head > .group-action { width:100%; }
  html body .group-form { padding:14px; }
  html body .group-form fieldset { min-width:0; max-width:100%; }
  html body .group-form footer button { min-width:0; }
  html body .group-session-list article > div:not(.group-session-actions) { min-width:0; flex-basis:100%; overflow-wrap:anywhere; }
  html body .group-study-actions label { flex-wrap:wrap; }
  html body .group-tool-card { padding:16px; }
  html body .group-tool-card .group-action { max-width:100%; white-space:normal; }
  html body .group-list-card > .group-action { margin-left:0; flex-basis:100%; }
  html body .lecture-dialog-footer { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; padding-top:6px; padding-bottom:calc(6px + env(safe-area-inset-bottom)); }
  html body .lecture-dialog-footer :is(button,a) { min-width:0; padding:8px; white-space:normal; }
  html body .lecture-dialog-head h2 { font-size:18px; }
  html body .reader-header h2 { font-size:18px; overflow-wrap:anywhere; }
  html body :is(.reader-header,.lecture-dialog-head) h2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
  html body .reader-tools { padding:8px; }
  html body .reader-tools :is(button,a) { min-height:44px; }
  html body .schedule-dialog .schedule-time-row label { min-width:0; }
  html body .schedule-dialog .schedule-time-row input { width:100%; min-width:0; }
  html body .schedule-dialog .schedule-selected-item { min-width:0; }
  html body .nb-top-panel :is(.nb-options,.nb-selected-tools) label { flex-wrap:wrap; max-width:100%; }
  html body .nb-context .nb-swatches { flex-wrap:wrap; }
  html body .nb-top-panel .nb-help { overflow-wrap:anywhere; }
}
@media (max-width:380px) {
  html body .welcome-hero { grid-template-columns:minmax(0,1fr) 72px; gap:8px; padding:14px; }
  html body .welcome-hero .hero-character { min-width:0; width:72px; }
  html body .welcome-hero .hero-character .design-mascot { width:72px; height:100px; }
  html body .welcome-hero .character-bubble { display:none; }
  html body .group-empty { flex-wrap:wrap; text-align:center; }
  html body .group-empty > div { min-width:0; width:100%; }
  html body .group-library-search { grid-template-columns:minmax(0,1fr); }
  html body .group-room-head .group-avatar { display:none; }
}
@media (max-width:900px) {
  html body .group-room-layout { display:flex; flex-direction:column; }
  html body .group-room-nav { display:none; }
  html body .group-mobile-section { display:flex; align-items:center; gap:10px; padding:4px 12px; border-bottom:1px solid #2b3d42; flex:none; }
  html body .group-mobile-section span { font-size:12px; }
  html body .group-mobile-section select { flex:1; min-width:0; min-height:44px; background:#17282e; border:1px solid #355058; border-radius:8px; color:#fff; padding:8px; }
  html body.mobile-keyboard-open .group-mobile-section { display:none; }
  html body .group-main { flex:1; }
  html body .group-side { display:none; }
  html body .group-in-study .group-study { max-height:none; padding:8px; }
  html body .group-in-study .group-main { display:flex; }
  html body .group-in-study .group-side-tabs { display:none; }
  html body .group-in-study .group-study-composer { flex:none; }
  html body .group-in-study .group-study-mobile-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; padding:4px 10px calc(4px + env(safe-area-inset-bottom)); flex:none; border-top:1px solid #2b3d42; }
  html body .group-in-study .group-composer { padding-bottom:8px; }
  html body .group-in-study[data-study-view=chat] .group-main,
  html body .group-in-study[data-study-view=people] .group-main { display:none; }
  html body .group-in-study[data-study-view=chat] .group-side,
  html body .group-in-study[data-study-view=people] .group-side { display:flex; flex:1; min-height:0; border-left:0; }
  html body .group-in-study[data-study-view=chat] .group-side-conversation { display:flex; }
  html body .group-in-study[data-study-view=chat] .group-people { display:none; }
  html body .group-in-study[data-study-view=people] .group-side-conversation { display:none; }
  html body .group-in-study[data-study-view=people] .group-people { display:block; }
  html body.mobile-keyboard-open .group-study-mobile-tabs { display:none; }
}
/* Short landscape screens and open keyboards still need a usable content area. */
@media (max-width:900px) and (max-height:500px) {
  html body .lecture-dialog-head :is(.lecture-kicker,p),
  html body .schedule-footer > span { display:none; }
  html body .lecture-dialog-head { padding-top:4px; padding-bottom:4px; }
  html body .lecture-dialog-footer { display:flex; flex-wrap:wrap; padding-top:4px; padding-bottom:4px; }
  html body .lecture-dialog-footer button { flex:1 1 100px; }
  html body .schedule-dialog .schedule-steps { padding-bottom:4px; }
  html body .schedule-dialog .schedule-footer { padding:4px 12px; }
  html body .schedule-dialog .schedule-footer > div { width:100%; }
  html body .group-wizard-hero img { display:none; }
}
/* A single 48px reader bar leaves the viewport to the lesson. */
html body .reader-dialog .reader-header{position:relative;z-index:2;display:flex;align-items:center;flex:none;gap:8px;min-height:0;height:calc(48px + env(safe-area-inset-top));box-sizing:border-box;padding:env(safe-area-inset-top) max(8px,env(safe-area-inset-right)) 0 max(8px,env(safe-area-inset-left));background:#101a20}
html body .reader-dialog .reader-header h2{display:block;flex:1;min-width:0;margin:0;font-size:14px;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal}
html body .reader-dialog .reader-header :is(button,summary){display:grid;place-items:center;flex:none;box-sizing:border-box;width:36px;min-width:36px;height:36px;min-height:36px;padding:0;border-radius:6px;font-size:18px;line-height:1;box-shadow:none}
html body .reader-dialog .reader-header [data-reader-close]{background:transparent;border:0}
html body .reader-dialog .reader-controls{flex:none;min-width:0}
html body .reader-dialog .reader-pages{display:flex;width:auto;flex-wrap:nowrap;gap:4px;margin:0;font-size:12px;white-space:nowrap}
html body .reader-dialog .reader-pages input{box-sizing:border-box;width:48px;min-width:0;height:32px;padding:4px;text-align:center;font-size:14px;appearance:textfield;-moz-appearance:textfield}
html body .reader-dialog .reader-pages input::-webkit-inner-spin-button,html body .reader-dialog .reader-pages input::-webkit-outer-spin-button{margin:0;-webkit-appearance:none}
html body .reader-dialog .reader-zoom{min-width:40px;text-align:center;font-variant-numeric:tabular-nums}
html body .reader-dialog .reader-actions{position:relative;flex:none}
html body .reader-dialog .reader-actions summary{cursor:pointer;list-style:none;background:transparent;border:0;font-size:24px;color:var(--text)}
html body .reader-dialog .reader-actions summary::-webkit-details-marker{display:none}
html body .reader-dialog .reader-header :is(button,summary):focus-visible{outline:2px solid var(--green);outline-offset:1px}
html body .reader-dialog .reader-actions:not([open])>.reader-tools{display:none}
html body .reader-dialog .reader-tools{position:absolute;top:calc(100% + 6px);right:0;display:flex;flex-direction:column;align-items:stretch;gap:6px;width:min(240px,calc(100vw - 24px));max-height:none;overflow:visible;box-sizing:border-box;margin:0;padding:8px;border:1px solid var(--line);border-radius:10px;box-shadow:0 8px 24px #0005;background:#18272c}
html body .reader-dialog .reader-tools button{display:block;width:100%;height:auto;min-height:44px;padding:8px 12px;text-align:left;font-size:14px;line-height:1.4}
html body .reader-dialog .reader-offline-status{font-size:12px;overflow-wrap:anywhere}
html body .reader-dialog .reader-offline-status:empty{display:none}
html body .reader-dialog .reader-status{position:absolute;z-index:1;top:calc(52px + env(safe-area-inset-top));left:12px;right:12px;width:fit-content;max-width:calc(100% - 24px);min-height:0;margin:0;padding:6px 10px;border-radius:6px;background:#101a20ed;font-size:12px;pointer-events:none}
html body .reader-dialog .reader-status:empty{display:none}
html body .reader-dialog .reader-content{padding-top:8px}
html body .reader-dialog .reader-speed{margin:0}
html body .reader-dialog .reader-speed select{height:32px;margin:0;padding:4px;font-size:13px}
@media(max-width:600px){
 html body .reader-dialog .reader-header{display:grid;grid-template-columns:44px minmax(0,1fr) auto 44px;height:auto;min-height:calc(48px + env(safe-area-inset-top));gap:0 4px}
 html body .reader-dialog .reader-header :is(button,summary){width:44px;min-width:44px;height:44px;min-height:44px}
 html body .reader-dialog .reader-header h2{grid-column:2;font-size:13px}
 html body .reader-dialog .reader-actions{grid-column:4;grid-row:1}
 html body .reader-dialog .reader-controls:has(.reader-pages){grid-column:1/-1;grid-row:2;justify-self:center}
 html body .reader-dialog .reader-pages{gap:2px}
 html body .reader-dialog .reader-pages input{height:40px;width:44px;font-size:16px}
 html body .reader-dialog .reader-status{top:auto;bottom:calc(12px + env(safe-area-inset-bottom))}
 html body .reader-dialog .reader-tools button{width:100%;height:auto}
 html body .reader-dialog .reader-speed select{height:44px;font-size:16px}
}
/* Library actions need real columns, rather than four shrinking flex items. */
html body .materials-view .material-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
html body .materials-view .is-list .material-grid{grid-template-columns:minmax(0,1fr)}
html body .materials-view .material-item .material-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%;align-items:stretch}
html body .materials-view .material-item .material-actions>:is(button,a){grid-column:auto;display:flex;align-items:center;justify-content:center;box-sizing:border-box;min-width:0;width:100%;max-width:100%;min-height:44px;height:auto;margin:0;padding:10px 12px;font-size:12px;line-height:1.4;text-align:center;white-space:normal;word-break:normal;overflow-wrap:normal;hyphens:none;text-wrap:balance}
html body .materials-view .material-folder .material-actions>:only-child{grid-column:1/-1}
html body .materials-view .material-actions>:last-child:nth-child(odd){grid-column:1/-1}
@media(max-width:1100px){
 html body .materials-view .is-list .material-item{grid-template-columns:52px minmax(0,1fr)}
 html body .materials-view .is-list .material-item .material-actions{grid-column:1/-1}
}
@media(max-width:700px){
 html body .materials-view .material-grid{grid-template-columns:minmax(0,1fr);gap:12px}
 html body .materials-view .material-item .material-actions>:is(button,a){padding:10px 8px}
}
/* Final group layout: explicit tracks prevent old sidebar rules from competing.
   The visual viewport keeps the composer above iOS and Android keyboards. */
html body .group-room .group-main,html body .group-room .group-panel,html body .group-room .group-study-media{min-width:0;min-height:0}
html body .group-room .group-tools-menu{max-height:calc(var(--group-viewport-height,100dvh) - 68px)}
html body .group-room .group-message,html body .group-room .group-tool-card{overflow-wrap:anywhere;min-width:0}
html body .group-room .group-section-head{gap:8px;flex-wrap:wrap}
html body .group-room .group-section-head button{white-space:normal;min-height:44px}
html body .group-room .group-card-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
@media(max-width:700px){html body .group-room .group-card-grid{grid-template-columns:minmax(0,1fr)}}
.group-source-origins,.personal-library-entry{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:12px 0}
.personal-library-entry span{color:#adbab4;font-size:13px}.group-source-origins button{max-width:100%;white-space:normal;overflow-wrap:anywhere}
.personal-file-dialog .group-flow-head button{margin-left:auto}.personal-upload{padding:12px;border:1px dashed #b6f34a;border-radius:12px;overflow:hidden}
.personal-upload input{max-width:100%}.personal-file-list article{padding:16px;border:1px solid #355058;border-radius:12px;margin:12px 0;overflow-wrap:anywhere}
.personal-file-list small{display:block;color:#adbab4;margin:6px 0}.personal-file-actions{display:flex;flex-wrap:wrap;gap:8px}.personal-file-actions button{min-height:44px;white-space:normal}
.personal-file-dialog [data-personal-error]{color:#ffb1a9}
@media(max-width:900px){
 html body dialog.group-room,html body dialog.group-flow{inset:var(--group-viewport-top,0px) 0 auto;margin:0;width:100%;max-width:100%;height:var(--group-viewport-height,100dvh);max-height:var(--group-viewport-height,100dvh);border-radius:0;box-sizing:border-box}
 html body .group-room .group-room-layout{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);flex:1;min-height:0;min-width:0;overflow:hidden}
 html body .group-room.group-in-study .group-room-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto}
 html body .group-room.group-in-study .group-main,html body .group-room.group-in-study .group-side{grid-column:1;grid-row:1}
 html body .group-room.group-in-study .group-study-composer{grid-column:1;grid-row:2;min-width:0}
 html body .group-room.group-in-study[data-study-view=material] .group-main{display:flex}
 html body .group-room.group-in-study[data-study-view=material] .group-side{display:none}
 html body .group-room.group-in-study[data-study-view=chat] .group-main,html body .group-room.group-in-study[data-study-view=people] .group-main{display:none}
 html body .group-room.group-in-study[data-study-view=chat] .group-side,html body .group-room.group-in-study[data-study-view=people] .group-side{display:flex}
 html body .group-room.group-in-study .group-study-mobile-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;padding:4px 8px calc(4px + env(safe-area-inset-bottom));flex:none}
 html body.mobile-keyboard-open .group-room.group-in-study .group-study-mobile-tabs,html body .group-room.group-keyboard-open.group-in-study .group-study-mobile-tabs{display:grid;padding-bottom:4px}
 html body .group-room .group-composer{padding:8px;gap:6px;align-items:center}
 html body .group-room .group-composer textarea,html body .group-flow .group-form input,html body .group-flow .group-form select{font-size:16px}
 html body .group-room .group-study-media video,html body .group-room .group-study-media audio{width:100%;max-width:100%;object-fit:contain}
 html body .group-room .group-study{padding:4px;max-height:none}
 html body .group-room .group-people{padding:12px;border-left:0}
 html body .group-room .group-room-head>div:not(.group-tools-menu){flex:1;min-width:0;gap:6px}
 html body .group-room .group-room-head h2{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
 html body .group-room .group-room-head p{font-size:10px;max-width:40%;white-space:normal;line-height:1.2}
 html body .group-room .group-room-head .group-avatar{display:block;flex:none}
 html body .personal-file-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
}
