:root {
  --paper: #f5f6f1;
  --paper-deep: #eaeee7;
  --surface: #ffffff;
  --ink: #18211d;
  --muted: #607066;
  --soft: #8a9a90;
  --line: #d8dfd8;
  --line-strong: #bdcabe;
  --accent: #0f7a56;
  --accent-deep: #07543c;
  --signal: #b85c38;
  --blue: #315f8f;
  --shadow: 0 18px 44px rgba(24, 33, 29, 0.08);
  --radius: 8px;
  --font-sans: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-serif: Georgia, Cambria, "Noto Serif SC", "Songti SC", serif;
  color-scheme: light;
  font-family: var(--font-sans);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 33, 29, 0.035) 1px, transparent 1px) 0 0 / 100% 34px,
    var(--paper);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.atlas-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 360px) auto;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(16px, 3vw, 30px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 241, 0.9);
  backdrop-filter: blur(18px);
}

.atlas-brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.atlas-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #f5f6f1;
  font-weight: 850;
}

.atlas-brand strong,
.atlas-brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.mode-nav {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.mode-nav a,
.baseline-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.mode-nav a.active,
.mode-nav a:hover,
.baseline-link:hover {
  background: var(--ink);
  color: #fff;
}

.jump-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 12px;
}

.jump-search span,
.eyebrow {
  color: var(--soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.jump-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.atlas-shell {
  min-height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr) 326px;
  align-items: start;
}

.tree-pane,
.relation-pane {
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
  overflow: auto;
  padding: 22px 18px;
}

.tree-pane {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
}

.relation-pane {
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.pane-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.pane-heading strong {
  color: var(--muted);
  font-size: 12px;
}

.tree-root {
  display: grid;
  gap: 8px;
}

.tree-group {
  border-bottom: 1px solid var(--line);
  padding: 0 0 12px;
}

.tree-group summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.35;
  list-style-position: outside;
}

.tree-section {
  margin: 12px 0 0 17px;
}

.tree-section-title {
  margin: 0 0 5px;
  color: #718177;
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
}

.tree-link {
  display: block;
  border-left: 2px solid transparent;
  padding: 7px 8px 7px 12px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.35;
}

.tree-link:hover,
.tree-link.active {
  border-left-color: var(--accent);
  background: #edf4ef;
  color: var(--accent-deep);
}

.main-view {
  min-width: 0;
  padding: clamp(24px, 4.5vw, 58px);
  outline: 0;
}

.article-shell {
  max-width: 850px;
  margin: 0 auto;
}

.article-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 750;
}

.pill.accent {
  border-color: rgba(15, 122, 86, 0.28);
  background: #e9f4ee;
  color: var(--accent-deep);
}

.pill.signal {
  border-color: rgba(184, 92, 56, 0.28);
  background: #fff0e9;
  color: #873d23;
}

.article-shell h1,
.graph-title h1,
.path-title h1 {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: clamp(38px, 5vw, 68px);
  line-height: 1.03;
  letter-spacing: 0;
}

.lead {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.75;
}

.section-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 28px;
}

.section-strip a {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  padding: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.section-strip strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.markdown {
  padding-top: 10px;
}

.markdown h2,
.markdown h3 {
  font-family: var(--font-serif);
  letter-spacing: 0;
}

.markdown h2 {
  margin: 42px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 29px;
}

.markdown h3 {
  margin: 30px 0 12px;
  font-size: 23px;
}

.markdown p,
.markdown li {
  color: #283630;
  font-size: 17px;
  line-height: 1.82;
}

.markdown p {
  max-width: 68ch;
}

.markdown a {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown code {
  border-radius: 5px;
  background: #e9efeb;
  color: var(--accent-deep);
  padding: 2px 5px;
}

.code-block,
.diagram-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 22px rgba(24, 33, 29, 0.04);
  margin: 18px 0;
}

.code-block figcaption,
.diagram-block figcaption {
  min-height: 34px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: #718177;
  font-size: 12px;
  font-weight: 720;
  padding: 0 14px;
}

.markdown pre {
  overflow-x: auto;
  margin: 0;
  background: #f7f9f5;
  color: #23302a;
  padding: 14px 16px;
  line-height: 1.7;
  font-size: 13px;
}

.markdown pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.diagram-block figcaption {
  color: #718177;
}

.markdown table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.82);
}

.markdown th,
.markdown td {
  min-width: 160px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.65;
}

.markdown th {
  background: var(--paper-deep);
}

.markdown blockquote {
  margin: 20px 0;
  border-left: 3px solid var(--signal);
  background: rgba(255, 255, 255, 0.62);
  padding: 10px 0 10px 16px;
  color: var(--muted);
}

.markdown details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  padding: 12px 14px;
  margin: 14px 0;
}

.markdown summary {
  cursor: pointer;
  color: var(--accent-deep);
  font-weight: 800;
}

.rail-block {
  border-bottom: 1px solid var(--line);
  padding: 0 0 18px;
  margin: 0 0 18px;
}

