/* ============================================================
   师伴 · AI 教学闭环平台 — MVP 设计系统（浅色主题）
   ============================================================ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8eb;
  --border-strong: #d3d7dd;
  --text: #1f2329;
  --text-2: #5f6368;
  --text-3: #9aa0a6;
  --primary: #3b5bdb;
  --primary-hover: #334bc0;
  --primary-tint: #eef1fe;
  --green: #16a34a;
  --green-tint: #e8f6ee;
  --amber: #d97706;
  --amber-tint: #fdf2e2;
  --red: #dc2626;
  --red-tint: #fdecec;
  --lime: #4d7c0f;
  --lime-tint: #eef7e0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* [hidden] 必须压过 .app{display:flex} 等作者规则，否则未登录时外壳仍会渲染 */
[hidden] { display: none !important; }
/* 全局禁止横向滚动；需要横向滚动的容器（表格 / 热力图 / 标签栏）单独放行 */
html, body { height: 100%; overflow-x: hidden; max-width: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--primary-tint); }

/* ---------- 布局骨架 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #3b5bdb, #6a4ddb);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 15px; }
.brand-text span { font-size: 11px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px;
  transition: background .12s, color .12s;
}
.nav a svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }

.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-meta b { font-size: 13px; }
.user-meta span { font-size: 11px; color: var(--text-3); }
.demo-chip {
  margin: 8px 4px 0; padding: 5px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  font-size: 11px; color: var(--text-3); text-align: center;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 54px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.ai-mode-chip {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: 12px;
  padding: 5px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.ai-mode-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.ai-mode-chip.live::before { background: var(--green); }

.net-toggle { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.net-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.net-dot.off { background: var(--red); }
/* 实时通道已连接：呼吸式绿点，区别于普通在线状态 */
.net-dot.live { animation: liveBreath 1.8s ease-in-out infinite; }
@keyframes liveBreath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); opacity: 1; }
  50% { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); opacity: .7; }
}

/* ---------- 版本更新提示条 ---------- */
.update-banner {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 9000;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--primary);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text);
  max-width: min(92vw, 560px);
  animation: fadeIn .2s ease;
}
.update-banner .update-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
  flex: 0 0 auto; animation: liveBreath 1.8s ease-in-out infinite;
}
.update-banner .update-text { flex: 1 1 auto; line-height: 1.5; }
.update-banner .update-text b { color: var(--primary); }
@media (max-width: 640px) {
  .update-banner { flex-wrap: wrap; gap: 8px; padding: 12px; bottom: 12px; }
  .update-banner .update-text { flex: 1 1 100%; }
}

.sync-btn {
  border: none; background: var(--amber); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.content { flex: 1; overflow-y: auto; padding: 22px 26px 40px; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.page-head h1 { font-size: 19px; font-weight: 700; }
.page-head .sub { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12px; color: var(--text-3); font-weight: 400; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-side { grid-template-columns: 300px 1fr; align-items: start; }
.grid-main { grid-template-columns: 1fr 340px; align-items: start; }
.grid-5-7 { grid-template-columns: 5fr 7fr; align-items: start; }
.grid-7-5 { grid-template-columns: 7fr 5fr; align-items: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500;
  padding: 7px 14px; border-radius: var(--radius-sm);
  transition: all .12s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-tint); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}
.badge-green { background: var(--green-tint); color: var(--green); }
.badge-amber { background: var(--amber-tint); color: var(--amber); }
.badge-red { background: var(--red-tint); color: var(--red); }
.badge-blue { background: var(--primary-tint); color: var(--primary); }
.badge-gray { background: #f0f1f3; color: var(--text-2); }
.badge-lime { background: var(--lime-tint); color: var(--lime); }

.tag {
  display: inline-block; font-size: 11.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 6px; margin: 0 6px 6px 0;
}

.select, .input, .textarea {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px;
  transition: border-color .12s;
}
.select:focus, .input:focus, .textarea:focus { outline: none; border-color: var(--primary); }
.textarea { resize: vertical; line-height: 1.65; }
.textarea.borderless { border: 1px solid transparent; background: var(--surface-2); }
.textarea.borderless:focus { border-color: var(--primary); background: var(--surface); }

.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }

.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: #cbd0d6; transition: .15s;
}
.slider::before {
  content: ""; position: absolute; width: 15px; height: 15px;
  left: 2px; top: 2px; border-radius: 50%; background: #fff;
  transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(15px); }

.progress { height: 7px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s; }
.progress-bar.green { background: var(--green); }
.progress-bar.amber { background: var(--amber); }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  transition: background .1s; text-align: left; width: 100%;
  background: none; border-left: none; border-right: none; border-top: none;
  font-size: 13px; color: var(--text);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item.active { background: var(--primary-tint); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 500; }
.list-item .d { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: flex; flex-direction: column; gap: 9px; }
.kv-row { display: flex; justify-content: space-between; font-size: 13px; }
.kv-row .k { color: var(--text-2); }
.kv-row .v { font-weight: 500; }

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-2);
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

