/* ==========================================================
   响应式 / 超大屏（2K·4K 一体机、超宽屏）
   —— 放在最后加载，覆盖前面的具体尺寸；只放大不重排，保证结构一致
   ========================================================== */

/* ---------- 1921 ~ 2600：轻度放大 ---------- */
@media (min-width: 1921px) and (max-width: 2600px) {
  html { font-size: 17px; }
  .dash-main { grid-template-columns: 300px 1fr 380px; }
  .cc-code { font-size: 60px; }
  .dstat { min-width: 118px; }
  .dstat .v { font-size: 30px; }
  .sum-table th, .sum-table td { height: 60px; font-size: 23px; }
  .sum-table tbody td { font-size: 26px; }
  .roll-btn { font-size: 36px; }
  .panel-btn { font-size: 21px; }
}

/* ---------- 2601+：2K / 4K 大屏，等比放大 ---------- */
@media (min-width: 2601px) {
  body.student-body { font-size: 20px; }
  .stage { padding: 28px 34px 24px; gap: 20px; }
  .stage-main { grid-template-columns: 1fr 380px; gap: 26px; }
  .topbar { padding: 16px 28px; border-radius: 26px; }
  .topbar .who .n { font-size: 24px; }
  .topbar .who .c { font-size: 15px; }
  .chip { font-size: 18px; padding: 11px 20px; }
  .zone-head h2 { font-size: 28px; }
  .zone-head p { font-size: 18px; }
  .pips-legend i { width: 24px; height: 24px; }
  .roll-btn { height: 190px; font-size: 44px; border-radius: 34px; }
  .panel-btn { height: 110px; font-size: 24px; border-radius: 26px; }
  .mini-btn { height: 76px; font-size: 19px; }
  .qs .v { font-size: 36px; }
  .qs .k { font-size: 15px; }
  .progress .track { width: 420px; height: 16px; }
  .progress .txt { font-size: 19px; }

  /* 教师端大屏 */
  .dash { padding: 20px 26px 16px; gap: 18px; }
  .dash-head { padding: 14px 26px; border-radius: 26px; }
  .dh-logo { width: 62px; height: 62px; }
  .dh-1 { font-size: 27px; }
  .dh-2 { font-size: 16px; }
  .dash-main { grid-template-columns: 360px 1fr 460px; }
  .dstat { min-width: 140px; padding: 10px 20px; }
  .dstat .k { font-size: 14px; }
  .dstat .v { font-size: 34px; }
  .cc-title { font-size: 16px; }
  .cc-code { font-size: 76px; }
  .cc-qr { width: 240px; height: 240px; }
  .cc-tip, .cc-link { font-size: 14px; }
  .cr-v { font-size: 32px; }
  .cbtn { height: 58px; font-size: 17px; }
  .sc-head h3 { font-size: 22px; }
  .sum-table th, .sum-table td { height: 72px; font-size: 26px; }
  .sum-table tbody td { font-size: 30px; }
  .sum-table thead th:first-child, .sum-table tbody th { font-size: 19px; }
  .chart-foot { font-size: 16px; }
  .stu-head h3 { font-size: 22px; }
  .avatar { width: 50px; height: 50px; font-size: 21px; }
  .si-name { font-size: 19px; }
  .si-sub { font-size: 14px; }
  .search { height: 52px; font-size: 17px; }
  .filter-bar button { height: 42px; font-size: 15px; }
  .launch-card { padding: 44px 48px; border-radius: 40px; }
  .main-card h2 { font-size: 40px; }
  .main-card p { font-size: 20px; }
  .lb-t2 { font-size: 50px; }
  .launch-btn { height: 76px; font-size: 26px; }
}

/* ---------- 超宽屏（21:9 等）避免中心过宽 ---------- */
@media (min-width: 2400px) and (min-aspect-ratio: 21 / 9) {
  .dash-main { grid-template-columns: 340px minmax(0, 1.4fr) 440px; }
}

