:root {
  --bg: #0f1117;
  --bg-soft: #171a23;
  --bg-card: #1d2130;
  --bg-raise: #232838;
  --border: #2a3040;
  --text: #e6e9f0;
  --text-dim: #9aa3b8;
  --text-faint: #6b7488;
  --primary: #4f8cff;
  --primary-soft: rgba(79, 140, 255, .12);
  --green: #2ecc71;
  --green-soft: rgba(46, 204, 113, .14);
  --red: #ff5c5c;
  --red-soft: rgba(255, 92, 92, .14);
  --amber: #ffb020;
  --amber-soft: rgba(255, 176, 32, .14);
  --purple: #b07cff;
  --purple-soft: rgba(176, 124, 255, .14);
  --radius: 12px;

  /* 三大类配色 */
  --c-create: #2ecc71;
  --c-struct: #4f8cff;
  --c-behav: #ffb020;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 10px;
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
  color: #fff;
  flex-shrink: 0;
}

.brand h1 { font-size: 17px; font-weight: 600; letter-spacing: .3px; }
.brand .sub { font-size: 12px; color: var(--text-faint); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.tab {
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13.5px;
  cursor: pointer;
  transition: all .16s;
  font-family: inherit;
}
.tab:hover { border-color: #3d4763; color: var(--text); }
.tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}

/* 指向独立页面的导航项（课后习题册） */
.tab-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: rgba(99,102,241,.16);
  border-color: var(--primary);
  color: #a5b4fc;
  font-weight: 600;
}
.tab-link:hover { background: rgba(99,102,241,.28); color: #c7d2fe; }

/* ---------- 全局进度 ---------- */
.global-progress {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-faint);
}
.gp-bar {
  flex: 1; height: 5px;
  background: var(--bg-card);
  border-radius: 3px; overflow: hidden;
  max-width: 420px;
}
.gp-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green), var(--primary));
  border-radius: 3px;
  transition: width .4s ease;
}

/* ---------- 视图容器 ---------- */
main { flex: 1; display: flex; min-height: 0; }
.view { display: none; width: 100%; }
.view.active { display: flex; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 118px);
  position: sticky;
  top: 118px;
}

.search-box { padding: 12px; border-bottom: 1px solid var(--border); }
.search-box input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.chapter-list { flex: 1; overflow-y: auto; padding: 8px 0 24px; }

.chapter-group { margin-bottom: 4px; }

.cat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.cat-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cat-count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 6px;
}

.mode-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 18px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .14s;
  font-size: 13.5px;
}
.mode-item:hover { background: var(--bg-card); }
.mode-item.active {
  background: var(--primary-soft);
  border-left-color: var(--primary);
  color: var(--primary);
}
.ch-num {
  font-size: 11px;
  color: var(--text-faint);
  font-family: ui-monospace, Consolas, monospace;
  min-width: 22px;
}
.mode-item.active .ch-num { color: var(--primary); }
.mode-name { flex: 1; }
.mode-cn { font-size: 11.5px; color: var(--text-faint); }
.mode-item.done .mode-name::after {
  content: "✓";
  color: var(--green);
  font-size: 12px;
  margin-left: 6px;
}

/* ---------- 内容区 ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  height: calc(100vh - 118px);
  padding: 28px 36px 80px;
  max-width: 1180px;
}

.empty-state {
  text-align: center;
  padding: 100px 20px;
  color: var(--text-faint);
}
.empty-icon { font-size: 44px; margin-bottom: 16px; opacity: .5; }
.empty-state h2 { font-size: 18px; color: var(--text-dim); margin-bottom: 10px; font-weight: 500; }
.empty-state p { font-size: 13.5px; margin-bottom: 6px; }
.empty-state .tip { font-size: 12.5px; color: var(--text-faint); margin-top: 14px; }

/* ---------- 模式详情 ---------- */
.mode-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 24px;
}
.mode-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  font-weight: 500;
}
.badge-create { background: var(--green-soft); color: var(--c-create); }
.badge-struct { background: var(--primary-soft); color: var(--c-struct); }
.badge-behav  { background: var(--amber-soft); color: var(--c-behav); }

