/*
 * YENTUMI Gradebook Enterprise — Universal Mobile Application Architecture v3
 * Step 5.98 / release 2026.08.30.120
 *
 * Loaded LAST across staff, teacher, school leadership, main admin, family/public,
 * authentication and installed PWA surfaces. This is a presentation contract only.
 */

:root{
  --gb-u-gutter:16px;
  --gb-u-gap:12px;
  --gb-u-touch:44px;
  --gb-u-radius:14px;
  --gb-u-visual-height:100dvh;
  --gb-u-safe-top:env(safe-area-inset-top,0px);
  --gb-u-safe-right:env(safe-area-inset-right,0px);
  --gb-u-safe-bottom:env(safe-area-inset-bottom,0px);
  --gb-u-safe-left:env(safe-area-inset-left,0px);
  --gb-u-dock-space:calc(70px + var(--gb-u-safe-bottom));
}

html,body{max-width:100%;}
body.gb-mobile-system{overflow-x:clip;}
body.gb-mobile-system,body.gb-mobile-system *{box-sizing:border-box;}
body.gb-mobile-system :where(img,svg,video,canvas,picture,iframe){max-width:100%;}
body.gb-mobile-system :where(img,video,canvas,picture){height:auto;}
body.gb-mobile-system :where(pre,code){max-width:100%;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;}
body.gb-mobile-system :where(main,.main,.content,.page-content,.main-content,.dashboard-main,.dashboard-content,.workspace,.portal-main,.portal-content,.admin-main,.admin-content,.container,.container-fluid,.panel,.card,.box,.section,.widget,form,fieldset){min-width:0;}

/* Prevent inherited legacy break-all rules from creating vertical letter stacks. */
body.gb-mobile-system :where(h1,h2,h3,h4,h5,h6,p,label,legend,small,strong,b,span,a,button,th,td,li,dd,dt){word-break:normal;overflow-wrap:break-word;}

