:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --border: #2d3a4f;
  --radius: 12px;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app { max-width: 960px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }

.header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.brand h1 { font-size: 1.35rem; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

.stats { font-size: 0.85rem; color: var(--muted); text-align: right; }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab.active, .tab:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.hero h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.hero-actions { margin-top: 1rem; }

.qty-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 1rem 0;
}
.qty-table th, .qty-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  text-align: left;
}
.qty-table th { background: var(--surface2); color: var(--muted); }
.qty-table td:nth-child(3) { color: var(--accent2); font-weight: 600; }

.quick-practice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.35rem; }

.submit-hint {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
#btn-submit-exam:disabled { opacity: 0.45; cursor: not-allowed; }

.badge {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.35rem;
  margin-left: 0.2rem;
  font-size: 0.7rem;
  line-height: 1.2rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  vertical-align: middle;
}

.wrongbook-header h2 { font-size: 1.1rem; margin-bottom: 0.35rem; }
.wrongbook-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 1rem 0;
}
.wrongbook-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.wrongbook-toolbar select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.danger-text { color: var(--danger) !important; }

.wrong-summary {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.wrong-list-page { max-height: 65vh; overflow-y: auto; }

.wrong-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--surface2);
}
.wrong-row .row-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}
.wrong-row .row-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.wrong-row .row-stem { font-size: 0.9rem; margin-bottom: 0.35rem; }
.wrong-row .row-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.wrong-row .row-actions button {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.wrong-row .row-actions button:hover { color: var(--text); }
.wrong-row .row-exp {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.highlight-card {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), var(--surface));
}

.drill-entry .btn { flex: 1; min-width: 140px; }

.drill-bar { margin-bottom: 1rem; padding: 0.85rem 1rem; }
.drill-bar-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.drill-bar-actions { display: flex; gap: 0.5rem; margin-top: 0.65rem; }

#drill-card-wrap .question { margin-bottom: 0; }
.drill-feedback {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 8px;
  font-size: 0.92rem;
}
.drill-feedback.correct { background: rgba(34, 197, 94, 0.15); border: 1px solid var(--accent2); }
.drill-feedback.wrong { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); }
.drill-feedback .exp { margin-top: 0.5rem; color: var(--muted); font-size: 0.88rem; }

.drill-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.drill-actions .btn { flex: 1; min-width: 120px; }

.tag-focus {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  font-weight: 700;
}

.options label.disabled { opacity: 0.55; pointer-events: none; }

.exam-mode-tag {
  font-size: 0.8rem;
  color: var(--warn);
  margin-left: 0.5rem;
}

.exam-spec { margin: 0 0 1rem 1.1rem; color: var(--muted); font-size: 0.92rem; }
.exam-spec li { margin-bottom: 0.35rem; }
.exam-spec strong { color: var(--text); }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat-box {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.85rem;
  text-align: center;
}
.stat-box .num { font-size: 1.6rem; font-weight: 700; color: var(--accent2); }
.stat-box .label { font-size: 0.8rem; color: var(--muted); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

.exam-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.timer {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--warn);
  min-width: 72px;
}

.timer.warning { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

.progress-wrap { flex: 1; min-width: 180px; }
.progress-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
.progress { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent2); width: 0%; transition: width 0.3s; }

.section-title {
  font-size: 1rem;
  color: var(--accent);
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
}

.question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.question.unanswered { border-left: 3px solid var(--warn); }
.question.answered { border-left: 3px solid var(--accent2); }

.q-instant-feedback {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.q-instant-feedback.correct { background: rgba(34, 197, 94, 0.15); border: 1px solid var(--accent2); }
.q-instant-feedback.wrong { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); }
.q-instant-feedback .fb-icon { font-weight: 700; margin-right: 0.3rem; }
.q-instant-feedback.correct .fb-icon { color: var(--accent2); }
.q-instant-feedback.wrong .fb-icon { color: var(--danger); }
.q-instant-feedback .fb-exp { margin-top: 0.4rem; color: var(--muted); font-size: 0.85rem; }

.q-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.q-meta .tag-variant { color: var(--warn); }

.q-stem { margin-bottom: 0.65rem; font-size: 0.95rem; }

.options label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.options label:hover { background: var(--surface2); }
.options input { margin-top: 0.25rem; }