.mode-header h2 {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.mode-header h2 .en {
  font-size: 15px;
  color: var(--text-faint);
  font-weight: 400;
  margin-left: 10px;
  font-family: ui-monospace, Consolas, monospace;
}
.mode-meta {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 10px;
}
.mode-meta span b { color: var(--text-dim); font-weight: 500; }

.intent-box {
  background: var(--bg-card);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin: 18px 0 0;
  font-size: 14.5px;
  color: var(--text);
}

/* ---------- 三个板块 tab ---------- */
.panel-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 28px 0 0;
}
.panel-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  margin-bottom: -1px;
}
.panel-tab:hover { color: var(--text-dim); }
.panel-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}
.panel-tab .cnt {
  font-size: 11px;
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  color: var(--text-faint);
}

.panel { display: none; padding-top: 24px; }
.panel.active { display: block; }

/* ---------- 通用小节 ---------- */
.sec {
  margin-bottom: 32px;
}
.sec-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}
.sec-title::before {
  content: "";
  width: 3px; height: 17px;
  background: var(--primary);
  border-radius: 2px;
}
.sec-title .hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-faint);
  margin-left: auto;
}

.prose { font-size: 14.5px; line-height: 1.85; color: #d2d8e6; }
.prose p { margin-bottom: 12px; }
.prose b, .prose strong { color: var(--text); font-weight: 600; }
.prose code {
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.8px;
  color: #8ec5ff;
}
.prose ul, .prose ol { margin: 10px 0 14px 22px; }
.prose li { margin-bottom: 7px; }

/* 角色表 */
.role-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 12px 0;
}
.role-table th {
  text-align: left;
  padding: 9px 12px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
.role-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(42, 48, 64, .6);
  vertical-align: top;
}
.role-table tr:last-child td { border-bottom: none; }
.role-table td:first-child { color: #8ec5ff; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.role-table td:nth-child(2) { color: var(--text-dim); }

/* ---------- UML 容器 ---------- */
.uml-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow-x: auto;
  margin-bottom: 14px;
}
.uml-box .uml-svg { display: block; margin: 0 auto; }
.uml-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  justify-content: center;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
}
.uml-legend b { color: var(--text-dim); font-size: 13px; margin-right: 3px; }

.uml-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-bottom: 8px;
}

