/* ==========================================================================
   运筹学 · 解题推演台  —  浅色学术风格
   ========================================================================== */

:root {
  --paper: #f8f3e7;
  --paper-deep: #efe5d2;
  --card: #fffdf8;
  --card-soft: #faf5e8;
  --ink: #22303e;
  --ink-2: #56606c;
  --ink-3: #8b8372;
  --line: #d8cdb7;
  --line-soft: #e9e1d1;
  --red: #bc4b34;
  --red-soft: #f7e4dd;
  --blue: #2f5f86;
  --blue-soft: #e3edf5;
  --green: #3d7358;
  --green-soft: #e4efe8;
  --gold: #b07c22;
  --gold-soft: #f6ecd4;
  --violet: #6a5a8c;
  --violet-soft: #ece7f4;
  --shadow: 0 14px 30px -24px rgba(34, 48, 62, 0.65);
  --serif: Georgia, "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  --kai: "KaiTi", "Kaiti SC", "STKaiti", "SimSun", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(70, 58, 38, 0.1) 1px, transparent 1.2px),
    radial-gradient(circle at 12% 0%, rgba(188, 75, 52, 0.065), transparent 46%),
    radial-gradient(circle at 92% 14%, rgba(47, 95, 134, 0.07), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(176, 124, 34, 0.05), transparent 55%);
  background-size: 22px 22px, 100% 100%, 100% 100%, 100% 100%;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #f3d9a6; color: #3a2a16; }

button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; letter-spacing: 0.01em; }

a { color: var(--blue); }

:focus-visible {
  outline: 2.5px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

kbd {
  font-family: var(--mono);
  font-size: 0.82em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  background: var(--card-soft);
  color: var(--ink-2);
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 26px;
  background: rgba(248, 243, 231, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1.5px solid var(--line);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(188, 75, 52, 0.35), transparent);
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fdf6e4;
  font-family: var(--serif);
  font-size: 23px;
  border-radius: 11px;
  transform: rotate(-2.5deg);
  box-shadow: 3px 3px 0 rgba(34, 48, 62, 0.16);
  border: 1.5px solid var(--ink);
}

.brand-text { min-width: 0; max-width: min(62vw, 660px); }
.brand-text h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text p {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-meta { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.stat-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 13px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  color: var(--ink-3);
}
.stat-label { letter-spacing: 0.06em; }
.stat-num { font-family: var(--mono); font-weight: 700; color: var(--green); font-size: 13px; }
.mini-bar {
  width: 64px;
  height: 6px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}
.mini-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 17px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--ink); color: #fff8ea; }
.btn.ghost { border-color: var(--line); box-shadow: 0 2px 0 var(--line); background: var(--card); }
.btn.ghost:hover { border-color: var(--ink-3); box-shadow: 0 3px 0 var(--line); }
.btn.small { padding: 6px 13px; font-size: 12.5px; }
.btn.accent { background: var(--red); border-color: var(--red); color: #fff7e8; box-shadow: 0 2px 0 #8f3524; }
.btn.accent:hover { box-shadow: 0 3px 0 #8f3524; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.mini-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.15s ease;
}
.mini-btn:hover { border-color: var(--ink-3); color: var(--ink); background: var(--card-soft); }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--red); }

/* ---------- layout ---------- */

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 69px;
  height: calc(100vh - 69px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px 18px;
  border-right: 1.5px solid var(--line-soft);
}

.side-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  padding: 0 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.navlist { display: flex; flex-direction: column; gap: 3px; }

.nav {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background: none;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: 0.17s ease;
}
.nav:hover { background: var(--card); border-color: var(--line-soft); transform: translateX(2px); }
.nav.active {
  background: var(--card);
  border-color: var(--line);
  box-shadow: 0 3px 0 -1px var(--line);
  color: var(--ink);
}
.nav .ic {
  width: 31px;
  height: 31px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-2);
  transition: 0.17s ease;
}
.nav .ic svg { width: 18px; height: 18px; }
.nav.active .ic { background: var(--ink); color: #fff8ea; border-color: var(--ink); }
.nav-label { display: grid; line-height: 1.28; min-width: 0; }
.nav-label b { font-size: 14px; font-weight: 650; letter-spacing: 0.03em; }
.nav-label small { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-bottom {
  margin-top: auto;
  padding: 16px 4px 0;
  border-top: 1px dashed var(--line);
}
.side-bottom .side-label { padding: 0 8px; }

.chapter-select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  font-size: 13px;
  cursor: pointer;
}
.side-actions { display: flex; gap: 6px; margin-top: 7px; }
.side-actions .mini-btn { flex: 1; }
.side-note { margin: 10px 2px 0; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }

.view {
  width: 100%;
  min-width: 0;
  max-width: 1180px;
  padding: 30px 36px 90px;
  outline: none;
}

/* ---------- view head ---------- */

.viewhead { margin-bottom: 20px; }
.viewhead .kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--red);
  text-transform: uppercase;
}
.viewhead h2 {
  margin: 3px 0 6px;
  font-size: 31px;
  line-height: 1.22;
  display: inline-block;
  position: relative;
}
.viewhead h2::after {
  content: "";
  position: absolute;
  left: 0;
  right: 18%;
  bottom: -2px;
  height: 3px;
  background: linear-gradient(90deg, var(--red), rgba(188, 75, 52, 0));
  border-radius: 3px;
  opacity: 0.55;
}
.viewhead .desc { margin: 0; max-width: 66ch; color: var(--ink-2); font-size: 14px; }
.viewhead .head-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.viewhead .head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- walkthrough ---------- */

.route-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.route-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  padding: 7px 13px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.16s ease;
}
.route-tab .no {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.route-tab:hover { border-color: var(--ink-3); color: var(--ink); }
.route-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff8ea;
  box-shadow: 0 3px 0 rgba(34, 48, 62, 0.22);
}
.route-tab.active .no { color: rgba(255, 248, 234, 0.6); }

.walk-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) 246px;
  gap: 22px;
  align-items: start;
}

.walk-main { min-width: 0; }
.node-card { min-width: 0; }
.node-diagrams, .node-diagram { min-width: 0; }

.trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 13px;
  font-size: 11.5px;
}
.trail button {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line-soft);
  background: rgba(255, 253, 248, 0.65);
  color: var(--ink-3);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  cursor: pointer;
  transition: 0.15s ease;
}
.trail button:hover { color: var(--ink); border-color: var(--line); }
.trail button.current { background: var(--ink); border-color: var(--ink); color: #fff8ea; }
.trail .sep { color: var(--ink-3); opacity: 0.55; }

.node-card {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 24px 28px 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  --accent: var(--red);
  animation: rise 0.34s ease both;
}
.node-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
  opacity: 0.85;
}
.node-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(188, 75, 52, 0.05), transparent 70%);
  pointer-events: none;
}
.node-card.tone-blue { --accent: var(--blue); }
.node-card.tone-green { --accent: var(--green); }
.node-card.tone-gold { --accent: var(--gold); }
.node-card.tone-violet { --accent: var(--violet); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.node-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 10.5px;
  letter-spacing: 0.15em;
  color: var(--ink-3);
  font-weight: 700;
  text-transform: uppercase;
}
.step-badge {
  background: var(--accent);
  color: #fff8ea;
  border-radius: 6px;
  padding: 2px 8px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  font-size: 10.5px;
}
.node-tag {
  margin-left: auto;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--gold);
  border: 1px dashed #d9bd82;
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 600;
}
.recall-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.15s ease;
}
.recall-toggle:hover { border-color: var(--ink-3); color: var(--ink); }
.recall-toggle .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.node-card.recall .recall-toggle .dot { background: var(--red); }

.node-card h2 {
  margin: 10px 0 7px;
  font-size: 28px;
  line-height: 1.3;
}
.node-summary {
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.8;
  max-width: 62ch;
}

.decision-q {
  margin: 18px 0 14px;
  padding: 14px 17px;
  border: 1.5px dashed #d5b878;
  border-radius: 13px;
  background: var(--gold-soft);
}
.decision-q .lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--gold);
}
.decision-q p {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  color: #4c3a18;
}
.decision-q .qnote { margin-top: 6px; font-family: var(--sans); font-size: 12.5px; color: #7a6534; }

.steps { list-style: none; margin: 20px 0 0; padding: 0; }
.step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 13px;
  padding-bottom: 17px;
  position: relative;
}
.step::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 36px;
  bottom: 0;
  border-left: 1.5px dashed var(--line);
}
.step:last-child { padding-bottom: 0; }
.step:last-child::before { display: none; }
.step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card-soft);
  border: 1.5px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  position: relative;
  z-index: 1;
}
.step-main { padding-top: 3px; min-width: 0; }
.step h4 {
  margin: 0 0 3px;
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: 0.2s ease;
}
.step-body { color: var(--ink-2); font-size: 14px; line-height: 1.8; }
.step-body b { color: var(--ink); font-weight: 650; }

.math {
  font-family: var(--mono);
  background: #f3ecdc;
  border-radius: 5px;
  padding: 0.5px 5px;
  color: #7a3b2a;
  font-size: 0.92em;
  white-space: nowrap;
}

/* KaTeX inline / display formulas */
.katex { font-size: 1.04em; }
.katex-display {
  margin: 0.55em 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.katex-display > .katex { font-size: 1.05em; }
.step-body .katex, .callout .katex, .node-summary .katex { font-size: 1.02em; }
.node-card h2 .katex { font-size: 0.9em; }
.map-node .katex { font-size: 0.96em; }
.opt .katex { font-size: 1em; }
.fc-a .katex-display { margin: 0.35em 0; }
.formula .katex { font-size: 1.02em; }
.formula .katex-display { margin: 0; }
.term-card .formula { white-space: normal; line-height: 2; }

.math-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
.math-table th, .math-table td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.math-table th { background: var(--card-soft); font-weight: 700; color: var(--ink); }
.math-table td { color: var(--ink-2); line-height: 1.7; }
.math-table .katex { font-size: 0.98em; }

.recall-cover {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--ink-3);
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.15s ease;
}
.recall-cover span { font-weight: 650; color: var(--ink-2); }
.recall-cover em { font-style: normal; font-size: 11px; opacity: 0.75; }
.recall-cover:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }

.node-card.recall .step:not(.is-revealed) .step-body { display: none; }
.node-card.recall .step:not(.is-revealed) .recall-cover { display: inline-flex; }
.node-card.recall .step:not(.is-revealed) h4 {
  color: transparent;
  text-shadow: 0 0 9px rgba(34, 48, 62, 0.55);
  user-select: none;
}
.node-card.recall .step:not(.is-revealed) h4 .math { visibility: hidden; }

.recall-actions { margin-top: 14px; }