.empty {
  padding: 36px 20px; text-align: center; color: var(--text-3);
}
.empty .icon { font-size: 26px; margin-bottom: 8px; opacity: .5; }
.empty .t { font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty .d { font-size: 12px; line-height: 1.6; }

/* ---------- 统计卡 / 闭环 ---------- */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px 16px; display: flex; flex-direction: column; gap: 6px;
}
.stat-card .num { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-card .num small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.stat-card .label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-card .foot { font-size: 11.5px; color: var(--text-3); }

.loop-steps { display: flex; flex-direction: column; gap: 0; }
.loop-step {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 0; position: relative;
}
.loop-step::before {
  content: ""; position: absolute; left: 11px; top: 30px; bottom: -6px;
  width: 2px; background: var(--border);
}
.loop-step:last-child::before { display: none; }
.step-dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; z-index: 1;
  background: #eef0f3; color: var(--text-3);
}
.step-dot.done { background: var(--green); color: #fff; }
.step-dot.doing { background: var(--primary); color: #fff; animation: pulse 1.6s infinite; }
.loop-step .grow { flex: 1; }
.loop-step .t { font-size: 13px; font-weight: 600; }
.loop-step .d { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ---------- 备课 ---------- */
.prep-out { display: flex; flex-direction: column; gap: 14px; }
.prep-section { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.prep-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.prep-section-head .hint { font-weight: 400; font-size: 11px; color: var(--text-3); }
.prep-section .textarea { border: none; border-radius: 0; background: var(--surface); }
.prep-section .textarea:focus { box-shadow: inset 0 0 0 1px var(--primary); }

.stream-cursor { display: inline-block; width: 8px; height: 15px; background: var(--primary); animation: blink .8s infinite; vertical-align: -2px; }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.live-panel {
  border: 1px dashed var(--green); background: var(--green-tint);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 12px; color: #14532d; line-height: 1.6;
  max-height: 180px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

.trace-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 12px; }
.trace-item:last-child { border-bottom: none; }
.trace-item .time { color: var(--text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.trace-item .body { flex: 1; line-height: 1.55; }
.trace-item .body b { font-weight: 600; }

/* ---------- 随堂测 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  border: none; background: none; font-size: 13.5px; font-weight: 500;
  color: var(--text-2); padding: 9px 14px; border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs .tab-badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px;
  background: var(--amber); color: #fff; border-radius: 999px;
  font-size: 10.5px; text-align: center; margin-left: 5px; padding: 0 4px;
}

.q-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.q-item .q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.q-item .q-no { font-size: 12px; font-weight: 700; color: var(--primary); }
.q-item .q-stem { font-size: 13.5px; line-height: 1.7; margin-bottom: 10px; }
.q-options { display: flex; flex-direction: column; gap: 7px; }
.quiz-option {
  display: flex; align-items: center; gap: 9px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; background: var(--surface);
  transition: all .12s; width: 100%;
}
.quiz-option:hover:not(:disabled) { border-color: var(--primary); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); font-weight: 600; }
.quiz-option.correct { border-color: var(--green); background: var(--green-tint); color: var(--green); }
.quiz-option.wrong { border-color: var(--red); background: var(--red-tint); color: var(--red); }
.quiz-option .opt-key {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border-strong); font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.quiz-option.selected .opt-key { border-color: var(--primary); background: var(--primary); color: #fff; }

.student-stage {
  max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 26px 28px; position: relative;
}
.student-stage .stage-chip {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 11px;
  padding: 3px 12px; border-radius: 999px; white-space: nowrap;
}
.student-stage .q-progress { font-size: 12px; color: var(--text-3); margin-bottom: 14px; display: flex; justify-content: space-between; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.bar-row .bar-label { width: 118px; flex-shrink: 0; color: var(--text-2); }
.bar-row .bar-track { flex: 1; height: 14px; background: #eef0f3; border-radius: 4px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 4px; }
.bar-row .bar-val { width: 64px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); flex-shrink: 0; }

.opt-dist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.opt-dist .od {
  font-size: 11.5px; padding: 3px 9px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.opt-dist .od.hot { background: var(--red-tint); border-color: #f3c1c1; color: var(--red); font-weight: 600; }

/* ---------- 批改 ---------- */
.ai-card { border: 1px solid #c7d2fe; background: #f6f8ff; border-radius: var(--radius-sm); padding: 12px 14px; }
.ai-card .ai-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ai-card .ai-title { font-size: 12.5px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 6px; }
.ai-card .ai-title svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.score-box { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.score-box input { width: 62px; text-align: center; font-weight: 700; }
.score-box .max { color: var(--text-3); font-size: 12px; }
.conf-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); margin: 8px 0; }
.conf-row .progress { flex: 1; height: 5px; }
.answer-pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 12.5px; line-height: 1.7; white-space: pre-wrap;
  font-family: inherit; margin-bottom: 10px;
}
.answer-pre.err { border-color: #f3c1c1; background: #fffafa; }

/* ---------- 学情 ---------- */
.heatmap-wrap { overflow: auto; max-height: 330px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.heatmap { min-width: 640px; }
.heat-row { display: grid; grid-template-columns: 96px repeat(6, 1fr); border-bottom: 1px solid var(--border); }
.heat-row:last-child { border-bottom: none; }
.heat-row.head { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.heat-row.head .heat-cell { font-size: 11.5px; font-weight: 600; color: var(--text-2); padding: 8px 6px; }
.heat-cell {
  padding: 8px 6px; font-size: 12px; text-align: center;
  border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  min-height: 34px;
}
.heat-cell:last-child { border-right: none; }
.heat-cell.name { justify-content: flex-start; font-weight: 500; gap: 7px; background: var(--surface); position: sticky; left: 0; }
.heat-cell.name .rank { font-size: 10.5px; color: var(--text-3); width: 16px; }
.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); margin-top: 10px; }
.heat-legend .cell { width: 22px; height: 12px; border-radius: 3px; }

.tier-col { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tier-col .tier-head { padding: 9px 12px; font-size: 12.5px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.tier-a .tier-head { background: var(--green-tint); color: var(--green); }
.tier-b .tier-head { background: var(--amber-tint); color: var(--amber); }
.tier-c .tier-head { background: var(--red-tint); color: var(--red); }
.tier-col .tier-body { padding: 8px 12px; font-size: 12px; color: var(--text-2); line-height: 1.8; max-height: 150px; overflow-y: auto; }
.tier-col .tier-foot { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }

.advice-actions { display: flex; gap: 8px; margin-top: 12px; }
.sugg-q { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; align-items: flex-start; }
.sugg-q:last-child { border-bottom: none; }
.sugg-q .qn { font-weight: 700; color: var(--primary); flex-shrink: 0; }
.sugg-q .qt { line-height: 1.6; }

/* ---------- 隐私 ---------- */
.role-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.role-card {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: left; background: var(--surface);
  transition: all .12s;
}
.role-card:hover { border-color: var(--border-strong); }
.role-card.active { border-color: var(--primary); background: var(--primary-tint); }
.role-card .rn { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.role-card .rd { font-size: 11.5px; color: var(--text-2); line-height: 1.55; }

.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.perm-row:last-child { border-bottom: none; }
.perm-row .pt { font-size: 13px; font-weight: 600; }
.perm-row .pd { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.5; max-width: 520px; }

.danger-zone { border: 1px solid #f3c1c1; background: #fffafa; border-radius: var(--radius-sm); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.danger-zone .dz-t { font-size: 13px; font-weight: 700; color: var(--red); }
.danger-zone .dz-d { font-size: 11.5px; color: var(--text-2); margin-top: 3px; line-height: 1.5; }

/* ---------- 模态 / Toast ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 18, 24, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { border: none; background: none; font-size: 18px; color: var(--text-3); line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; font-size: 13px; line-height: 1.7; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.guide-step { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.guide-step:last-child { border-bottom: none; }
.guide-step .gn {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.guide-step .gt { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.guide-step .gd { font-size: 12px; color: var(--text-2); line-height: 1.6; }

#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .2s ease; max-width: 520px;
}
.toast.success { background: #166534; }
.toast.warn { background: #b45309; }
.toast.error { background: #b91c1c; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.sync-log { font-size: 12px; line-height: 1.8; color: var(--text-2); max-height: 220px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-variant-numeric: tabular-nums; }
.sync-log .ok { color: var(--green); font-weight: 600; }
.sync-log .cf { color: var(--amber); font-weight: 600; }

.queue-item { display: flex; justify-content: space-between; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.queue-item:last-child { border-bottom: none; }

@media (max-width: 1180px) {
  .grid-side, .grid-main, .grid-5-7, .grid-7-5 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   登录 / 注册页
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}

.auth-card {
  background: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.brand-logo.lg {
  width: 52px;
  height: 52px;
  font-size: 24px;
  border-radius: 14px;
}
.auth-brand h1 {
  font-size: 26px;
  margin: 0;
  letter-spacing: 1px;
}
.auth-brand p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.auth-tabs {
  margin-bottom: 22px;
}
.auth-tabs button {
  flex: 1;
}

.auth-error {
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: #dc2626;
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.auth-note {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  line-height: 2;
}
.auth-note b {
  display: block;
  color: var(--text-2);
  font-size: 12.5px;
  margin-bottom: 4px;
}

.auth-side {
  background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 48px 56px;
  position: relative;
  overflow: hidden;
}
.auth-side::after {
  content: '';
  position: absolute;
  right: -140px;
  bottom: -140px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}
.auth-side-inner {
  position: relative;
  z-index: 1;
  max-width: 460px;
}
.auth-side h2 {
  font-size: 27px;
  line-height: 1.5;
  margin: 0 0 16px;
  letter-spacing: 0.5px;
}
.auth-side > .auth-side-inner > p {
  font-size: 14px;
  line-height: 1.8;
  opacity: 0.92;
  margin: 0 0 30px;
}

.auth-feats > div {
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.auth-feats > div:last-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.auth-feats b {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}
.auth-feats span {
  font-size: 12.5px;
  opacity: 0.85;
}

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-card { padding: 32px 24px; max-width: none; }
}

/* ============================================================
   连拍错题（手机 / 平板端）
   设计目标：竖屏一屏完成「拍 → 认 → 定」三步，不跳页
   ============================================================ */
.btn-lg { padding: 12px 20px; font-size: 15px; font-radius: var(--radius); }
.select-sm { padding: 4px 8px; font-size: 12px; max-width: 100%; }

/* --- 引导说明 --- */
.cap-intro { margin-bottom: 16px; }
.cap-intro-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cap-step {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.cap-step .n {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.cap-step b { display: block; font-size: 13px; margin-bottom: 2px; }
.cap-step span:not(.n) { font-size: 11.5px; color: var(--text-2); line-height: 1.5; }

/* --- 双栏布局（桌面） --- */
.cap-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cap-left, .cap-right { min-width: 0; }

/* --- 拍摄快门 --- */
.cap-shutter {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; width: 100%; min-height: 190px; cursor: pointer;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); transition: all .15s; user-select: none;
}
.cap-shutter:hover { border-color: var(--primary); background: var(--primary-tint); }
.cap-shutter:active { transform: scale(.99); }
.cap-shutter-icon {
  width: 66px; height: 66px; border-radius: 50%;
  background: var(--primary); position: relative;
  box-shadow: 0 0 0 6px var(--primary-tint);
}
.cap-shutter-icon::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 2px solid #fff; border-radius: 50%;
}
.cap-shutter-txt { font-size: 14px; font-weight: 600; text-align: center; line-height: 1.5; }
.cap-shutter-txt i { font-style: normal; font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.cap-hint { font-size: 11.5px; color: var(--text-3); margin-top: 10px; line-height: 1.6; }

/* --- 照片列表 --- */
.cap-shots { display: flex; flex-direction: column; gap: 12px; }
.cap-shot {
  display: flex; gap: 12px; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.cap-shot-img {
  position: relative; flex-shrink: 0;
  width: 84px; height: 84px; border-radius: 8px; overflow: hidden;
  background: var(--border); display: flex; align-items: center; justify-content: center;
}
.cap-shot-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cap-shot-ph { font-size: 11px; color: var(--text-3); }
.cap-shot-idx {
  position: absolute; left: 4px; top: 4px; min-width: 18px; height: 18px;
  background: rgba(0,0,0,.62); color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.cap-shot-body { flex: 1; min-width: 0; }
.cap-shot-state {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 5px; margin-bottom: 5px;
}
.cap-st-pending { background: var(--amber-tint); color: var(--amber); }
.cap-st-wrong { background: var(--red-tint); color: var(--red); }
.cap-st-right { background: var(--green-tint); color: var(--green); }
.cap-shot-line {
  font-size: 12px; color: var(--text-2); line-height: 1.6;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cap-shot-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.cap-shot-acts { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.cap-shot-acts .select { flex: 1; min-width: 120px; }

/* --- 结论卡 --- */
.cap-result-hot { border-color: #f3b9b9; }
.cap-headline {
  font-size: 14.5px; font-weight: 600; line-height: 1.75; color: var(--text);
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--primary-tint); border-left: 3px solid var(--primary);
}
.cap-result-hot .cap-headline { background: var(--red-tint); border-left-color: var(--red); }
.cap-question {
  margin-top: 10px; font-size: 13px; color: var(--text-2); line-height: 1.7;
  padding: 9px 12px; background: var(--surface-2);
  border-radius: var(--radius-sm); border: 1px dashed var(--border-strong);
}
.cap-reasons { margin-top: 14px; }
.cap-reason { padding: 9px 0; border-bottom: 1px solid var(--border); }
.cap-reason:last-child { border-bottom: none; }
.cr-label {
  font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px;
  margin-bottom: 3px;
}
.cr-src {
  font-size: 10.5px; font-weight: 400; color: var(--green);
  background: var(--green-tint); padding: 1px 6px; border-radius: 4px;
}
.cr-detail { font-size: 12px; color: var(--text-2); line-height: 1.7; }
.cap-sugg { margin-top: 14px; padding: 11px 13px; background: var(--lime-tint); border-radius: var(--radius-sm); }
.cs-title { font-size: 12.5px; font-weight: 600; color: var(--lime); margin-bottom: 6px; }
.cs-item { font-size: 12px; color: var(--text-2); line-height: 1.7; display: flex; gap: 7px; }
.cs-item .n {
  flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%;
  background: var(--lime); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.cap-cta { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.cap-cta .btn { flex: 1; min-width: 130px; }

/* --- 变式题 --- */
.var-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.var-item:last-child { border-bottom: none; }
.var-no {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.var-body { flex: 1; min-width: 0; }
.var-stem { font-size: 13px; line-height: 1.7; margin-bottom: 3px; }
.var-meta { font-size: 11px; color: var(--text-3); }
.var-explain { font-size: 11.5px; color: var(--text-2); line-height: 1.6; margin-top: 4px; }
.cap-done { border-color: #b7e3c6; background: var(--green-tint); }
.cd-title { font-size: 14px; font-weight: 700; color: var(--green); margin-bottom: 5px; }
.cd-line { font-size: 12.5px; color: var(--text-2); line-height: 1.7; }

/* --- 错题本 --- */
.eb-list { display: flex; flex-direction: column; gap: 12px; }
.eb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.eb-title { font-size: 13.5px; font-weight: 600; line-height: 1.6; }
.eb-tag {
  display: inline-block; font-size: 11px; font-weight: 600; color: var(--primary);
  background: var(--primary-tint); padding: 1px 6px; border-radius: 4px; margin-right: 6px;
}
.eb-meta-row { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--text-3); }
.eb-wrong { color: var(--red); font-weight: 600; }
.eb-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.eb-acts { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.eb-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.eb-row:last-child { border-bottom: none; }
.eb-no {
  flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--primary);
  background: var(--primary-tint); padding: 2px 7px; border-radius: 5px;
}
.eb-stem { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eb-meta { flex-shrink: 0; font-size: 11.5px; color: var(--red); font-weight: 600; }
.chip {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.chip-red { background: var(--red-tint); color: var(--red); border-color: transparent; }

/* --- 手机端：单栏 + 更大的拍摄区 --- */
@media (max-width: 900px) {
  .cap-layout { grid-template-columns: 1fr; }
  .cap-intro-steps { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .cap-shutter { min-height: 168px; }
  .cap-shot { flex-direction: column; }
  .cap-shot-img { width: 100%; height: 150px; }
  .cap-shot-acts .select { min-width: 100%; }
  .cap-cta .btn { min-width: 100%; }
  .cap-headline { font-size: 14px; }
}

/* --- 工作台：连拍错题入口卡 --- */
.cap-entry {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  text-decoration: none; color: inherit; margin-bottom: 16px;
  border: 1px solid var(--border); background: var(--surface);
  transition: all .14s;
}
.cap-entry:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.cap-entry-icon {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #5c7cfa);
  position: relative;
}
.cap-entry-icon::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,.28);
}
.cap-entry-body { flex: 1; min-width: 0; }
.cap-entry-title { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.cap-entry-desc { font-size: 12px; color: var(--text-2); line-height: 1.6; }
.cap-entry-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.cap-entry-tags span {
  font-size: 10.5px; color: var(--primary); background: var(--primary-tint);
  padding: 1px 7px; border-radius: 4px;
}
.cap-entry-go { flex-shrink: 0; font-size: 24px; color: var(--text-3); line-height: 1; }

@media (max-width: 720px) {
  .cap-entry { flex-wrap: wrap; }
  .cap-entry-desc { font-size: 11.5px; }
}

/* --- 桌面安装按钮 --- */
.install-btn { white-space: nowrap; }
@media (max-width: 720px) {
  .install-btn { display: none; }
}


/* ============================================================
   响应式适配（手机 / 平板 / 触控 / 深色 / 降低动效）
   —— 置于文件末尾，确保对后置基础规则有最终决定权
   ============================================================ */

/* ---------- 汉堡按钮（桌面隐藏，手机显示） ---------- */
.menu-btn {
  display: none;
  width: 36px; height: 36px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  align-items: center; justify-content: center;
  position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.menu-btn::before {
  content: ''; width: 18px; height: 2px; border-radius: 2px;
  background: currentColor; box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}
.menu-btn:hover { border-color: var(--primary); color: var(--primary); }
.menu-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 抽屉遮罩（桌面不存在） ---------- */
.sidebar-scrim { display: none; }

/* ---------- 平板：≤1024px 侧栏收窄 + 双栏转单栏 ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 188px; padding: 16px 8px; }
  .brand { padding: 2px 4px 16px; gap: 8px; }
  .brand-logo { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }
  .brand-text span { display: none; }
  .nav a { padding: 8px 8px; gap: 8px; font-size: 13.5px; }
  .nav a svg { width: 15px; height: 15px; }
  .user-card { padding: 6px 4px; gap: 8px; }
  .demo-chip { display: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 16px 36px; }
  .grid-2, .cap-layout { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; gap: 8px; }
  .page-head { flex-wrap: wrap; gap: 10px; }
}

/* ---------- 手机：≤768px 抽屉式侧栏 + sticky 顶栏 ---------- */
@media (max-width: 768px) {
  .app { height: 100vh; height: 100dvh; }

  /* 抽屉侧栏 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 264px; max-width: 82vw; min-width: 232px;
    padding: 16px 12px calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: none; overflow-y: auto; overscroll-behavior: contain;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(16, 24, 40, .28);
  }
  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(15, 18, 24, .45);
    opacity: 0; visibility: hidden;
    transition: opacity .26s ease, visibility .26s;
  }
  body.sidebar-open .sidebar-scrim { opacity: 1; visibility: visible; }
  body.sidebar-open .content { overflow: hidden; }

  /* 顶栏：sticky + 汉堡按钮 */
  .topbar {
    height: 52px; padding: 0 12px; gap: 8px;
    justify-content: flex-start;
    position: sticky; top: 0; z-index: 40;
  }
  .menu-btn { display: inline-flex; width: 44px; height: 44px; }
  .topbar-title {
    flex: 1 1 auto; min-width: 0; font-size: 14.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar-actions {
    flex: 0 1 auto; min-width: 0; gap: 6px;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions > * { flex-shrink: 0; }
  .ai-mode-chip { font-size: 0; gap: 4px; padding: 5px 8px; }
  .ai-mode-chip::after { content: 'AI'; font-size: 11px; font-weight: 600; }
  /* 离线状态点与开关重复，窄屏隐藏以给标题让出空间 */
  .net-toggle #net-label, .net-toggle .net-dot { display: none; }
  .install-btn { display: none; }

  /* 内容区 */
  .content {
    padding: 14px 14px calc(30px + env(safe-area-inset-bottom));
    overflow-x: hidden; overscroll-behavior: contain;
  }
  .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-head h1 { font-size: 17px; }
  .grid-2, .grid-3, .grid-4,
  .grid-side, .grid-main, .grid-5-7, .grid-7-5 { grid-template-columns: 1fr; }
  .role-cards { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; gap: 8px; padding: 12px 13px; }
  .card-body { padding: 13px 13px; }
  .grid { gap: 12px; }
  .tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; }
  .kv-row { flex-wrap: wrap; gap: 2px 10px; }
  .kv-row .v { text-align: right; word-break: break-word; }
  .danger-zone { flex-direction: column; align-items: flex-start; gap: 10px; }
  .perm-row .pd { max-width: 100%; }
  .bar-row .bar-label { width: 88px; }
  .student-stage { padding: 18px 16px; }
  .ai-card .ai-head { flex-wrap: wrap; gap: 6px; }
  .heat-legend { flex-wrap: wrap; }
  .advice-actions { flex-wrap: wrap; }
  .advice-actions .btn { flex: 1 1 120px; }
  .list-item { gap: 10px; padding: 11px 13px; }

  /* 表格：外层滚动容器放行横向滚动，表格本身给最小宽度触发滚动 */
  .table { min-width: 520px; }
  .table th, .table td { padding: 8px 10px; }

  /* 热力图 / 宽表格：卡片内容区局部放行横向滚动，避免溢出到卡片外 */
  .card-body { overflow-x: auto; overscroll-behavior-x: contain; }
  .card-body::-webkit-scrollbar { height: 6px; }
  .card-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
  .heatmap { min-width: 560px; }

  /* 模态框：占满宽度、底部对齐、按钮全宽 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal, .modal.wide {
    width: 100%; max-width: 100%; max-height: 88vh;
    border-radius: 16px 16px 0 0;
  }
  .modal-head { padding: 13px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot {
    flex-direction: column; gap: 8px;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .modal-foot .btn { width: 100%; }

  /* Toast 不超出屏幕 */
  #toast-root { top: 12px; left: 12px; right: 12px; transform: none; }
  .toast { max-width: 100%; border-radius: 12px; }

  /* 登录页 */
  .auth-wrap { min-height: 100vh; min-height: 100dvh; }
  .auth-card { padding: 28px 20px; }
  .auth-brand { gap: 12px; margin-bottom: 22px; }
  .auth-brand h1 { font-size: 22px; }
  .brand-logo.lg { width: 44px; height: 44px; font-size: 20px; border-radius: 12px; }
}

/* ---------- 触控设备：触摸目标 ≥ 44×44 px ---------- */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-lg { min-height: 44px; }
  .nav a { min-height: 44px; }
  .tabs button { min-height: 44px; }
  .list-item { min-height: 48px; }
  .quiz-option { min-height: 46px; }
  .role-card { min-height: 44px; }
  .cap-shot-acts .btn { min-height: 44px; }
  .modal-close {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .menu-btn { width: 44px; height: 44px; }
  /* 16px 字号可避免 iOS Safari 聚焦时自动放大 */
  .select, .input, .textarea { min-height: 44px; font-size: 16px; }
  .select-sm { min-height: 32px; }
  .heat-cell { min-height: 38px; }
  /* 开关本体仅 34×19，把可点范围向上下扩到 44px 高（宽度不变，避免挤占顶栏标题） */
  .switch {
    height: 44px;
    display: inline-flex; align-items: center; justify-content: flex-start;
  }
  .switch .slider {
    position: absolute; inset: auto; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 34px; height: 19px;
  }
  .switch input:checked + .slider::before { transform: translateX(15px); }
}

/* ---------- 降低动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 深色模式 ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1216;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f38;
    --border-strong: #3a404b;
    --text: #e8ebf0;
    --text-2: #a9b1bd;
    --text-3: #79818e;
    --primary: #8ea2ff;
    --primary-hover: #3f52c8;
    --primary-tint: #1e2540;
    --green: #46c07a;
    --green-tint: #12301f;
    --amber: #e0a23c;
    --amber-tint: #33260f;
    --red: #ef6b62;
    --red-tint: #341a19;
    --lime: #9ad04b;
    --lime-tint: #1f2a10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
  }
  .brand-logo { background: linear-gradient(135deg, #4f63d8, #7b5cd8); }
  .btn-primary { background: #4f63d8; border-color: #4f63d8; }
  .btn-primary:hover { background: #5b6fe4; border-color: #5b6fe4; }
  .sync-btn { background: #b8801f; }
  .slider { background: #454c58; }
  .switch .slider::before { background: #f2f4f8; }
  .progress, .step-dot, .badge-gray, .bar-row .bar-track { background: #232833; }
  .badge-gray { color: var(--text-2); }
  .ai-card { border-color: #2f3a63; background: #171d33; }
  .answer-pre.err { border-color: #6b3330; background: #22181a; }
  .opt-dist .od.hot { border-color: #6b3330; }
  .danger-zone { border-color: #6b3330; background: #22181a; }
  .cap-result-hot { border-color: #6b3330; }
  .cap-done { border-color: #2f6647; }
  .live-panel { color: #b6e8c6; }
  .auth-card { background: var(--surface); }
  .auth-error { background: #2c1615; border-color: #6b3330; color: #f0938b; }
  .student-stage .stage-chip { background: #2b3140; color: #e8ebf0; }
  .guide-step .gn, .quiz-option.selected .opt-key,
  .step-dot.doing, .cap-shutter-icon { background: #4f63d8; }
  .toast { background: #262c38; color: #e8ebf0; }
  .toast.success { background: #17603a; }
  .toast.warn { background: #7a4a0c; }
  .toast.error { background: #8c2620; }
}

/* ============================================================
   学生端（Student端）
   —— 独立于教师端的极简界面：底部导航 + 大卡片 + 大点击区
   ============================================================ */

/* 登录页：教师/学生身份切换 */
.auth-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
}
.auth-tabs .auth-tab {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.auth-tabs .auth-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

/* ---------- 学生端底部导航 ---------- */
.stu-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.stu-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  min-height: 44px;
  transition: color .16s, background .16s;
}
.stu-nav-icon { font-size: 19px; line-height: 1.2; }
.stu-nav-btn.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- 学生端首页 ---------- */
.stu-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #6d4fe0 100%);
  border: none;
  color: #fff;
}
.stu-hero .card-body { padding: 18px 20px; }
.stu-hero-main { flex: 1; min-width: 0; }
.stu-hello { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.stu-class { font-size: 12.5px; opacity: .88; margin-top: 3px; }
.stu-hero-stat {
  text-align: center;
  padding: 0 12px;
  border-left: 1px solid rgba(255, 255, 255, .22);
}
.stu-hero-stat b { display: block; font-size: 22px; font-weight: 700; line-height: 1.1; }
.stu-hero-stat span { font-size: 11px; opacity: .85; }

/* ---------- 作业卡片 ---------- */
.stu-asg {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .16s, transform .12s, box-shadow .16s;
  background: var(--surface);
}
.stu-asg:last-child { margin-bottom: 0; }
.stu-asg:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(59, 91, 219, .1); }
.stu-asg:active { transform: scale(.995); }
.stu-asg-main { flex: 1; min-width: 0; }
.stu-asg-title {
  font-size: 14.5px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stu-asg-meta {
  display: flex; gap: 12px; margin-top: 4px;
  font-size: 11.5px; color: var(--text-3);
}
.stu-asg-side { text-align: right; flex-shrink: 0; }
.stu-asg-score { font-size: 12px; color: var(--text-3); }
.stu-asg-score.graded { color: var(--primary); font-weight: 700; font-size: 14px; }
.stu-asg-state { font-size: 11.5px; color: var(--primary); margin-top: 3px; font-weight: 500; }

/* ---------- 题目 ---------- */
.stu-q {
  padding: 16px 0;
  border-bottom: 1px dashed var(--border);
}
.stu-q:last-of-type { border-bottom: none; padding-bottom: 4px; }
.stu-q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.stu-q-no {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 11.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stu-q-type { font-size: 11.5px; color: var(--text-3); }
.stu-q-score { font-size: 11.5px; color: var(--text-3); margin-left: auto; }
.stu-q-stem {
  font-size: 14.5px; line-height: 1.75; color: var(--text-1);
  margin-bottom: 12px; white-space: pre-wrap; word-break: break-word;
}
.stu-input, .stu-textarea { font-size: 14px; }
.stu-textarea { min-height: 110px; resize: vertical; line-height: 1.7; }

.stu-options { display: flex; flex-direction: column; gap: 8px; }
.stu-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.6;
  transition: border-color .14s, background .14s;
  min-height: 44px;
}
.stu-option:hover { border-color: var(--primary); }
.stu-option.checked, .stu-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.stu-option input { margin-top: 3px; flex-shrink: 0; accent-color: var(--primary); }
.stu-option-letter {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--bg-2); color: var(--text-2);
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stu-option:has(input:checked) .stu-option-letter { background: var(--primary); color: #fff; }
.stu-option-text { flex: 1; word-break: break-word; }

/* ---------- 批改结果 ---------- */
.stu-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.7;
  border-left: 3px solid;
}
.stu-result.ok { background: #ecfdf5; border-color: #10b981; color: #065f46; }
.stu-result.bad { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.stu-result.neutral { background: var(--bg-2); border-color: var(--border); color: var(--text-2); }
.stu-result-head { font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.stu-result-score { font-weight: 700; }
.stu-result-basis { margin-top: 6px; font-weight: 400; opacity: .9; }
.stu-answer { margin-top: 7px; font-weight: 600; }
.stu-explain { margin-top: 5px; font-weight: 400; opacity: .88; }

/* ---------- 错题本 ---------- */
.stu-eb {
  padding: 14px 0;
  border-bottom: 1px dashed var(--border);
}
.stu-eb:last-child { border-bottom: none; padding-bottom: 4px; }
.stu-eb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.stu-eb-wrong { font-size: 11.5px; color: #ef4444; margin-left: auto; }
.stu-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stu-tag {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary); font-weight: 500;
}

/* ---------- 绑定班级 ---------- */
.bind-box {
  margin-top: 12px; padding: 16px;
  background: var(--bg-2); border-radius: 10px;
  border: 1px dashed var(--border);
}
.bind-title { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }

/* ---------- 手机端：底部导航固定 + 内容留白 ---------- */
@media (max-width: 768px) {
  .stu-nav { display: flex; }
  .content { padding-bottom: 78px; }
  .stu-hero { flex-wrap: wrap; }
  .stu-hero-stat { border-left: none; padding: 0 10px; }
}
@media (min-width: 769px) {
  .stu-nav { display: flex; position: static; border-top: none; background: transparent; padding: 0; }
  .stu-nav-btn { max-width: 120px; }
}

/* ============================================================
   资源管理面板
   ============================================================ */
.mg-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
  overflow-x: auto;
}
.mg-tab {
  flex: 1;
  min-width: 64px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, color .16s;
}
.mg-tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.mg-section { display: flex; flex-direction: column; gap: 14px; }
.mg-form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mg-form-row .input, .mg-form-row .select { flex: 1; min-width: 140px; }
.mg-form-block {
  padding: 14px;
  background: var(--bg-2);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.mg-textarea { font-size: 13px; line-height: 1.7; resize: vertical; min-height: 96px; font-family: inherit; }

.mg-list { display: flex; flex-direction: column; gap: 8px; }
.mg-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.mg-item.slim { padding: 10px 13px; }
.mg-item-main { flex: 1; min-width: 0; }
.mg-item-title { font-size: 14px; font-weight: 600; color: var(--text-1); }
.mg-item-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.mg-item-side { text-align: right; flex-shrink: 0; }
.mg-item-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.mg-invite { font-size: 11.5px; color: var(--text-3); margin-bottom: 5px; }
.mg-invite b {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--primary); font-size: 13px; letter-spacing: 1px;
}
.mg-invite.none { color: var(--text-3); opacity: .7; }

.mg-note {
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-2);
}
.mg-note b { color: var(--text-1); }

.mg-danger {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px dashed var(--border);
}
.mg-hint { font-size: 11.5px; color: var(--text-3); flex: 1; min-width: 180px; }

/* 作业选题面板 */
.mg-qpick {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.mg-qpick:empty { display: none; }
.mg-qpick-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 7px; cursor: pointer;
  font-size: 13px; line-height: 1.55;
  min-height: 36px;
}
.mg-qpick-item:hover { background: var(--bg-2); }
.mg-qpick-item input { accent-color: var(--primary); flex-shrink: 0; }
.mg-qpick-item label {
  display: flex; align-items: center; gap: 9px;
  flex: 1; min-width: 0; cursor: pointer;
}
.mg-qpick-no {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--bg-2); color: var(--text-3);
  font-size: 10.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mg-qpick-stem { flex: 1; color: var(--text-1); word-break: break-word; }
/* 每题分值设置：窄屏时换行，避免挤压题干 */
.mg-qpick-score {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-3); font-size: 12px; white-space: nowrap;
  flex-shrink: 0; cursor: default;
}
.mg-score-input {
  width: 54px; padding: 3px 6px; font-size: 12px; text-align: center;
}
@media (max-width: 560px) {
  .mg-qpick-item { flex-wrap: wrap; }
  .mg-qpick-score { margin-left: 27px; }
}

/* ============================================================
   AI 模型配置面板
   ============================================================ */
.ai-cfg-status {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.ai-cfg-status.on { background: #ecfdf5; border-color: #a7f3d0; }
.ai-cfg-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-3); flex-shrink: 0;
}
.ai-cfg-status.on .ai-cfg-dot { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.ai-cfg-state { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.ai-cfg-hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.ai-cfg-msg {
  margin-top: 10px; font-size: 12.5px; line-height: 1.7;
  padding: 0; color: var(--text-2);
}
.ai-cfg-msg.ok { color: #059669; }
.ai-cfg-msg.error { color: #dc2626; }

.ai-cfg-help {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px; line-height: 1.85; color: var(--text-2);
}
.ai-cfg-help summary { cursor: pointer; font-weight: 600; color: var(--text-1); }
.ai-cfg-help ol { margin: 10px 0 0; padding-left: 20px; }
.ai-cfg-help li { margin-bottom: 7px; }
.ai-cfg-help code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; padding: 1px 5px;
  background: var(--bg-2); border-radius: 4px; color: var(--primary);
}

/* ============================================================
   页头操作区（导出按钮等）
   ============================================================ */
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
@media (max-width: 720px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-actions { justify-content: flex-start; }
  .page-actions .select { width: 100% !important; }
}