/* ---------- 代码块 ---------- */
.code-box {
  background: #12151d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  font-family: ui-monospace, Consolas, monospace;
}
.code-head .lang {
  margin-left: auto;
  background: var(--bg-raise);
  padding: 1px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  letter-spacing: .5px;
}
.code-box pre {
  padding: 14px 16px;
  overflow-x: auto;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 12.8px;
  line-height: 1.75;
  color: #c8d0e0;
}
/* 极简语法高亮 */
.tk-kw { color: #c792ea; }
.tk-str { color: #c3e88d; }
.tk-cmt { color: #5c6784; font-style: italic; }
.tk-type { color: #82aaff; }
.tk-num { color: #f78c6c; }
.tk-ann { color: #ffcb6b; }

/* ---------- 课后题 ---------- */
.q-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.q-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.q-no {
  flex-shrink: 0;
  font-size: 11.5px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--amber);
  background: var(--amber-soft);
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 2px;
}
.q-text { flex: 1; font-size: 14px; color: var(--text); }
.q-page {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  margin-top: 3px;
}
.q-body { padding: 16px 18px; }

.a-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--primary-soft);
  border: 1px solid rgba(79, 140, 255, .35);
  border-radius: 8px;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.a-toggle:hover { background: rgba(79, 140, 255, .2); }
.a-toggle.open { background: transparent; border-color: var(--border); color: var(--text-faint); }

.a-body {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.a-body.show { display: block; }

/* ===== 课后练习：题干 + 答案全部直出 ===== */
.ex-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 10px;
}
.ex-bar-txt { flex: 1; font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.ex-bar-txt b { color: var(--amber); }

/* 题干里的代码块 / 多行文本 */
.q-text p { margin: 0 0 8px; line-height: 1.85; }
.q-text p:last-child { margin-bottom: 0; }
.q-text .code-box { margin: 10px 0 4px; }
.q-text ol, .q-text ul { margin: 6px 0 8px; padding-left: 22px; }
.q-text li { line-height: 1.8; margin: 3px 0; }

.ans-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600;
  color: var(--green);
  letter-spacing: .02em;
}
.ans-title::before {
  content: '✓'; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--green-soft); color: var(--green);
  font-size: 11px;
}
.ans-title .a-toggle { margin-left: auto; }
.a-toggle.sm { padding: 3px 10px; font-size: 12px; }
.a-body.show { margin-top: 10px; padding-top: 12px; }

/* 答案分区：思路 / 步骤 / 关键点 各自成块，互不挤在一起 */
.ans-sec { margin: 0 0 14px; }
.ans-sec:last-child { margin-bottom: 0; }
.ans-sec > b {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--primary);
  padding: 1px 8px;
  background: var(--primary-soft);
  border-radius: 5px;
}
.ans-sec > p { margin: 0 0 7px; line-height: 1.9; }
.ans-sec > p:last-child { margin-bottom: 0; }
.ans-sec > ul, .ans-sec > ol { margin: 0 0 7px; padding-left: 22px; }
.ans-sec li { line-height: 1.85; margin: 4px 0; }
.ans-sec-key > b { color: var(--amber); background: var(--amber-soft); }
.ans-sec-key {
  padding: 12px 14px;
  background: rgba(255, 180, 84, .06);
  border-left: 2px solid var(--amber);
  border-radius: 0 8px 8px 0;
}

.ans-steps { margin: 0; padding-left: 20px; }
.ans-steps li { line-height: 1.85; margin: 5px 0; }
.ans-steps li::marker { color: var(--primary); font-weight: 600; }

/* ---------- 我的新题 ---------- */
.empty-panel {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-faint);
}
.empty-panel .icon { font-size: 32px; opacity: .45; margin-bottom: 12px; }
.empty-panel h3 { font-size: 15px; color: var(--text-dim); font-weight: 500; margin-bottom: 8px; }
.empty-panel p { font-size: 13px; margin-bottom: 4px; }
.empty-panel code {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 12px;
  color: #8ec5ff;
}

/* ---------- 真题 ---------- */
.exam-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 36px 90px;
  width: 100%;
}
.exam-hero {
  background: linear-gradient(135deg, rgba(79,140,255,.13), rgba(176,124,255,.1));
  border: 1px solid #33395a;
  border-radius: 14px;
  padding: 26px 28px;
  margin-bottom: 30px;
}
.exam-hero h2 { font-size: 24px; margin-bottom: 8px; font-weight: 600; }
.exam-hero .desc { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }
.exam-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.fact {
  background: rgba(15,17,23,.5);
  border-radius: 9px;
  padding: 11px 14px;
}
.fact .k { font-size: 11px; color: var(--text-faint); margin-bottom: 3px; }
.fact .v { font-size: 15px; font-weight: 600; color: var(--primary); }

.exam-sec { margin-bottom: 34px; }
.exam-sec > h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px;
}
.exam-sec > .subtitle {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 16px;
  padding-left: 2px;
}
.score-tag {
  font-size: 11.5px;
  background: var(--amber-soft);
  color: var(--amber);
  padding: 2px 9px;
  border-radius: 6px;
  font-weight: 500;
}

