/* 綿羊雲端服務 V3.1.4.0 | Mobile + desktop dual-track release.
   All changes scoped to <= 860px unless shared accessibility behavior is necessary. */
#sc314MobileBackdrop[hidden]{display:none!important}
.sc314-mobile-backdrop,.sc314-mobile-drawer{display:none}
@media (max-width:860px){
  :root{--sc314-safe-bottom:env(safe-area-inset-bottom,0px)}
  html,body{max-width:100%;overflow-x:clip}
  /* Keep global UI on the same origin/data model; no duplicate mobile shell. */
  .shell,.student-layout{min-width:0}
  .main{min-width:0;padding:12px 12px calc(110px + var(--sc314-safe-bottom))!important}
  .topbar{gap:8px;top:0;z-index:14}
  .topbar .space-chip{min-width:0;max-width:min(48vw,220px);min-height:44px}
  .topbar .search-wrap{min-width:0}
  .topbar .search{font-size:16px;min-height:44px}
  .topbar-tools,.hero-actions{min-width:0}
  /* Six equal navigation targets, every one at least 44px high. */
  .mobile-bar{grid-template-columns:repeat(6,minmax(0,1fr))!important;gap:2px;padding:5px 5px calc(6px + var(--sc314-safe-bottom))!important;z-index:55!important}
  .mobile-bar button{min-height:52px;min-width:0;padding:5px 0!important;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:3px;font-size:11px!important;touch-action:manipulation;white-space:nowrap}
  .mobile-bar button .mi{line-height:1;display:grid!important;place-items:center;margin:0!important;height:23px}
  .mobile-bar button .line-icon{width:21px;height:21px}
  .mobile-bar button:focus-visible,.sc314-drawer-close:focus-visible{outline:3px solid #f3a06d;outline-offset:1px}
  .mobile-bar button.active,.mobile-bar button[aria-expanded=true]{background:#fff0e6;border-radius:12px;color:#a95428!important}
  .mobile-shortcuts.show{bottom:calc(74px + var(--sc314-safe-bottom))}
  .version-dock{bottom:calc(83px + var(--sc314-safe-bottom))!important;right:10px!important;font-size:10px!important}
  .toast-wrap{left:12px!important;right:12px!important;bottom:calc(83px + var(--sc314-safe-bottom))!important;max-width:none;z-index:600}
  .toast-wrap .toast{max-width:100%;width:100%;overflow-wrap:anywhere}
  .sc314-mobile-backdrop:not([hidden]){display:block;position:fixed;inset:0;background:rgba(23,39,48,.48);z-index:170;touch-action:none}
  .sc314-mobile-drawer{display:flex;flex-direction:column;position:fixed;left:0;right:0;bottom:0;height:min(87dvh,780px);max-height:calc(100dvh - env(safe-area-inset-top,0px));padding:0;background:#fff;z-index:171;border-radius:22px 22px 0 0;box-shadow:0 -16px 60px rgba(24,44,55,.24);visibility:hidden;transform:translateY(110%);pointer-events:none;transition:transform .22s ease,visibility .22s ease}
  .sc314-mobile-drawer.open{visibility:visible;transform:translateY(0);pointer-events:auto}
  .sc314-drawer-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:16px 18px 12px;border-bottom:1px solid #e2e8ed}
  .sc314-drawer-head small{font-size:11px;font-weight:700;color:#84929b}.sc314-drawer-head h2{font-size:19px;margin:2px 0;color:#344d5e}
  .sc314-drawer-close{border:1px solid #d7dfe5;border-radius:12px;background:#fff;width:44px;height:44px;font-size:20px}
  .sc314-mobile-menu-body{overflow:auto;overscroll-behavior:contain;min-height:0;flex:1;padding:14px 12px 18px}
  .sc314-mobile-menu-body .nav{display:grid!important;gap:6px}
  .sc314-mobile-menu-body .nav>button,.sc314-mobile-menu-body .nav details>button{display:flex!important;align-items:center;gap:12px;min-height:48px;padding:11px 14px!important;text-align:left;width:100%;font-size:14px;font-weight:750;border-radius:12px;background:#f7f9fa;border:1px solid #e6ebed;color:#344e60}
  .sc314-mobile-menu-body .nav button.hidden{display:none!important}
  .sc314-mobile-menu-body .nav button.active{background:#fff0e7!important;color:#b95d2b!important;border-color:#f5d3bd}
  .sc314-mobile-menu-body .nav button .line-icon{width:20px;height:20px;flex-shrink:0}
  .sc314-mobile-menu-body .nav button .count{margin-left:auto}
  .sc314-mobile-menu-body .nav details{border:1px solid #e3e8ec;border-radius:14px;overflow:hidden;padding:6px}
  .sc314-mobile-menu-body .nav details summary{min-height:46px;display:flex;align-items:center;gap:10px;font-weight:850;font-size:13px;color:#577083;padding:10px;cursor:pointer}
  .sc314-mobile-menu-body .nav details>button{margin:4px 0;max-width:100%}
  .sc314-drawer-footer{border-top:1px solid #edf0f2;padding:12px 16px calc(14px + var(--sc314-safe-bottom));background:#fff}
  .sc314-mobile-fonts{display:flex;align-items:center;gap:6px;margin-bottom:10px;color:#657a86;font-size:12px;font-weight:700}
  .sc314-mobile-fonts span{margin-right:auto}
  .sc314-mobile-fonts button{border-radius:9px;border:1px solid #dce5ea!important;background:#f8fafb!important;color:#426071!important;min-height:42px;min-width:44px;width:44px!important;padding:0;font-size:14px!important}
  .sc314-drawer-footer>button{border:1px solid #ebd6d3;color:#b55a52;background:#fff7f6;border-radius:12px;width:100%;min-height:46px;font-weight:800}
  body.sc314-menu-open{overflow:hidden;touch-action:none}
  body.sc314-menu-open .mobile-bar{pointer-events:none}
  body.sc314-menu-open .global-font-size-control,body.sc314-student-menu-open .global-font-size-control{visibility:hidden}
  body:has(#app:not(.hidden)) .global-font-size-control{display:none!important}
  body:has(#authScreen:not(.hidden)) .global-font-size-control{top:calc(6px + env(safe-area-inset-top,0px))!important;bottom:auto!important;right:6px!important;transform:scale(.8);transform-origin:top right}
  /* Student route: retain original permission-checked sidebar, now with a proper overlay. */
  .student-sidebar{z-index:184!important}
  .sc314-student-backdrop:not([hidden]){display:block;position:fixed;inset:0;background:rgba(30,47,58,.50);z-index:180}
  .sc314-student-backdrop[hidden]{display:none!important}
  .student-mobile-menu{min-width:44px!important;min-height:44px!important;touch-action:manipulation}
  .student-main-topbar{position:sticky;top:0;z-index:15;min-width:0}
  .student-top-space{min-width:0}.student-top-space select{max-width:100%}
  .student-content{padding-bottom:calc(30px + var(--sc314-safe-bottom))!important;min-width:0}
  /* A narrow screen should never clip a dialog's close/save actions. */
  .modal-layer{padding:10px max(10px,env(safe-area-inset-right,0px))!important;align-items:center}
  .modal,.student-world-space-modal{box-sizing:border-box;width:min(100%,640px)!important;max-width:100%!important;max-height:calc(100dvh - 22px - env(safe-area-inset-bottom,0px))!important;overflow-y:auto;overscroll-behavior:contain;padding:16px!important;border-radius:18px!important}
  .modal-head{position:sticky;top:-16px;background:#fff;z-index:2;padding:3px 0 8px!important}
  .modal-head .close,.modal-head button.close{min-width:44px;min-height:44px;flex:none}
  .modal-actions{flex-wrap:wrap;gap:8px}.modal-actions .btn{min-height:44px}
  .content-panel,.panel,.world-card,.student-hero,.student-card,.sc312-shell{min-width:0;max-width:100%}
  .table-wrap,.sc312-list-panel{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain}
  .hero-actions .btn,.btn,.icon-btn,.filter{min-height:42px}
  .teacher-school-cascade,.v313-student-region{min-width:0}
  /* 16px input font prevents unexpected iOS browser auto-zoom when selecting a school. */
  .auth-box input,.auth-box textarea,.auth-box select,
  .field input,.field textarea,.field select,
  .sc312-field input,.sc312-field select{font-size:16px!important;max-width:100%;min-height:44px}
  .auth-box{max-width:100%}
  .student-project-form,.student-login-grid{min-width:0}
  .sc312-intro,.sc312-filters,.sc312-list-panel{min-width:0}
  .sc312-controls{grid-template-columns:repeat(2,minmax(0,1fr))}
  .sc312-field{min-width:0}
  .sc312-actions button{min-height:44px}
}
@media(max-width:560px){
  .auth-screen{padding:10px!important;min-height:100dvh;align-items:start}
  .auth-box{width:100%!important;padding:18px 14px 24px!important;border-radius:19px!important;box-shadow:0 4px 14px rgba(40,60,70,.08)!important}
  .auth-brand{margin-bottom:14px}.auth-brand h1{font-size:24px!important}
  .teacher-school-cascade{padding:12px!important}
  .teacher-school-cascade-head{flex-wrap:wrap}
  .student-login-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .main{padding:9px 10px calc(108px + env(safe-area-inset-bottom,0px))!important}
  .topbar .space-chip{max-width:50vw;font-size:12px;padding:8px 10px}
  .topbar-tools .icon-btn{width:42px;height:42px;min-width:42px}
  .hero,.hero-dashboard{padding:16px!important;border-radius:17px!important}
  .hero h2,.hero-dashboard h2{font-size:clamp(20px,6vw,25px)!important}
  .stats{gap:8px}.stat{padding:11px}
  .link-grid,body.compact .link-grid,.works-grid{grid-template-columns:1fr!important;min-width:0}
  .sc312-controls{grid-template-columns:1fr!important}
  .sc312-list-head{flex-wrap:wrap}
  .sc312-card{overflow-wrap:anywhere}
  .student-content{padding:10px 10px calc(26px + env(safe-area-inset-bottom,0px))!important}
  .student-main-topbar{gap:7px;padding:10px!important}
  .student-main-tools{max-width:100%}
  .student-top-space{flex:1 1 140px}
  .mobile-bar button{font-size:10px!important}
}
@media (prefers-reduced-motion:reduce){.sc314-mobile-drawer{transition:none!important}}