/* ---------- 低分辨率一体机（1366×768 及更矮） ---------- */
@media (max-height: 800px) and (min-width: 900px) {
  .stage { padding: 12px 14px; gap: 10px; }
  .topbar { padding: 8px 16px; border-radius: 18px; }
  .topbar .logo-sm { width: 38px; height: 38px; border-radius: 12px; }
  .topbar .logo-sm svg { width: 20px; height: 20px; }
  .topbar .who .n { font-size: 17px; }
  .zone-head { top: 14px; }
  .zone-head h2 { font-size: 19px; }
  .zone-head p { font-size: 13px; margin-top: 4px; }
  .roll-btn { height: 86px; font-size: 24px; border-radius: 24px; }
  .panel-btn { height: 62px; font-size: 17px; border-radius: 18px; }
  .mini-btn { height: 46px; font-size: 15px; }
  .qs { padding: 9px 12px; }
  .qs .v { font-size: 24px; }
  .progress-wrap { bottom: 12px; }
  .progress { padding: 7px 16px; }
  .progress .track { width: 200px; height: 10px; }
  .progress .txt { font-size: 14px; }

  .dash { padding: 10px 12px 8px; gap: 9px; }
  .dash-head { padding: 7px 14px; border-radius: 16px; }
  .dh-logo { width: 40px; height: 40px; border-radius: 12px; }
  .dh-logo svg { width: 22px; height: 22px; }
  .dh-1 { font-size: 18px; }
  .dstat { min-width: 86px; padding: 5px 12px; }
  .dstat .v { font-size: 22px; }
  .dash-main { grid-template-columns: 232px 1fr 280px; gap: 9px; }
  .code-card { padding: 12px 12px 10px; }
  .cc-code { font-size: 42px; margin: 0 0 6px; }
  .cc-qr { width: 146px; height: 146px; padding: 6px; }
  .cc-tip { display: none; }
  .ctrl-card { padding: 10px 12px 12px; }
  .ctrl-row { padding: 2px 0 8px; }
  .cr-v { font-size: 22px; }
  .ctrl-grid { margin-top: 8px; gap: 6px; }
  .cbtn { height: 40px; font-size: 13.5px; }
  .sum-card { padding: 10px 14px 8px; }
  .sc-head { margin-bottom: 6px; }
  .sc-head h3 { font-size: 16px; }
  .sum-table th, .sum-table td { height: 44px; font-size: 18px; }
  .sum-table tbody td { font-size: 21px; }
  .sum-table .pct-row td { height: 30px; font-size: 12px; }
  .chart-card { padding: 10px 14px 6px; }
  .chart-foot { font-size: 12px; }
  .stu-card { padding: 10px 10px 8px; }
  .stu-head h3 { font-size: 16px; margin-bottom: 8px; }
  .search { height: 36px; font-size: 14px; }
  .filter-bar { margin: 8px 0 6px; }
  .filter-bar button { height: 30px; font-size: 12px; }
  .stu-item { padding: 7px 8px; }
  .avatar { width: 34px; height: 34px; font-size: 15px; border-radius: 10px; }
  .si-name { font-size: 14.5px; }
  .si-sub { font-size: 11.5px; }
}

/* ---------- 平板竖屏（768~1024 宽） ---------- */
@media (max-width: 1024px) and (max-height: 1366px) and (orientation: portrait) {
  /* 学生端：骰子区在上，操作区在下（两行按钮） */
  .stage-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .roll-btn { flex: 1 1 100%; height: 104px; flex-direction: row; border-radius: 26px; }
  .panel-btns, .quick-stats, .mini-btns { flex: 1 1 100%; }
  .panel { width: 100vw; border-radius: 24px 24px 0 0; top: 6vh; }
}

/* ---------- 手机竖屏 ---------- */
@media (max-width: 520px) {
  .join-card { border-radius: 26px; padding: 26px 20px 22px; }
  .brand-line { margin-bottom: 20px; }
  .brand-logo { width: 46px; height: 46px; border-radius: 14px; }
  .brand-logo svg { width: 26px; height: 26px; }
  .brand-line .t1 { font-size: 12px; letter-spacing: 2px; }
  .brand-line .t2 { font-size: 22px; }
  .join-title { font-size: 19px; }
  .join-sub { font-size: 14px; margin-bottom: 18px; }
  .field label { font-size: 14px; }
  .input { height: 56px; font-size: 20px; border-radius: 15px; }
  .input.code { font-size: 28px; letter-spacing: 8px; }
  .join-actions { flex-direction: column; }
  .join-actions .btn { width: 100%; height: 56px; font-size: 19px; }
  .join-actions .btn#btnHelpJoin { min-width: 0; }
  /* 历史课堂条目：窄屏隐藏按钮（整条可点），避免文字被挤成竖排 */
  .hist-item .btn { display: none; }
  .hi-code { width: auto; font-size: 20px; min-width: 56px; }
  .hi-name, .hi-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }

  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .logo-sm { display: none; }
  .topbar .who .n { font-size: 16px; }
  .topbar .who .c { font-size: 11px; }
  .topbar .btn { min-height: 38px !important; padding: 0 12px !important; font-size: 14px !important; }
  .stage { padding: 8px; gap: 8px; }
  .zone-head { top: 12px; }
  .zone-head h2 { font-size: 15px; padding: 0 8px; line-height: 1.4; }
  .zone-head p { display: none; }
  .progress-wrap { bottom: 10px; }
  .progress { padding: 6px 12px; gap: 8px; }
  .progress .track { width: 130px; height: 9px; }
  .progress .txt { font-size: 12.5px; }
  .roll-btn { height: 74px; font-size: 21px; border-radius: 20px; }
  .panel-btn { height: 56px; font-size: 15px; border-radius: 16px; }
  .mini-btn { height: 44px; font-size: 14px; border-radius: 14px; }
  .qs { padding: 8px 10px; border-radius: 14px; }
  .qs .k { font-size: 11px; }
  .qs .v { font-size: 22px; }
  .panel-head { padding: 14px 14px 12px; }
  .panel-head h3 { font-size: 19px; }
  .panel-head .sub { font-size: 12.5px; }
  .panel-close { width: 42px; height: 42px; font-size: 19px; }
  .stat-table th, .stat-table td { height: 46px; font-size: 16px; }
  .stat-table thead th { font-size: 15px; }
  .stat-table thead th:first-child, .stat-table tbody th:first-child { width: 86px; font-size: 13px; padding-left: 8px; }
  .stat-table tbody th { font-size: 13px; }
  .pill { font-size: 14px; padding: 8px 13px; }
  .pill b { font-size: 17px; }
  .insight { font-size: 14px; padding: 12px 14px; }
  .modal { padding: 22px; }
  .modal h3 { font-size: 20px; }
  .modal p { font-size: 15px; }
  .toast { font-size: 15px; padding: 10px 16px; }

  /* 手机上教师端：单列堆叠 */
  .dash-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .dh-stats { flex-wrap: wrap; gap: 6px; margin-left: 0; width: 100%; }
  .dh-1 { font-size: 15px; }
  .dash .dh-actions .conn { display: none; }
}