/* A generic internal overflow boundary is preferable to whole-page horizontal scrolling. */
.gb-u-table-shell{display:block;width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden;overscroll-behavior-inline:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable;}
.gb-u-table-shell>table:not(.gb-u-card-table){width:100%;min-width:var(--gb-u-table-min,620px);}
.gb-u-table-shell:focus-visible{outline:3px solid color-mix(in srgb,var(--accent,#1765d8) 35%,transparent);outline-offset:2px;border-radius:10px;}

.gb-u-tabs{max-width:100%;overflow-x:auto!important;overflow-y:hidden!important;overscroll-behavior-inline:contain;-webkit-overflow-scrolling:touch;scrollbar-width:thin;}
.gb-u-tabs>*{flex-shrink:0;}
.gb-u-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0;}
.gb-u-actions>:where(button,.button,a,[role="button"]){max-width:100%;}
.gb-u-dialog{max-width:calc(100vw - 24px)!important;max-height:calc(var(--gb-u-visual-height) - var(--gb-u-safe-top) - var(--gb-u-safe-bottom) - 24px)!important;}

@media (max-width:767px){
  :root{--gb-u-gutter:clamp(12px,4vw,18px);--gb-u-gap:10px;}
  html{width:100%;overflow-x:hidden;-webkit-text-size-adjust:100%;text-size-adjust:100%;}
  body.gb-mobile-system{width:100%;min-width:0;margin:0;overflow-x:hidden;}

  /* Common content frame — applies to all portal families without knowing page routes. */
  body.gb-mobile-system :where(main,.main,.content,.page-content,.main-content,.dashboard-main,.dashboard-content,.workspace,.portal-main,.portal-content,.admin-main,.admin-content){width:100%;max-width:100%;min-width:0;}
  body.gb-mobile-system :where(.container,.container-fluid){width:100%;max-width:100%;min-width:0;margin-inline:auto;}
  body.gb-mobile-system :where(.page,.page-shell,.workspace,.workspace-shell,.content-shell,.portal-shell){max-width:100%;min-width:0;}

  /* Cards/panels must never create viewport overflow. */
  body.gb-mobile-system :where(.card,.panel,.box,.widget,.module-card,.settings-card,.summary-card,.metric-card,.stat-card,.surface,.sheet){max-width:100%;min-width:0;}

  /* Form contract. Native desktop/tablet controls remain untouched above this breakpoint. */
  body.gb-mobile-system :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea){
    width:100%;max-width:100%;min-width:0;font-size:16px!important;
  }
  body.gb-mobile-system :where(input,select,textarea,button,.button,[role="button"]){min-height:var(--gb-u-touch);}
  body.gb-mobile-system :where(textarea){resize:vertical;}
  body.gb-mobile-system :where(input[type="checkbox"],input[type="radio"]){width:auto;min-width:20px;min-height:20px;}
  body.gb-mobile-system :where(button,.button,a.button,[role="button"]){max-width:100%;white-space:normal;line-height:1.25;text-align:center;}
  body.gb-mobile-system :where(label){max-width:100%;min-width:0;}

  /* Common form and workflow grids collapse once, globally. */
  body.gb-mobile-system :where(.form-grid,.fields-grid,.field-grid,.filters-grid,.filter-grid,.settings-grid,.editor-grid,.details-grid,.profile-grid,.registration-grid,.input-grid,.control-grid){
    grid-template-columns:minmax(0,1fr)!important;
  }
  body.gb-mobile-system :where(.cards-grid,.card-grid,.module-grid,.workspace-grid,.overview-grid,.content-grid,.split-grid,.two-column,.two-col,.three-column,.three-col){
    grid-template-columns:minmax(0,1fr)!important;
  }
  body.gb-mobile-system :where(.stats-grid,.stat-grid,.kpi-grid,.metric-grid,.summary-grid,.dashboard-stats){
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }

  /* Headers/toolbars/action rows reflow instead of forcing fixed desktop widths. */
  body.gb-mobile-system :where(.page-header,.content-header,.section-header,.panel-header,.card-header,.toolbar,.page-toolbar,.filter-toolbar,.title-row,.heading-row){
    max-width:100%;min-width:0;flex-wrap:wrap!important;gap:8px;
  }
  body.gb-mobile-system :where(.actions,.form-actions,.page-actions,.card-actions,.toolbar-actions,.button-row,.action-row,.modal-actions,.dialog-actions,.footer-actions,.sticky-actions).gb-u-actions{
    width:100%;
  }
  body.gb-mobile-system .gb-u-actions>:where(button,.button,a,[role="button"]){flex:1 1 132px;min-width:0;}

  /* Dialogs become safe mobile sheets while preserving their native <dialog> workflow. */
  body.gb-mobile-system dialog.gb-u-dialog{
    width:min(100%,calc(100vw - 16px))!important;
    margin:auto auto max(8px,var(--gb-u-safe-bottom))!important;
    border-radius:18px!important;
    padding:max(14px,env(safe-area-inset-top,0px)) 14px max(14px,env(safe-area-inset-bottom,0px))!important;
    overflow:auto;
  }
  body.gb-mobile-system :where(.modal,.modal-dialog,.modal-content,.dialog-panel,.sheet-panel,.bottom-sheet){max-width:calc(100vw - 16px)!important;min-width:0!important;}

  /* Generic tables: safe/simple ones become labelled cards; complex tables scroll internally. */
  .gb-u-table-shell{border-radius:12px;}
  table.gb-u-card-table{display:block!important;width:100%!important;min-width:0!important;border:0!important;background:transparent!important;}
  table.gb-u-card-table>thead{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important;}
  table.gb-u-card-table>tbody{display:grid!important;gap:10px!important;width:100%!important;}
  table.gb-u-card-table>tbody>tr{display:grid!important;width:100%!important;min-width:0!important;border:1px solid var(--border,#dce4ef)!important;border-radius:13px!important;background:var(--surface,#fff)!important;padding:8px 10px!important;box-shadow:0 3px 12px rgba(15,35,60,.035);}
  table.gb-u-card-table>tbody>tr[hidden]{display:none!important;}
  table.gb-u-card-table>tbody>tr>td{display:grid!important;grid-template-columns:minmax(90px,34%) minmax(0,1fr)!important;align-items:start!important;gap:10px!important;width:100%!important;min-width:0!important;max-width:100%!important;padding:8px 2px!important;border:0!important;border-bottom:1px solid color-mix(in srgb,var(--border,#dce4ef) 60%,transparent)!important;white-space:normal!important;text-align:left!important;}
  table.gb-u-card-table>tbody>tr>td:last-child{border-bottom:0!important;}
  table.gb-u-card-table>tbody>tr>td::before{content:attr(data-gb-col-label);font-size:10px;line-height:1.35;font-weight:800;letter-spacing:.045em;text-transform:uppercase;color:var(--muted,#64748b);overflow-wrap:break-word;}
  table.gb-u-card-table>tbody>tr>td[data-gb-col-label=""]::before{display:none;}
  table.gb-u-card-table>tbody>tr>td:has(>.gb-u-actions),table.gb-u-card-table>tbody>tr>td:last-child{align-items:center;}

  /* Media, charts and embedded documents are contained instead of widening pages. */
  body.gb-mobile-system :where(canvas,svg,img,video,iframe,object,embed){max-width:100%!important;}
  body.gb-mobile-system :where(.chart,.chart-wrap,.chart-container,.graph,.graph-wrap,.media-wrap,.preview-wrap,.viewer-wrap){max-width:100%;min-width:0;overflow-x:auto;}

  /* Existing installed-app/family docks stay inside the device safe area. */
  body.gb-mobile-system :where(.pwa-app-dock,.mobile-bottom-nav,.bottom-nav,.parent-mobile-dock,.family-mobile-dock,.app-bottom-bar){max-width:100vw;left:max(0px,var(--gb-u-safe-left));right:max(0px,var(--gb-u-safe-right));}
  body.gradebook-installed-app.gb-u-phone :where(.dashboard-main,.dashboard-content,.main-content,.page-content,.portal-main,.portal-content){padding-bottom:max(var(--gb-u-dock-space),var(--gb-u-safe-bottom))!important;}

  /* Account/popover/menu surfaces cannot render off-screen. */
  body.gb-mobile-system :where(.popover,.dropdown-menu,.menu-panel,.account-popover,.enterprise-user-popover,.context-menu){max-width:calc(100vw - 16px)!important;}

  /* Long pills/tags stay readable without pushing the viewport. */
  body.gb-mobile-system :where(.badge,.pill,.chip,.tag,.status,.status-chip){max-width:100%;white-space:normal;overflow-wrap:break-word;}

  /* Keyboard-aware state set by universal-mobile.js. */
  body.gb-u-keyboard-open :where(.pwa-app-dock,.mobile-bottom-nav,.bottom-nav,.parent-mobile-dock,.family-mobile-dock,.app-bottom-bar){
    opacity:0!important;pointer-events:none!important;transform:translateY(calc(100% + var(--gb-u-safe-bottom)))!important;
  }
  body.gb-u-keyboard-open :where(.sticky-actions,.form-actions.is-sticky,.save-bar,.lesson-assessment-savebar){bottom:8px!important;}
}

@media (max-width:430px){
  :root{--gb-u-gutter:12px;}
  body.gb-mobile-system .gb-u-actions>:where(button,.button,a,[role="button"]){flex-basis:calc(50% - 4px);}
}

@media (max-width:359px){
  :root{--gb-u-gutter:10px;--gb-u-gap:8px;}
  body.gb-mobile-system :where(.stats-grid,.stat-grid,.kpi-grid,.metric-grid,.summary-grid,.dashboard-stats){grid-template-columns:minmax(0,1fr)!important;}
  body.gb-mobile-system .gb-u-actions>:where(button,.button,a,[role="button"]){flex-basis:100%;width:100%;}
  table.gb-u-card-table>tbody>tr>td{grid-template-columns:minmax(0,1fr)!important;gap:4px!important;}
}

@media (max-width:767px) and (orientation:landscape){
  body.gb-mobile-system dialog.gb-u-dialog{max-height:calc(var(--gb-u-visual-height) - 10px)!important;}
}

@media print{
  .gb-u-table-shell{overflow:visible!important;}
  table.gb-u-card-table{display:table!important;}
  table.gb-u-card-table>thead{position:static!important;width:auto!important;height:auto!important;margin:0!important;overflow:visible!important;clip:auto!important;white-space:normal!important;display:table-header-group!important;}
  table.gb-u-card-table>tbody{display:table-row-group!important;}
  table.gb-u-card-table>tbody>tr{display:table-row!important;border:0!important;padding:0!important;box-shadow:none!important;}
  table.gb-u-card-table>tbody>tr>td{display:table-cell!important;padding:initial!important;border:initial!important;}
  table.gb-u-card-table>tbody>tr>td::before{display:none!important;}
}

/* ========================================================================== 
 * STEP 5.98 — GRADEBOOK + SAVI UNIVERSAL MOBILE APPLICATION ARCHITECTURE v3
 * Release 2026.08.30.120
 *
 * This block intentionally loads AFTER all specialist page styles, including
 * SAVI Copilot. It is the final mobile contract for the entire product.
 * ========================================================================== */
:root{
  --gb-m-vh:var(--gb-u-visual-height,100dvh);
  --gb-m-vw:100vw;
  --gb-m-safe-top:env(safe-area-inset-top,0px);
  --gb-m-safe-right:env(safe-area-inset-right,0px);
  --gb-m-safe-bottom:env(safe-area-inset-bottom,0px);
  --gb-m-safe-left:env(safe-area-inset-left,0px);
  --gb-m-host-header:0px;
  --gb-m-host-dock:0px;
  --gb-m-keyboard:0px;
  --gb-m-content-max:720px;
}

/* Universal viewport containment: no page should become wider than the device. */
body.gb-mobile-system :where(.dashboard-shell,.shell,.page-shell,.workspace-shell,.portal-shell,.tai-app,.tai-workspace,.teacher-copilot-page,.copilot-shell,.copilot-chat){
  min-width:0;
  max-width:100%;
}

@media (max-width:767px){
  html,body{width:100%;max-width:100%;}
  body.gb-mobile-system{
    min-width:0;
    overflow-x:hidden!important;
    overscroll-behavior-x:none;
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
  }

  /* One consistent mobile content rhythm across Gradebook portals. */
  body.gb-mobile-system :where(.dashboard-main,.dashboard-content,.main-content,.page-content,.portal-main,.portal-content,.admin-main,.admin-content,main.shell){
    min-width:0!important;
    max-width:100%!important;
    scroll-padding-top:calc(var(--gb-m-host-header) + 10px);
    scroll-padding-bottom:calc(var(--gb-m-host-dock) + var(--gb-m-safe-bottom) + 16px);
  }

  /* Headers are safe-area aware and never float over their own content. */
  body.gb-mobile-system :where(.app-header,.mobile-app-header,.portal-header,.admin-header){
    max-width:100vw!important;
    padding-top:max(0px,var(--gb-m-safe-top));
    z-index:80;
  }

  /* Bottom app navigation is one host-owned navigation layer. */
  body.gb-mobile-system :where(.pwa-app-dock,.mobile-bottom-nav,.bottom-nav,.parent-mobile-dock,.family-mobile-dock,.app-bottom-bar){
    left:var(--gb-m-safe-left)!important;
    right:var(--gb-m-safe-right)!important;
    bottom:0!important;
    max-width:calc(100vw - var(--gb-m-safe-left) - var(--gb-m-safe-right))!important;
    padding-bottom:max(6px,var(--gb-m-safe-bottom));
    z-index:90;
  }
  body.gb-mobile-system.gb-m-has-dock :where(.dashboard-main,.dashboard-content,.main-content,.page-content,.portal-main,.portal-content,main.shell){
    padding-bottom:calc(var(--gb-m-host-dock) + var(--gb-m-safe-bottom) + 16px)!important;
  }

  /* Keyboard state: free the typing area and keep the focused workflow visible. */
  body.gb-m-keyboard-open :where(.pwa-app-dock,.mobile-bottom-nav,.bottom-nav,.parent-mobile-dock,.family-mobile-dock,.app-bottom-bar){
    display:none!important;
  }
  body.gb-m-keyboard-open :where(.sticky-actions,.save-bar,.lesson-assessment-savebar,.tai-editor-sticky,.tai-resource-savebar){
    bottom:max(6px,var(--gb-m-safe-bottom))!important;
  }

  /* Touch and form baseline. 16px inputs avoid Safari focus zoom. */
  body.gb-mobile-system :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea){
    font-size:16px!important;
    max-width:100%!important;
  }
  body.gb-mobile-system :where(button,.button,[role="button"],a.button,.pwa-dock-item){
    min-height:44px;
    touch-action:manipulation;
  }

  /* Long desktop action bars become mobile action groups instead of overflow rows. */
  body.gb-mobile-system :where(.page-actions,.toolbar-actions,.card-actions,.form-actions,.dialog-actions,.modal-actions,.button-row,.action-row){
    min-width:0!important;
    max-width:100%!important;
    gap:8px!important;
    flex-wrap:wrap!important;
  }

  /* Dialogs and sheets are constrained to the actual visible viewport. */
  body.gb-mobile-system dialog.gb-u-dialog,
  body.gb-mobile-system :where(.modal-dialog,.dialog-panel,.sheet-panel,.bottom-sheet){
    max-height:calc(var(--gb-m-vh) - var(--gb-m-safe-top) - var(--gb-m-safe-bottom) - 12px)!important;
    overscroll-behavior:contain;
  }
}

/* --------------------------------------------------------------------------
 * SAVI / independent Teacher AI — one mobile app shell, one scrolling surface.
 * -------------------------------------------------------------------------- */
@media (max-width:900px){
  .teacher-ai-public .tai-mobile-launcher{
    top:calc(10px + var(--gb-m-safe-top))!important;
    left:calc(10px + var(--gb-m-safe-left))!important;
    width:48px!important;
    min-width:48px!important;
    height:48px!important;
    padding:0!important;
    border-radius:15px!important;
    background:#fff!important;
    color:#122033!important;
    border:1px solid #d9e3ef!important;
    box-shadow:0 8px 24px rgba(15,23,42,.13)!important;
    -webkit-backdrop-filter:none!important;
    backdrop-filter:none!important;
    z-index:120!important;
  }
  html[data-theme="dark"] .teacher-ai-public .tai-mobile-launcher{
    background:#102238!important;color:#eef4ff!important;border-color:#29405d!important;
  }

  .teacher-ai-public .tai-app-sidebar{
    top:0!important;
    bottom:0!important;
    width:min(320px,88vw)!important;
    height:100vh!important;
    height:var(--gb-m-vh)!important;
    min-height:0!important;
    padding-top:calc(12px + var(--gb-m-safe-top))!important;
    padding-bottom:calc(12px + var(--gb-m-safe-bottom))!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
    background:#fff!important;
    opacity:1!important;
    -webkit-backdrop-filter:none!important;
    backdrop-filter:none!important;
    z-index:130!important;
  }
  html[data-theme="dark"] .teacher-ai-public .tai-app-sidebar{background:#0e1b2d!important;}
  .teacher-ai-public .tai-sidebar-scrim{
    position:fixed!important;
    inset:0!important;
    background:rgba(9,18,31,.52)!important;
    -webkit-backdrop-filter:none!important;
    backdrop-filter:none!important;
    z-index:125!important;
  }

  .teacher-ai-public .tai-app>.tai-workspace{
    min-width:0!important;
    max-width:100%!important;
    padding-top:calc(70px + var(--gb-m-safe-top))!important;
    padding-left:clamp(10px,3.7vw,16px)!important;
    padding-right:clamp(10px,3.7vw,16px)!important;
    padding-bottom:calc(20px + var(--gb-m-safe-bottom))!important;
  }
}

/* --------------------------------------------------------------------------
 * SAVI Copilot phone workspace.
 * Conversation owns the screen; composer is part of the layout, not an overlay.
 * -------------------------------------------------------------------------- */
@media (max-width:767px){
  body.gb-mobile-system:has(.teacher-copilot-page),
  body.gb-mobile-system.gb-m-savi-copilot{
    overflow:hidden!important;
  }

  .tai-app>.tai-workspace.teacher-copilot-page.public{
    height:var(--gb-m-vh)!important;
    min-height:0!important;
    padding:0!important;
    overflow:hidden!important;
  }

  .teacher-copilot-page.public,
  .teacher-copilot-page.school{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
  }

  .teacher-copilot-page .copilot-shell{
    display:flex!important;
    flex-direction:column!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    height:var(--gb-m-vh)!important;
    min-height:0!important;
    margin:0!important;
    border:0!important;
    border-radius:0!important;
    overflow:hidden!important;
    box-shadow:none!important;
    background:var(--copilot-surface,#fff)!important;
  }

  .teacher-copilot-page.school .copilot-shell{
    height:calc(var(--gb-m-vh) - var(--gb-m-host-header) - var(--gb-m-host-dock))!important;
    min-height:0!important;
  }

  .teacher-copilot-page .copilot-chat{
    display:flex!important;
    flex:1 1 auto!important;
    flex-direction:column!important;
    min-height:0!important;
    height:auto!important;
    overflow:hidden!important;
  }

  .teacher-copilot-page .copilot-chat-head{
    position:relative!important;
    top:auto!important;
    flex:0 0 auto!important;
    min-height:64px!important;
    padding:10px 10px!important;
    gap:7px!important;
    background:var(--copilot-surface,#fff)!important;
    border-bottom:1px solid var(--copilot-line,#dbe4f0)!important;
    box-shadow:none!important;
    z-index:4!important;
  }

  .teacher-copilot-page .copilot-chat-primary{gap:8px!important;min-width:0!important;}
  .teacher-copilot-page .copilot-title{min-width:0!important;}
  .teacher-copilot-page .copilot-title h1{
    margin:0!important;
    font-size:20px!important;
    line-height:1.05!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  .teacher-copilot-page .copilot-kicker,
  .teacher-copilot-page .copilot-title p,
  .teacher-copilot-page .copilot-product-mark,
  .teacher-copilot-page .copilot-capability-row{display:none!important;}

  .teacher-copilot-page .copilot-history-toggle,
  .teacher-copilot-page .copilot-head-form button{
    width:44px!important;
    min-width:44px!important;
    height:44px!important;
    min-height:44px!important;
    padding:0!important;
    border-radius:13px!important;
  }
  .teacher-copilot-page .copilot-history-toggle b{display:none!important;}
  .teacher-copilot-page .copilot-head-actions{gap:6px!important;flex-wrap:nowrap!important;}
  .teacher-copilot-page .copilot-context-pill{display:none!important;}
  .teacher-copilot-page .copilot-price-pill{
    max-width:94px!important;
    min-height:32px!important;
    padding:4px 8px!important;
    font-size:9px!important;
  }

  .teacher-copilot-page .copilot-transcript{
    flex:1 1 auto!important;
    min-height:0!important;
    height:auto!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior-y:contain!important;
    -webkit-overflow-scrolling:touch!important;
    padding:14px 10px 16px!important;
    scroll-padding-bottom:18px!important;
  }

  .teacher-copilot-page .copilot-empty{
    width:100%!important;
    max-width:520px!important;
    margin:auto!important;
    padding:24px 4px!important;
  }
  .teacher-copilot-page .copilot-empty h2{font-size:22px!important;}
  .teacher-copilot-page .copilot-empty>p{font-size:13px!important;line-height:1.5!important;}

  .teacher-copilot-page .copilot-message{
    width:100%!important;
    max-width:100%!important;
    margin:0 0 16px!important;
    gap:8px!important;
  }
  .teacher-copilot-page .copilot-message.user{padding-left:24px!important;}
  .teacher-copilot-page .copilot-message-bubble{
    max-width:92%!important;
    padding:11px 13px!important;
    font-size:14px!important;
    line-height:1.5!important;
  }
  .teacher-copilot-page .copilot-avatar{
    width:30px!important;height:30px!important;flex-basis:30px!important;border-radius:10px!important;
  }
  .teacher-copilot-page .copilot-message-body{
    max-width:calc(100% - 38px)!important;
    min-width:0!important;
  }
  .teacher-copilot-page .copilot-answer{font-size:14px!important;line-height:1.58!important;}

  .teacher-copilot-page .copilot-guidance-card,
  .teacher-copilot-page .copilot-assessment-check{
    width:100%!important;
    max-width:100%!important;
    padding:12px!important;
    gap:9px!important;
    border-radius:14px!important;
  }
  .teacher-copilot-page .copilot-actions{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    gap:7px!important;
  }
  .teacher-copilot-page .copilot-actions a,
  .teacher-copilot-page .copilot-follow-ups button{
    width:100%!important;
    min-height:46px!important;
    justify-content:space-between!important;
    padding:10px 12px!important;
    text-align:left!important;
    font-size:13px!important;
    line-height:1.35!important;
  }
  .teacher-copilot-page .copilot-follow-ups>div{display:grid!important;gap:7px!important;}
  .teacher-copilot-page .copilot-grounding{
    margin-top:10px!important;
    border-radius:12px!important;
  }
  .teacher-copilot-page .copilot-grounding summary{
    min-height:46px!important;
    display:flex!important;
    align-items:center!important;
    gap:7px!important;
    padding:0 10px!important;
  }
  .teacher-copilot-page .copilot-response-tools{
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:8px!important;
    flex-wrap:wrap!important;
  }
  .teacher-copilot-page .copilot-response-tools button{
    min-width:44px!important;
    min-height:44px!important;
  }

  /* Compact composer: always visible, never covers the conversation. */
  .teacher-copilot-page .copilot-composer{
    position:relative!important;
    inset:auto!important;
    flex:0 0 auto!important;
    width:auto!important;
    max-width:none!important;
    margin:8px max(8px,var(--gb-m-safe-right)) max(8px,var(--gb-m-safe-bottom)) max(8px,var(--gb-m-safe-left))!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr) 48px!important;
    gap:6px!important;
    padding:7px 7px 6px 12px!important;
    border-radius:18px!important;
    background:var(--copilot-surface,#fff)!important;
    box-shadow:0 9px 28px rgba(15,23,42,.12)!important;
    z-index:6!important;
  }
  .teacher-copilot-page .copilot-composer-brand{display:none!important;}
  .teacher-copilot-page .copilot-composer textarea{
    width:100%!important;
    min-height:48px!important;
    max-height:112px!important;
    padding:10px 3px 7px!important;
    resize:none!important;
    font-size:16px!important;
    line-height:1.4!important;
  }
  .teacher-copilot-page .copilot-composer>button{
    width:48px!important;
    height:48px!important;
    min-height:48px!important;
    align-self:end!important;
    border-radius:14px!important;
  }
  .teacher-copilot-page .copilot-composer-foot{
    grid-column:1/-1!important;
    min-height:12px!important;
    padding:0 3px 1px!important;
    gap:5px!important;
    font-size:8px!important;
  }
  .teacher-copilot-page .copilot-composer-foot span,
  .teacher-copilot-page .copilot-composer-foot em{display:none!important;}
  .teacher-copilot-page .copilot-composer-foot small{
    margin:0!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  /* Conversation library is a real mobile drawer, not a second page column. */
  .teacher-copilot-page .copilot-conversations{
    position:fixed!important;
    top:0!important;
    right:0!important;
    bottom:0!important;
    left:auto!important;
    width:min(92vw,360px)!important;
    height:100vh!important;
    height:var(--gb-m-vh)!important;
    min-height:0!important;
    padding-top:var(--gb-m-safe-top)!important;
    padding-bottom:var(--gb-m-safe-bottom)!important;
    border-radius:18px 0 0 18px!important;
    background:#fff!important;
    -webkit-backdrop-filter:none!important;
    backdrop-filter:none!important;
    z-index:150!important;
  }
  html[data-theme="dark"] .teacher-copilot-page .copilot-conversations{background:#0e1b2d!important;}
  .teacher-copilot-page .copilot-history-scrim{
    position:fixed!important;
    inset:0!important;
    z-index:145!important;
    background:rgba(9,18,31,.55)!important;
  }

  /* Keyboard-open SAVI: composer stays in the visible viewport and docks disappear. */
  body.gb-m-keyboard-open .teacher-copilot-page.school .copilot-shell{
    height:calc(var(--gb-m-vh) - var(--gb-m-host-header))!important;
  }
  body.gb-m-keyboard-open .teacher-copilot-page .copilot-composer{
    margin-bottom:max(4px,var(--gb-m-safe-bottom))!important;
  }
}

@media (max-width:430px){
  .teacher-copilot-page .copilot-chat-head{padding-left:8px!important;padding-right:8px!important;}
  .teacher-copilot-page .copilot-price-pill{display:none!important;}
  .teacher-copilot-page .copilot-transcript{padding-left:8px!important;padding-right:8px!important;}
  .teacher-copilot-page .copilot-message-bubble{max-width:95%!important;}
  .teacher-copilot-page .copilot-conversations{width:94vw!important;}
}

@media (max-width:359px){
  .teacher-copilot-page .copilot-title h1{font-size:18px!important;}
  .teacher-copilot-page .copilot-transcript{padding-inline:6px!important;}
  .teacher-copilot-page .copilot-composer{margin-inline:6px!important;padding-left:9px!important;}
  .teacher-copilot-page .copilot-actions a,
  .teacher-copilot-page .copilot-follow-ups button{font-size:12px!important;}
}

@media (max-width:900px) and (orientation:landscape) and (max-height:520px){
  .teacher-ai-public .tai-app-sidebar{width:min(300px,70vw)!important;}
  .teacher-copilot-page .copilot-chat-head{min-height:54px!important;padding-block:5px!important;}
  .teacher-copilot-page .copilot-transcript{padding-top:8px!important;padding-bottom:8px!important;}
  .teacher-copilot-page .copilot-composer{margin-top:5px!important;margin-bottom:5px!important;}
}

@media (prefers-reduced-motion:reduce){
  .teacher-ai-public .tai-app-sidebar,
  .teacher-copilot-page .copilot-conversations,
  .teacher-copilot-page .copilot-history-scrim{transition:none!important;}
}

/* --------------------------------------------------------------------------
 * Step 5.98 cascade guarantee.
 * SAVI specialist assets may be emitted after the shared mobile asset on some
 * live routes. These scoped selectors deliberately carry host-shell specificity
 * so the universal phone geometry remains authoritative without replacing any
 * Step 5.97 SAVI feature files.
 * -------------------------------------------------------------------------- */
@media (max-width:900px){
  body.gb-mobile-system .teacher-ai-public .tai-app-sidebar{
    position:fixed!important;
    top:0!important;bottom:0!important;
    height:100vh!important;height:var(--gb-m-vh)!important;
    max-height:var(--gb-m-vh)!important;
    overflow-y:auto!important;overflow-x:hidden!important;
    background:#fff!important;
    -webkit-backdrop-filter:none!important;backdrop-filter:none!important;
    padding-top:max(10px,var(--gb-m-safe-top))!important;
    padding-bottom:max(10px,var(--gb-m-safe-bottom))!important;
    z-index:1200!important;
  }
  html[data-theme="dark"] body.gb-mobile-system .teacher-ai-public .tai-app-sidebar{
    background:#0e1b2d!important;
  }
}

@media (max-width:767px){
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page{
    min-width:0!important;max-width:100%!important;
    overflow:hidden!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-shell{
    display:flex!important;flex-direction:column!important;
    width:100%!important;max-width:100%!important;min-width:0!important;
    min-height:0!important;overflow:hidden!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page.public .copilot-shell{
    height:var(--gb-m-vh)!important;min-height:0!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page.school .copilot-shell{
    height:calc(var(--gb-m-vh) - var(--gb-m-host-header) - var(--gb-m-host-dock))!important;
    min-height:0!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-chat{
    display:flex!important;flex-direction:column!important;flex:1 1 auto!important;
    min-height:0!important;overflow:hidden!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-chat-head{
    position:relative!important;top:auto!important;flex:0 0 auto!important;
    min-height:58px!important;padding:7px 10px!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-transcript{
    flex:1 1 auto!important;height:auto!important;min-height:0!important;
    overflow-y:auto!important;overflow-x:hidden!important;
    padding:12px 9px 14px!important;scroll-padding-bottom:14px!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-message,
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-message-body,
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-guidance-card,
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-assessment-check{
    min-width:0!important;max-width:100%!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-actions,
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-follow-ups>div{
    display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:7px!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-actions a,
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-follow-ups button{
    width:100%!important;max-width:100%!important;min-height:46px!important;
    white-space:normal!important;overflow-wrap:anywhere!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-composer{
    position:relative!important;inset:auto!important;
    flex:0 0 auto!important;width:auto!important;max-width:none!important;
    margin:6px 8px max(7px,var(--gb-m-safe-bottom))!important;
    padding:7px 7px 6px 11px!important;
    grid-template-columns:minmax(0,1fr) 48px!important;
    border-radius:20px!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-composer textarea{
    min-height:48px!important;max-height:112px!important;font-size:16px!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-composer>button{
    width:48px!important;height:48px!important;min-width:48px!important;min-height:48px!important;
  }
  body.gb-mobile-system.gb-m-keyboard-open.gb-m-savi-copilot .teacher-copilot-page.school .copilot-shell{
    height:calc(var(--gb-m-vh) - var(--gb-m-host-header))!important;
  }
  body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-conversations{
    position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:auto!important;
    width:min(94vw,360px)!important;height:100vh!important;height:var(--gb-m-vh)!important;
    overflow-y:auto!important;overflow-x:hidden!important;background:#fff!important;
    -webkit-backdrop-filter:none!important;backdrop-filter:none!important;z-index:150!important;
  }
  html[data-theme="dark"] body.gb-mobile-system.gb-m-savi-copilot .teacher-copilot-page .copilot-conversations{
    background:#0e1b2d!important;
  }
}