.callout {
  margin: 12px 0;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1.5px solid;
  font-size: 13.5px;
  line-height: 1.78;
}
.callout .lbl {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin-bottom: 3px;
}
.callout p { margin: 0; }
.callout p + p { margin-top: 5px; }
.callout.quote { background: var(--gold-soft); border-color: #e4d0a6; color: #5d4a25; position: relative; }
.callout.quote::before {
  content: "“";
  position: absolute;
  right: 12px;
  top: -10px;
  font-family: var(--serif);
  font-size: 48px;
  line-height: 1;
  color: rgba(176, 124, 34, 0.28);
}
.callout.quote .lbl { color: #9a6c1c; }
.callout.warn { background: var(--red-soft); border-color: #e8c6bb; color: #6d3023; }
.callout.warn .lbl { color: var(--red); }
.callout.tip { background: var(--blue-soft); border-color: #c8dae8; color: #29485f; }
.callout.tip .lbl { color: var(--blue); }

.term-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 15px;
}
.term-row .row-label { font-size: 10.5px; letter-spacing: 0.14em; color: var(--ink-3); font-weight: 800; margin-right: 2px; }
.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.2px dashed var(--line);
  background: var(--card-soft);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.15s ease;
}
.term-chip::before { content: "§"; font-family: var(--serif); color: var(--ink-3); font-size: 11px; }
.term-chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.node-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.node-actions .spacer { flex: 1; }

.branch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin: 4px 0 0;
}
.branch {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 13px;
  padding: 13px 15px;
  text-align: left;
  cursor: pointer;
  transition: 0.17s ease;
  box-shadow: 0 3px 0 -1px var(--line);
}
.branch:hover { transform: translateY(-2px); box-shadow: 0 5px 0 -1px var(--line); }
.branch b { display: flex; align-items: center; gap: 7px; font-family: var(--serif); font-size: 17.5px; margin-bottom: 3px; }
.branch b::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone, var(--ink-3));
}
.branch .hint { display: block; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.branch .to { display: block; margin-top: 5px; font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.branch.yes { border-color: #b9d2c2; background: var(--green-soft); --tone: var(--green); box-shadow: 0 3px 0 -1px #b9d2c2; }
.branch.yes b { color: var(--green); }
.branch.no { border-color: #e5c3b8; background: var(--red-soft); --tone: var(--red); box-shadow: 0 3px 0 -1px #e5c3b8; }
.branch.no b { color: var(--red); }
.branch.alt1 { border-color: #c9d8e4; background: var(--blue-soft); --tone: var(--blue); box-shadow: 0 3px 0 -1px #c9d8e4; }
.branch.alt1 b { color: var(--blue); }
.branch.alt2 { border-color: #d9cfe6; background: var(--violet-soft); --tone: var(--violet); box-shadow: 0 3px 0 -1px #d9cfe6; }
.branch.alt2 b { color: var(--violet); }

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.hub-card {
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 12px 14px;
  cursor: pointer;
  transition: 0.17s ease;
}
.hub-card:hover { border-color: var(--ink-3); transform: translateY(-2px); box-shadow: var(--shadow); }
.hub-card .no { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.hub-card b { display: block; font-family: var(--serif); font-size: 15.5px; margin: 1px 0 3px; }
.hub-card span { display: block; font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }

.route-done {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 16px;
  border: 1.5px dashed var(--green);
  border-radius: 14px;
  background: var(--green-soft);
}
.route-done .stamp {
  flex: none;
  width: 64px;
  height: 64px;
  border: 2px solid var(--green);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--green);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  transform: rotate(-8deg);
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.route-done h4 { margin: 0 0 3px; font-size: 15px; color: #244736; }
.route-done p { margin: 0; font-size: 12.5px; color: #3f5e4d; }

.walk-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 90px; }
.side-card {
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 13px 15px;
}
.side-card h3 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.side-card p { margin: 0; font-size: 12px; color: var(--ink-2); line-height: 1.7; }
.side-route {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: none;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.side-route:hover { background: var(--card); border-color: var(--line-soft); }
.side-route.active { background: var(--card); border-color: var(--line); color: var(--ink); font-weight: 600; }
.side-route small { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 400; }
.mini-trail { list-style: none; margin: 0; padding: 0; counter-reset: mt; }
.mini-trail li {
  counter-increment: mt;
  position: relative;
  padding: 2px 0 2px 20px;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.mini-trail li::before {
  content: counter(mt);
  position: absolute;
  left: 0;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  font-family: var(--mono);
  font-size: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.mini-trail li.current { color: var(--ink); font-weight: 650; }
.mini-trail li.current::before { background: var(--red); border-color: var(--red); color: #fff; }

.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.mini-stats div { text-align: center; background: var(--card); border: 1px solid var(--line-soft); border-radius: 8px; padding: 7px 3px 5px; }
.mini-stats b { display: block; font-family: var(--mono); font-size: 15px; color: var(--ink); line-height: 1.2; }
.mini-stats b small { font-size: 9.5px; color: var(--ink-3); font-weight: 400; }
.mini-stats span { font-size: 9.5px; color: var(--ink-3); letter-spacing: 0.06em; }

/* ---------- mind map ---------- */

.map-toolbar { display: flex; gap: 7px; flex-wrap: wrap; }
.map-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 0 0 10px;
}
.map-note .dot-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

.map-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: calc(100vh - 240px);
  background-image: radial-gradient(rgba(34, 48, 62, 0.055) 1px, transparent 1px);
  background-size: 18px 18px;
}
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 19px; padding-left: 17px; border-left: 1.5px dashed var(--line); }
.tree li { position: relative; padding: 2.5px 0; }
.tree ul > li::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 20px;
  width: 14px;
  border-top: 1.5px dashed var(--line);
}
.map-row { display: flex; align-items: center; gap: 5px; position: relative; }
.map-caret {
  width: 17px;
  height: 17px;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  color: var(--ink-3);
  font-size: 9px;
  cursor: pointer;
  line-height: 1;
  transition: 0.15s ease;
}
.map-caret:hover { border-color: var(--ink-3); color: var(--ink); }
.map-caret .chev { display: block; transition: transform 0.18s ease; }
.map-caret.blank { visibility: hidden; border-color: transparent; }
li.collapsed > .map-row .chev { transform: rotate(-90deg); }
li.collapsed > ul { display: none; }

.map-node {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  padding: 3px 7px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  text-align: left;
  font-family: var(--sans);
}
.map-node .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tone, var(--red)); flex: none; }
.map-node strong { font-family: var(--serif); font-size: 13.5px; }
.map-node .sub { color: var(--ink-3); font-size: 11.5px; }
button.map-node { cursor: pointer; }
button.map-node strong {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
button.map-node:hover { background: var(--card-soft); border-color: var(--line); color: var(--blue); }
button.map-node:hover strong { text-decoration-color: currentColor; }
.map-node .jump { font-size: 9px; color: var(--ink-3); opacity: 0; transition: 0.15s; }
button.map-node:hover .jump { opacity: 1; }
button.map-node.focus {
  background: var(--gold-soft);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176, 124, 34, 0.16);
}
button.map-node.focus strong { text-decoration-color: var(--gold); }

.map-root { display: flex; align-items: center; gap: 12px; padding: 2px 0 16px; border-bottom: 1px dashed var(--line); margin-bottom: 14px; }
.map-root .seal {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff6e3;
  border-radius: 9px;
  font-family: var(--serif);
  font-size: 19px;
  transform: rotate(-3deg);
}
.map-root h3 { margin: 0; font-size: 19px; line-height: 1.3; }
.map-root p { margin: 0; font-size: 11px; letter-spacing: 0.1em; color: var(--ink-3); }

.tone-1 { --tone: var(--red); }
.tone-2 { --tone: var(--blue); }
.tone-3 { --tone: var(--green); }
.tone-4 { --tone: var(--gold); }
.tone-5 { --tone: var(--violet); }

/* ---------- checklist ---------- */

.check-summary {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.ring {
  --p: 0;
  width: 106px;
  height: 106px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line-soft) 0);
  display: grid;
  place-items: center;
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--card); }
.ring .ring-txt { position: relative; text-align: center; line-height: 1.15; }
.ring .ring-txt b { display: block; font-family: var(--serif); font-size: 24px; }
.ring .ring-txt small { font-size: 9.5px; letter-spacing: 0.14em; color: var(--ink-3); }
.check-copy h3 { margin: 0 0 2px; font-size: 19px; }
.check-copy p { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.check-copy .big-num { font-family: var(--mono); font-size: 13px; color: var(--green); font-weight: 700; }
.check-summary .spacer { flex: 1; }
.check-tools { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card-soft);
  border-radius: 999px;
  padding: 5px 11px;
  user-select: none;
}
.switch input { display: none; }
.switch .knob {
  width: 26px;
  height: 15px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: 0.18s ease;
  flex: none;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--card);
  transition: 0.18s ease;
}
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(11px); }

.check-group {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.check-group > header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--card-soft);
  border-bottom: 1px solid var(--line-soft);
}
.check-group > header h3 { margin: 0; font-size: 14.5px; }
.check-group > header .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.check-group > header .bar { width: 70px; height: 5px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.check-group > header .bar i { display: block; height: 100%; width: 0; background: var(--green); }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 9px 18px;
  border-bottom: 1px dashed var(--line-soft);
  transition: background 0.15s ease;
  cursor: pointer;
}
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: rgba(250, 245, 232, 0.55); }
.check-box {
  width: 19px;
  height: 19px;
  flex: none;
  margin-top: 3px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: transparent;
  display: grid;
  place-items: center;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  transition: 0.15s ease;
}
.check-box:hover { border-color: var(--green); }
.check-row.done .check-box { background: var(--green); border-color: var(--green); color: #fff; }
.check-text { font-size: 13.5px; line-height: 1.65; color: var(--ink); flex: 1; }
.check-row.done .check-text { color: var(--ink-3); text-decoration: line-through; text-decoration-color: rgba(61, 115, 88, 0.45); }
.check-row .go {
  flex: none;
  margin-top: 1px;
  font-size: 10.5px;
  color: var(--ink-3);
  border: 1px solid transparent;
  background: none;
  border-radius: 7px;
  padding: 2px 7px;
  cursor: pointer;
  opacity: 0;
  transition: 0.15s ease;
}
.check-row:hover .go { opacity: 1; }
.check-row .go:hover { color: var(--blue); border-color: var(--line); background: var(--card); }
.check-row.hidden-row { display: none; }

/* ---------- flashcards ---------- */

.fc-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip-select {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
}
.chip-select.active { background: var(--ink); border-color: var(--ink); color: #fff8ea; }

.fc-wrap { max-width: 680px; margin: 0 auto; }
.fc-meta { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; }
.fc-meta .spacer { flex: 1; }
.fc-progress { flex: 1; max-width: 200px; height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.fc-progress i { display: block; height: 100%; width: 0; background: var(--red); border-radius: inherit; transition: width 0.3s ease; }

.flashcard {
  perspective: 1600px;
  height: 382px;
  cursor: pointer;
  user-select: none;
}
.fc-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.2, 0.75, 0.25, 1);
}
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 30px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
  background: var(--card);
  overflow: hidden;
}
.fc-face::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green));
  opacity: 0.65;
}
.fc-back { transform: rotateY(180deg); background: var(--card-soft); }
.fc-cat {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--red);
  border: 1px solid #e4bdb2;
  background: var(--red-soft);
  border-radius: 999px;
  padding: 2px 9px;
  margin-bottom: 18px;
}
.fc-q {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}
.fc-front-foot { margin-top: 26px; font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.fc-front-foot .rule { flex: 1; border-top: 1px dashed var(--line); }
.fc-a {
  font-size: 16px;
  line-height: 1.9;
  color: var(--ink);
  max-height: 64%;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}
.fc-a b { color: var(--red); }
.fc-a .math { font-size: 0.9em; }
.fc-back .fc-link { margin-top: auto; padding-top: 16px; font-size: 11.5px; color: var(--ink-3); }

.fc-marks { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.mark-btn {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 11px;
  padding: 7px 16px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: 0.15s ease;
}
.mark-btn small { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.mark-btn:hover { transform: translateY(-1px); }
.mark-btn.again:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.mark-btn.hard:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.mark-btn.easy:hover { border-color: var(--green); color: var(--green); background: var(--green-soft); }

.fc-summary {
  max-width: 640px;
  margin: 10px auto 0;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 26px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.fc-summary h3 { margin: 0 0 4px; font-size: 22px; }
.fc-summary p { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); }
.fc-tally { display: flex; justify-content: center; gap: 22px; margin: 14px 0 20px; flex-wrap: wrap; }
.fc-tally div { font-family: var(--mono); font-size: 22px; }
.fc-tally small { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.12em; color: var(--ink-3); }
.fc-tally .t-again { color: var(--red); }
.fc-tally .t-hard { color: var(--gold); }
.fc-tally .t-easy { color: var(--green); }

/* ---------- quiz ---------- */

.quiz-wrap { max-width: 760px; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 11.5px; color: var(--ink-3); }
.quiz-top .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.quiz-top .bar i { display: block; height: 100%; width: 0; background: var(--violet); transition: width 0.3s ease; }
.quiz-top .score { font-family: var(--mono); color: var(--violet); font-weight: 700; }
.quiz-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 24px 26px;
  box-shadow: var(--shadow);
}
.quiz-card .q-cat {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--violet);
  border: 1px solid #d4c9e5;
  background: var(--violet-soft);
  border-radius: 999px;
  padding: 2px 9px;
  margin-bottom: 10px;
}
.quiz-card h3 { margin: 0 0 14px; font-size: 20px; line-height: 1.55; font-weight: 600; }
.opts { display: flex; flex-direction: column; gap: 7px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 11px;
  padding: 10px 13px;
  cursor: pointer;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  transition: 0.15s ease;
}
.opt .letter {
  width: 25px;
  height: 25px;
  flex: none;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 0;
}
.opt:hover:not(.locked) { background: var(--card-soft); border-color: var(--ink-3); }
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.opt.locked { cursor: default; }
.opt.dim { opacity: 0.55; }

.quiz-explain {
  margin-top: 14px;
  border-top: 1px dashed var(--line);
  padding-top: 13px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
  animation: rise 0.25s ease both;
}
.quiz-explain .verdict { font-weight: 700; margin-bottom: 4px; }
.quiz-explain .verdict.ok { color: var(--green); }
.quiz-explain .verdict.no { color: var(--red); }
.quiz-explain .term-link { margin-top: 7px; }
.quiz-foot { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.quiz-foot .spacer { flex: 1; }
.quiz-result { text-align: center; padding: 10px 0; }
.quiz-result .big-score { font-family: var(--serif); font-size: 56px; line-height: 1.1; color: var(--violet); }
.quiz-result .big-score small { font-size: 18px; color: var(--ink-3); }
.quiz-result h3 { margin: 4px 0; font-size: 22px; }
.quiz-result p { color: var(--ink-2); font-size: 13px; }
.wrong-list { text-align: left; margin: 18px 0; border-top: 1px dashed var(--line); padding-top: 14px; }
.wrong-list h4 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.1em; color: var(--ink-3); }
.wrong-item { font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; line-height: 1.65; }
.wrong-item b { color: var(--ink); font-weight: 600; }
.wrong-item .ans { color: var(--green); }

/* ---------- glossary ---------- */

.glossary-search {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 9px 14px;
  max-width: 560px;
  margin-bottom: 12px;
}
.glossary-search svg { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.glossary-search input {
  border: 0;
  outline: 0;
  background: none;
  flex: 1;
  font-size: 14px;
  min-width: 0;
}
.glossary-search kbd { flex: none; }
.cat-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 13px;
}
.term-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 8px 20px -22px rgba(34, 48, 62, 0.6);
  transition: 0.17s ease;
}
.term-card:hover { border-color: var(--line); transform: translateY(-2px); }
.term-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.term-head h3 { margin: 0; font-size: 18px; }
.term-head .en { font-size: 11px; color: var(--ink-3); letter-spacing: 0.03em; }
.term-card p { margin: 0; font-size: 12.8px; line-height: 1.78; color: var(--ink-2); }
.term-card .formula {
  margin: 8px 0;
  font-family: var(--mono);
  font-size: 12px;
  background: #f3ecdc;
  color: #6b4128;
  border-radius: 7px;
  padding: 6px 9px;
  overflow-x: auto;
  white-space: nowrap;
}
.term-card .term-tip {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 7px;
  padding: 4px 8px;
  line-height: 1.6;
}
.term-card .term-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; gap: 8px; }
.term-card .cat { font-size: 10px; letter-spacing: 0.1em; color: var(--ink-3); }
.term-card .term-node {
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.term-card .term-node:hover { color: var(--red); }
.empty {
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  padding: 30px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* ---------- drawer ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(30, 36, 42, 0.34);
  z-index: 55;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.scrim.show { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 94vw);
  z-index: 60;
  background: var(--paper);
  border-left: 1.5px solid var(--line);
  box-shadow: -24px 0 60px -40px rgba(0, 0, 0, 0.55);
  transform: translateX(104%);
  transition: transform 0.28s cubic-bezier(0.2, 0.75, 0.25, 1);
  overflow-y: auto;
  padding: 20px 22px 44px;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.drawer-head .label { font-size: 10px; letter-spacing: 0.2em; font-weight: 800; color: var(--ink-3); }
.drawer-head .close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--ink-2);
}
.drawer-head .close:hover { border-color: var(--ink); color: var(--ink); }
.drawer .node-card { padding: 22px; border-radius: 16px; }
.drawer .node-card h2 { font-size: 24px; }
.drawer .node-card .node-summary { font-size: 14px; }
.drawer .drawer-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- popover ---------- */