/* ---------- 横屏矮屏手机 ---------- */
@media (max-height: 460px) and (orientation: landscape) {
  .side { flex-direction: row; flex-wrap: nowrap; align-items: stretch; }
  .roll-btn { flex: 0 0 30%; height: auto; flex-direction: column; font-size: 18px; }
  .roll-btn small { display: none; }
  .panel-btns { flex: 1 1 auto; }
  .quick-stats { display: none; }
  .mini-btns { flex: 0 0 20%; flex-direction: column; margin-top: 0; gap: 6px; }
  .stage-main { grid-template-columns: 1fr 300px; grid-template-rows: 1fr; }
  .topbar { padding: 6px 10px; }
  .zone-head { display: none; }
  .progress-wrap { display: none; }
  .dash-head { padding: 6px 12px; }
  .dh-2 { display: none; }
}

/* ---------- 触屏设备通用：滚动更顺滑、避免 iOS 橡皮筋误触 ---------- */
.app, .dash, .launch { -webkit-overflow-scrolling: touch; }
.momentum, .chart-box { -webkit-overflow-scrolling: touch; }

/* ---------- 横竖屏切换后触屏设备：加大点击热区 ---------- */
@media (pointer: coarse) {
  .btn { min-height: 52px; }
  .panel-close { width: 52px; height: 52px; }
  .stu-item { padding-top: 11px; padding-bottom: 11px; }
  .hist-item { padding-top: 16px; padding-bottom: 16px; }
  .filter-bar button { min-height: 38px; }
  /* 触屏上禁用 hover 抖动 */
  .panel-btn:hover, .hist-item:hover, .btn:hover { transform: none; }
}

/* ---------- 不支持 backdrop-filter 的浏览器（Firefox 老版等）降级为不透明 ---------- */
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .topbar { background: #fff; }
  .modal-mask, .drawer-mask { background: rgba(15, 23, 42, .55); }
  .toast { background: rgba(15, 23, 42, .95); }
}


/* ---------- 教师端：≤1100px 学生明细改为抽屉 ---------- */
@media (max-width: 1100px) {
  .dash-main { grid-template-columns: 1fr; grid-template-rows: none; display: block; }
  /* 抽屉遮罩 */
  .drawer-mask {
    display: none;
    position: fixed; top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(15, 23, 42, .38); z-index: 58;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  }
  /* 抽屉：固定右侧滑出，不再参与 grid 布局（修复重叠） */
  .drawer-mask.showing { display: block; }
  .dash-right {
    display: block;
    position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 92vw);
    z-index: 60; padding: 12px;
    -webkit-transform: translateX(105%); transform: translateX(105%);
    transition: -webkit-transform .28s cubic-bezier(.25, .8, .3, 1);
    transition: transform .28s cubic-bezier(.25, .8, .3, 1);
    background: rgba(241, 245, 249, .2);
  }
  .dash-right.showing {
    -webkit-transform: translateX(0); transform: translateX(0);
  }
  .dash-right .stu-card { height: 100%; max-height: 100%; }
  .drawer-close {
    display: -webkit-box; display: -ms-flexbox; display: flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 12px;
    border: none; background: var(--ink-100); color: var(--ink-600);
    font-size: 17px; cursor: pointer; -ms-flex-negative: 0; flex-shrink: 0;
  }
  .drawer-close:active { background: var(--ink-100); filter: brightness(.95); }
  .stu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  /* 浮动入口 */
  .stu-fab {
    display: -webkit-box; display: -ms-flexbox; display: flex;
    position: fixed; right: 14px; bottom: 18px; z-index: 55;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center; gap: 8px;
    padding: 12px 20px 12px 16px; border: none; border-radius: 999px;
    background: linear-gradient(180deg, #10b981, #059669); color: #fff;
    font-size: 16px; font-weight: 700; cursor: pointer;
    box-shadow: 0 12px 24px -6px rgba(5, 150, 105, .55);
  }
  .stu-fab svg { width: 22px; height: 22px; }
  .stu-fab b {
    min-width: 24px; height: 24px; padding: 0 6px;
    display: -webkit-box; display: -ms-flexbox; display: flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
    background: rgba(255, 255, 255, .25); border-radius: 999px; font-size: 13px;
  }
}
