/* ================= 高中物理知识架构 · Light Theme ================= */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --border-strong: #d5dce8;
  --text: #1e293b;
  --text-sub: #64748b;
  --text-mute: #94a3b8;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-dark: #1d4ed8;
  --accent: #0284c7;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
  --shadow-lg: 0 8px 30px rgba(15,23,42,.10);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "PingFang SC","Microsoft YaHei","Segoe UI",-apple-system,BlinkMacSystemFont,sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* ---------- Header ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 2px rgba(15,23,42,.03);
}
.header-inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 24px 12px;
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; flex-shrink: 0; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #fff; font-size: 24px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(13,148,136,.3);
}
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--text-mute); }
.nav-tabs { display: flex; gap: 4px; margin-left: 12px; }
.nav-tab {
  border: none; background: transparent; color: var(--text-sub);
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; gap: 7px; transition: all .15s;
}
.nav-tab:hover { background: var(--surface-2); color: var(--text); }
.nav-tab.active { background: var(--primary-soft); color: var(--primary); }
.nav-ico { font-size: 15px; }
.header-stats { margin-left: auto; display: flex; gap: 8px; }
.hstat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px; font-size: 11px; color: var(--text-sub);
  white-space: nowrap;
}
.hstat b { color: var(--primary); font-size: 13px; }

/* ---------- Main / Views ---------- */
.app-main { max-width: 1600px; margin: 0 auto; padding: 18px 24px 40px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to {opacity:1;transform:none;} }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  transition: all .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(13,148,136,.22);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-sub); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Graph toolbar ---------- */
.graph-toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 12px; margin-bottom: 14px;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-box {
  position: relative; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); height: 36px; min-width: 270px;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-ico { padding-left: 11px; color: var(--text-mute); font-size: 17px; }
.search-box input { border: none; outline: none; background: transparent; padding: 0 10px; flex: 1; height: 100%; }
.select-ctrl {
  height: 36px; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 0 10px; color: var(--text); outline: none;
}
.chk-ctrl { display: flex; align-items: center; gap: 5px; color: var(--text-sub); font-size: 12px; cursor: pointer; white-space: nowrap; }