.practice-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.practice-controls label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.practice-controls select, .practice-controls input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.practice-card .feedback {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.feedback.correct { background: rgba(34, 197, 94, 0.15); border: 1px solid var(--accent2); }
.feedback.wrong { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); }

.score-hero {
  text-align: center;
  padding: 2rem 1rem;
}
.score-hero .big {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
}
.score-hero.pass .big { color: var(--accent2); }
.score-hero.fail .big { color: var(--danger); }
.score-hero .verdict { font-size: 1.2rem; margin-top: 0.5rem; }

.type-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.wrong-sync-status { margin: 0.5rem 0; font-size: 0.85rem; }
.wrong-sync-msg.ok { color: var(--accent2); }
.wrong-sync-msg.err { color: var(--danger); }
.wrong-sync-msg.info { color: var(--muted); }

.wrong-list { max-height: 420px; overflow-y: auto; }
.wrong-item {
  border-left: 3px solid var(--danger);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--surface2);
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
}
.wrong-item .exp { color: var(--muted); margin-top: 0.35rem; font-size: 0.82rem; }

@media (max-width: 600px) {
  .exam-bar { flex-direction: column; align-items: stretch; }
}

/* ─── 上机实操（lab） ─── */
body.cheatsheet-fullscreen .app {
  max-width: 100% !important;
  padding: 1rem 0.75rem 1rem;
}
body.cheatsheet-fullscreen #view-cheatsheet { margin: 0; }
body.cheatsheet-fullscreen #view-grammar { margin: 0; }
body.cheatsheet-fullscreen #cheatsheet-frame {
  height: calc(100vh - 110px) !important;
}
body.cheatsheet-fullscreen #grammar-frame {
  height: calc(100vh - 110px) !important;
}

body.lab-fullscreen .app {
  max-width: 100% !important;
  padding: 1rem !important;
}

.lab-shell { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; align-items: start; transition: grid-template-columns 0.2s ease; }
.lab-shell.sidebar-collapsed { grid-template-columns: 56px 1fr; }
.lab-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  height: calc(100vh - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 1rem;
  transition: padding 0.2s ease;
}

/* 折叠状态：只显示题号，内容隐藏 */
.lab-sidebar.collapsed { padding: 0.4rem 0.2rem; }
.lab-sidebar.collapsed .lab-sidebar-head strong,
.lab-sidebar.collapsed .lab-group-head,
.lab-sidebar.collapsed .lab-q-name,
.lab-sidebar.collapsed .lab-q-tag {
  display: none;
}
.lab-sidebar.collapsed .lab-group { margin-bottom: 0.4rem; padding-top: 0.4rem; border-top: 1px dashed var(--border); }
.lab-sidebar.collapsed .lab-group:first-child { border-top: none; padding-top: 0; }
.lab-sidebar.collapsed .lab-q-item {
  display: flex;
  justify-content: center;
  padding: 0.3rem 0;
}
.lab-sidebar.collapsed .lab-q-id { font-size: 0.74rem; font-weight: 600; }
.lab-sidebar.collapsed .lab-sidebar-head { justify-content: center; border: none; padding-bottom: 0; }
.lab-sidebar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.btn-tiny { padding: 0.15rem 0.5rem; font-size: 0.8rem; }
.lab-group { margin-bottom: 0.75rem; }
.lab-group-head { display: flex; justify-content: space-between; padding: 0.35rem 0.25rem; font-size: 0.85rem; color: var(--muted); border-bottom: 1px dashed var(--border); }
.lab-group-name { font-weight: 600; color: var(--text); }
.lab-q-list { list-style: none; padding: 0.25rem 0; }
.lab-q-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
  border: 1px solid transparent;
}
.lab-q-item:hover { background: var(--surface2); }
.lab-q-item.active { background: rgba(59, 130, 246, 0.18); border-color: var(--accent); }
.lab-q-item.done { color: var(--muted); }
.lab-q-item.done::before { content: "✓"; color: var(--accent2); margin-right: 0.2rem; }
.lab-q-id { font-family: monospace; color: var(--muted); }
.lab-q-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lab-q-tag { font-size: 0.7rem; padding: 0.05rem 0.4rem; background: var(--surface2); border-radius: 4px; color: var(--muted); }

