:root {
  --paper: #fbfaf7;
  --surface: #ffffff;
  --ink: #102849;
  --ink-2: #244365;
  --muted: #66778b;
  --faint: #98a4b1;
  --line: #dbe1e6;
  --line-strong: #b9c7d4;
  --accent: #ff6330;
  --accent-soft: #fff0e9;
  --green: #47a86c;
  --green-soft: #eaf7ef;
  --blue-soft: #edf4fa;
  --shadow: 0 18px 60px rgb(16 40 73 / 12%);
  --radius: 10px;
  --header-h: 76px;
  --rail-w: 244px;
  --detail-w: 430px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

button { color: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgb(255 99 48 / 28%);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: var(--header-h);
  display: grid;
  grid-template-columns: var(--rail-w) minmax(280px, 680px) auto;
  align-items: center;
  gap: 24px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line-strong);
  background: rgb(251 250 247 / 96%);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand > svg {
  width: 38px;
  flex: 0 0 38px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand-copy { display: grid; gap: 1px; }

.brand-copy strong {
  font-family: "Songti SC", "STSong", serif;
  font-size: 26px;
  letter-spacing: .03em;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.search-box {
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.search-box:focus-within {
  border-color: var(--ink-2);
  box-shadow: 0 0 0 4px rgb(16 40 73 / 6%);
}

.search-box svg, .top-action svg, .menu-button svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}

.search-box input::placeholder { color: #78889a; }

kbd {
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.top-action, .menu-button {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.menu-button { display: none; width: 42px; padding: 0; }

.app-shell {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  grid-template-columns: var(--rail-w) minmax(420px, 1fr) var(--detail-w);
}

.domain-rail {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .12em;
}

.rail-heading button {
  display: none;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.domain-button {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  margin: 2px 0;
  padding: 8px 10px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.domain-button:hover { background: var(--blue-soft); }

.domain-button.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.domain-button svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.domain-button span {
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
}

.domain-button small {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.progress-note {
  margin-top: auto;
  padding: 18px 12px 8px;
  border-top: 1px solid var(--line);
}

.progress-note .coverage-line {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
}

.progress-note > div:first-child {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.progress-note strong { color: var(--ink); }

.progress-track {
  height: 5px;
  margin: 10px 0 12px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width .25s ease;
}

.progress-note p {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.6;
}

.knowledge-map {
  min-width: 0;
  padding: 38px clamp(24px, 4vw, 64px) 80px;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M28 0H0V28' fill='none' stroke='%23dce2e7' stroke-opacity='.34' stroke-width='1'/%3E%3C/svg%3E");
}

.map-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto 25px;
}

.breadcrumb {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .1em;
}

.map-heading h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(29px, 3vw, 40px);
  font-weight: 700;
  letter-spacing: .015em;
}

.map-heading p:last-child {
  max-width: 630px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.result-count {
  display: grid;
  flex: 0 0 auto;
  padding: 0 0 5px;
  text-align: right;
}

.result-count strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
}

.result-count span { color: var(--muted); font-size: 11px; }

.filter-bar {
  position: sticky;
  z-index: 5;
  top: calc(var(--header-h) + 8px);
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto 18px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 8px 24px rgb(16 40 73 / 5%);
  backdrop-filter: blur(10px);
}

.view-tabs { display: flex; gap: 3px; }

.view-tabs button, .clear-search {
  min-height: 35px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.view-tabs button:hover { color: var(--ink); }

.view-tabs button.is-active {
  background: var(--ink);
  color: white;
}

.clear-search { color: var(--accent); }

.path-canvas {
  position: relative;
  max-width: 900px;
  min-height: 400px;
  margin: 0 auto;
  padding: 20px clamp(12px, 3vw, 40px) 36px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 88%);
}

.path-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.path-legend span { display: inline-flex; align-items: center; gap: 6px; }

.legend-dot {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.legend-dot.current { border-color: var(--accent); box-shadow: inset 0 0 0 2px white; background: var(--accent); }
.legend-dot.mastered { border-color: var(--green); background: var(--green); }
.legend-dot.saved { border-radius: 2px; border-color: var(--ink-2); background: var(--blue-soft); }

.topic-list {
  position: relative;
  padding: 25px 0 0 28px;
}

.topic-list::before {
  content: "";
  position: absolute;
  top: 27px;
  bottom: 24px;
  left: 8px;
  width: 1px;
  background: var(--line-strong);
}

.stage-heading {
  position: relative;
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.stage-heading:not(:first-child) { margin-top: 27px; }

.stage-heading::before {
  content: "";
  position: absolute;
  top: .45em;
  left: -24px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--ink-2);
  box-shadow: 0 0 0 1px var(--ink-2);
}

.topic-node {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin: 8px 0;
  padding: 15px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .17s ease, border-color .17s ease, box-shadow .17s ease;
}

.topic-node::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -21px;
  width: 20px;
  height: 1px;
  background: var(--line-strong);
}

.topic-node:hover {
  transform: translateX(3px);
  border-color: #8fa5b9;
  box-shadow: 0 8px 24px rgb(16 40 73 / 8%);
}

.topic-node.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(255 99 48 / 12%);
}

.topic-node.is-mastered { border-left: 4px solid var(--green); padding-left: 13px; }

.topic-main { min-width: 0; }

.topic-title-row { display: flex; align-items: baseline; gap: 9px; }

.topic-index {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.topic-node h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  line-height: 1.3;
}

.topic-node p {
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 10px;
  white-space: nowrap;
}

.topic-state {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.is-mastered .topic-state { border-color: var(--green); background: var(--green); color: white; }

.topic-state svg { width: 11px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.save-mark {
  width: 12px;
  height: 15px;
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1.6;
}

.is-saved .save-mark { fill: var(--accent-soft); stroke: var(--accent); }

.empty-state {
  padding: 70px 20px 50px;
  text-align: center;
}

.empty-state svg {
  width: 58px;
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.empty-state h2 { margin: 15px 0 6px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

.detail-panel {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  padding: 28px 24px 54px;
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.detail-close {
  display: none;
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 17px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}

.detail-domain {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .1em;
}

.detail-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
}

.detail-title-row h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 28px;
  line-height: 1.28;
}

.detail-source {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.icon-action {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

.icon-action svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-action.is-saved { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.concept-lead {
  margin: 22px 0 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 750;
}

.section-label::before {
  content: "";
  width: 3px;
  height: 16px;
  background: var(--accent);
}

.concept-lead > p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.85;
}

.analogy {
  margin-top: 14px;
  padding: 13px 14px;
  border-left: 3px solid var(--ink-2);
  background: var(--blue-soft);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.7;
}

.concept-visual {
  margin: 16px 0 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.concept-visual strong { display: block; margin-bottom: 8px; font-size: 11px; }

.fraction-bar { display: flex; height: 44px; overflow: hidden; border: 2px solid var(--ink); border-radius: 6px; }
.fraction-bar i { flex: 1; border-right: 1px solid var(--ink); background: white; }
.fraction-bar i:last-child { border-right: 0; }
.fraction-bar i.on { background: #ff845f; }
.visual-caption { margin: 8px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

.key-list, .pitfall-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.key-list li, .pitfall-list li {
  position: relative;
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.65;
}

.key-list li::before {
  content: "";
  position: absolute;
  top: .62em;
  left: 1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.pitfall-list li::before {
  content: "!";
  position: absolute;
  top: 1px;
  left: 0;
  color: var(--accent);
  font-weight: 800;
}

.detail-section { padding: 20px 0 0; }

.formula-box {
  display: grid;
  gap: 7px;
  margin-top: 11px;
}

.formula-line {
  padding: 10px 12px;
  border-left: 2px solid var(--ink-2);
  background: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.relation-links { display: flex; flex-wrap: wrap; gap: 7px; }

.relation-links button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11px;
  cursor: pointer;
}

.relation-links button:hover { border-color: var(--accent); color: var(--accent); }

.example-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
  border-bottom: 1px solid var(--line);
}

.example-tabs button {
  padding: 10px 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.example-tabs button.is-active { border-bottom-color: var(--accent); color: var(--accent); }

.example-card { padding: 17px 0 0; }

.example-context {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.example-question {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 620;
  line-height: 1.75;
  white-space: pre-line;
}

.example-actions { display: flex; gap: 8px; margin-top: 14px; }

.answer-toggle, .hint-toggle, .detail-primary, .dialog-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.answer-toggle.primary, .detail-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.hint-box, .answer-box, .practice-answer {
  margin-top: 12px;
  padding: 13px 14px;
  border-left: 3px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.75;
  white-space: pre-line;
}

.answer-box { border-left-color: var(--green); background: var(--green-soft); }

.answer-box strong, .practice-answer strong { color: var(--ink); }

.mastery-actions {
  position: sticky;
  bottom: -54px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 25px -24px -54px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  backdrop-filter: blur(10px);
}

.detail-primary.secondary { border-color: var(--ink); background: var(--ink); }

.mastery-actions button.is-active { border-color: var(--green); background: var(--green); }

.source-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.practice-dialog {
  width: min(540px, calc(100vw - 28px));
  padding: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.practice-dialog::backdrop { background: rgb(16 40 73 / 36%); backdrop-filter: blur(3px); }

.dialog-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  font-size: 26px;
  cursor: pointer;
}

.dialog-label { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .1em; }
.practice-dialog h2 { margin: 0 0 20px; font-family: "Songti SC", serif; font-size: 25px; }
.practice-question { font-size: 16px; font-weight: 620; line-height: 1.8; white-space: pre-line; }
.practice-answer { border-left-color: var(--green); background: var(--green-soft); }
.practice-dialog > .answer-toggle { margin-top: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; padding-top: 17px; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  z-index: 80;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible { opacity: 1; transform: none; }

.mobile-scrim { position: fixed; z-index: 39; inset: 0; background: rgb(16 40 73 / 35%); }

@media (max-width: 1240px) {
  :root { --detail-w: 390px; --rail-w: 224px; }
  .topbar { gap: 18px; }
  .brand-copy small { display: none; }
  .knowledge-map { padding-inline: 28px; }
}

@media (max-width: 1060px) {
  :root { --rail-w: 220px; }
  .topbar { grid-template-columns: var(--rail-w) minmax(250px, 1fr) auto auto; }
  .menu-button { display: inline-flex; }
  .app-shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .detail-panel {
    position: fixed;
    z-index: 45;
    top: var(--header-h);
    right: 0;
    width: min(var(--detail-w), 92vw);
    transform: translateX(104%);
    box-shadow: var(--shadow);
    transition: transform .24s ease;
  }
  .detail-panel.is-open { transform: none; }
  .detail-close { display: block; }
}

@media (max-width: 760px) {
  :root { --header-h: 126px; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: 50px 48px;
    gap: 8px 10px;
    padding: 10px 14px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .brand-copy strong { font-size: 22px; }
  .brand > svg { width: 32px; flex-basis: 32px; }
  .search-box { grid-column: 1 / -1; grid-row: 2; height: 44px; }
  .search-box kbd { display: none; }
  .top-action { grid-column: 2; grid-row: 1; width: 42px; padding: 0; }
  .top-action span { display: none; }
  .menu-button { grid-column: 3; grid-row: 1; }
  .app-shell { display: block; }
  .domain-rail {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    width: min(300px, 88vw);
    height: 100dvh;
    padding-top: 18px;
    transform: translateX(-104%);
    box-shadow: var(--shadow);
    transition: transform .23s ease;
  }
  .domain-rail.is-open { transform: none; }
  .rail-heading button { display: block; }
  .knowledge-map { padding: 26px 14px 65px; }
  .map-heading { align-items: start; }
  .map-heading h1 { font-size: 28px; }
  .result-count { display: none; }
  .filter-bar { top: calc(var(--header-h) + 6px); overflow-x: auto; }
  .view-tabs { flex: 0 0 auto; }
  .view-tabs button { padding-inline: 11px; }
  .path-canvas { padding-inline: 14px; }
  .path-legend { gap: 9px; }
  .topic-list { padding-left: 24px; }
  .topic-node { padding: 14px 12px; }
  .topic-node p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .topic-meta > span:first-child { display: none; }
  .detail-panel {
    top: 7vh;
    width: 100%;
    height: 93dvh;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    transform: translateY(105%);
  }
  .detail-panel.is-open { transform: none; }
  .detail-title-row { padding-right: 30px; }
  .practice-dialog { padding: 26px 20px 22px; }
}

@media (max-width: 420px) {
  .path-legend span:nth-child(3) { display: none; }
  .topic-node { grid-template-columns: minmax(0, 1fr); }
  .topic-meta { justify-content: flex-end; }
  .mastery-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .topbar, .domain-rail, .filter-bar, .detail-close, .mastery-actions, .practice-dialog, .toast { display: none !important; }
  .app-shell { display: block; }
  .knowledge-map { padding: 0; background: white; }
  .path-canvas { border: 0; }
  .detail-panel { position: static; width: auto; height: auto; border: 0; overflow: visible; }
}