/* 真题选择题 */
.mcq-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.mcq-q { display: flex; gap: 10px; margin-bottom: 12px; font-size: 14px; }
.mcq-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--bg-raise);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
  margin-top: 2px;
}
.mcq-opts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.mcq-opt {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-dim);
  transition: all .15s;
}
.mcq-opt:hover { border-color: #3d4763; color: var(--text); }
.mcq-opt.correct {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  font-weight: 500;
}
.mcq-opt.wrong {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}
.mcq-exp {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.75;
}
.mcq-exp.show { display: block; }
.mcq-exp b { color: var(--green); }

/* ---------- 全景观测 ---------- */
.map-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 36px 90px;
  width: 100%;
}
.map-intro { margin-bottom: 28px; }
.map-intro h2 { font-size: 22px; margin-bottom: 8px; font-weight: 600; }
.map-intro p { font-size: 14px; color: var(--text-dim); }

.cat-block { margin-bottom: 34px; }
.cat-block-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.cat-block-head h3 { font-size: 17px; font-weight: 600; }
.cat-block-head .n {
  font-size: 12px;
  color: var(--text-faint);
  background: var(--bg-card);
  padding: 2px 9px;
  border-radius: 8px;
}
.cat-block-head .note { font-size: 12.5px; color: var(--text-faint); margin-left: auto; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 12px;
}
.mode-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  cursor: pointer;
  transition: all .18s;
  border-top: 2px solid transparent;
}
.mode-card:hover {
  background: var(--bg-card);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.mode-card.create { border-top-color: var(--c-create); }
.mode-card.struct { border-top-color: var(--c-struct); }
.mode-card.behav  { border-top-color: var(--c-behav); }
.mode-card.done { opacity: .55; }

.mc-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.mc-ch { font-size: 11px; color: var(--text-faint); font-family: ui-monospace, monospace; }
.mc-name { font-size: 15px; font-weight: 600; }
.mc-en { font-size: 11px; color: var(--text-faint); font-family: ui-monospace, monospace; margin-bottom: 8px; }
.mc-intent { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }

/* ---------- 底部 ---------- */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  flex-wrap: wrap;
  gap: 10px;
}
.link-btn {
  background: none; border: none;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.link-btn:hover { color: var(--red); }

/* ---------- 通用按钮 ---------- */
.btn {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-family: inherit;
  transition: all .15s;
}
.btn:hover { border-color: #3d4763; color: var(--text); }
.btn.primary { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.btn.primary:hover { background: rgba(79,140,255,.22); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 12px; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2f3648; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3d455c; }

/* ---------- 实验作业 ---------- */
.hw-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 36px 90px;
  width: 100%;
}

.hw-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.hw-tab {
  flex: 1 1 190px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 15px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-dim);
  transition: all .16s;
}
.hw-tab:hover { border-color: #3d4763; }
.hw-tab b { font-size: 13.5px; color: var(--text); font-weight: 600; }
.hw-tab span { font-size: 12.5px; }
.hw-tab i {
  font-style: normal;
  font-size: 11px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
}
.hw-tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.hw-tab.active b, .hw-tab.active span { color: var(--primary); }

.hw-lab { display: none; }
.hw-lab.active { display: block; }

.hw-lab-head {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
}
.hw-lab-head h3 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.hw-lab-meta { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.hw-lab-meta b { color: var(--text); }

.hw-warn {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--amber-soft);
  border-left: 2px solid var(--amber);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: #ffd591;
  line-height: 1.75;
}
.hw-warn b { color: var(--amber); }

.hw-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 14px;
}
.hw-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.hw-no {
  font-size: 11.5px;
  font-family: ui-monospace, Consolas, monospace;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
.hw-name { font-size: 15px; font-weight: 600; flex: 1; min-width: 200px; }
.hw-pats { display: flex; gap: 6px; flex-wrap: wrap; }
.pat-chip {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--pc, var(--border));
  color: var(--pc, var(--text-dim));
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.pat-chip:hover { background: rgba(255, 255, 255, .06); }
.pat-chip.plain {
  color: var(--text-faint);
  border-color: var(--border);
  cursor: default;
}

.hw-scene {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.8;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-left: 2px solid var(--border);
  border-radius: 0 8px 8px 0;
  margin-bottom: 14px;
}

.hw-points { font-size: 14px; color: #d2d8e6; line-height: 1.85; }
.hw-sub {
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.hw-points ol { margin: 0 0 4px 22px; }
.hw-points li { margin-bottom: 6px; }

.hw-pit {
  margin-top: 12px;
  padding: 9px 14px;
  background: var(--red-soft);
  border-radius: 8px;
  font-size: 13px;
  color: #ffb4b4;
  line-height: 1.75;
}
.hw-pit b { color: var(--red); }

/* 参考代码折叠块 */
.hw-ref {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f131b;
  overflow: hidden;
}
.hw-ref > summary {
  cursor: pointer;
  padding: 11px 15px;
  font-size: 13.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  list-style: none;
}
.hw-ref > summary::-webkit-details-marker { display: none; }
.hw-ref > summary::before {
  content: '▸';
  color: var(--text-faint);
  font-size: 11px;
  transition: transform .15s;
}
.hw-ref[open] > summary::before { transform: rotate(90deg); }
.hw-ref > summary:hover { color: var(--text); background: rgba(255,255,255,.02); }
.hw-ref-ico { font-size: 14px; }
.hw-ref-meta {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 400;
}
.hw-ref-body { padding-top: 0; }
.hw-ref-file {
  padding: 6px 15px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  color: var(--primary);
  background: #12161f;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  letter-spacing: .2px;
}
.hw-ref .code-box {
  margin: 0 !important;
  border: 0;
  border-radius: 0;
  background: #10141c;
}
.hw-ref .code-box pre { padding: 11px 15px; font-size: 12.4px; }
.hw-ref-note {
  padding: 10px 15px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  background: #0d1117;
}
.hw-ref-note a { color: var(--primary); text-decoration: none; }
.hw-ref-note a:hover { text-decoration: underline; }

/* ---------- 笔记精要 ---------- */
.notes-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 36px 90px;
  width: 100%;
}
.notes-credit {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.7;
}
.notes-sec { margin-top: 38px; }
.notes-sec-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 10px;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
  line-height: 1.3;
}
.notes-sec > p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.8;
  margin-bottom: 16px;
}
.notes-sub-title {
  margin: 18px 0 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--oc);
  display: flex;
  align-items: center;
  gap: 8px;
}
.notes-sub-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.notes-grid { display: grid; gap: 12px; }
.notes-notation { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.notes-relations { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.notes-contrasts { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.notes-oneliners { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.notes-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: #d2d8e6;
}
.notes-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.notes-card-body { font-size: 13px; }
.notes-card-body ol { margin: 0 0 0 20px; }
.notes-card-body li { margin-bottom: 6px; }
.notes-card-body li:last-child { margin-bottom: 0; }
.notes-card-rule {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}
.notes-card-rule .hw-sub {
  display: inline-block;
  margin-right: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
}

/* 关系卡 */
.notes-rel {
  border-left: 3px solid var(--rc);
  display: flex;
  flex-direction: column;
}
.notes-s {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--rc);
  font-family: ui-monospace, Consolas, monospace;
}
.notes-name { font-size: 14.5px; }
.notes-en {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
  font-family: ui-monospace, Consolas, monospace;
}
.notes-rel .nv { margin-bottom: 7px; }
.notes-rel .nv:last-child { margin-bottom: 0; }
.notes-rel .nv b {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--bg-raise);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  vertical-align: 1px;
}
.notes-rel .nv.trap b { background: var(--red-soft); color: var(--red); }
.notes-rel .uml-box {
  margin-top: 12px;
  padding: 6px;
  background: #14171f;
  border-radius: 8px;
}

/* 辨析卡 */
.notes-contrast { display: flex; flex-direction: column; }
.notes-tag {
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
}
.notes-tag.extra { background: var(--purple-soft); color: var(--purple); }
.notes-tag.plain {
  background: var(--bg-raise);
  color: var(--text-faint);
  margin-left: auto;
  font-weight: 400;
}
.notes-ct-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 9px;
  line-height: 1.5;
}
.notes-punch {
  margin-top: 11px;
  padding: 9px 13px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #cdd8f5;
  line-height: 1.7;
}

