:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --admin-accent: #7c3aed;
  --admin-accent-dark: #6d28d9;
  --header-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--primary); }

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1e3a5f 0%, #0f2744 45%, #1a4a6e 100%);
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-card.admin-login { border-top: 4px solid var(--admin-accent); }

.login-logo {
  width: 56px; height: 56px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 28px;
  background: linear-gradient(135deg, var(--primary), #1e40af);
}
.admin-login .login-logo { background: linear-gradient(135deg, var(--admin-accent), #4c1d95); }

.login-card h1 { text-align: center; font-size: 1.5rem; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 0.9rem; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.875rem; margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; outline: none; background: #fff;
  /* 16px 避免 iOS 聚焦自动放大 */
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.admin-login .form-group input:focus { border-color: var(--admin-accent); box-shadow: 0 0 0 3px #ede9fe; }
.form-group textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 0.9rem; font-weight: 500; transition: .2s;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-height: 40px; text-decoration: none; color: inherit;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.admin-app .btn-primary, .admin-login .btn-primary { background: var(--admin-accent); color: #fff; }
.admin-app .btn-primary:hover, .admin-login .btn-primary:hover { background: var(--admin-accent-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; min-height: 32px; }

.app {
  height: 100vh; height: 100dvh;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 16px 0 12px; height: var(--header-h); display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--primary-light); flex-shrink: 0;
  user-select: none;
}
.admin-app .header-logo { background: #ede9fe; }
.header-title { font-size: 1.1rem; font-weight: 600; white-space: nowrap; user-select: none; }
.header-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; font-weight: 500;
  background: var(--primary-light); color: var(--primary); flex-shrink: 0;
}
.admin-app .header-badge { background: #ede9fe; color: var(--admin-accent); }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-name { font-size: 0.875rem; color: var(--text); font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-toggle {
  display: none;
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; align-items: center; justify-content: center;
  flex-direction: column; gap: 5px; padding: 0; flex-shrink: 0;
}
.menu-toggle span {
  display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px;
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  z-index: 90; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.sidebar-backdrop.show {
  display: block; opacity: 1; pointer-events: auto;
}

.main { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; flex-shrink: 0; overflow-y: auto;
}
.nav-item {
  padding: 12px 14px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  font-size: 0.9rem; color: var(--text-muted); transition: .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.admin-app .nav-item.active { background: #ede9fe; color: var(--admin-accent); }

.content { flex: 1; padding: 24px; overflow: auto; -webkit-overflow-scrolling: touch; }
.page-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 4px; }
.page-desc { color: var(--text-muted); margin-bottom: 20px; font-size: 0.9rem; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; max-width: 100%;
}

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat-card .num { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.admin-app .stat-card .num { color: var(--admin-accent); }
.stat-card .label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: .2s;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
}
.card h3 { font-size: 1rem; margin-bottom: 8px; }
.card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.card .meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }

.table-wrap {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; min-width: 560px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #f8fafc; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 200; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  max-height: 92vh; max-height: 92dvh; overflow: auto; box-shadow: var(--shadow-lg);
  padding-bottom: var(--safe-bottom);
}
@media (min-width: 769px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 16px; max-height: 90vh; padding-bottom: 0; }
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: min(1100px, 96vw); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h2 { font-size: 1.1rem; padding-right: 12px; }
.modal-close {
  border: none; background: var(--bg); width: 36px; height: 36px; border-radius: 8px;
  font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px calc(16px + var(--safe-bottom));
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border);
}

/* 答题情况弹窗 */
.exam-stats { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.exam-stats-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.exam-stats-search {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px;
}
.exam-stats-search input {
  flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; background: #fff;
}
.exam-stats-search input:focus {
  outline: none; border-color: var(--admin-accent); box-shadow: 0 0 0 3px #ede9fe;
}
.exam-stats-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.exam-stats-summary {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc;
}
.exam-stats-metric {
  text-align: center; padding: 8px 6px; border-radius: 10px; background: #fff;
  border: 1px solid var(--border);
}
.exam-stats-metric .num {
  font-size: 1.35rem; font-weight: 800; color: var(--admin-accent); line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.exam-stats-metric .label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.exam-stats-metric.is-max .num { color: var(--success); }
.exam-stats-metric.is-min .num { color: var(--warning); }
.exam-stats-hint {
  margin: 0; color: var(--text-muted); font-size: 0.8rem; line-height: 1.45;
}
.exam-stats-table {
  max-height: min(52vh, 480px); overflow: auto;
}
.exam-stats-table table { min-width: 720px; }
.exam-stats-table thead th {
  position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border);
}
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: 999px;
  background: #eef2ff; color: #4338ca; font-weight: 700; font-size: 0.85rem;
}
.rank-badge.rank-1 { background: #fef3c7; color: #b45309; }
.rank-badge.rank-2 { background: #e2e8f0; color: #475569; }
.rank-badge.rank-3 { background: #ffedd5; color: #c2410c; }
.cell-user { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.cell-user strong { font-size: 0.9rem; }
.cell-user span { font-size: 0.75rem; color: var(--text-muted); }
.cell-dept {
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-score { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-score strong { color: var(--admin-accent); font-size: 1rem; }
.cell-score span { color: var(--text-muted); font-size: 0.8rem; }
.cell-time {
  white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 0.85rem;
}
.cell-actions { white-space: nowrap; }
.cell-actions .btn { margin-right: 4px; }
.cell-stem { max-width: 320px; word-break: break-word; }
.attempt-detail-head h3 { margin: 0 0 8px; font-size: 1.05rem; }
.attempt-detail-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px;
}

@media (max-width: 900px) {
  .exam-stats-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .exam-stats-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exam-stats-bar { flex-direction: column; align-items: stretch; }
  .exam-stats-actions .btn { flex: 1; }
}

.toast {
  position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 999; font-size: 0.9rem;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem;
  background: var(--primary-light); color: var(--primary);
}
.badge.ok { background: #d1fae5; color: var(--success); }
.badge.warn { background: #fef3c7; color: var(--warning); }
.badge.off { background: #fee2e2; color: var(--danger); }

.exam-q { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.exam-q .q-title { font-weight: 600; margin-bottom: 10px; word-break: break-word; }
.exam-q label {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 8px; cursor: pointer;
  border-radius: 8px; margin: 2px 0;
}
.exam-q label:active { background: var(--bg); }
.exam-q input { margin-top: 4px; width: 18px; height: 18px; flex-shrink: 0; }
.exam-timer {
  position: sticky;
  top: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  margin: 0 0 12px;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
}

/* 答题中：顶栏固定悬浮在站点 header 下方 */
body.is-exam-taking .exam-timer {
  position: fixed;
  top: var(--header-h);
  left: 220px; /* 与侧栏宽度一致 */
  right: 0;
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: 0 4px 14px rgba(15,23,42,.12);
  z-index: 95;
}
body.is-exam-taking .exam-timer-spacer {
  display: block;
  height: var(--exam-timer-h, 52px);
  margin-bottom: 12px;
  flex-shrink: 0;
}
.exam-timer-spacer { display: none; }
.exam-timer-main {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 12px; min-height: 44px;
}
.exam-timer-info {
  min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px;
}
.exam-timer-title {
  font-size: 0.95rem; font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exam-timer-meta {
  font-size: 0.75rem; color: var(--text-muted); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exam-timer-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.exam-timer-remain {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem; font-weight: 600;
  color: var(--text); min-width: 5.6em; text-align: right;
  white-space: nowrap;
}
.exam-timer-remain-label {
  font-weight: 500; color: var(--text-muted); font-size: 0.8rem;
}
.exam-timer-remain.is-urgent { color: var(--danger); }
.exam-timer-remain.is-urgent .exam-timer-remain-label { color: var(--danger); }
.exam-live-score {
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 3.2em;
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.exam-live-score.hidden,
.exam-live-score[hidden] { display: none !important; }
.exam-progress {
  height: 3px; background: #e8edf3; overflow: hidden; margin: 0; border-radius: 0;
}
.exam-progress > span {
  display: block; height: 100%; background: var(--primary); width: 0%; transition: width .2s;
}
.exam-pwd-panel { width: min(400px, 100%); }

.answer-pick {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.answer-sq {
  width: 40px; height: 40px; border: 2px solid var(--border); border-radius: 8px;
  background: #fff; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); transition: all .15s; padding: 0 12px; flex-shrink: 0;
  min-width: 40px; width: auto;
}
.answer-sq:hover { border-color: var(--primary); color: var(--primary); }
.answer-sq.on {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

.form-hint { color: var(--text-muted); font-size: 0.8rem; margin: 6px 0 0; }
.opt-edit-list { display: flex; flex-direction: column; gap: 8px; }
.opt-edit-row { display: flex; align-items: center; gap: 8px; }
.opt-edit-letter {
  width: 28px; height: 28px; border-radius: 6px; background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.opt-edit-input { flex: 1; }
.opt-del { width: 36px; padding: 0; flex-shrink: 0; }
.judge-fixed-opts { display: flex; gap: 12px; flex-wrap: wrap; }
.judge-fixed-opt {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.judge-fixed-opt b {
  width: 24px; height: 24px; border-radius: 6px; background: #fff; border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem;
}

.bank-pick {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.bank-pick-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 0.9rem;
}
.bank-pick-item:has(input:checked) { border-color: var(--primary); background: var(--primary-light, #eff6ff); color: var(--primary); }
.fixed-q-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.fixed-q-list {
  max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
}
.fixed-q-item {
  display: flex; gap: 8px; padding: 6px 4px; align-items: flex-start; cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.fixed-q-item:last-child { border-bottom: 0; }
.fixed-q-text { font-size: 0.9rem; line-height: 1.4; }
.fixed-q-text em {
  font-style: normal; font-size: 0.75rem; color: var(--text-muted);
  background: var(--bg); padding: 1px 6px; border-radius: 4px; margin-right: 4px;
}
.exam-preview-panel { width: min(720px, 100%); max-height: min(86vh, 780px); }
.exam-preview-q { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #eef2f7; }
.exam-preview-opts { color: var(--text); font-size: 0.92rem; line-height: 1.7; padding-left: 4px; }

.empty { text-align: center; padding: 48px 16px; color: var(--text-muted); }

.exam-layout { display: block; }
.exam-sheet-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
.exam-sheet-panel {
  background: #fff; border-radius: 16px 16px 12px 12px; width: min(560px, 100%);
  max-height: min(80vh, 640px); overflow: auto; padding: 20px; box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
.exam-sheet-panel h3 { margin: 0 0 8px; }
.exam-sheet-panel .hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 12px; }
.content-desc-clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5;
}
.content-viewer {
  margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #0f172a08;
  min-height: 360px;
}
.content-viewer iframe, .content-viewer video, .content-viewer img {
  width: 100%; min-height: 480px; border: 0; display: block; background: #fff;
}
.content-viewer img { min-height: auto; max-height: 80vh; object-fit: contain; margin: 0 auto; }
.content-viewer audio,
.announce-audio audio {
  width: 100%; display: block; margin: 0;
}
.announce-audio {
  margin-top: 12px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 12px; background: #f8fafc; min-height: auto !important;
}
.announce-attachment { margin-top: 14px; }
.announce-media { margin-top: 0; }
.announce-att-actions { margin-top: 10px; }
.announce-card .meta { margin-top: 12px; }
.exam-nav {
  position: sticky; top: calc(var(--header-h) + 8px); background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; max-height: calc(100vh - 120px); overflow: auto;
}
.exam-nav .nav-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; }
.exam-nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.exam-nav-grid button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  padding: 8px 0; cursor: pointer; font-size: 0.75rem; min-height: 36px;
}
.exam-nav-grid button.done { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.exam-nav-grid button.current { background: var(--primary); color: #fff; border-color: var(--primary); }
.exam-type-title {
  font-size: 0.95rem; font-weight: 700; margin: 18px 0 10px; padding-left: 10px;
  border-left: 3px solid var(--primary);
}
.pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.pager button[disabled] { opacity: .45; cursor: not-allowed; }

/* ===== 平板 ===== */
@media (max-width: 1024px) {
  .content { padding: 20px 16px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ===== 手机 ===== */
@media (max-width: 768px) {
  :root { --header-h: 56px; }

  .menu-toggle { display: inline-flex; }

  .header { padding: 0 10px; height: var(--header-h); }
  .header-title { font-size: 1rem; }
  .header-badge { display: none; }
  .user-name { display: inline-block; max-width: 110px; font-size: 0.8rem; }
  .header-right .btn { padding: 8px 12px; font-size: 0.85rem; }

  .main { position: relative; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(280px, 82vw);
    z-index: 95;
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
    border-right: none;
    padding-bottom: calc(16px + var(--safe-bottom));
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.show { display: block; top: var(--header-h); }

  .nav-item { padding: 14px 16px; font-size: 0.95rem; }

  .content {
    padding: 16px 12px calc(24px + var(--safe-bottom));
    width: 100%;
  }

  .page-title { font-size: 1.2rem; }
  .page-desc { font-size: 0.85rem; margin-bottom: 14px; }

  .form-row { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; border-radius: 16px; }
  .login-card h1 { font-size: 1.35rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .num { font-size: 1.35rem; }

  .card-grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 16px; }
  @media (hover: hover) {
    .card:hover { transform: none; }
  }

  .toolbar { gap: 8px; }
  .toolbar .btn, .toolbar a.btn { flex: 1 1 auto; min-width: calc(50% - 8px); }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }

  table { font-size: 0.8rem; min-width: 520px; }
  th, td { padding: 10px 10px; }

  .exam-layout {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }
  .exam-nav {
    position: sticky;
    bottom: 0;
    top: auto;
    order: 2;
    max-height: none;
    margin-top: 8px;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,.06);
    padding-bottom: calc(12px + var(--safe-bottom));
    z-index: 40;
  }
  .exam-nav-grid { grid-template-columns: repeat(8, 1fr); gap: 6px; }
  .exam-nav-grid button { min-height: 40px; font-size: 0.8rem; }

  .exam-timer {
    top: 0;
    border-radius: 0;
    margin-left: -12px;
    margin-right: -12px;
    margin-bottom: 10px;
    border-left: 0;
    border-right: 0;
    width: calc(100% + 24px);
  }
  body.is-exam-taking .exam-timer {
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
  }
  body.is-exam-taking .exam-timer-spacer {
    margin-left: -12px;
    margin-right: -12px;
    width: calc(100% + 24px);
    margin-bottom: 10px;
  }
  .exam-timer-main { padding: 7px 12px; gap: 8px; flex-wrap: wrap; }
  .exam-timer-title { font-size: 0.88rem; }
  .exam-timer-meta { font-size: 0.7rem; }
  .exam-timer-remain { font-size: 0.9rem; min-width: 4.8em; }
  .exam-timer-remain-label { display: none; }
  .exam-live-score { font-size: 0.95rem; }
  .exam-timer-actions { flex-wrap: wrap; justify-content: flex-end; }
  .exam-timer-actions .btn { min-height: 36px; padding: 6px 12px; flex-shrink: 0; }

  .exam-q { padding: 14px; }
  .exam-q label { padding: 12px 8px; font-size: 0.95rem; }

  .modal-footer .btn { flex: 1; min-height: 44px; }
  .pager { justify-content: center; width: 100%; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .exam-nav-grid { grid-template-columns: repeat(6, 1fr); }
  .header-title { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
}