.popover {
  position: fixed;
  z-index: 75;
  width: min(320px, calc(100vw - 24px));
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 13px;
  padding: 14px 16px;
  box-shadow: 0 22px 44px -24px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
  animation: rise 0.18s ease both;
}
.popover h4 { margin: 0 0 4px; font-size: 16px; color: var(--ink); display: flex; align-items: baseline; gap: 7px; }
.popover h4 small { font-size: 10px; color: var(--ink-3); font-weight: 400; }
.popover .formula { margin-top: 6px; font-family: var(--mono); font-size: 11.5px; background: #f3ecdc; border-radius: 6px; padding: 4px 7px; color: #6b4128; overflow-x: auto; white-space: nowrap; }
.popover .pop-foot { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.popover .pop-foot .spacer { flex: 1; }

/* ---------- modal ---------- */

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal-wrap[hidden] { display: none; }
.modal-scrim { position: absolute; inset: 0; background: rgba(30, 36, 42, 0.42); }
.modal {
  position: relative;
  width: min(780px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  padding: 26px 30px 30px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.55);
  animation: rise 0.28s ease both;
}
.modal h2 { margin: 0 0 4px; font-size: 25px; }
.modal h3 { margin: 22px 0 8px; font-size: 16px; }
.modal p { font-size: 13px; color: var(--ink-2); line-height: 1.8; }
.modal ul { padding-left: 20px; font-size: 13px; color: var(--ink-2); line-height: 1.9; }
.modal .close-x {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}
.modal .close-x:hover { border-color: var(--ink); }
.modal pre {
  background: #2a3541;
  color: #f4ead6;
  border-radius: 10px;
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
}
.modal code { font-family: var(--mono); font-size: 0.92em; background: #f0e7d4; border-radius: 4px; padding: 1px 4px; }
.modal pre code { background: none; padding: 0; color: inherit; }
.modal .modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.modal .kbd-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.modal .kbd-table td { padding: 5px 4px; border-bottom: 1px dashed var(--line-soft); color: var(--ink-2); }
.modal .kbd-table td:first-child { width: 130px; }
.modal .callout { margin: 10px 0; }

/* ---------- tour ---------- */

.tour { position: fixed; inset: 0; z-index: 90; display: none; }
.tour.open { display: block; }
.tour-spot {
  position: absolute;
  border: 2px solid #fff6e0;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(22, 28, 34, 0.6);
  transition: all 0.28s ease;
  pointer-events: none;
}
.tour-card {
  position: absolute;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  width: min(470px, calc(100vw - 28px));
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  padding: 19px 22px 18px;
  box-shadow: 0 26px 60px -24px rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.tour-card.top { top: 24px; bottom: auto; }
.tour-card .tour-step { font-size: 10px; font-weight: 800; letter-spacing: 0.2em; color: var(--red); }
.tour-card h3 { margin: 5px 0 5px; font-size: 19px; }
.tour-card p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.75; }
.tour-card .tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.tour-card .tour-actions .spacer { flex: 1; }
.tour-card .tour-dots { display: flex; gap: 4px; }
.tour-card .tour-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.tour-card .tour-dots i.on { background: var(--red); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff8ea;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 12.5px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: 0.24s ease;
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.6);
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- misc ---------- */

.empty-view {
  padding: 60px 24px;
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.55);
}
.empty-view h2 { margin: 0 0 6px; }
.empty-view p { color: var(--ink-2); font-size: 13.5px; }

.footnote {
  margin: 18px 2px 0;
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 7px;
}
.footnote::before { content: ""; width: 16px; border-top: 1px solid var(--line); }

.hidden { display: none !important; }

/* ---------- diagrams ---------- */

.diagram-legend {
  margin: -4px 0 14px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.55);
}
.dg-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  font-size: 11px;
  color: var(--ink-3);
}
.dg-legend .dg-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dg-key.ink { background: var(--ink); }
.dg-key.red { background: var(--red); }
.dg-key.green { background: var(--green); }
.dg-key.gold { background: var(--gold); }
.dg-key.hollow { background: var(--card); border: 1.5px solid var(--line); }

