/* 材料科学基础 · 学习手册 —— 样式 */
:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #17202a;
  --ink-2: #3f4b58;
  --muted: #78838f;
  --line: #e3ded4;
  --line-2: #efece4;
  --brand: #1b3a57;
  --brand-2: #2c5a80;
  --brand-soft: #eaf1f6;
  --accent: #b0652a;
  --accent-soft: #f9efe4;
  --tip: #1c6f57;
  --tip-soft: #e8f4ef;
  --warn: #9a6410;
  --warn-soft: #fbf1dc;
  --exam: #a03246;
  --exam-soft: #fbeaed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 32, 42, .05), 0 8px 24px -12px rgba(23, 32, 42, .16);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  --bg: #101418;
  --panel: #171c22;
  --panel-2: #1b2229;
  --ink: #e8edf2;
  --ink-2: #b9c4ce;
  --muted: #8593a0;
  --line: #262f38;
  --line-2: #1f272e;
  --brand: #8fb8d6;
  --brand-2: #a9cbe4;
  --brand-soft: #1a242c;
  --accent: #dfa06a;
  --accent-soft: #241d17;
  --tip: #63c4a3;
  --tip-soft: #14211d;
  --warn: #d9a954;
  --warn-soft: #241f13;
  --exam: #e2839a;
  --exam-soft: #241519;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 28px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 650; color: var(--ink); }
kbd {
  font-family: var(--mono);
  font-size: .82em;
  padding: .1em .45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink-2);
}

/* ---------------- 布局 ---------------- */
.app {
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  max-width: 1520px;
  margin: 0 auto;
}

#sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel-2);
  z-index: 30;
}

.brand {
  display: block;
  padding: 22px 22px 16px;
  color: var(--ink);
  border-bottom: 1px solid var(--line-2);
}
.brand:hover { text-decoration: none; }
.brand-t {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
}
.brand-s {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

#nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  scrollbar-width: thin;
}
#nav::-webkit-scrollbar { width: 6px; }
#nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.nav-group {
  margin: 14px 10px 6px;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-group:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.4;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.nav-item.on {
  background: var(--brand);
  color: #fff;
}
.nav-item.on .n-num { color: rgba(255, 255, 255, .7); }
html[data-theme="dark"] .nav-item.on { color: #0e1418; }
html[data-theme="dark"] .nav-item.on .n-num { color: rgba(0, 0, 0, .55); }

.n-num {
  flex: none;
  width: 20px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: -.02em;
}
.n-txt { flex: 1; min-width: 0; }
.n-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tip);
  flex: none;
}
.nav-item.on .n-dot { background: #bff0dd; }

.side-prog { padding: 14px 22px 20px; border-top: 1px solid var(--line-2); }
.sp-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.sp-bar i { display: block; height: 100%; background: var(--tip); border-radius: 2px; transition: width .3s; }
.sp-txt {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
}
.sp-pct { font-family: var(--mono); }

/* ---------------- 主区 ---------------- */
#main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
}

.icon-btn {
  flex: none;
  width: 34px; height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }
#menuBtn { display: none; }

.crumb {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 34%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--muted);
}

.search-wrap { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
#search {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
#search::placeholder { color: var(--muted); }
.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--muted);
  pointer-events: none;
}

.results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.res {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
}
.res:hover { background: var(--brand-soft); text-decoration: none; }
.res-k {
  flex: none;
  align-self: flex-start;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  line-height: 1.6;
}
.res-m { min-width: 0; display: block; }
.res-t { display: block; font-size: 14px; line-height: 1.5; }
.res-s {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.res-empty, .res-more { padding: 10px; font-size: 13px; color: var(--muted); }

/* ---------------- 内容区 ---------------- */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 48px;
  padding: 36px 40px 60px;
  max-width: 1080px;
}

#view { min-width: 0; }

/* 工具页没有页内目录时，让正文占满整行 */
body.no-toc .stage { grid-template-columns: minmax(0, 1fr); max-width: 1180px; }

/* 例题页：按章两列排布，展开时互不挤压 */
.ex-card { scroll-margin-top: 84px; }
.ex-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; margin-bottom: 6px; }
.ex-cols .ex-card { margin-bottom: 0; }
@media (max-width: 1180px) { .ex-cols { grid-template-columns: minmax(0, 1fr); } }

/* 首页 */
.hero {
  position: relative;
  padding: 40px 40px 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--brand-soft) 0%, transparent 58%),
    var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px; bottom: -80px;
  width: 260px; height: 260px;
  border-radius: 50%;
  border: 1px solid var(--line);
  opacity: .7;
}
.hero-kicker {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero-h1 {
  margin: 14px 0 12px;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.18;
  letter-spacing: -.02em;
  font-weight: 750;
}
.hero-slash { color: var(--line); margin: 0 .12em; font-weight: 300; }
.hero-sub {
  max-width: 46em;
  margin: 0 0 26px;
  color: var(--ink-2);
  font-size: 15.5px;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--line);
}
.stat { padding: 14px 16px; background: var(--panel); }
.stat-v { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.stat-k { font-size: 12.5px; color: var(--muted); }

/* 章节头 */
.ch-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}
.ch-num {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--accent-soft);
}
.stars { display: inline-flex; gap: 2px; font-size: 12px; color: var(--line); }
.stars i { font-style: normal; }
.stars i.on { color: var(--accent); }

