/* Mobile adaptation of @赛博老爸's workstation; desktop rules stay in web.css. */
.mobile-header,.mobile-nav,.mobile-class-switch,.mobile-roster,.mobile-gesture-hint,.mobile-rail-mask,.mobile-rail-head{display:none}
.mobile-table-scroll{position:relative;max-width:100%;overflow:auto}
@media (max-width:767px), (max-height:500px) and (max-width:1000px){
  :root{--mobile-head:calc(60px + env(safe-area-inset-top,0px));--mobile-foot:calc(68px + env(safe-area-inset-bottom,0px))}
  html,body{width:100%;height:100%;overflow:hidden;overscroll-behavior:none}
  *{-webkit-tap-highlight-color:transparent}
  .app,.app.with-rail{display:block;inset:auto;top:var(--mobile-head);left:0;right:0;height:calc(var(--mobile-vh,100dvh) - var(--mobile-head) - var(--mobile-foot))}
  .side,.fs-global{display:none}
  .main{position:absolute;inset:0;min-width:0}
  .mobile-header{display:flex;position:fixed;inset:0 0 auto;height:var(--mobile-head);padding:calc(8px + env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) 8px max(16px,env(safe-area-inset-left,0px));align-items:center;justify-content:space-between;gap:12px;background:#fafafaf2;border-bottom:1px solid var(--line);z-index:45;backdrop-filter:blur(16px)}
  .mobile-brand{display:flex;align-items:center;gap:10px;color:var(--ink);min-width:0}
  .mobile-brand>span{min-width:0}
  .mobile-brand .brand-mark{width:34px;height:34px;flex:none}
  .mobile-brand strong{display:block;font-size:15px;line-height:1.3}
  .mobile-brand small{display:block;font-size:11px;color:var(--ink3);max-width:190px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobile-overview{flex:none;gap:4px}
  .mobile-header [hidden]{display:none!important}
  .mobile-header .mobile-status{font-size:11px;color:var(--ink3);white-space:nowrap}
  .mobile-nav{position:fixed;inset:auto 0 0;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));height:var(--mobile-foot);padding:6px max(8px,env(safe-area-inset-right,0px)) calc(6px + env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));background:#fffffff5;border-top:1px solid var(--line);z-index:55;backdrop-filter:blur(16px)}
  .mobile-nav a{display:flex;flex-direction:column;gap:4px;align-items:center;justify-content:center;border-radius:14px;color:var(--ink3);font-size:10px;min-width:0;min-height:48px;line-height:1.2}
  .mobile-nav a .ico{width:22px;height:22px;display:grid;place-items:center}
  .mobile-nav a svg{width:20px;height:20px}
  .mobile-nav a.on{color:var(--ink);font-weight:600;background:var(--fill)}
  .mobile-nav .cnt{display:none}
  .mobile-keyboard{--mobile-foot:0px}
  .mobile-keyboard .mobile-nav{display:none}
  .page{padding:20px 16px 28px;scroll-padding-bottom:24px}
  .page-head{padding-right:0;gap:8px;margin-bottom:16px;align-items:center}
  .page-head>div:first-child{flex-basis:100%;min-width:0}
  .page-head .grow{display:none}
  .page-head>.btn{flex:1;padding:0 10px}
  .page-title{font-size:22px;line-height:1.4;letter-spacing:-.5px}
  .page-desc{font-size:12px;line-height:1.65;margin-top:3px;overflow-wrap:anywhere}
  .panel{padding:16px;min-width:0}
  .panel-title{font-size:14px}
  .panel-sub{line-height:1.65}
  .btn{min-height:42px;font-size:13px}
  .btn-sm,.btn-xs{min-height:38px}
  .btn-icon{width:42px;padding:0}
  .modal-x{width:42px;height:42px;flex:none}
  .inp,.sel,.ta,input:not([type=checkbox]):not([type=radio]),textarea,select{font-size:16px!important}
  .inp,.sel{min-height:44px}
  .field>label{font-size:13px}
  .field{margin-bottom:16px}
  .row2,.row3,.grid2,.grid3,.cs-grid{grid-template-columns:minmax(0,1fr)}
  .grid2,.grid3{gap:14px}
  .seg button,.chips button{min-height:38px}
  .filterbar{gap:12px}
  .filterbar .inp{width:100%;height:44px}
  .filterbar .chips{gap:7px}
  .chips button{padding:0 12px}
  /* Classroom tools are kept clear of the scene and the bottom navigation. */
  .class-title{display:block;left:16px;right:16px;top:10px;transform:none;font-size:17px;text-align:left;overflow:hidden;text-overflow:ellipsis}
  .class-title small{font-size:11px;margin-left:6px}
  .top-tools{top:42px;left:12px;right:12px;gap:8px;justify-content:space-between}
  .top-tools>.btn-dark{padding:0 12px;min-height:42px}
  .top-tools .rail-toggle{display:none}
  .zoom{flex:none;height:42px;align-items:center}
  .zoom button{width:38px;height:42px}
  .zoom button.zoom-fit{padding:0 10px;font-size:13px}
  .demo-bar{top:94px;left:12px;right:12px;justify-content:space-between;font-size:11px;padding-left:12px;min-height:38px;box-shadow:none;border:1px solid var(--line)}
  .demo-bar .btn{min-height:30px;font-size:11px}
  .mobile-class-switch{display:flex;position:absolute;left:12px;right:12px;top:var(--mobile-switch-top,142px);height:40px;align-items:center;justify-content:space-between;gap:10px;z-index:7}
  .mobile-class-switch .seg{background:#eaeae7;padding:3px}
  .mobile-class-switch button{height:32px;min-height:32px;padding:0 14px;font-size:12px}
  .mobile-class-switch small{font-size:10px;color:var(--ink3)}
  .stage{touch-action:none;overscroll-behavior:none}
  .mobile-gesture-hint{display:block;position:absolute;bottom:var(--mobile-scene-bottom,68px);left:50%;transform:translateX(-50%);white-space:nowrap;font-size:10px;color:var(--ink3);background:#fafafacb;padding:5px 10px;border-radius:20px;pointer-events:none}
  .dock{left:12px;right:12px;bottom:10px;transform:none;gap:8px;align-items:stretch}
  .dock>.seg{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));padding:4px;border-radius:18px;flex:none}
  .dock>.seg button{height:40px;min-height:40px;justify-content:center;padding:0 4px;font-size:12px;border-radius:14px}
  .subbar{display:flex;flex-wrap:nowrap;width:100%;max-height:100px;overflow-x:auto;overflow-y:hidden;gap:10px;padding:8px 10px;white-space:nowrap;font-size:12px;touch-action:pan-x}
  .subbar>*{flex-shrink:0}
  .subbar .btn{min-height:36px}
  .subbar .inp,.subbar .sel{min-height:36px;max-width:170px;font-size:14px}
  .subbar .legend-ramp{font-size:11px}
  .mobile-roster{display:none;position:absolute;left:0;right:0;top:var(--mobile-roster-top,190px);bottom:var(--mobile-roster-bottom,68px);overflow:auto;padding:4px 12px 14px;overscroll-behavior:contain}
  .mobile-roster-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px}
  .mobile-student{display:flex;min-width:0;min-height:114px;flex-direction:column;align-items:center;justify-content:center;gap:5px;padding:12px 4px;border-radius:16px;background:#fff;border:1px solid var(--line2);color:var(--ink);box-shadow:0 3px 8px -7px #0003}
  .mobile-student .ava{border-radius:50%;flex:none}
  .mobile-student strong{font-size:14px;line-height:1.5;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .mobile-student small{font-size:10px;color:var(--ink3);line-height:1.4;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobile-student .mobile-student-state{font-size:10px;padding:2px 7px;border-radius:20px;background:var(--fill);color:var(--ink2);line-height:1.5}
  .mobile-student.leave .mobile-student-state{background:var(--amber-soft);color:#90600e}
  .mobile-student.absent .mobile-student-state{background:var(--red-soft);color:#a8322a}
  .mobile-student.late .mobile-student-state{background:var(--blue-soft);color:#1f63c7}
  .mobile-student.selected{border-color:var(--blue);box-shadow:0 0 0 1px var(--blue);background:var(--blue-soft)}
  .mobile-student.empty-seat{border-style:dashed;background:transparent}
  .class-page.mobile-list-view .mobile-roster{display:block}
  .class-page.mobile-list-view .stage,.class-page.mobile-list-view .mobile-gesture-hint,.class-page.mobile-list-view .empty-class{visibility:hidden}
  .pick-card{top:auto;bottom:var(--mobile-roster-bottom,68px);left:12px;right:12px;transform:none;padding:14px 12px;gap:10px;border:1px solid var(--line2);flex-wrap:wrap}
  .pick-card .nm{font-size:22px;letter-spacing:0}
  .pick-card>.modal-x{position:absolute;right:4px;top:4px}
  .pick-card .btn{font-size:12px}
  .empty-class{left:18px!important;right:18px!important;top:48%!important;transform:none!important;max-width:100%;padding:16px;gap:10px}
  /* The overview drawer has its own dismiss control and backdrop. */
  .app.with-rail .rail{position:fixed;top:calc(10px + env(safe-area-inset-top,0px));bottom:auto;right:10px;width:min(360px,calc(100vw - 20px));height:calc(var(--mobile-vh,100dvh) - 20px - env(safe-area-inset-top,0px));border-radius:22px;z-index:70;padding:16px 18px 24px;transform:translateX(calc(100% + 20px));background:var(--bg)}
  .app.rail-open .rail{transform:none}
  .mobile-rail-head{display:flex;align-items:center;justify-content:space-between;position:sticky;top:-16px;margin:-4px -2px 10px;background:var(--bg);z-index:3;padding-bottom:6px}
  .mobile-rail-head strong{font-size:16px}
  .app.rail-open .mobile-rail-mask{display:block;position:fixed;inset:0;background:#0005;z-index:69;border-radius:0}
  .app:not(.with-rail) .rail{display:none}
  /* Student records use cards; the score grid keeps horizontal scrolling. */
  #stuTbl{box-shadow:none;background:none;border-radius:0}
  #stuTbl .tbl,#stuTbl tbody{display:block;width:100%}
  #stuTbl thead{display:none}
  #stuTbl tbody{display:grid;gap:10px}
  #stuTbl tbody tr{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px 10px;padding:14px;border:1px solid var(--line);border-radius:18px;background:#fff}
  #stuTbl .tbl td{display:block;padding:0;border:0;white-space:normal;text-align:left;font-size:12px;background:transparent}
  #stuTbl .tbl td:nth-child(1){grid-column:1;grid-row:2;color:var(--ink3)}
  #stuTbl .tbl td:nth-child(2){grid-column:1;grid-row:1;font-size:15px}
  #stuTbl .tbl td:nth-child(3),#stuTbl .tbl td:nth-child(6),#stuTbl .tbl td:nth-child(7){display:none}
  #stuTbl .tbl td:nth-child(4){grid-column:1;grid-row:3}
  #stuTbl .tbl td:nth-child(5){grid-column:2;grid-row:3;justify-self:end}
  #stuTbl .tbl td:nth-child(8){grid-column:1;grid-row:4;align-self:center}
  #stuTbl .tbl td:nth-child(9){grid-column:2;grid-row:2;justify-self:end}
  #stuTbl .tbl td:nth-child(9)::before{content:'排名 ';color:var(--ink3)}
  #stuTbl .tbl td:nth-child(10){grid-column:2;grid-row:1;justify-self:end;align-self:center}
  #stuTbl .tbl td:nth-child(10)::before{content:'积分 ';color:var(--ink3)}
  #stuTbl .tbl td:nth-child(11){grid-column:2;grid-row:4;justify-self:end}
  #stuTbl .tbl td[colspan]{grid-column:1/-1;grid-row:auto}
  .tbl .ops,.tl-item .del{opacity:1}
  #stuTbl .tags{gap:4px}
  #stuTbl .tag{font-size:10px;max-width:100%;padding:0 6px}
  .score-layout{grid-template-columns:minmax(0,1fr);gap:16px}
  .score-layout>*{min-width:0}
  .exam-list{flex-direction:row;overflow-x:auto;overflow-y:hidden;padding:2px 1px 10px;gap:10px}
  .exam-item{flex:0 0 172px;min-height:86px;padding:12px}
  .exam-item .t{font-size:13px}
  .exam-item .m{font-size:10px}
  #scGrid .tbl-wrap{max-height:55dvh!important;max-width:100%}
  .grid-tbl{min-width:660px}
  .grid-tbl th:first-child,.grid-tbl td:first-child{display:none}
  .grid-tbl th:nth-child(2),.grid-tbl td:nth-child(2){position:sticky;left:0;z-index:2;background:#fff;border-right:1px solid var(--line);min-width:80px}
  .grid-tbl th:nth-child(2){z-index:4}
  .grid-tbl input{min-width:76px;height:46px;font-size:16px}
  .paste-hint{font-size:11px;padding:10px;line-height:1.7;align-items:flex-start}
  .paste-hint svg{flex:none;margin-top:3px}
  .stat-row{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .stat-row .kpi:last-child:nth-child(odd){grid-column:1/-1}
  .kpi{padding:12px;min-width:0}
  .kpi .v{font-size:23px}
  .kpi .k,.kpi .d{font-size:11px}
  .small-mult{grid-template-columns:minmax(0,1fr)}
  .chart{min-width:0;max-width:100%}
  .chart svg{max-width:100%;height:auto}
  .tbl-wrap{max-width:100%;overscroll-behavior:contain}
  .set-layout{grid-template-columns:minmax(0,1fr);gap:18px}
  .set-layout>div{min-width:0}
  .set-nav{flex-direction:row;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;gap:5px;padding:2px 0 8px;position:relative}
  .set-nav button{min-height:40px;white-space:nowrap;flex:none;padding:0 12px;font-size:12px}
  .set-sec{margin-bottom:14px}
  .info-grid,.dev-info .info-grid{grid-template-columns:76px minmax(0,1fr);font-size:12px;gap:10px}
  .info-grid>div{min-width:0;overflow-wrap:anywhere}
  .dev-mail{flex-wrap:wrap;gap:4px}
  .dev-mail a{font-size:11px}
  .stepper{padding:4px 8px 4px 12px;gap:7px}
  .stepper button{width:38px;height:38px}
  .cs-prev{max-width:100%;padding:18px 8px}
  .cs-grid{gap:16px}
  .cs-acts{margin-left:0;width:100%}
  .room-wrap{gap:14px}
  .modal,.modal.wide{left:8px;right:8px;top:calc(var(--mobile-vtop,0px) + var(--mobile-vh,100dvh)/2);bottom:auto;transform:translateY(-50%);width:auto;max-height:calc(var(--mobile-vh,100dvh) - 24px);border-radius:22px;animation:fade .15s}
  .modal-head{padding:12px 16px 4px;flex:none;min-height:54px}
  .modal-body{min-height:0;padding:12px 16px;overscroll-behavior:contain}
  .modal-foot{padding:12px 16px max(14px,env(safe-area-inset-bottom,0px));flex:none;border-top:1px solid var(--line);background:#fff;border-radius:0 0 22px 22px;flex-wrap:wrap}
  .modal-foot .btn{flex:1}
  .drawer{inset:auto 0 auto;top:var(--mobile-vtop,0px);width:100%;height:var(--mobile-vh,100dvh);max-height:var(--mobile-vh,100dvh)}
  .dr-hero{padding:calc(58px + env(safe-area-inset-top,0px)) 18px 16px;gap:12px;flex:none}
  .dr-tools{top:calc(8px + env(safe-area-inset-top,0px));right:12px}
  .dr-hero>.ava{width:64px;height:64px}
  .dr-name{font-size:22px;flex-wrap:wrap;gap:6px}
  .dr-meta{font-size:12px}
  .drawer-body{min-height:0;padding:0 16px calc(24px + env(safe-area-inset-bottom,0px));overscroll-behavior:contain}
  .tabs{margin:0 16px;gap:20px;overflow-x:auto;overflow-y:hidden;flex:none;position:relative}
  .tabs button{min-height:44px;white-space:nowrap;flex:none;font-size:13px}
  .hcard{max-width:calc(100vw - 24px)}
  .pop{left:12px!important;right:12px;top:auto!important;bottom:calc(var(--mobile-foot) + 16px);width:auto;max-height:calc(var(--mobile-vh,100dvh) - var(--mobile-head) - var(--mobile-foot) - 24px);overflow-y:auto;border:1px solid var(--line2);border-radius:22px;padding:16px}
  .pop .chips button{min-height:42px}
  .ai-home{padding:24px 16px 28px;min-height:0}
  .ai-hello{gap:10px;margin-bottom:20px}
  .ai-hello h1{font-size:23px}
  .ai-hello p{font-size:12px;flex-wrap:wrap;gap:5px}
  .tpl-tabs{gap:16px;margin:24px 0 12px;white-space:nowrap;overflow-x:auto;overflow-y:hidden;padding-bottom:6px;position:relative}
  .tpl-tabs button{min-height:38px;font-size:12px;flex:none}
  .tpl-grid{grid-template-columns:minmax(0,1fr);gap:10px}
  .tpl{min-height:94px;padding:16px}
  .composer{padding:14px;border-radius:18px}
  .composer textarea{font-size:16px;min-height:76px}
  .composer-bar{gap:6px}
  .ctx-chip{min-height:34px;font-size:11px;padding:0 9px}
  .send{width:42px;height:42px}
  .thread-head{padding:12px 16px 4px!important;gap:8px;flex-wrap:wrap}
  .thread-head .t{font-size:14px;min-width:80px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .ai-thread{padding:10px 12px;min-height:0}
  .ai-foot{padding:8px 12px 12px}
  .ai-note{font-size:10px;line-height:1.6}
  .msg.bot>.ava{width:26px;height:26px}
  .msg{gap:7px}
  .md{padding:12px;font-size:14px}
  .msg.user .bubble{max-width:88%}
  .msg-tools{flex-wrap:wrap}
  .prompt-box{max-height:45dvh}
  .welcome{padding:max(24px,env(safe-area-inset-top,0px)) 22px max(24px,env(safe-area-inset-bottom,0px));place-items:start center}
  .welcome-in{margin:auto 0;min-width:0;padding:14px 0}
  .welcome h1{font-size:23px;line-height:1.5;max-width:290px;margin:0 auto 8px;letter-spacing:-.5px;text-wrap:balance}
  .welcome p.lead{font-size:12px;margin-bottom:26px;line-height:1.7}
  .w-avatars{gap:30px;margin-bottom:24px}
  .w-avatars button .circle{width:92px;height:92px}
  .w-avatars .ava{width:82px;height:82px}
  .w-form{grid-template-columns:minmax(0,1fr);gap:0;text-align:left;width:100%}
  .w-mode{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;margin:6px 0 22px}
  .w-mode button{width:100%;padding:14px 16px;font-size:12px;line-height:1.7}
  .w-mode button b{font-size:14px}
  .w-go{width:100%;height:48px}
  .welcome-in>.muted{font-size:10px!important;line-height:1.7}
  .welcome .sign{display:block;white-space:normal;padding-top:20px!important;font-size:10px}
  .toast{bottom:calc(var(--mobile-foot) + 18px);max-width:calc(100vw - 32px);white-space:normal;text-align:center;border-radius:18px;font-size:12px;line-height:1.6}
}
@media (max-width:359px){.mobile-nav a{font-size:9px}.top-tools{gap:5px}.top-tools>.btn-dark{padding:0 9px;font-size:12px}.zoom button{width:32px}.zoom button.zoom-fit{padding:0 7px}.class-title small{display:none}.mobile-class-switch small{max-width:142px;font-size:9px}.mobile-roster-grid{gap:6px}.mobile-student{min-height:108px}.dr-tools{gap:4px}.dr-tools .btn{padding:0 8px;font-size:11px}.page-head>.btn{padding:0 7px;font-size:11px;gap:4px}}
@media (max-height:500px) and (max-width:1000px){:root{--mobile-head:48px;--mobile-foot:54px}.mobile-nav{padding-top:3px;padding-bottom:3px}.mobile-nav a{min-height:44px;flex-direction:row}.mobile-header{padding-top:4px;padding-bottom:4px}.mobile-roster-grid{grid-template-columns:repeat(5,minmax(0,1fr))}.class-title{display:none}.top-tools{top:8px;right:180px}.mobile-class-switch{left:auto;right:12px;width:150px}.mobile-class-switch small{display:none}.mobile-class-switch button{padding:0 12px}.mobile-student{min-height:100px}.demo-bar{display:none}}
@media (max-height:500px) and (max-width:1000px){.mobile-student{display:grid;grid-template-columns:28px minmax(0,1fr);gap:3px 6px;padding:8px;min-height:84px;text-align:left}.mobile-student>svg{grid-column:1;grid-row:1/3;width:28px;height:28px}.mobile-student strong{grid-column:2;grid-row:1;font-size:12px}.mobile-student small{grid-column:1/-1;grid-row:3;text-align:center}.mobile-student .mobile-student-state{grid-column:2;grid-row:2;font-size:9px;padding:1px 5px}}