/* 一句话卡 */
.notes-oneliner {
  border-top: 2px solid var(--oc);
  padding: 11px 14px;
}
.notes-oneliner .notes-card-head { margin-bottom: 6px; }
.notes-pat {
  color: var(--oc);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.notes-pat:hover { text-decoration: underline; }
.notes-oneliner .notes-card-body {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.75;
}

/* 底部提示条 */
.notes-callout {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.8;
}
.notes-callout b { color: var(--amber); margin-right: 6px; }

@media (max-width: 720px) {
  .notes-wrap { padding: 20px 16px 70px; }
  .notes-relations, .notes-contrasts { grid-template-columns: 1fr; }
}

/* ---------- 设计原则 ---------- */
.pr-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 36px 90px;
  width: 100%;
}

.pr-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.pr-nav-btn {
  padding: 9px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .16s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pr-nav-btn:hover { border-color: #3d4763; color: var(--text); }
.pr-nav-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.pr-nav-btn span {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 8px;
}

.pr-group { display: none; }
.pr-group.active { display: block; }

.pr-group-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.pr-group-head h3 { font-size: 18px; font-weight: 600; }
.pr-note { font-size: 13px; color: var(--text-dim); }
.pr-src {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
  margin-left: auto;
}

.pr-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 14px;
}
.pr-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.pr-idx {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-family: ui-monospace, monospace;
  flex-shrink: 0;
}
.pr-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pr-title b { font-size: 16px; font-weight: 600; }
.pr-title i {
  font-style: normal;
  font-size: 12px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
}
.pr-core {
  font-size: 14px;
  color: #9fd8ff;
  background: rgba(79, 140, 255, .08);
  border-left: 2px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 9px 14px;
  margin-bottom: 12px;
  line-height: 1.7;
}
.pr-points {
  font-size: 14px;
  color: #d2d8e6;
  line-height: 1.85;
  margin: 0 0 0 20px;
}
.pr-points li { margin-bottom: 8px; }

.pr-map {
  margin-top: 34px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.pr-map-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.pr-map-head h3 { font-size: 17px; font-weight: 600; }
.pr-map-head span { font-size: 12.5px; color: var(--text-faint); }

.pr-map-row {
  display: grid;
  grid-template-columns: 150px 1fr 220px;
  gap: 14px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
}
.pr-map-row:last-child { border-bottom: none; }
.pm-left { font-size: 13.5px; color: var(--amber); font-weight: 500; }
.pm-mid { display: flex; gap: 6px; flex-wrap: wrap; }
.pm-right { font-size: 12.5px; color: var(--text-faint); line-height: 1.6; }

/* ---------- 习题精讲 ---------- */
.quiz-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 36px 90px;
  width: 100%;
}
.qz-sec-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
  margin: 26px 0 16px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.qz-sec-title::before {
  content: "";
  width: 3px; height: 17px;
  background: var(--primary);
  border-radius: 2px;
}
.qz-sec-title .cnt {
  font-size: 11.5px;
  font-family: ui-monospace, monospace;
  background: var(--bg-card);
  color: var(--text-faint);
  padding: 1px 8px;
  border-radius: 8px;
  font-weight: 400;
}

.fill-ans {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.fill-line {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  color: #c3e88d;
  line-height: 1.95;
  border-bottom: 1px dashed rgba(255, 255, 255, .05);
}
.fill-line:last-child { border-bottom: none; }

/* ---------- 我的新题：原题 / 思考过程 / 答案类图 ---------- */
.orig-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: 8px;
  padding: 12px 16px 14px;
  margin-bottom: 14px;
}
.orig-label {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--purple);
  background: var(--purple-soft);
  padding: 1px 8px;
  border-radius: 5px;
  margin-bottom: 8px;
  font-family: ui-monospace, Consolas, monospace;
}
.orig-box p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 8px;
  text-indent: 2em;
}
.orig-box p:last-child { margin-bottom: 0; }