/* ---------- Graph layout ---------- */
.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
.graph-panel, .side-panel, .record-card, .config-card, .exam-head {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.graph-panel { overflow: hidden; display: flex; flex-direction: column; }
.panel-head { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.panel-head h3 { font-size: 14px; font-weight: 700; }
.panel-hint { font-size: 11px; color: var(--text-mute); }
.panel-head-right { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px 12px; }
.graph-canvas-wrap { position: relative; height: 620px; background: radial-gradient(circle at 50% 40%, #fbfcff, #f1f5fb); overflow: hidden; }
.graph-svg { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-svg:active { cursor: grabbing; }
.graph-svg .edge { stroke: #cbd5e1; stroke-width: 1; opacity: .5; }
.graph-svg .edge.hl { stroke: var(--primary); stroke-width: 2; opacity: .9; }
.graph-svg .node { cursor: pointer; transition: opacity .2s; }
.graph-svg .node circle { stroke: #fff; stroke-width: 1.5; transition: all .15s; }
.graph-svg .node:hover circle { stroke: var(--text); stroke-width: 2.5; }
.graph-svg .node.selected circle { stroke: var(--primary); stroke-width: 3; }
.graph-svg .node text { font-size: 10px; fill: var(--text); pointer-events: none; text-anchor: middle; }
.graph-svg .node text.node-label {
  font-size: 11px; font-weight: 500; fill: #1e293b;
  paint-order: stroke fill; stroke: rgba(255,255,255,.94); stroke-width: 3px; stroke-linejoin: round;
  pointer-events: none; text-anchor: middle;
}
.graph-svg .node text.node-label.label-strong { font-size: 12px; font-weight: 700; fill: #0f172a; }
.graph-svg .node.dim { opacity: .12; }
.graph-legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: 60%; background: rgba(255,255,255,.85); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-sub); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.zoom-ctrl { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom-ctrl button { width: 32px; height: 32px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; font-size: 16px; color: var(--text-sub); box-shadow: var(--shadow); }
.zoom-ctrl button:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Side panel ---------- */
.side-panel { display: flex; flex-direction: column; gap: 14px; }
.selection-card, .point-detail-card, .module-list-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.selection-head h3 { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.sel-count { background: var(--primary); color: #fff; border-radius: 12px; padding: 1px 8px; font-size: 12px; }
.sel-max { color: var(--text-mute); font-size: 12px; }
.selected-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 60px; max-height: 132px; overflow-y: auto; margin: 12px 0; align-content: flex-start; }
.empty-hint { font-size: 12px; color: var(--text-mute); line-height: 1.8; width: 100%; text-align: center; padding-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary);
  border: 1px solid #dde3ff; border-radius: 16px; padding: 3px 6px 3px 10px; font-size: 11px; font-weight: 600;
}
.chip .chip-x { cursor: pointer; width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.chip .chip-x:hover { background: var(--primary); color: #fff; }
.point-detail-card { min-height: 100px; }
.detail-empty { color: var(--text-mute); font-size: 12px; text-align: center; padding: 20px 0; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.detail-head h4 { font-size: 14px; }
.detail-lv { font-size: 11px; color: var(--warn); background: var(--warn-soft); padding: 1px 7px; border-radius: 10px; white-space: nowrap; }
.detail-desc { font-size: 12px; color: var(--text-sub); line-height: 1.7; }
.detail-meta { font-size: 11px; color: var(--text-mute); margin-top: 8px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag { font-size: 10px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.tag-gaokao { background: #fef3c7; color: #b45309; }
.tag-weak { background: #fee2e2; color: #b91c1c; }
.tag-easy { background: #ffedd5; color: #c2410c; }
.tag-basic { background: #e0f2fe; color: #0369a1; }
.tag-method { background: #ede9fe; color: #6d28d9; }
.rel-points { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rel-chip { font-size: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; color: var(--text-sub); cursor: pointer; }
.rel-chip:hover { border-color: var(--primary); color: var(--primary); }
.module-list { max-height: 340px; overflow-y: auto; padding: 6px 0; }
.mod-group { border-bottom: 1px solid var(--border); }
.mod-group:last-child { border-bottom: none; }
.mod-title { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; font-weight: 700; cursor: pointer; user-select: none; }
.mod-title:hover { background: var(--surface-2); }
.mod-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.mod-badge { margin-left: auto; font-size: 10px; color: var(--text-mute); font-weight: 500; }
.mod-arrow { color: var(--text-mute); transition: transform .2s; font-size: 10px; }
.mod-group.collapsed .mod-arrow { transform: rotate(-90deg); }
.mod-group.collapsed .chapters { display: none; }
.chapter { padding: 4px 0; }
.chapter-name { font-size: 11px; color: var(--text-mute); padding: 3px 10px 3px 26px; font-weight: 600; }
.pt-item { display: flex; align-items: center; gap: 7px; padding: 3px 10px 3px 26px; font-size: 11px; cursor: pointer; border-radius: 6px; }
.pt-item:hover { background: var(--primary-soft); }
.pt-item input { accent-color: var(--primary); width: 13px; height: 13px; }
.pt-item .pt-name { flex: 1; }
.pt-item .pt-tag { font-size: 9px; }

/* ---------- Practice ---------- */
.practice-layout { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; align-items: start; }
.config-card { padding: 18px; position: sticky; top: 78px; }
.config-card h3 { font-size: 15px; margin-bottom: 16px; }
.config-section { padding: 12px 0; border-top: 1px solid var(--border); }
.config-section:first-of-type { border-top: none; padding-top: 0; }
.config-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-sub); margin-bottom: 10px; }
.badge { background: var(--primary-soft); color: var(--primary); border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.config-points { display: flex; flex-wrap: wrap; gap: 5px; max-height: 120px; overflow-y: auto; margin-bottom: 10px; }
.config-points .chip { font-size: 10px; }
.stepper { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.stepper button { width: 30px; height: 30px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; font-size: 17px; color: var(--text); }
.stepper button:hover { border-color: var(--primary); color: var(--primary); }
.stepper span { font-size: 20px; font-weight: 700; min-width: 30px; text-align: center; }
.config-section input[type=range] { width: 100%; accent-color: var(--primary); }
.radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.radio-group label { display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; }
.radio-group label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.radio-group input { accent-color: var(--primary); }
.config-tip { font-size: 11px; color: var(--text-mute); line-height: 1.6; margin-top: 10px; }

.exam-head { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.exam-head h2 { font-size: 17px; }
.muted { color: var(--text-mute); font-size: 12px; }
.exam-progress { display: flex; gap: 5px; }
.prog-dot { width: 24px; height: 6px; border-radius: 3px; background: var(--border); }
.prog-dot.done { background: var(--success); }
.prog-dot.current { background: var(--primary); }
.question-area { display: flex; flex-direction: column; gap: 14px; }
.exam-empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 70px 20px; text-align: center; }
.empty-illustration { font-size: 46px; color: #dbe2f0; font-style: italic; margin-bottom: 12px; }
.exam-empty h3 { font-size: 16px; margin-bottom: 6px; }
.exam-empty p { color: var(--text-mute); font-size: 13px; }

.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.q-index { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.q-num { background: var(--primary); color: #fff; border-radius: 7px; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.q-type-tag { font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-sub); }
.q-meta { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.q-meta .mini-tag { font-size: 9px; padding: 1px 6px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.q-stem { font-size: 15px; line-height: 1.9; margin-bottom: 16px; }
.q-options { display: flex; flex-direction: column; gap: 8px; }
.q-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
  transition: all .15s; background: var(--surface);
}
.q-option:hover { border-color: var(--primary); background: var(--primary-soft); }
.q-option .opt-key { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; background: var(--surface); }
.q-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.q-option.selected .opt-key { background: var(--primary); color: #fff; border-color: var(--primary); }
.q-option.correct { border-color: var(--success); background: var(--success-soft); }
.q-option.correct .opt-key { background: var(--success); color: #fff; border-color: var(--success); }
.q-option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.q-option.wrong .opt-key { background: var(--danger); color: #fff; border-color: var(--danger); }
.q-option.disabled { cursor: default; }
.q-option.disabled:hover { border-color: var(--border-strong); background: var(--surface); }
.q-options.multi .opt-key { border-radius: 6px; }
.multi-hint { margin-top: 8px; font-size: 12px; color: var(--text-sub); line-height: 1.6; }
.fill-input { width: 100%; max-width: 360px; padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; font-size: 15px; }
.fill-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.fill-input.correct { border-color: var(--success); background: var(--success-soft); }
.fill-input.wrong { border-color: var(--danger); background: var(--danger-soft); }
.q-actions { display: flex; gap: 8px; margin-top: 16px; }
.result-box { margin-top: 14px; border-radius: var(--radius-sm); padding: 14px; animation: fadeIn .2s; }
.result-correct { background: var(--success-soft); border: 1px solid #bbf7d0; }
.result-wrong { background: #fff7ed; border: 1px solid #fed7aa; }
.result-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.result-correct .result-title { color: var(--success); }
.result-wrong .result-title { color: var(--danger); }
.result-section { margin-top: 10px; font-size: 13px; line-height: 1.8; }
.result-section .rs-label { font-weight: 700; color: var(--text); display: block; margin-bottom: 2px; }
.diagnosis-reason { background: rgba(255,255,255,.7); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: 0 6px 6px 0; }
.diagnosis-tip { background: rgba(255,255,255,.7); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 6px 6px 0; margin-top: 6px; }
.solution-box { background: rgba(255,255,255,.75); border: 1px solid var(--border); padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.9; }
.solution-toggle { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 12px; user-select: none; }
.solve-hint { background: var(--primary-soft); border: 1px dashed #c7d2fe; border-radius: var(--radius-sm); padding: 14px; font-size: 13px; color: var(--primary); text-align: center; }
.solve-locked { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-size: 12px; color: var(--text-mute); text-align: center; margin-top: 12px; }
.lock-ico { font-size: 14px; }
.answer-highlight { background: rgba(13,148,136,.08); border-left: 3px solid var(--primary); padding: 8px 12px; border-radius: 0 6px 6px 0; font-weight: 700; }
.hints-box { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 10px 14px; border-radius: 0 6px 6px 0; font-size: 12px; line-height: 1.9; margin-top: 6px; }
.self-assess { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 12px; border-top: 1px dashed var(--border); }
.related-cta { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.related-cta .rel-label { font-size: 12px; color: var(--text-sub); }
.exam-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.exam-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.exam-summary h2 { font-size: 20px; margin-bottom: 8px; }
.score-big { font-size: 40px; font-weight: 800; color: var(--primary); }

/* ---------- Records ---------- */
.records-wrap { display: flex; flex-direction: column; gap: 16px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .sc-label { font-size: 12px; color: var(--text-sub); }
.stat-card .sc-value { font-size: 28px; font-weight: 800; margin-top: 4px; }
.stat-card .sc-sub { font-size: 11px; color: var(--text-mute); }
.records-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.record-card { overflow: hidden; }
.mastery-list, .wrong-list { max-height: 480px; overflow-y: auto; padding: 8px 0; }
.mastery-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.mastery-item:hover { background: var(--surface-2); }
.mastery-name { font-size: 12px; width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mastery-bar { flex: 1; height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.mastery-bar-fill { height: 100%; border-radius: 4px; }
.mastery-rate { font-size: 11px; color: var(--text-sub); width: 40px; text-align: right; }
.wrong-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.wrong-item:last-child { border-bottom: none; }
.wrong-q { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.wrong-reason { font-size: 11px; color: var(--danger); }
.wrong-meta { font-size: 10px; color: var(--text-mute); margin-top: 4px; }
.list-empty { text-align: center; color: var(--text-mute); padding: 40px 20px; font-size: 13px; }

/* ---------- 用户区 ---------- */
.header-install-btn {
  margin-left: 10px; flex: 0 0 auto; cursor: pointer;
  border: 1px solid var(--primary); background: var(--primary-soft); color: var(--primary);
  border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.header-install-btn:hover { background: var(--primary); color: #fff; }
.user-area { margin-left: 8px; display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 7px; background: var(--primary-soft);
  border: 1px solid #dde3ff; border-radius: 20px; padding: 4px 6px 4px 5px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #4338ca); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-name { font-size: 12px; font-weight: 700; color: var(--primary); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-switch { border: none; background: transparent; color: var(--text-mute); font-size: 11px; padding: 2px 6px; border-radius: 10px; }
.user-switch:hover { background: #dde3ff; color: var(--primary); }

/* ---------- 登录弹层 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f7fb 45%, #e0f2fe 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-overlay.hidden { display: none; }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 38px 34px 30px; text-align: center; animation: loginIn .35s ease;
}
@keyframes loginIn { from { opacity:0; transform: translateY(16px) scale(.98);} to {opacity:1;transform:none;} }
.login-logo {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary), #4338ca); color: #fff;
  font-size: 34px; font-weight: 600; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(13,148,136,.3);
}
.login-card h1 { font-size: 19px; margin-bottom: 8px; }
.login-sub { color: var(--text-sub); font-size: 12px; margin-bottom: 24px; line-height: 1.7; }
.login-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border-strong);
  border-radius: 10px; outline: none; font-size: 15px; text-align: center; margin-bottom: 14px;
}
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-recent { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 16px; }
.login-recent:empty { display: none; }
.recent-label { width: 100%; font-size: 11px; color: var(--text-mute); margin-bottom: 2px; }
.recent-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px;
  padding: 4px 12px; font-size: 12px; color: var(--text-sub); cursor: pointer;
}
.recent-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.login-foot { font-size: 11px; color: var(--text-mute); margin-top: 18px; }

/* ---------- 分学期选择 ---------- */
.stage-select { border-color: var(--primary); color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.stage-config-section { background: var(--surface-2); margin: 0 -18px; padding: 12px 18px; border-top: none !important; }
.stage-note { font-size: 10px; color: var(--text-mute); font-weight: 400; }
.stage-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.stage-tab {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-sub);
  padding: 5px 10px; border-radius: 16px; font-size: 11px; font-weight: 600; transition: all .15s;
}
.stage-tab:hover { border-color: var(--primary); color: var(--primary); }
.stage-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.stage-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.stage-hint { font-size: 10px; color: var(--text-mute); margin-top: 8px; line-height: 1.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--text); color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- PWA 安装引导条 ---------- */
.hidden { display: none !important; }
.install-bar {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 1500; display: flex; align-items: center; gap: 10px;
  width: calc(100% - 32px); max-width: 440px;
  padding: 11px 12px; box-sizing: border-box;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  box-shadow: 0 10px 34px rgba(30, 41, 90, .18);
  animation: installIn .35s ease both;
}
@keyframes installIn { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.install-ico {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, #4f7cff, #2b48c4); color: #fff;
  font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.install-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.install-txt b { font-size: 14px; color: #1e293b; }
.install-txt span { font-size: 11px; color: #64748b; }
.install-btn {
  flex: 0 0 auto; border: 0; border-radius: 9px; padding: 8px 15px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.install-btn:hover { background: var(--primary-dark); }
.install-close {
  flex: 0 0 auto; border: 0; background: transparent; color: #94a3b8;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.install-close:hover { color: #475569; }

/* ---------- 安装引导弹窗 ---------- */
.im-mask {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; box-sizing: border-box;
}
.im-card {
  position: relative; width: 100%; max-width: 420px;
  background: #fff; border-radius: 20px; padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
  text-align: center; animation: imPop .3s ease both;
}
@keyframes imPop { from { opacity: 0; transform: scale(.92) translateY(12px); } to { opacity: 1; transform: none; } }
.im-close {
  position: absolute; top: 12px; right: 14px; border: 0; background: transparent;
  color: #94a3b8; font-size: 26px; line-height: 1; cursor: pointer; padding: 2px 6px;
}
.im-close:hover { color: #475569; }
.im-logo {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 15px;
  background: linear-gradient(135deg, #0d9488, #059669); color: #fff;
  font-size: 34px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .32);
}
.im-card h2 { margin: 0 0 6px; font-size: 20px; color: #1e293b; }
.im-browser { margin: 0 0 16px; font-size: 12px; color: #64748b; }
.im-steps { text-align: left; display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.im-step {
  display: flex; align-items: flex-start; gap: 11px;
  background: #f8fafc; border: 1px solid #eef2f7; border-radius: 12px;
  padding: 11px 13px; font-size: 14px; color: #334155; line-height: 1.55;
}
.im-num {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.im-tip {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  border-radius: 10px; padding: 9px 12px; font-size: 12px; line-height: 1.5; text-align: left;
}
.im-actions { display: flex; gap: 10px; margin-top: 18px; }
.im-copy, .im-primary {
  flex: 1; border-radius: 10px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.im-copy { border: 1px solid var(--border); background: #fff; color: #475569; }
.im-copy:hover { border-color: var(--primary); color: var(--primary); }
.im-primary { border: 0; background: var(--primary); color: #fff; }
.im-primary:hover { background: var(--primary-dark); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .graph-layout { grid-template-columns: 1fr; }
  .side-panel { flex-direction: row; flex-wrap: wrap; }
  .side-panel > * { flex: 1; min-width: 280px; }
  .practice-layout { grid-template-columns: 1fr; }
  .config-card { position: static; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .records-grid { grid-template-columns: 1fr; }
}

/* ============ 手机适配：字号放大 + 触摸优化 ============ */
@media (max-width: 720px) {
  /* 基础字号放大，行高更舒适 */
  body { font-size: 16px; line-height: 1.7; }

  /* —— Header —— */
  .header-inner { flex-wrap: wrap; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; }
  .brand-sub { display: none; }
  .brand-icon { width: 38px; height: 38px; font-size: 22px; }
  .brand-title { font-size: 17px; }
  .header-stats { margin-left: auto; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
  .hstat { font-size: 12px; padding: 4px 9px; }
  .hstat b { font-size: 14px; }
  .header-install-btn { margin-left: 4px; padding: 9px 12px; font-size: 14px; }
  .nav-tabs { order: 3; width: 100%; margin-left: 0; justify-content: space-between; gap: 3px; }
  .nav-tab { flex: 1; justify-content: center; padding: 11px 3px; font-size: 14px; }
  .nav-ico { font-size: 16px; }
  .user-name { font-size: 14px; }
  .user-switch { font-size: 13px; }
  .user-avatar { width: 30px; height: 30px; font-size: 14px; }

  /* —— 主体留白 —— */
  .app-main { padding: 14px 14px 40px; }

  /* —— 按钮 / 输入框：触摸目标放大，输入字号≥16px 防 iOS 自动缩放 —— */
  .btn { font-size: 15px; padding: 11px 16px; }
  .btn-sm { font-size: 14px; padding: 8px 12px; }
  .btn-lg { font-size: 16px; padding: 12px 16px; }
  input, select, textarea { font-size: 16px; }
  .search-box { min-width: 0; width: 100%; height: 44px; }
  .search-box input { font-size: 16px; }
  .select-ctrl { height: 44px; font-size: 16px; }
  .chk-ctrl { font-size: 14px; }
  .graph-toolbar { gap: 10px; }

  /* —— 图谱页 —— */
  .graph-canvas-wrap { height: 440px; }
  .panel-head { padding: 14px 16px; }
  .panel-head h3 { font-size: 16px; }
  .panel-head-right { width: 100%; justify-content: flex-start; }
  .panel-hint { font-size: 13px; }
  .graph-legend { max-width: calc(100% - 70px); }
  .legend-item { font-size: 12px; }
  .zoom-ctrl button { width: 38px; height: 38px; font-size: 18px; }

  /* —— 选点侧栏 —— */
  .side-panel { flex-direction: column; }
  .side-panel > * { min-width: 0; width: 100%; }
  .selection-head h3, .config-card h3 { font-size: 17px; }
  .sel-count, .sel-max { font-size: 14px; }
  .empty-hint { font-size: 14px; }
  .chip { font-size: 14px; padding: 6px 9px 6px 13px; }
  .chip .chip-x { width: 20px; height: 20px; font-size: 14px; }
  .detail-head h4 { font-size: 16px; }
  .detail-lv { font-size: 13px; }
  .detail-desc { font-size: 15px; }
  .detail-meta { font-size: 13px; }
  .tag { font-size: 12px; padding: 2px 9px; }
  .rel-chip { font-size: 13px; padding: 3px 10px; }
  .mod-title { font-size: 15px; padding: 11px 10px; }
  .mod-badge, .mod-arrow { font-size: 12px; }
  .chapter-name { font-size: 14px; padding: 6px 10px 6px 24px; }
  .pt-item { font-size: 15px; padding: 9px 10px 9px 24px; }
  .pt-item input { width: 18px; height: 18px; }
  .pt-item .pt-tag { font-size: 11px; }

  /* —— 出题配置 —— */
  .config-card { padding: 16px; }
  .config-section { padding: 14px 0; }
  .config-label { font-size: 15px; }
  .badge { font-size: 13px; }
  .stage-note, .stage-hint, .config-tip { font-size: 13px; }
  .stage-tab { font-size: 14px; padding: 9px 13px; }
  .config-points .chip { font-size: 13px; }
  .stepper button { width: 38px; height: 38px; font-size: 20px; }
  .stepper span { font-size: 22px; }
  .radio-group label { font-size: 14px; padding: 10px; }

  /* —— 题目区（重点放大） —— */
  .exam-head { padding: 16px; flex-wrap: wrap; gap: 8px; }
  .exam-head h2 { font-size: 19px; }
  .muted, .rel-label { font-size: 14px; }
  .exam-empty h3 { font-size: 18px; }
  .exam-empty p { font-size: 15px; }
  .q-card { padding: 16px; }
  .q-index { font-size: 15px; }
  .q-num { width: 30px; height: 30px; font-size: 15px; }
  .q-type-tag { font-size: 12px; padding: 3px 10px; }
  .q-meta .mini-tag { font-size: 11px; padding: 2px 8px; }
  .q-stem { font-size: 17px; line-height: 1.95; }
  .q-option { padding: 14px 14px; font-size: 16px; }
  .q-option .opt-key { width: 26px; height: 26px; font-size: 14px; }
  .fill-input { font-size: 16px; padding: 12px 14px; max-width: 100%; }
  .result-title { font-size: 16px; }
  .result-section, .solution-box { font-size: 15px; line-height: 1.85; }
  .diagnosis-reason, .diagnosis-tip { font-size: 15px; }
  .answer-highlight { font-size: 15px; }
  .hints-box { font-size: 14px; }
  .solve-hint { font-size: 15px; }
  .solution-toggle { font-size: 14px; }
  .related-cta .btn, .self-assess .btn { font-size: 14px; }
  .exam-summary h2 { font-size: 22px; }

  /* —— 记录页 —— */
  .stat-card { padding: 14px; }
  .stat-card .sc-label { font-size: 14px; }
  .stat-card .sc-value { font-size: 30px; }
  .stat-card .sc-sub { font-size: 13px; }
  .mastery-name { font-size: 14px; width: 96px; }
  .mastery-rate { font-size: 13px; width: 42px; }
  .wrong-q { font-size: 15px; }
  .wrong-reason { font-size: 14px; }
  .wrong-meta { font-size: 12px; }
  .list-empty { font-size: 14px; }

  /* —— 登录弹层 —— */
  .login-card { padding: 30px 22px 24px; }
  .login-card h1 { font-size: 21px; }
  .login-sub { font-size: 14px; }
  .login-input { font-size: 16px; }
  .recent-label, .login-foot { font-size: 13px; }
  .recent-chip { font-size: 14px; padding: 6px 14px; }

  /* —— 安装引导 —— */
  .install-txt b { font-size: 15px; }
  .install-txt span { font-size: 12px; }
  .im-card h2 { font-size: 21px; }
  .im-step { font-size: 15px; }
  .im-tip { font-size: 13px; }
  .im-copy, .im-primary { font-size: 15px; }
}

/* 超窄屏（≤360px）进一步收紧 */
@media (max-width: 360px) {
  .hstat { display: none; }
  .stage-tab { font-size: 13px; padding: 8px 10px; }
  .q-stem { font-size: 16px; }
  .q-option { font-size: 15px; }
}