.lab-main { min-width: 0; }
.lab-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.lab-topbar-left { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lab-title { font-weight: 700; font-size: 1rem; }
.lab-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.lab-topbar-right { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.lab-mode-switch { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.lab-mode-switch .mode-btn { border-radius: 0; border: none; padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.lab-mode-switch .mode-btn.active { background: var(--accent); color: white; }

.lab-content { display: block; }
.lab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; transition: grid-template-columns 0.25s ease; }
.lab-grid.three-col { grid-template-columns: 1fr 1fr 1fr; }
.lab-col { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; overflow: hidden; transition: min-width 0.25s; }
.lab-col.col-minimized { min-width: 48px; max-width: 48px; overflow: hidden; }
.lab-col.col-minimized .lab-col-body { display: none; }
.lab-col.col-minimized .lab-stem-head { writing-mode: vertical-lr; text-orientation: mixed; white-space: nowrap; padding: 0.5rem 0.3rem; font-size: 0.78rem; border-bottom: none; }
.lab-col.col-minimized .lab-stem-head .lab-stem-open,
.lab-col.col-minimized .lab-stem-head .lab-legend { display: none; }
.lab-col.col-minimized .lab-materials,
.lab-col.col-minimized .lab-mat-list { display: none; }
.lab-col-toggle {
  font-size: 0.82rem;
  padding: 1px 6px;
  margin: -2px 4px -2px 0;
  opacity: 0.6;
  cursor: pointer;
  vertical-align: middle;
}
.lab-col-toggle:hover { opacity: 1; }
.lab-stem-head {
  font-weight: 600;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lab-stem-open { font-size: 0.78rem; color: var(--accent); text-decoration: none; }
.lab-stem-open:hover { text-decoration: underline; }
.lab-stem-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}
.lab-stem-frame.tall { height: 700px; }

.lab-mat-list { display: flex; flex-direction: column; gap: 0.35rem; }
.lab-mat-list a { color: var(--accent); text-decoration: none; font-size: 0.88rem; }
.lab-mat-list a:hover { text-decoration: underline; }

.lab-cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.6rem;
  overflow: hidden;
}
.lab-cell-head { padding: 0.35rem 0.6rem; background: rgba(0, 0, 0, 0.2); font-size: 0.78rem; color: var(--muted); }
.lab-cell-src {
  padding: 0.75rem;
  font-family: "Menlo", "Consolas", "JetBrains Mono", monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  color: #f8f8f2;
}
.lab-cell-src.editable { background: #0d1117; }

.lab-blank {
  background: #1e2937;
  border: 1px solid var(--accent);
  color: #ffd866;
  font-family: inherit;
  font-size: inherit;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  min-width: 6ch;
  max-width: 100%;
  outline: none;
  box-sizing: content-box;
  vertical-align: baseline;
  transition: width 0.08s ease-out;
}
.lab-blank:focus { background: #2a3a4f; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3); }

.lab-legend {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--muted);
}
.lab-legend .hl-blank,
.lab-legend .hl-blank-miss {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0 0.35rem;
  margin: 0 0.1rem;
}

/* 预览模式：填空高亮 */
.hl-blank {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  border-bottom: 1px solid var(--warn);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
}
.hl-blank-miss {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-bottom: 1px dashed var(--danger);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.lab-essay-answer {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.7;
  background: var(--surface2);
  padding: 0.8rem 1rem;
  border-radius: 6px;
  max-height: 70vh;
  overflow-y: auto;
}

.lab-essay {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
}

.lab-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.lab-actions .hint { margin-left: 0.5rem; color: var(--accent2); font-size: 0.85rem; }

.lab-grade { border-left: 4px solid var(--accent); padding-left: 1rem; }
.lab-grade.ok { border-left-color: var(--accent2); }
.lab-grade.fail { border-left-color: var(--danger); }
.lab-grade-header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.lab-grade-score { font-size: 1.1rem; }
.lab-grade-score .big { font-size: 2.2rem; font-weight: 800; color: var(--accent); }
.lab-grade.ok .big { color: var(--accent2); }
.lab-grade.fail .big { color: var(--danger); }
.lab-grade-summary { margin: 0.5rem 0; color: var(--muted); }
.lab-grade-badge {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
}
.lab-grade-badge.cache { background: rgba(245, 158, 11, 0.18); color: var(--warn); border: 1px solid var(--warn); }
.lab-grade-badge.fresh { background: rgba(59, 130, 246, 0.18); color: var(--accent); border: 1px solid var(--accent); }
.lab-grade-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.75rem; flex-wrap: wrap; }
.lab-grade-actions .hint { color: var(--accent2); font-size: 0.84rem; }
.lab-grade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.75rem 0;
}
.lab-grade-table th, .lab-grade-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.lab-grade-table th { color: var(--muted); font-weight: 500; }
.lab-grade-sug {
  margin-top: 0.5rem;
  padding: 0.6rem;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 6px;
  font-size: 0.9rem;
}

.lab-grade-fail { color: var(--danger); }

/* 设置弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h3 { margin-bottom: 0.5rem; }
.modal-card .hint { margin-bottom: 1rem; }
.modal-card label {
  display: block;
  margin: 0.6rem 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.modal-card label input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-family: inherit;
}
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.llm-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: var(--surface2);
  border-radius: 6px;
}
.llm-presets .hint { margin: 0; font-size: 0.8rem; }

.llm-server-status {
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.llm-server-ok {
  color: var(--accent2);
  word-break: break-all;
  flex: 1;
  min-width: 200px;
}

/* 素材列表行 */
.lab-mat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.5rem;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 0.86rem;
}
.lab-mat-row + .lab-mat-row { margin-top: 0.35rem; }
.lab-mat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-mat-tag {
  display: inline-block;
  padding: 0 0.4rem;
  margin-left: 0.4rem;
  background: var(--accent2);
  color: white;
  border-radius: 4px;
  font-size: 0.7rem;
}
.lab-mat-btns { display: flex; gap: 0.35rem; }
.lab-mat-btns .btn-tiny { font-size: 0.78rem; padding: 0.2rem 0.6rem; }

/* 预览 modal */
.preview-card {
  max-width: 92vw;
  width: 1080px;
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.preview-title { font-weight: 600; font-size: 0.95rem; }
.preview-actions { display: flex; gap: 0.4rem; }
.preview-body {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  background: var(--bg);
  min-height: 300px;
}
.preview-loading, .preview-na {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}
.preview-img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  margin: 0 auto;
  background: white;
  border-radius: 4px;
}
.preview-iframe {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
}
.preview-iframe.pdf {
  height: 80vh;
  border: none;
}
.preview-pre {
  font-family: "Menlo", "Consolas", "JetBrains Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.6;
  background: var(--surface);
  padding: 1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 75vh;
  overflow: auto;
}
.preview-meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.5rem; }
.preview-table-wrap {
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: #111;
}
.preview-table, .preview-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.preview-table th, .preview-table td,
.preview-table-wrap th, .preview-table-wrap td {
  padding: 0.35rem 0.6rem;
  border: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}