.rail-block h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
}

.toc-list,
.relation-list,
.stat-list {
  display: grid;
  gap: 9px;
}

.toc-list a {
  display: block;
  border-left: 2px solid transparent;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toc-list a.level-3 {
  margin-left: 12px;
}

.toc-list a:hover {
  border-left-color: var(--accent);
  color: var(--accent-deep);
}

.relation-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.relation-card strong {
  line-height: 1.35;
}

.relation-card small {
  color: var(--muted);
  line-height: 1.55;
}

.stat-list span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stat-list strong {
  color: var(--ink);
}

.graph-route {
  grid-template-columns: 1fr;
}

.graph-route .tree-pane,
.graph-route .relation-pane {
  display: none;
}

.graph-view,
.path-view {
  max-width: 1180px;
  margin: 0 auto;
}

.graph-view {
  max-width: none;
}

.graph-title,
.path-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
}

.graph-title p,
.path-title p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.graph-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.graph-actions button,
#graphCanvas {
  cursor: pointer;
}

.graph-scope {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.graph-scope button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 780;
}

.graph-scope button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 7px 16px rgba(24, 33, 29, 0.14);
}

.graph-back {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 780;
}

.graph-back:hover {
  background: var(--accent-deep);
}

.graph-board {
  position: relative;
  min-height: 520px;
  height: min(62vh, 680px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(15, 122, 86, 0.04), transparent 44%),
    linear-gradient(rgba(24, 33, 29, 0.04) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(90deg, rgba(24, 33, 29, 0.04) 1px, transparent 1px) 0 0 / 34px 34px,
    #fbfcf8;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7),
    0 14px 38px rgba(24, 33, 29, 0.08);
}

.graph-board::before,
.graph-board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.graph-board::before {
  background:
    linear-gradient(180deg, rgba(251, 252, 248, 0.42), transparent 20%, transparent 78%, rgba(251, 252, 248, 0.5)),
    linear-gradient(90deg, rgba(251, 252, 248, 0.72), transparent 20%, transparent 82%, rgba(251, 252, 248, 0.72));
}

.graph-board::after {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(24, 33, 29, 0.04);
}

#graphCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#graphCanvas.dragging {
  cursor: grabbing;
}

.graph-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-grid;
  grid-template-columns: 32px 48px 32px;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(24, 33, 29, 0.08);
  backdrop-filter: blur(12px);
}

.graph-zoom button {
  min-width: 0;
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
  line-height: 1;
}

.graph-zoom button:last-child {
  border-right: 0;
}

.graph-zoom button:hover {
  background: #edf4ef;
  color: var(--accent-deep);
}

.graph-zoom button:active {
  background: var(--ink);
  color: #fff;
}

.graph-board-status {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.graph-board-status span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.graph-board-status strong {
  color: var(--ink);
}

.graph-tooltip {
  position: absolute;
  z-index: 5;
  width: min(300px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 11px 12px;
  box-shadow: 0 18px 42px rgba(24, 33, 29, 0.12);
  pointer-events: none;
  backdrop-filter: blur(16px);
}

.graph-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.graph-tooltip small {
  display: block;
  margin-bottom: 4px;
  color: var(--soft);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.graph-tooltip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.path-stage {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 20px;
  margin: 0 0 26px;
}

.path-number {
  position: sticky;
  top: 92px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}

.path-panel {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.path-panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 31px;
}

.path-panel p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.7;
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.path-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  padding: 14px;
}

.path-card:hover {
  border-color: rgba(15, 122, 86, 0.38);
  box-shadow: 0 12px 26px rgba(24, 33, 29, 0.07);
}

.path-card strong {
  line-height: 1.35;
}

.path-card small {
  margin-top: auto;
  color: var(--muted);
  line-height: 1.45;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .atlas-topbar {
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .jump-search {
    grid-column: 1 / -1;
  }

  .baseline-link {
    justify-self: end;
  }

  .atlas-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .relation-pane {
    grid-column: 1 / -1;
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .atlas-topbar,
  .atlas-shell,
  .section-strip,
  .graph-title,
  .path-title,
  .path-stage {
    grid-template-columns: 1fr;
  }

  .mode-nav {
    overflow-x: auto;
  }

  .tree-pane,
  .relation-pane {
    position: static;
    height: auto;
    border-right: 0;
  }

  .tree-pane {
    border-bottom: 1px solid var(--line);
  }

  .main-view {
    padding: 24px 16px 38px;
  }

  .article-shell h1,
  .graph-title h1,
  .path-title h1 {
    font-size: clamp(34px, 12vw, 44px);
  }

  .graph-board,
  .graph-fallback {
    min-height: 500px;
    height: 62vh;
  }

  .graph-board-status span {
    min-height: 25px;
    padding: 0 8px;
    font-size: 11px;
  }

  .graph-board-status {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .graph-zoom {
    top: 10px;
    right: 10px;
    grid-template-columns: 30px 44px 30px;
  }

  .path-number {
    position: static;
  }
}