.think-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 12px 16px 14px 14px;
  margin-bottom: 16px;
}
.think-label {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 1px 8px;
  border-radius: 5px;
  margin-bottom: 8px;
  font-family: ui-monospace, Consolas, monospace;
}
.think-list {
  margin: 0;
  padding-left: 22px;
  counter-reset: th;
  list-style: none;
}
.think-list li {
  position: relative;
  font-size: 13.8px;
  line-height: 1.8;
  color: var(--text-dim);
  margin-bottom: 9px;
  padding-left: 4px;
}
.think-list li::before {
  counter-increment: th;
  content: counter(th);
  position: absolute;
  left: -21px;
  top: 3px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
  display: flex; align-items: center; justify-content: center;
}
.think-list li:last-child { margin-bottom: 0; }

.ans-uml {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.ans-uml:empty { display: none; }
.ans-uml svg { display: block; margin: 0 auto; }

@media (max-width: 900px) {
  .sidebar { width: 210px; }
  .content { padding: 20px 18px 70px; }
  .mode-header h2 { font-size: 22px; }
  .exam-wrap, .map-wrap, .hw-wrap, .pr-wrap, .quiz-wrap { padding: 20px 18px 70px; }
  .hw-wrap { height: auto; }
  .pr-map-row { grid-template-columns: 1fr; gap: 6px; }
}


/* ==========================================================
   移动端适配（手机竖屏 ≤640px）
   策略：叠加增强，不改动桌面原设计
   ========================================================== */
@media (max-width: 640px) {
  /* --- 整体：视图容器由 flex 改纵向文档流 --- */
  main { display: block; }
  .view.active { display: block; }

  /* --- 顶栏：纵向堆叠，tabs 横滑 --- */
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .brand .sub { display: none; }
  .tabs {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab, .tabs .tab-link { flex: 0 0 auto; white-space: nowrap; padding: 7px 12px; font-size: 12.5px; }

  /* --- 侧栏改为文档流置顶 --- */
  .sidebar {
    width: 100% !important;
    height: auto !important;
    position: static !important;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible !important;
  }
  .sidebar .chapter-list { max-height: 260px; overflow-y: auto; }
  .content { height: auto !important; max-width: 100%; padding: 18px 14px 40px !important; overflow: visible !important; min-width: 0; }

  /* --- 各视图包装容器收紧 --- */
  .exam-wrap, .map-wrap, .hw-wrap, .pr-wrap, .quiz-wrap,
  .notes-wrap { padding: 14px 12px 40px !important; height: auto !important; max-width: 100%; }

  /* --- 模式详情排版 --- */
  .mode-header h2 { font-size: 20px; }
  .intent-box { padding: 12px 14px; }

  /* --- 面板页（原理/笔记/全景）--- */
  .pr-map-row { grid-template-columns: 1fr !important; }
  .notes-notation, .notes-relations, .notes-contrasts, .notes-oneliners { grid-template-columns: 1fr !important; }

  /* --- 代码与表格防溢出 --- */
  .code-box pre { max-width: 100%; overflow-x: auto; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  pre { max-width: 100%; overflow-x: auto; }

  /* --- 触控 --- */
  input, select, textarea { font-size: 16px; }
  button, .tab, .mode-item, .panel-tab { touch-action: manipulation; min-height: 34px; }

  html, body { overflow-x: hidden; }
}