.diagram-jumps { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 15px; }
.diagram-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
  transition: 0.15s ease;
}
.diagram-jump b { font-family: var(--mono); font-size: 10px; color: var(--ink-3); font-weight: 400; }
.diagram-jump:hover { border-color: var(--ink-3); color: var(--ink); transform: translateY(-1px); }
.diagram-list { display: flex; flex-direction: column; gap: 16px; }
.diagram-card {
  min-width: 0;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  scroll-margin-top: 88px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.diagram-card.focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(176, 124, 34, 0.16), var(--shadow);
}
.diagram-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.diagram-no {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff8ea;
  font-family: var(--mono);
  font-size: 11px;
  transform: rotate(-2deg);
}
.diagram-head h3 { margin: 1px 0 2px; font-size: 19px; line-height: 1.35; }
.diagram-head p { margin: 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.dg-head-actions { margin-left: auto; flex: none; padding-top: 2px; }
.diagram-card .dg-caption {
  margin: 10px 2px 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  font-size: 12px;
  line-height: 1.75;
  color: var(--ink-2);
}
.dg-scroll { max-width: 100%; min-width: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 3px; }
.dg-scroll .dg { min-width: 520px; }

.dg {
  position: relative;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: var(--card-soft);
}
.dg + .dg { margin-top: 10px; }
.dg-flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.dg-step {
  position: relative;
  flex: 1 1 140px;
  min-width: 140px;
  padding: 9px 11px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--card);
}
.dg-step .dg-no {
  position: absolute;
  top: -9px;
  left: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff8ea;
  font-family: var(--mono);
  font-size: 9px;
}
.dg-step > b { display: block; margin-top: 3px; font-family: var(--serif); font-size: 13.5px; line-height: 1.4; }
.dg-step > span, .dg-step > small { display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.65; color: var(--ink-2); }
.dg-step.good { background: var(--green-soft); border-color: #b9d2c2; }
.dg-step.good b { color: #244736; }
.dg-step.bad { background: var(--red-soft); border-color: #e5c3b8; }
.dg-step.bad b { color: #6d3023; }
.dg-step.hot { background: var(--gold-soft); border-color: #e4d0a6; }
.dg-step.hot b { color: #5d4a25; }
.dg-step.blue { background: var(--blue-soft); border-color: #c8dae8; }
.dg-step.blue b { color: #29485f; }
.dg-step.ghost { background: transparent; border-style: dashed; }
.dg-step.center { text-align: center; }
.dg-arrow {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 18px;
}
.dg-arrow.down { transform: rotate(90deg); padding: 1px 0; }
.dg-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dg-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dg-col .dg-step { flex: 0 0 auto; }
.dg-levels { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dg-level { display: flex; justify-content: center; align-items: stretch; gap: 10px; flex-wrap: wrap; width: 100%; }
.dg-level .dg-step { flex: 0 1 180px; }

.dg-note {
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-2);
}
.dg-note b { color: var(--ink); }

.dg-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  background: var(--card);
  font-size: 12px;
}
.dg-table th, .dg-table td {
  border: 1px solid var(--line);
  padding: 5px 7px;
  text-align: center;
  vertical-align: middle;
  line-height: 1.6;
}
.dg-table th {
  background: var(--card-soft);
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.dg-table td { color: var(--ink-2); }
.dg-table .rowhead { text-align: left; white-space: nowrap; font-weight: 650; color: var(--ink); }
.dg-table .hl { background: var(--gold-soft); }
.dg-table .hl-bad { background: var(--red-soft); }
.dg-table .hl-good { background: var(--green-soft); }
.dg-table .dim { opacity: 0.42; }
.dg-table .pivot { background: var(--gold-soft); outline: 2px solid var(--red); outline-offset: -2px; font-weight: 700; color: var(--ink); }
.dg-table .num { font-family: var(--mono); }
.dg-table .left { text-align: left; }
.dg-table caption { caption-side: bottom; padding-top: 5px; font-size: 10.5px; color: var(--ink-3); }

.dg-stage {
  position: relative;
  width: 100%;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  min-width: 560px;
  aspect-ratio: var(--ar, 16 / 9);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background-color: var(--card);
  background-image: radial-gradient(rgba(34, 48, 62, 0.075) 1px, transparent 1px);
  background-size: 17px 17px;
  overflow: hidden;
}
.dg-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dg-stage .dg-pin {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 3px 7px -6px rgba(34, 48, 62, 0.55);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}
.dg-stage .dg-pin.plain { background: transparent; border-color: transparent; box-shadow: none; }
.dg-stage .dg-pin.good { background: var(--green-soft); border-color: #b9d2c2; color: #244736; }
.dg-stage .dg-pin.hot { background: var(--gold-soft); border-color: #e4d0a6; color: #5d4a25; }
.dg-stage .dg-pin.bad { background: var(--red-soft); border-color: #e5c3b8; color: #6d3023; }
.dg-stage .dg-pin.blue { background: var(--blue-soft); border-color: #c8dae8; color: #29485f; }
.dg-stage .dg-pin.dim { background: var(--card-soft); border-color: var(--line-soft); color: var(--ink-3); }
.dg-stage .dg-pin.wide { white-space: normal; max-width: 160px; text-align: center; }
.dg-svg .edge { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.dg-svg .edge.dashed { stroke-dasharray: 6 5; }
.dg-svg .edge.dim { stroke: var(--line); }
.dg-svg .edge.hot { stroke: var(--red); stroke-width: 2.4; }
.dg-svg .edge.good { stroke: var(--green); stroke-width: 2.4; }
.dg-svg .edge.gold { stroke: var(--gold); stroke-width: 2.4; }
.dg-svg .node { fill: var(--card); stroke: var(--ink); stroke-width: 1.6; }
.dg-svg .node.hot { fill: var(--gold-soft); stroke: var(--gold); }
.dg-svg .node.good { fill: var(--green-soft); stroke: var(--green); }
.dg-svg .node.bad { fill: var(--red-soft); stroke: var(--red); }
.dg-svg .node.dim { fill: var(--card-soft); stroke: var(--line); }
.dg-svg .axis { stroke: var(--ink-3); stroke-width: 1.2; fill: none; }
.dg-svg .curve { fill: none; stroke: var(--blue); stroke-width: 2.2; }
.dg-svg .curve.red { stroke: var(--red); }
.dg-svg .curve.green { stroke: var(--green); }
.dg-svg .curve.dashed { stroke-dasharray: 6 5; }
.dg-svg .fill-soft { fill: var(--gold-soft); opacity: 0.55; }
.dg-svg .fill-green { fill: var(--green-soft); opacity: 0.5; }
.dg-svg .fill-red { fill: var(--red-soft); opacity: 0.5; }

.dg-range { position: relative; min-width: 420px; height: 58px; margin: 16px 4px 4px; }
.dg-range-line { position: absolute; left: 0; right: 0; top: 25px; height: 6px; border-radius: 999px; background: var(--line-soft); }
.dg-range-ok { position: absolute; top: 25px; height: 6px; border-radius: 999px; background: var(--green); }
.dg-range-point { position: absolute; top: 15px; width: 13px; height: 13px; border-radius: 50%; background: var(--red); border: 2px solid var(--card); transform: translateX(-50%); }
.dg-range-lab { position: absolute; top: 37px; transform: translateX(-50%); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

.node-diagrams { display: flex; flex-direction: column; gap: 8px; margin: 15px 0 4px; }
.node-diagram {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: var(--card-soft);
  overflow: hidden;
}
.node-diagram summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.node-diagram summary::-webkit-details-marker { display: none; }
.node-diagram summary::before { content: "▸"; display: inline-block; transition: transform 0.15s ease; font-size: 10px; }
.node-diagram[open] summary::before { transform: rotate(90deg); }
.node-diagram summary b { font-family: var(--serif); font-size: 13px; letter-spacing: 0; color: var(--ink); font-weight: 700; }
.node-diagram .dg-wrap { padding: 0 9px 9px; }
.node-diagram .dg { border: 0; padding: 4px 0 0; background: transparent; }
.node-diagram .dg-scroll .dg { min-width: 480px; }
.node-diagram .dg-caption { margin: 5px 2px 0; font-size: 11px; line-height: 1.65; color: var(--ink-3); }

/* ---------- responsive ---------- */

@media (max-width: 1120px) {
  .walk-grid { grid-template-columns: 1fr; }
  .walk-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 65px;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1.5px solid var(--line);
    background: rgba(248, 243, 231, 0.96);
    backdrop-filter: blur(8px);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .sidebar > .side-label { display: none; }
  .navlist { flex-direction: row; gap: 4px; }
  .nav { width: auto; padding: 5px 9px; flex: none; }
  .nav .ic { width: 27px; height: 27px; }
  .nav .ic svg { width: 16px; height: 16px; }
  .nav-label small { display: none; }
  .nav-label b { font-size: 12.5px; white-space: nowrap; }
  .side-bottom {
    display: flex;
    align-items: center;
    flex: none;
    margin: 0 0 0 4px;
    padding: 0 0 0 6px;
    border-top: 0;
    border-left: 1px dashed var(--line);
  }
  .side-bottom .side-label, .side-bottom .side-actions, .side-bottom .side-note { display: none; }
  .side-bottom .chapter-select { width: 104px; padding: 5px 7px; font-size: 11.5px; }
  .view { padding: 22px 18px 70px; }
  .viewhead h2 { font-size: 26px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { display: none; }
  .brand-mark { width: 38px; height: 38px; font-size: 20px; }
  .stat-pill { display: none; }
  .topbar { padding: 10px 16px; }
  .node-card { padding: 20px 18px; }
  .node-card h2 { font-size: 24px; }
  .branch-grid { grid-template-columns: 1fr; }
  .map-card { max-height: none; padding: 16px; }
  .flashcard { height: 420px; }
  .fc-q { font-size: 21px; }
  .fc-face { padding: 24px 22px; }
  .glossary-grid { grid-template-columns: 1fr; }
  .fc-meta .spacer { display: none; }
}

@media (max-width: 560px) {
  .dg-scroll .dg { min-width: 0; }
  .dg-flow { flex-direction: column; }
  .dg-flow .dg-step { flex: 0 0 auto; }
  .dg-arrow { transform: rotate(90deg); padding: 1px 0; }
  .dg-split { grid-template-columns: 1fr; }
  .diagram-card { padding: 15px 14px; }
  .diagram-head { flex-wrap: wrap; }
  .diagram-head h3 { font-size: 17px; }
  .dg-head-actions { margin-left: 0; }
  .sidebar { flex-wrap: wrap; height: auto; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .navlist { gap: 3px; width: 100%; }
  .nav { padding: 6px 8px; gap: 0; }
  .nav .ic { display: none; }
  .nav-label b { font-size: 12px; }
  .side-bottom { margin: 2px 0 0 auto; padding: 4px 0 0; border-left: 0; border-top: 1px dashed var(--line); width: 100%; justify-content: flex-end; }
  .side-bottom .chapter-select { width: 150px; }
  .viewhead .head-actions { margin-left: 0; width: 100%; }
  .check-summary { gap: 16px; padding: 16px; }
  .check-summary .ring { width: 84px; height: 84px; }
  .check-tools { width: 100%; }
  .walk-side { grid-template-columns: 1fr; }
  .flashcard { height: 460px; }
  .fc-q { font-size: 19px; }
  .fc-a { font-size: 14.5px; }
  .quiz-card { padding: 18px 16px; }
  .modal { padding: 22px 18px; }
  .tour-card { bottom: 16px; padding: 16px; }
}

@media (hover: none) {
  .check-row .go { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .sidebar, .walk-side, .route-tabs, .node-actions, .fc-marks, .fc-toolbar,
  .recall-toggle, .recall-cover, .recall-actions, .tour, .toast, .trail { display: none !important; }
  body { background: #fff; }
  .shell { display: block; }
  .view { padding: 0; max-width: none; }
  .node-card, .map-card, .check-group, .term-card { box-shadow: none; break-inside: avoid; }
  .map-card { max-height: none; overflow: visible; }
  .node-card.recall .step .step-body { display: block !important; }
  .node-card.recall .step h4 { color: var(--ink) !important; text-shadow: none !important; }
}

/* ==========================================================================
   原卷 PDF 查看器
   ========================================================================== */

.view.view-wide { max-width: 1560px; }

.pdf-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 3px 2px 9px;
  margin: -6px 0 14px;
  border-bottom: 1px dashed var(--line-soft);
  scrollbar-width: thin;
}
.pdf-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.16s ease;
}
.pdf-tab .no { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.02em; }
.pdf-tab small { font-size: 10px; color: var(--red); }
.pdf-tab:hover { border-color: var(--ink-3); color: var(--ink); }
.pdf-tab.active { background: var(--ink); border-color: var(--ink); color: #fff8ea; box-shadow: 0 2px 0 rgba(34, 48, 62, 0.25); }
.pdf-tab.active .no, .pdf-tab.active small { color: #f0dcc2; }

.pdf-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 218px;
  gap: 14px;
  align-items: start;
}

.pdf-rail {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 118px);
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.pdf-rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pdf-rail-head span { font-size: 10.5px; font-weight: 800; letter-spacing: 0.18em; color: var(--ink-3); text-transform: uppercase; }
.pdf-rail-head small { font-size: 10.5px; color: var(--green); font-weight: 700; white-space: nowrap; }
.pdf-filter {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
}
.pdf-filter:focus { border-color: var(--blue); outline: none; }
.pdf-node-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.pdf-node { display: flex; align-items: stretch; gap: 2px; border-radius: 9px; transition: background 0.15s; }
.pdf-node[hidden] { display: none; }
.pdf-node:hover { background: var(--card-soft); }
.pdf-node.active { background: var(--gold-soft); box-shadow: inset 0 0 0 1px rgba(176, 124, 34, 0.35); }
.pdf-node-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  border: 0;
  background: none;
  text-align: left;
  padding: 6px 5px;
  border-radius: 8px;
  cursor: pointer;
}
.pdf-node-dot {
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  flex: none;
}
.pdf-node.located .pdf-node-dot { background: var(--green); border-color: var(--green); }
.pdf-node-text { flex: 1; min-width: 0; line-height: 1.35; }
.pdf-node-text b { display: block; font-size: 12px; font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-node-text small { display: block; font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-node-state {
  flex: none;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0 5px;
  margin-top: 4px;
}
.pdf-node.located .pdf-node-state { color: var(--green); border-color: rgba(61, 115, 88, 0.35); background: var(--green-soft); }
.pdf-node-go { align-self: center; border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 15px; padding: 4px 5px; border-radius: 6px; }
.pdf-node-go:hover { color: var(--red); background: var(--red-soft); }
.pdf-rail-note { margin: 6px 1px 0; font-size: 10px; color: var(--ink-3); line-height: 1.5; }

.pdf-main { min-width: 0; }
.pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 13px 13px 0 0;
}
.pdf-toolgroup { display: flex; align-items: center; gap: 4px; }
.pdf-toolgroup-end { margin-left: auto; }
.pdf-ic {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-2);
}
.pdf-ic:hover { border-color: var(--ink-3); color: var(--ink); background: var(--card-soft); }
.pdf-ic[hidden] { display: none; }
.pdf-zoom {
  min-width: 58px;
  height: 30px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  cursor: pointer;
}
.pdf-zoom:hover { border-color: var(--ink-3); }
.pdf-pill {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.pdf-pill:hover { border-color: var(--ink-3); color: var(--ink); }
.pdf-pill.active { background: var(--ink); border-color: var(--ink); color: #fff8ea; }
.pdf-search-group { flex: 1; min-width: 150px; }
.pdf-search-group input {
  flex: 1;
  min-width: 90px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 0 9px;
  font-size: 12px;
}
.pdf-search-group input:focus { border-color: var(--blue); outline: none; }
.pdf-search-count { font-size: 10.5px; color: var(--ink-3); min-width: 38px; font-family: var(--mono); }

.pdf-stage {
  position: relative;
  overflow: hidden;
  height: min(68vh, 760px);
  min-height: 420px;
  background-color: #e9e1d1;
  background-image: radial-gradient(rgba(70, 58, 38, 0.13) 1px, transparent 1.2px);
  background-size: 20px 20px;
  border: 1px solid var(--line);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.pdf-stage.grabbing { cursor: grabbing; }
#pdf-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.pdf-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  background: rgba(248, 243, 231, 0.86);
  backdrop-filter: blur(2px);
  z-index: 5;
  color: var(--ink-2);
}
.pdf-loading[hidden] { display: none; }
.pdf-loading b { font-size: 13px; }
.pdf-loading small { font-size: 11px; color: var(--ink-3); }
.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: pdfspin 0.8s linear infinite;
}
@keyframes pdfspin { to { transform: rotate(360deg); } }
.pdf-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 26px;
  text-align: center;
  background: rgba(248, 243, 231, 0.94);
  z-index: 6;
}
.pdf-error[hidden] { display: none; }
.pdf-error b { color: var(--red); font-family: var(--serif); font-size: 17px; }
.pdf-error p { margin: 0; max-width: 44ch; font-size: 12px; color: var(--ink-2); word-break: break-word; }
.pdf-hl {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  border: 2px solid var(--red);
  background: rgba(188, 75, 52, 0.12);
  border-radius: 4px;
  box-shadow: 0 0 0 4px rgba(188, 75, 52, 0.09);
  animation: pdfpulse 1.3s ease 2;
}
.pdf-hl[hidden] { display: none; }
.pdf-hl.search { border-color: var(--blue); background: rgba(47, 95, 134, 0.14); box-shadow: 0 0 0 4px rgba(47, 95, 134, 0.1); }
.pdf-hl span {
  position: absolute;
  left: -2px;
  bottom: calc(100% + 6px);
  max-width: 240px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--red);
  color: #fff8ea;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 10px -6px rgba(0, 0, 0, 0.5);
}
.pdf-hl.search span { background: var(--blue); }
@keyframes pdfpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.pdf-minimap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  padding: 5px;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 10px 20px -18px rgba(34, 48, 62, 0.8);
  cursor: crosshair;
}
.pdf-minimap[hidden] { display: none; }
.pdf-minimap canvas { display: block; border-radius: 4px; }
.pdf-mm-box { position: absolute; border: 2px solid var(--red); background: rgba(188, 75, 52, 0.12); pointer-events: none; border-radius: 2px; }
.pdf-zoom-fab { position: absolute; left: 10px; bottom: 10px; z-index: 4; display: flex; flex-direction: column; gap: 4px; }
.pdf-zoom-fab button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink-2);
}
.pdf-zoom-fab button:hover { color: var(--ink); border-color: var(--ink-3); }
.pdf-zoom-fab button.active { background: var(--ink); color: #fff8ea; border-color: var(--ink); }

.pdf-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 13px 13px;
  font-size: 10.5px;
  color: var(--ink-3);
}
.pdf-pos { margin-left: auto; font-family: var(--mono); }
.pdf-hint { color: var(--ink-3); }
.pdf-hint kbd { font-size: 9.5px; padding: 0 4px; }

.pdf-links { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 90px; }
.pdf-link-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.pdf-link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.pdf-link-btn span { color: var(--ink-3); }
.pdf-link-btn:hover { border-color: var(--ink-3); color: var(--ink); background: var(--card-soft); }
.pdf-link-btn:hover span { color: var(--red); }
.pdf-range { width: 100%; accent-color: var(--ink); }
.pdf-range-note { display: flex; justify-content: space-between; margin-top: 3px !important; font-size: 9.5px !important; color: var(--ink-3) !important; }

.pdf-stage:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; }

@media (max-width: 1360px) {
  .pdf-shell { grid-template-columns: 226px minmax(0, 1fr) 196px; }
}
@media (max-width: 1180px) {
  .pdf-shell { grid-template-columns: 226px minmax(0, 1fr); }
  .pdf-links { display: none; }
  .pdf-stage { height: 62vh; }
}
@media (max-width: 900px) {
  .pdf-shell { grid-template-columns: 1fr; }
  .pdf-main { order: 1; }
  .pdf-rail { order: 2; position: static; max-height: none; }
  .pdf-node-list { max-height: 190px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
  .pdf-stage { height: 58vh; min-height: 340px; }
  .pdf-zoom-fab { display: none; }
  .pdf-minimap canvas { width: 120px !important; height: auto !important; }
}
@media (max-width: 620px) {
  .pdf-node-list { grid-template-columns: 1fr; }
  .pdf-search-group { order: 6; flex-basis: 100%; }
  .pdf-search-group input { width: 100%; }
  .pdf-toolgroup-end { margin-left: 0; }
  .pdf-hint { display: none; }
  .pdf-stage { height: 54vh; min-height: 300px; }
  .pdf-tabs { margin-top: 0; }
  .pdf-minimap { display: none; }
}
