:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e6e9f0;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #3b82f6;
  --brand-dark: #2563eb;
  --up: #10b981;
  --up-dark: #059669;
  --down: #f43f5e;
  --down-dark: #e11d48;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 4px 14px rgba(17, 24, 39, .05);
}

* { box-sizing: border-box; }
/* 禁用移动端手势缩放：pan-x pan-y 保留单指滚动、屏蔽双指捏合缩放 */
html, body { margin: 0; padding: 0; touch-action: pan-x pan-y; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* 触摸优化：去掉点按时的灰色高亮，并关闭双击缩放（双指缩放仍可用） */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--down); min-height: 1.2em; margin: 8px 0 0; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  touch-action: pan-x pan-y;
  transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
}
button:active { transform: translateY(1px); }
button.primary {
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  font-weight: 600;
}
button.primary:hover { background: var(--brand-dark); }
button.ghost {
  background: #eef1f7;
  color: var(--text);
  padding: 8px 14px;
  font-weight: 500;
}
button.ghost:hover { background: #e2e7f0; }
button.voice-on { background: #e3edff; color: var(--brand-dark); }
button.voice-on:hover { background: #d3e2ff; }
.who-btn { font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-box.wide { max-width: 560px; width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-sub { margin: 16px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; min-width: 0; }
.pw-row button { flex: none; }
.hint { min-height: 1.2em; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.login-box .small { font-size: 12px; margin: 10px 0 0; }
.login-box a { color: var(--brand); text-decoration: none; }
.login-box a:hover { text-decoration: underline; }
button.danger-ghost { color: var(--down); background: #fdeef0; }
button.danger-ghost:hover { background: #fbd9dd; }
.icon-btn { background: transparent; color: var(--muted); font-size: 14px; width: 26px; height: 26px; border-radius: 6px; }
.icon-btn:hover { background: #eef1f7; color: var(--text); }
.icon-btn.danger:hover { background: #fdeef0; color: var(--down); }

input {
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  touch-action: pan-x pan-y;
}
input:focus { outline: none; border-color: var(--brand); }

/* 登录 */
#login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #dbeafe, #f4f6fb);
  z-index: 100;
}
.login-box {
  background: var(--card);
  padding: 40px 36px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: min(340px, 92vw);
  text-align: center;
}
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
.login-box input { width: 100%; margin: 16px 0 12px; }
.login-box button { width: 100%; }

/* 伪装成账号框，只用来告诉浏览器密码管理器「用户名在这里」，
   避免它把密码本身当成用户名显示在保存提示里。离屏 + 透明，用户看不到也点不到。 */
.autofill-decoy {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
input.masked { -webkit-text-security: disc; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 700; min-width: 0; }
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
  background: #e7f8f1;
  color: var(--up-dark);
  transition: background .2s ease, color .2s ease;
}
.sync-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.sync-status.syncing { background: #fef3c7; color: #b45309; }
.sync-status.offline { background: #f1f5f9; color: #64748b; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  gap: 16px;
  padding: 16px 20px;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px 1fr; }
  .right { grid-column: 1 / -1; flex-direction: row; }
  .right .panel { flex: 1 1 0; min-width: 0; }
}
/* 移动端班级切换下拉（桌面端隐藏）；在 720px 媒体查询中显示 */
.mobile-class-select { display: none; }
/* 移动端：班级弹窗相关（桌面端隐藏） */
#btn-classes { display: none; }
.class-close { display: none; margin-left: auto; }
.class-backdrop { display: none; }
/* 触屏/粗指针设备（无 hover）：始终显示班级条目的编辑/删除按钮 */
@media (hover: none), (pointer: coarse) {
  .class-list .class-item .tools { opacity: 1; visibility: visible; pointer-events: auto; }
}

.right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.sidebar, .right .panel, .main {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sidebar { padding: 14px; overscroll-behavior: contain; }
.panel { padding: 14px; }
.panel-head {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.new-class { display: flex; gap: 8px; }
.new-class input { flex: 1; }

/* 班级列表 */
.class-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.class-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  min-height: 46px; /* 固定高度，防止 hover 显示操作按钮时改变行高导致整页抖动/闪烁 */
  border-radius: 10px;
  cursor: pointer;
  background: #f6f8fc;
}
.class-item:hover { background: #eef1f7; }
.class-item.active { background: #e3edff; color: var(--brand-dark); font-weight: 600; }
.class-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-item .tools {
  display: flex; gap: 2px; flex: none;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .12s ease;
}
.class-item:hover .tools { opacity: 1; visibility: visible; pointer-events: auto; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }

/* 记分板 */
.main { padding: 20px; min-height: 70vh; }
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.board-title { margin: 0; font-size: 20px; }
.board-actions { display: flex; gap: 10px; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* 全班加减分操作栏 */
.class-score {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #f6f8fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.class-score.disabled { opacity: .5; pointer-events: none; }
.class-score .cs-label { flex: none; font-size: 14px; font-weight: 700; color: var(--brand-dark); }
.class-score .cs-quick { display: flex; gap: 6px; flex: 1 1 auto; }
.class-score .cs-quick .qbtn { flex: 0 1 62px; min-width: 46px; }
.class-score .cs-custom { display: flex; gap: 6px; margin-left: auto; }
.class-score .cs-custom input { width: 88px; padding: 8px 10px; font-size: 13px; }
.class-score .cs-custom button { padding: 8px 14px; background: var(--brand); color: #fff; font-weight: 600; border-radius: 8px; }
.class-score .cs-custom button:hover { background: var(--brand-dark); }

.group-card {
  position: relative;
  border: 1px solid var(--line);
  border-left: 5px solid var(--c, #5B9BD5);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.group-head { display: flex; align-items: center; gap: 8px; }
.group-head .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, #5B9BD5); flex: none; }
.group-head .gname { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gscore { font-size: 40px; font-weight: 800; text-align: center; letter-spacing: .5px; }
.school-rank {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  background: #f1f5f9;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(17, 24, 39, .06);
}
.school-rank .rk-medal { font-size: 13px; line-height: 1; }
.school-rank.rk1 { color: #92400e; background: #fef3c7; border-color: #fcd34d; }
.school-rank.rk2 { color: #475569; background: #e2e8f0; border-color: #cbd5e1; }
.school-rank.rk3 { color: #9a3412; background: #fed7aa; border-color: #fdba74; }
.quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.qbtn { padding: 8px 0; font-weight: 600; font-size: 14px; border-radius: 8px; }
.qbtn.up { background: #e7f8f1; color: var(--up-dark); }
.qbtn.up:hover { background: #d0f0e2; }
.qbtn.down { background: #fdeef0; color: var(--down-dark); }
.qbtn.down:hover { background: #fbdcdf; }
.custom { display: flex; flex-direction: column; gap: 6px; }
.custom .row { display: flex; gap: 6px; }
.custom input { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.custom input.amount { width: 70px; flex: none; }
.custom button { padding: 8px; background: var(--brand); color: #fff; font-weight: 600; border-radius: 8px; }
.custom button:hover { background: var(--brand-dark); }

/* 排行榜 */
.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.lb-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f6f8fc; }
.lb-item .rank { width: 32px; flex: none; text-align: center; font-weight: 700; color: var(--muted); }
.lb-item.rank1 { background: #fdf1cf; border: 1px solid #f2d281; }
.lb-item.rank2 { background: #eef1f6; border: 1px solid #d3d9e3; }
.lb-item.rank1 .rank { color: #b45309; }
.lb-item.rank2 .rank { color: #64748b; }
.lb-item.rank3 .rank { color: #92400e; }
.lb-item .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.lb-item .lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-item .lb-score { font-weight: 700; }
.lb-toggle {
  margin-left: auto;
  display: flex;
  background: #eef1f7;
  border-radius: 8px;
  padding: 2px;
}
.lb-toggle button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.lb-toggle button.on {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* 记录 */
.history { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.hist-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: #f8fafc; font-size: 13px; }
.hist-delta { font-weight: 700; width: 30px; text-align: center; }
.hist-delta.pos { color: var(--up-dark); }
.hist-delta.neg { color: var(--down-dark); }
.hist-group { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hist-group.batch { color: var(--brand-dark); font-weight: 600; }
.hist-reason { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-time { color: var(--muted); font-size: 11px; flex: none; }

/* 投屏 */
#projector {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, #0f172a, #1e293b);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 30px 40px;
  z-index: 50;
}
.close-btn {
  position: absolute; top: 20px; right: 24px;
  background: rgba(255,255,255,.12); color: #fff;
  padding: 10px 16px; font-size: 15px;
}
.close-btn:hover { background: rgba(255,255,255,.2); }
.proj-tools { position: absolute; top: 20px; right: 24px; display: flex; gap: 10px; z-index: 2; }
.proj-tools .close-btn { position: static; }
.close-btn.voice-on { background: rgba(59,130,246,.5); }
.close-btn.voice-on:hover { background: rgba(59,130,246,.65); }
.projector-title { font-size: 30px; font-weight: 800; text-align: center; margin-bottom: 24px; }
.projector-board {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;   /* 滚到底后不要把滚动传给背后的页面 */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  align-content: start;
  padding-bottom: 8px;
}
.proj-card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-top: 6px solid var(--c);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  user-select: none;              /* 长按计分时不会选中文字 */
  -webkit-user-select: none;
}
.proj-card .p-name { font-size: 22px; font-weight: 600; }
.proj-card .p-score { font-size: 64px; font-weight: 800; margin-top: 8px; }
.proj-card .p-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.proj-card .pbtn {
  font-size: 20px;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  min-width: 74px;
}
.proj-card .pbtn.plus { background: rgba(16,185,129,.18); color: #6ee7b7; border-color: rgba(16,185,129,.38); }
.proj-card .pbtn.plus:hover { background: rgba(16,185,129,.3); }
.proj-card .pbtn.minus { background: rgba(244,63,94,.18); color: #fda4af; border-color: rgba(244,63,94,.38); }
.proj-card .pbtn.minus:hover { background: rgba(244,63,94,.3); }

/* 拖拽调序 */
.group-card { user-select: none; }
.group-card input { user-select: text; }
.drag-handle {
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  color: var(--muted);
  font-size: 15px;
}
.drag-handle:hover { background: #eef1f7; color: var(--text); }
.drag-handle:active { cursor: grabbing; }
.group-card.dragging {
  opacity: .72;
  position: relative;
  z-index: 10;
  box-shadow: 0 12px 26px rgba(17, 24, 39, .18);
}
#board.reordering { touch-action: none; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* 弹窗打开期间锁住背后的页面：窗口里的滚动区滚到头时，滚轮/触摸不会再带着整页一起滚 */
body.modal-open { overflow: hidden; }
.modal, .modal-box { overscroll-behavior: contain; }
.roster-body, .roster-nav, .ri-body, .ri-preview { overscroll-behavior: contain; }
.modal-box {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(17, 24, 39, .25);
  padding: 24px;
  width: min(380px, 100%);
}
.modal-box h3 { margin: 0 0 10px; font-size: 18px; }
.modal-box p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-box input[type="password"] { width: 100%; margin: 6px 0 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal-actions button { flex: 1; padding: 10px 0; }
/* 退出登录放在账号弹窗底部，单独一段 + 分隔线，和上面的保存操作区分开 */
.modal-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.modal-logout {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; padding: 11px 0;
  font-size: 14px; font-weight: 600; border-radius: 10px;
}
button.primary.danger { background: var(--down); }
button.primary.danger:hover { background: var(--down-dark); }

/* 防止移动端输入框聚焦时 iOS 自动放大整个页面：移动端所有输入元素字号 >= 16px */
html { -webkit-text-size-adjust: 100%; }

/* ---------------- 班级名单弹窗 ---------------- */
.modal-box.roster-box {
  width: min(760px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 14px;
}
.roster-box h3 { margin: 0; font-size: 19px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.roster-box .modal-head { gap: 10px; align-items: flex-start; }
.roster-box .modal-head .icon-btn { flex: none; }
.roster-sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.roster-tools { display: flex; gap: 8px; margin: 12px 0 0; flex-wrap: wrap; align-items: center; }
.roster-tools button { white-space: nowrap; }
.roster-search { flex: 1 1 200px; display: flex; align-items: center; gap: 8px; background: #f5f7fb; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.roster-search span { color: #9aa3b2; font-size: 13px; }
.roster-search input { flex: 1; min-width: 0; border: 0; background: none; padding: 0; font-size: 13.5px; outline: none; color: var(--text); }
/* 常驻快速添加条：选一次组，然后一直敲名字回车 */
.roster-quick { margin: 10px 0 0; background: linear-gradient(180deg, #f2f7ff, #eef4ff); border: 1px solid #cfe0fb; border-radius: 13px; padding: 10px 11px 9px; }
.rq-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rq-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; color: #4b5563; }
.rq-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.rq-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 2px 6px rgba(59, 130, 246, .35); }
.rq-chip.on i { background: #fff !important; }
.rq-n { font-size: 11px; opacity: .8; font-weight: 700; }
.rq-row { display: flex; gap: 8px; }
.rq-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 14px; background: #fff; outline: none; color: var(--text); }
.rq-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 130, 246, .14); }
.rq-row button { flex: none; padding: 9px 18px; }
.rq-hint { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 11.5px; color: #5b6472; }
.rq-undo { margin-left: auto; color: var(--brand-dark); font-weight: 600; background: #fff; border: 1px solid #cfe0fb; border-radius: 8px; padding: 4px 10px; font-size: 11.5px; flex: none; }
/* 主体：左边组导航 + 右边名单 */
.roster-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 12px; margin-top: 10px; }
.roster-nav { display: flex; flex-direction: column; gap: 2px; background: #f8fafd; border: 1px solid var(--line); border-radius: 12px; padding: 6px; overflow-y: auto; }
.rn-title { font-size: 11.5px; color: var(--muted); padding: 4px 8px 6px; }
.rn-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 9px; font-size: 13px; color: #374151; text-align: left; }
.rn-item i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.rn-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rn-item b { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.rn-item:hover { background: #eef2f9; }
.rn-item.on { background: #fff; box-shadow: var(--shadow); color: var(--brand-dark); font-weight: 600; }
.rn-item.on b { color: var(--brand-dark); }
.roster-body { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
.roster-empty { color: var(--muted); font-size: 14px; line-height: 1.8; padding: 16px 2px; }
.roster-group { border: 1px solid var(--line); border-left: 5px solid var(--c, #cbd5e1); border-radius: 13px; background: #fff; }
.roster-group.search-dim { opacity: .45; }
.rg-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: #fbfcfe; border-radius: 12px 8px 0 0; border-bottom: 1px solid #f1f4f9; position: sticky; top: 0; z-index: 3; flex-wrap: wrap; }
.rg-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--c, #cbd5e1); }
.rg-name { font-weight: 700; font-size: 15px; }
.rg-count { font-size: 11.5px; font-weight: 600; color: #4b5563; background: #eef1f7; border-radius: 999px; padding: 2px 9px; flex: none; }
.rg-score { font-size: 11.5px; font-weight: 600; color: var(--brand-dark); background: #eef4ff; border-radius: 999px; padding: 2px 9px; flex: none; }
.rg-btns { margin-left: auto; display: flex; gap: 6px; flex: none; }
.rg-add { font-size: 12.5px; font-weight: 600; color: var(--brand-dark); background: #fff; border: 1px solid #cfe0fb; border-radius: 9px; padding: 6px 12px; flex: none; white-space: nowrap; }
.rg-add:hover { background: #eef4ff; }
.rg-import { font-size: 12.5px; font-weight: 600; color: #4b5563; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 6px 12px; flex: none; white-space: nowrap; }
.rg-import:hover { background: #eef4ff; border-color: #cfe0fb; color: var(--brand-dark); }
.rg-rows { display: flex; flex-direction: column; }
.rg-none { color: var(--muted); font-size: 12.5px; padding: 10px 12px; }
.stu-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; position: relative; border-top: 1px solid #f1f4f9; }
.stu-row:first-child { border-top: 0; }
.stu-row:hover { background: #f8fbff; }
.stu-row.menu-open { background: #f4f8ff; }
.stu-row.search-hidden, .rg-none.search-hidden { display: none; }
.stu-row.dragging { background: #eef4ff; box-shadow: 0 10px 22px rgba(17, 24, 39, .16); z-index: 4; }
.stu-grip { color: #cdd4de; font-size: 13px; line-height: 1; padding: 6px 2px; cursor: grab; touch-action: none; flex: none; }
.stu-grip, .stu-more { background: transparent; }
.stu-grip:hover { color: var(--muted); }
.stu-av { width: 32px; height: 32px; border-radius: 50%; background: var(--c, #94a3b8); color: #fff; font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.stu-more { width: 34px; height: 32px; border-radius: 9px; color: #7b8697; font-size: 17px; line-height: 1; flex: none; }
.stu-more:hover, .stu-more.on { background: #eef1f7; color: var(--text); }
/* 行内小浮层：贴着这一行，不再把下面的学生整体顶下去 */
.stu-menu { position: absolute; right: 10px; top: calc(100% - 4px); z-index: 9; width: 268px; max-width: calc(100vw - 64px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 32px rgba(17, 24, 39, .18); padding: 10px; }
.stu-menu.up { top: auto; bottom: calc(100% - 4px); }
.sm-grp { font-size: 11.5px; color: var(--muted); margin: 0 0 6px; }
.sm-row { display: flex; gap: 7px; }
.sm-row + .sm-grp { margin-top: 9px; }
.sm-row input, .sm-row select { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13.5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); outline: none; }
.sm-row input:focus, .sm-row select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 130, 246, .14); }
.sm-row button { flex: none; padding: 8px 13px; font-size: 13px; }
/* ---------------- 批量导入到小组 ---------------- */
/* 打开导入面板时把「快速添加条」收起来，让注意力集中在这一件事上 */
.roster-box.importing #roster-quick { display: none; }
/* flex:none 很关键：不要被名单区挤扁；高度按内容长，长名单只滚面板中间，名单区留出约两百像素看上下文 */
.roster-import-panel { margin: 10px 0 0; background: #fff; border: 1px solid #cfe0fb; border-radius: 13px; box-shadow: 0 6px 20px rgba(17, 24, 39, .10); overflow: hidden; display: flex; flex-direction: column; max-height: 52vh; flex: none; }
.ri-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: linear-gradient(180deg, #f2f7ff, #eef4ff); border-bottom: 1px solid #dce8fb; flex-wrap: wrap; }
.ri-bar { width: 4px; height: 18px; border-radius: 2px; background: var(--c, var(--brand)); flex: none; }
.ri-title { font-size: 14.5px; font-weight: 700; }
.ri-lock { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #cfe0fb; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; color: #374151; }
.ri-lock i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--brand)); flex: none; }
.ri-lock button { color: var(--brand-dark); font-weight: 600; text-decoration: underline; font-size: 12px; }
.ri-close { width: 30px; height: 30px; border-radius: 9px; color: #8b95a5; font-size: 15px; line-height: 1; flex: none; }
.ri-close:hover { background: #eef1f7; color: var(--text); }
.ri-steps { display: flex; gap: 6px; padding: 9px 12px 0; flex-wrap: wrap; }
.ri-steps button { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: #f4f6fb; border-radius: 999px; padding: 5px 11px; }
.ri-steps button i { font-style: normal; width: 16px; height: 16px; border-radius: 50%; background: #dbe2ec; color: #5b6472; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ri-steps button.on { background: var(--brand); color: #fff; font-weight: 600; }
.ri-steps button.on i { background: rgba(255, 255, 255, .28); color: #fff; }
.ri-steps button.done i { background: #e9f7f1; color: var(--up-dark); }
/* 名单太长时只滚面板中间，步骤条和按钮始终看得到 */
.ri-body { padding: 11px 12px 3px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.ri-foot { display: flex; align-items: center; gap: 8px; padding: 11px 12px 12px; flex-wrap: wrap; flex: none; border-top: 1px solid #f1f4f9; position: relative; }
/* 内容被截断时给一条渐隐，看起来是「下面还有」而不是排版坏了 */
.ri-foot::before { content: ''; position: absolute; left: 0; right: 0; top: -18px; height: 18px; background: linear-gradient(rgba(255, 255, 255, 0), #fff); pointer-events: none; }
.ri-foot .ri-gap { margin-left: auto; }
.ri-foot button { padding: 9px 14px; font-size: 13px; font-weight: 600; border-radius: 9px; }
.ri-foot button:disabled { opacity: .55; cursor: not-allowed; }
.ri-tip { margin: 9px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
/* 第一步：选目标组 */
.ri-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ri-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: #4b5563; }
.ri-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #94a3b8); flex: none; }
.ri-chip small { font-size: 11px; color: #9aa3b2; }
.ri-chip.on { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); color: #fff; font-weight: 600; }
.ri-chip.on small, .ri-chip.on b { color: rgba(255, 255, 255, .9); }
/* 第二步：粘贴 + 实时解析 */
.ri-paste { background: #f7f9fc; border: 1px solid var(--line); border-radius: 11px; padding: 10px; }
.ri-ph { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.ri-ph span { font-size: 11.5px; color: var(--muted); }
.ri-paste textarea { width: 100%; min-height: 132px; font-family: inherit; font-size: 14px; line-height: 1.75; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; resize: vertical; background: #fff; color: var(--text); outline: none; }
.ri-paste textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 130, 246, .14); }
.ri-tools { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ri-tools button { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.ri-parse { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 10px; }
.ri-psum { font-size: 13px; font-weight: 600; }
.ri-psum b { font-variant-numeric: tabular-nums; }
.ri-psum b.ok { color: var(--up-dark); }
.ri-psum b.warn { color: #b45309; }
.ri-names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ri-nm { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; border-radius: 999px; padding: 4px 10px; border: 1px solid transparent; }
.ri-nm small { font-size: 10.5px; font-weight: 600; }
.ri-nm.new { background: #eef4ff; border-color: #cfe0fb; color: var(--brand-dark); font-weight: 600; }
.ri-nm.other, .ri-nm.same { background: #fff6e7; border-color: #f7dcae; color: #b45309; }
.ri-nm.dup { background: #f4f6fb; border-color: var(--line); color: #9aa3b2; text-decoration: line-through; }
.ri-nm.empty { background: #f4f6fb; border-color: var(--line); color: #9aa3b2; }
.ri-rule { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ri-rule > span { font-size: 12.5px; color: var(--muted); }
.ri-seg { display: flex; gap: 4px; background: #eef1f7; border-radius: 10px; padding: 3px; flex: 1 1 200px; }
.ri-seg button { flex: 1 1 90px; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; color: #4b5563; }
.ri-seg button.on { background: #fff; color: var(--brand-dark); font-weight: 600; box-shadow: 0 1px 3px rgba(17, 24, 39, .12); }
/* 第三步：确认 */
.ri-confirm { display: flex; align-items: center; gap: 8px; font-size: 13.5px; flex-wrap: wrap; }
.ri-confirm b { color: var(--brand-dark); }
.ri-gtag { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; }
.ri-gtag i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--brand)); flex: none; }
.ri-delta { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
/* 确认页名单太长时只滚这份名单，上面的结论和下面的按钮/提示始终看得到 */
.ri-preview { margin-top: 10px; border: 1px solid var(--line); border-radius: 11px; max-height: 208px; overflow-y: auto; overflow-x: hidden; }
/* 滚动条做得明显一点：看到条就知道下面还有内容 */
.ri-body::-webkit-scrollbar, .ri-preview::-webkit-scrollbar { width: 9px; }
.ri-body::-webkit-scrollbar-track, .ri-preview::-webkit-scrollbar-track { background: #f4f6fb; }
.ri-body::-webkit-scrollbar-thumb, .ri-preview::-webkit-scrollbar-thumb { background: #c3d0e2; border-radius: 9px; border: 2px solid #f4f6fb; }
.ri-body::-webkit-scrollbar-thumb:hover, .ri-preview::-webkit-scrollbar-thumb:hover { background: #9fb3cd; }
.ri-body, .ri-preview { scrollbar-width: thin; scrollbar-color: #c3d0e2 #f4f6fb; }
.ri-plabel { background: #f7f9fc; padding: 7px 11px; font-size: 11.5px; font-weight: 700; color: #4b5563; border-top: 1px solid var(--line); }
.ri-plabel:first-child { border-top: 0; }
.ri-prow { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border-top: 1px solid #f1f4f9; font-size: 13.5px; }
.ri-pav { width: 26px; height: 26px; border-radius: 50%; background: var(--c, var(--brand)); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ri-pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-prow.skip { color: #9aa3b2; }
.ri-prow.skip .ri-pname { text-decoration: line-through; }
.ri-pnote { margin-left: auto; font-size: 11.5px; color: #b45309; text-align: right; }
.ri-prow.skip .ri-pnote { color: #9aa3b2; }
.ri-more { padding: 7px 11px; border-top: 1px solid #f1f4f9; font-size: 11.5px; color: var(--muted); background: #fcfdff; }
/* 第四步：导入完成 */
.ri-done { display: flex; align-items: center; gap: 9px; background: #e9f7f1; border: 1px solid #c3e9d8; border-radius: 11px; padding: 10px 12px; font-size: 13.5px; font-weight: 600; color: #0f5132; flex-wrap: wrap; }
.ri-done button { margin-left: auto; background: #fff; border: 1px solid #c3e9d8; color: var(--up-dark); border-radius: 8px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; }
/* 刚导入进来的学生在名单里闪一下，方便当场对照 */
@keyframes stuFlash { from { background: #dbeafe; } to { background: transparent; } }
.stu-row.flash { animation: stuFlash 3s ease-out 1; }
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; }
  .custom input, .custom input.amount { font-size: 16px; }
  .class-score .cs-custom input { font-size: 16px; }
  /* 班级名单在手机上：收起左侧导航，改成单列 + 更大的点击区 */
  #roster-modal { padding: 8px; }
  .modal-box.roster-box { width: 100%; max-height: 94vh; padding: 12px 12px 10px; }
  .roster-main { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .roster-nav { display: none; }
  .roster-search { flex: 1 1 100%; }
  .roster-tools button { flex: 1 1 0; padding: 10px 8px; }
  .rq-row input, .roster-search input, .sm-row input, .sm-row select { font-size: 16px; }
  .stu-row { padding: 10px 10px; }
  .stu-grip { font-size: 16px; padding: 9px 4px; }
  .stu-more { width: 40px; height: 38px; font-size: 17px; }
  .stu-menu { left: 8px; right: 8px; width: auto; }
  .rg-head { padding: 10px 10px; }
  .rg-add { padding: 7px 10px; }
  /* 小组卡片上的两个按钮在手机上整行摊开，别挤成一团 */
  .rg-btns { flex: 1 1 100%; margin-left: 0; }
  .rg-btns button { flex: 1 1 0; padding: 8px 10px; }
  /* 导入面板：手机上按钮摊平，点着更稳 */
  .ri-head { padding: 9px 10px; }
  /* 第一行「标题 + ✕」，第二行整行是组名胶囊：不管屏幕多窄，✕ 都在右边，不会被挤到左边单独一行 */
  .ri-title { order: 1; flex: 1 1 auto; min-width: 0; }
  .ri-close { order: 2; }
  .ri-lock { order: 3; flex: 1 1 100%; margin-left: 0; }
  .ri-body { padding: 10px 10px 3px; }
  .ri-foot { padding: 10px 10px 11px; }
  .ri-foot button { flex: 1 1 0; padding: 11px 10px; }
  .ri-foot .ri-gap { display: none; }
  .ri-close { width: 34px; height: 34px; }
  /* 手机上导入面板独占弹窗剩下的高度：下面的名单先让位，不然两边都只挤出一条 */
  .roster-box.importing .roster-main { display: none; }
  .roster-import-panel { flex: 1 1 auto; max-height: none; }
  .ri-preview { max-height: 150px; }
  .ri-tools button { flex: 1 1 0; padding: 9px 10px; }
  .ri-chip { padding: 8px 12px; }
  /* 手机上把粘贴框收矮一点、提示行收紧，让「同名规则」那一行也能落在首屏里 */
  .ri-paste textarea { font-size: 16px; min-height: 104px; }
  .ri-ph { margin-bottom: 5px; }
  .ri-ph span { font-size: 11px; line-height: 1.5; }
  .ri-steps { padding: 7px 10px 0; }
}

/* ---------------------------------------------------------------------------
   移动端布局（≤720px）
   注意：这一整块必须放在所有基础样式之后。之前它位于文件中段，被后面的
   .main / .gscore / .history / #projector / .proj-card 等基础规则按「同权重
   后者优先」覆盖掉了，等于从未生效——例如投屏卡片分数一直是 64px 而不是 44px、
   卡片一直是一列而不是两列。
--------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
  .sidebar { order: 2; }
  .main { order: 1; }
  .right { order: 3; flex-direction: column; }
  .right .panel { flex: none; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 16px; }
  .actions { width: 100%; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .actions .ghost { padding: 8px 12px; font-size: 13px; white-space: nowrap; flex: none; }
  .main, .sidebar, .right .panel { padding: 12px; }
  .main { min-height: 0; }
  .board-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .board { grid-template-columns: 1fr; gap: 12px; }
  .class-score { gap: 6px; padding: 10px; }
  .class-score .cs-quick { flex: 1 1 100%; }
  .class-score .cs-quick .qbtn { flex: 1; min-width: 0; }
  .class-score .cs-custom { flex: 1 1 100%; margin-left: 0; }
  .class-score .cs-custom input { flex: 1; width: auto; }
  .gscore { font-size: 34px; }
  input, .custom input { font-size: 16px; }
  .icon-btn { width: 32px; height: 32px; font-size: 16px; }
  .drag-handle { font-size: 18px; }
  .qbtn { padding: 10px 0; font-size: 15px; }
  .class-list .class-item .tools { opacity: 1; visibility: visible; pointer-events: auto; }
  .mobile-class-select { display: block; width: 100%; margin-bottom: 12px; font-size: 16px; padding: 12px; }
  .history { max-height: 320px; }
  #projector { padding: 14px 12px; }
  .projector-title { font-size: 22px; margin-bottom: 14px; padding: 0 40px; }
  .projector-board { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
  .proj-card { padding: 14px; border-radius: 14px; }
  .proj-card .p-name { font-size: 18px; }
  .proj-card .p-score { font-size: 44px; margin-top: 4px; }
  .close-btn { top: 12px; right: 14px; padding: 8px 12px; font-size: 14px; }
  .proj-tools { top: 12px; right: 14px; }
  .proj-tools .close-btn { padding: 8px 12px; font-size: 14px; }
  /* 顶部操作：隐藏导出/导入；显示“班级”按钮 */
  #btn-classes { display: inline-flex; }
  #btn-export, #btn-import { display: none; }
  .class-close { display: inline-flex; }
  /* 班级板块改为点击按钮后弹出的窗口 */
  .sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    margin: 0;
    max-height: 82vh;
    overflow-y: auto;
    z-index: 60;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 12px 30px rgba(0,0,0,.22);
  }
  .sidebar.open { display: block; }
  .class-backdrop.open { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45); }
}

/* ---------------------------------------------------------------------------
   手机安全区（状态栏 / 刘海 / 底部指示条）
   index.html 的 viewport 已加 viewport-fit=cover，这里用 env(safe-area-inset-*)
   把贴边的元素顶开。投屏模式的两个按钮原来固定在 top:12px，会被状态栏压住。
   不支持 env() 的浏览器会忽略这些声明，自动沿用上面的默认值，不会更糟。
--------------------------------------------------------------------------- */
.topbar {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
}
.layout {
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
/* 投屏工具条：用 max() 保证不会比原来的间距更小 */
.proj-tools {
  top: max(20px, env(safe-area-inset-top, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
}
/* 投屏整屏：四周都让开安全区，横屏时左右刘海也算进去 */
#projector {
  padding-top: max(30px, env(safe-area-inset-top, 0px));
  padding-right: max(40px, env(safe-area-inset-right, 0px));
  padding-bottom: max(30px, env(safe-area-inset-bottom, 0px));
  padding-left: max(40px, env(safe-area-inset-left, 0px));
}

@media (max-width: 720px) {
  .topbar {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
  }
  .layout {
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  /* 移动端「班级」弹窗贴在屏幕顶部，同样要让开状态栏 */
  .sidebar {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .proj-tools {
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
  }
  #projector {
    padding-top: max(14px, env(safe-area-inset-top, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
  }
}

/* ---------------------------------------------------------------------------
   移动端体验优化
   1. 顶栏按钮加大触控目标、隐藏横向滚动条
   2. 记分卡快捷按钮加高到便于手指点按
   3. 投屏工具条改为跟随布局，不再压住班级标题
   4. 投屏卡片两个加减分按钮各占一半宽度，不会再挤出卡片
   5. 登录框与弹窗可滚动，软键盘弹出时不会被顶出屏幕
--------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .actions { gap: 6px; scrollbar-width: none; }
  .actions::-webkit-scrollbar { display: none; }
  /* 顶栏现在只剩「班级 / 语音播报 / 投屏模式 / 账号」四个按钮，
     内边距和间距都收窄一点、账号按钮限宽，保证 360px 及以上一行放得下 */
  .actions .ghost { padding: 10px 10px; font-size: 14px; }
  .who-btn { max-width: 96px; }

  .qbtn { padding: 12px 0; font-size: 15px; }
  .icon-btn { width: 36px; height: 36px; font-size: 17px; }
  .lb-toggle button { padding: 8px 12px; font-size: 13px; }

  #login, .modal {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  }
  /* margin:auto 让内容有空间时居中、空间不够时贴顶并可滚动 */
  .login-box, .modal-box { margin: auto; }
  .modal-box { padding: 18px; }
  /* 一行多个输入框在手机上挤不下，改为竖排 */
  .pw-row { flex-wrap: wrap; }
  .pw-row input, .pw-row button { flex: 1 1 100%; }

  .proj-tools {
    position: static;
    justify-content: flex-end;
    margin-bottom: 10px;
  }
  .proj-tools .close-btn { padding: 10px 14px; font-size: 15px; min-height: 44px; }
  .projector-title { padding: 0; margin-bottom: 12px; }

  .proj-card { padding: 14px; }
  .proj-card .p-actions { gap: 8px; margin-top: 12px; }
  .proj-card .pbtn { flex: 1 1 0; min-width: 0; padding: 12px 0; font-size: 22px; }
}