.preview-table thead, .preview-table-wrap thead {
  position: sticky;
  top: 0;
  background: #f3f4f6;
  z-index: 1;
}
.preview-table-wrap tr:nth-child(2n) td { background: #fafafa; }

.preview-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.preview-tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.25rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.84rem;
}
.preview-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

.preview-docx {
  background: white;
  color: #111;
  padding: 2rem 3rem;
  max-width: 800px;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  line-height: 1.8;
}
.preview-docx h1, .preview-docx h2, .preview-docx h3 { margin: 1rem 0 0.5rem; }
.preview-docx p { margin: 0.4rem 0; }
.preview-docx ul, .preview-docx ol { margin: 0.4rem 0 0.4rem 1.5rem; }
.preview-docx li { margin: 0.2rem 0; }
.preview-docx table { border-collapse: collapse; margin: 0.5rem 0; width: 100%; }
.preview-docx td, .preview-docx th { border: 1px solid #ccc; padding: 0.3rem 0.6rem; vertical-align: top; }
.preview-docx strong { color: #1f2937; }
.preview-warn-toggle {
  margin-top: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface2);
  border-radius: 4px;
  font-size: 0.8rem;
}
.preview-warnings { margin: 0.5rem 0 0 1.2rem; color: var(--muted); }
.preview-warnings li { padding: 0.15rem 0; }

@media (max-width: 900px) {
  .lab-shell { grid-template-columns: 1fr; }
  .lab-sidebar { position: relative; max-height: 280px; }
  .lab-grid, .lab-grid.three-col { grid-template-columns: 1fr !important; }
  .lab-col.col-minimized { max-width: none; min-width: 0; }
  .lab-col.col-minimized .lab-col-body { display: block; }
  .lab-col.col-minimized .lab-stem-head { writing-mode: horizontal-tb; }
}

/* 首页 · 考前上机知识点快捷入口 */
.cheatsheet-shortcut {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: linear-gradient(135deg, #1e3a8a 0%, #4338ca 60%, #7c3aed 100%);
  color: #fff;
  text-decoration: none;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.cheatsheet-shortcut:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(124, 58, 237, 0.4);
  text-decoration: none;
}
.cheatsheet-shortcut .cs-emoji {
  font-size: 1.7rem;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}
.cheatsheet-shortcut .cs-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}
.cheatsheet-shortcut .cs-text strong {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.cheatsheet-shortcut .cs-text .cs-sub {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.78);
  margin-top: 2px;
}
.cheatsheet-shortcut .cs-arrow {
  font-size: 1.4rem;
  opacity: 0.85;
  transition: transform 0.15s ease;
}
.cheatsheet-shortcut:hover .cs-arrow { transform: translateX(4px); }

/* ── AI 标注系统 ── */

/* 悬浮按钮 */
.ann-fab {
  position: absolute;
  z-index: 9000;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.12s;
}
.ann-fab:hover {
  transform: translateX(-50%) scale(1.06);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.55);
}