.ch-title {
  margin: 0;
  font-size: clamp(26px, 3.6vw, 36px);
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 750;
}
.ch-en {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ch-lead {
  margin: 22px 0 8px;
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.85;
}
.ch-lead::before { content: "导读　"; font-size: 11px; color: var(--accent); letter-spacing: .1em; }

/* 内容块 */
.blk-h3 {
  margin: 44px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
  scroll-margin-top: 84px;
}
.blk-p { margin: 14px 0; color: var(--ink-2); }
.blk-list { margin: 14px 0; padding-left: 1.35em; color: var(--ink-2); }
.blk-list li { margin: 7px 0; padding-left: .2em; }
.blk-list li::marker { color: var(--accent); }

.formula {
  margin: 18px 0;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-2);
  border-radius: 0 10px 10px 0;
  background: var(--brand-soft);
  scroll-margin-top: 84px;
}
.f-body {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.f-cap {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.note {
  display: flex;
  gap: 14px;
  margin: 20px 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  scroll-margin-top: 84px;
}
.note-tag {
  flex: none;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  letter-spacing: .06em;
  white-space: nowrap;
}
.note-body { min-width: 0; font-size: 15px; color: var(--ink-2); }
.note-tip { background: var(--tip-soft); border-color: transparent; }
.note-tip .note-tag { background: var(--tip); color: #fff; }
.note-warn { background: var(--warn-soft); border-color: transparent; }
.note-warn .note-tag { background: var(--warn); color: #fff; }
.note-exam { background: var(--exam-soft); border-color: transparent; }
.note-exam .note-tag { background: var(--exam); color: #fff; }

.tbl-wrap {
  margin: 18px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  scroll-margin-top: 84px;
}
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th, .tbl td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-2);
  line-height: 1.7;
}
.tbl th {
  background: var(--panel-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  white-space: nowrap;
}
.tbl td { color: var(--ink-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.mono, .tbl.mono td:first-child { font-family: var(--mono); font-size: 13px; }
.w-num { width: 68px; }
.w-name { width: 30%; }

.box {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  scroll-margin-top: 84px;
}
.box-h {
  padding: 10px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
  letter-spacing: .02em;
}
.box-b { padding: 14px 18px; font-size: 14.5px; line-height: 1.9; color: var(--ink-2); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  scroll-margin-top: 84px;
}
.card-t { font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.card-v { margin-top: 4px; font-size: 16px; font-weight: 700; color: var(--ink); }
.card-s { margin-top: 6px; font-size: 13.5px; line-height: 1.7; color: var(--ink-2); }

/* 章节尾 */
.ch-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--brand);
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, background .15s, color .15s;
}
html[data-theme="dark"] .btn { color: #0e1418; }
.btn:hover { opacity: .88; text-decoration: none; }
.btn.ghost {
  max-width: 34%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink-2);
}
.btn.ghost:hover { background: var(--brand-soft); color: var(--brand); }
.read-btn.on { background: var(--tip); border-color: var(--tip); color: #fff; }

/* 页内目录 */
#toc { align-self: start; }
.toc-in {
  position: sticky;
  top: 84px;
  font-size: 13px;
}
.toc-h {
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc-a {
  display: block;
  padding: 5px 0 5px 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.5;
}
.toc-a:hover { color: var(--brand-2); border-left-color: var(--brand-2); text-decoration: none; }

/* ---------------- 工具页 ---------------- */
.page-head { margin-bottom: 22px; }
.page-h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.02em;
  font-weight: 750;
}
.page-sub { margin: 8px 0 0; color: var(--ink-2); font-size: 14.5px; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 20px;
}
.inp {
  flex: 1;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.inp:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.cnt { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.f-sec {
  margin: 30px 0 12px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.f-item {
  margin: 12px 0;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.f-item .f-body { font-size: 14.5px; }
.f-jump {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.f-jump:hover { color: var(--brand-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--brand-2); color: var(--brand-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
html[data-theme="dark"] .chip.on { color: #0e1418; }

.term {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.term:first-child { border-top: 1px solid var(--line-2); }
.term-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.term-h b { font-size: 15.5px; }
.term-ch { font-size: 11.5px; color: var(--muted); }
.term-d { margin-top: 3px; font-size: 14px; color: var(--ink-2); }

/* 自测 */
.quiz-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.sel {
  height: 34px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
}
.score { font-size: 13px; color: var(--ink-2); }
.score b { font-family: var(--mono); }
.score .good { color: var(--tip); }

.q-card {
  margin: 16px 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color .2s;
}
.q-card.ok { border-color: color-mix(in srgb, var(--tip) 45%, var(--line)); }
.q-card.no { border-color: color-mix(in srgb, var(--exam) 45%, var(--line)); }
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.q-no {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-family: var(--mono);
  font-size: 12px;
}
.q-ch { font-size: 11.5px; color: var(--muted); }
.q-text { font-size: 15.5px; line-height: 1.75; margin-bottom: 12px; }
.q-opts { display: grid; gap: 8px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.opt:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.opt-k {
  flex: none;
  width: 20px; height: 20px;
  display: inline-grid;
  place-items: center;
  margin-top: 2px;
  border-radius: 5px;
  background: var(--line-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}
.opt.right { border-color: var(--tip); background: var(--tip-soft); color: var(--ink); }
.opt.right .opt-k { background: var(--tip); color: #fff; }
.opt.wrong { border-color: var(--exam); background: var(--exam-soft); }
.opt.wrong .opt-k { background: var(--exam); color: #fff; }
.q-card.done .opt { cursor: default; }
.q-card.done .opt:hover { border-color: var(--line); background: var(--panel-2); }
.q-card.done .opt.right:hover { border-color: var(--tip); background: var(--tip-soft); }
.q-card.done .opt.wrong:hover { border-color: var(--exam); background: var(--exam-soft); }

.q-ex {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-2);
}
.q-res { display: inline-block; margin-right: 8px; font-weight: 650; }
.q-card.ok .q-res { color: var(--tip); }
.q-card.no .q-res { color: var(--exam); }

.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 14px; }

.foot {
  padding: 26px 40px 46px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}
.foot p { margin: 2px 0; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(10, 14, 18, .42);
}

/* ---------------- 例题精解 ---------------- */
.ex-h {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 42px 0 0;
  padding-top: 22px;
  border-top: 2px solid var(--line);
  font-size: 19px;
  letter-spacing: -.01em;
}
.ex-h-s { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.ex-card {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  break-inside: avoid;
}
.ex-q { padding: 15px 20px 10px; font-size: 15.5px; line-height: 1.8; }
.ex-no {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  vertical-align: 2px;
  white-space: nowrap;
}
.ex-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 20px 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.ex-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ex-toggle i { font-style: normal; font-size: 11px; transition: transform .2s; }
.ex-card.open .ex-toggle i { transform: rotate(180deg); }
.ex-body { display: none; padding: 0 20px 18px; }
.ex-card.open .ex-body { display: block; animation: exfade .24s ease-out; }
@keyframes exfade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ex-steps { margin: 4px 0 14px; padding-left: 22px; font-size: 14.5px; line-height: 1.9; color: var(--ink-2); }
.ex-steps li { margin: 7px 0; }
.ex-steps li::marker { color: var(--accent); font-family: var(--mono); font-size: 12px; }
.ex-ans {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--tip-soft);
  font-size: 14.5px;
  line-height: 1.85;
}
.ex-ans b { color: var(--tip); }
.ex-tip {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--accent-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}
.ex-tip b { color: var(--accent); }
.ex-jump { display: block; padding: 2px 20px 14px; font-size: 12px; color: var(--muted); }
.ex-jump:hover { color: var(--brand); }
.ex-item { margin: 0; }

/* ---------------- 错题本 ---------------- */
.q-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--exam-soft);
  color: var(--exam);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
}
.q-card.cleared { border-color: var(--tip); background: var(--tip-soft); }
.q-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12.5px;
}
.n-badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 20px;
  background: var(--exam);
  color: #fff;
  font-family: var(--mono);
  font-size: 10.5px;
}
html[data-theme="dark"] .n-badge { color: #16100f; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .stage { grid-template-columns: minmax(0, 1fr); padding: 30px 32px 56px; max-width: 900px; }
  #toc { display: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 278px;
    transform: translateX(-102%);
    transition: transform .24s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .2);
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  #menuBtn { display: inline-grid; }
  .topbar { padding: 0 16px; gap: 10px; }
  .crumb { display: none; }
  .stage { padding: 22px 18px 48px; }
  .hero { padding: 26px 20px 24px; border-radius: 14px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ex-q { padding: 13px 15px 8px; }
  .ex-toggle { margin: 0 15px 12px; }
  .ex-body { padding: 0 15px 15px; }
  .ex-steps { padding-left: 19px; }
  .q-badge { display: none; }
  .ch-lead { padding: 14px 16px; }
  .ch-foot { flex-wrap: wrap; justify-content: center; }
  .btn.ghost { max-width: 100%; }
  .foot { padding: 22px 18px 38px; }
  .tbl th, .tbl td { padding: 9px 11px; }
  .note { flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  #sidebar, .topbar, #toc, .ch-foot, .scrim, .f-jump, .quiz-bar { display: none !important; }
  .app { display: block; }
  .stage { display: block; padding: 0; max-width: none; }
  body { background: #fff; font-size: 12pt; }
  .note, .tbl-wrap, .formula, .box, .ex-card, .q-card { break-inside: avoid; }
  .ex-body { display: block !important; }
  .ex-toggle { display: none; }
  a { color: inherit; }
}