/* 提问弹窗 */
.ann-popup {
  position: absolute;
  z-index: 9100;
  width: 400px;
  max-width: calc(100vw - 20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 0;
  overflow: hidden;
}
.ann-popup-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.8rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}
.ann-popup-title { font-weight: 600; font-size: 0.88rem; }
.ann-popup-close {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 0 2px; opacity: 0.8;
}
.ann-popup-close:hover { opacity: 1; }
.ann-popup-sel {
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  max-height: 60px;
  overflow-y: auto;
  line-height: 1.4;
}
.ann-popup-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 2.4em;
  font-family: inherit;
}
.ann-popup-input:focus { outline: none; background: var(--surface2); }
.ann-popup-actions { padding: 0.5rem 0.8rem; text-align: right; }
.ann-popup-result {
  padding: 0 0.8rem 0.7rem;
  max-height: 320px;
  overflow-y: auto;
}
.ann-ai-answer {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--fg);
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
}
.ann-popup-save { width: 100%; }

/* 标注气泡列表 */
.lab-annotations {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ann-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #8b5cf6;
  border-radius: var(--radius);
  overflow: hidden;
}
.ann-bubble-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
}
.ann-bubble-head:hover { background: var(--surface2); }
.ann-bubble-sel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a78bfa;
  font-style: italic;
}
.ann-bubble-time { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.ann-bubble-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 0 4px; opacity: 0.6;
}
.ann-bubble-del:hover { opacity: 1; color: #ef4444; }
.ann-bubble-body {
  padding: 0.5rem 0.8rem 0.6rem;
  font-size: 0.84rem;
  line-height: 1.6;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s;
}
.ann-bubble-body.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  opacity: 0;
}
.ann-bubble-q { color: #f59e0b; margin-bottom: 0.3rem; font-weight: 500; }
.ann-bubble-a { word-break: break-word; color: var(--fg); line-height: 1.65; }

/* AI 回答中的 Markdown 渲染 */
.ann-ai-answer { white-space: normal; word-break: break-word; }
.ann-ai-answer ul, .ann-bubble-a ul { margin: 0.3rem 0 0.3rem 1.2rem; padding: 0; }
.ann-ai-answer li, .ann-bubble-a li { margin: 0.15rem 0; }
.ann-md-code {
  display: block;
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0.4rem 0;
  font-size: 0.82rem;
  font-family: "Menlo", "Consolas", "JetBrains Mono", monospace;
  overflow-x: auto;
  white-space: pre;
}
.ann-md-inline {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: "Menlo", "Consolas", "JetBrains Mono", monospace;
}
.ann-md-h1 { font-size: 1.1rem; display: block; margin: 0.5rem 0 0.25rem; }
.ann-md-h2 { font-size: 1.02rem; display: block; margin: 0.4rem 0 0.2rem; }
.ann-md-h3 { font-size: 0.95rem; display: block; margin: 0.35rem 0 0.15rem; }
.ann-md-h4 { font-size: 0.9rem; display: block; margin: 0.3rem 0 0.1rem; }
