:root {
  --space: #05070d;
  --panel: rgba(12, 16, 28, 0.84);
  --panel-solid: #0e121e;
  --surface: rgba(20, 26, 44, 0.78);
  --surface-hover: rgba(30, 39, 64, 0.9);
  --line: rgba(140, 155, 190, 0.2);
  --line-strong: rgba(140, 155, 190, 0.34);
  --ink: #e8ecf6;
  --muted: #8c95ab;
  --gold: #ffe7a8;
  --pre: #8ea2ff;
  --lead: #7fe0a8;
  --cyan: #63b4ff;
  --purple: #e5b3ff;
  --green: #7fe0a8;
  --amber: #f4c76a;
  --red: #ff6f6f;
  --border: rgba(140, 155, 190, 0.2);
  --border-strong: rgba(140, 155, 190, 0.34);
  --text: #e8ecf6;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--space);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  overflow: hidden;
  color-scheme: dark;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: rgba(140, 155, 190, 0.26); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* Full-Bleed Canvas */
#star-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#star-canvas:active { cursor: grabbing; }

.map-loading {
  position: fixed;
  top: calc(50% + 14px);
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  color: #a2aec6;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

/* Top-Left Editorial HUD */
.hud-tl {
  position: fixed;
  top: 22px;
  left: 24px;
  max-width: 310px;
  z-index: 20;
  pointer-events: none;
}
.hud-tl h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #f6f8ff;
  text-shadow: 0 0 24px rgba(255, 231, 168, 0.28);
  pointer-events: auto;
  cursor: pointer;
  display: inline-block;
}
.hud-tl .sub {
  margin: 0 0 12px;
  color: #cbd3e6;
  font: 500 16px/1.65 var(--serif);
  transition: opacity 0.35s ease;
}
.map-count {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  transition: opacity 0.35s ease;
}
.map-count strong { color: var(--ink); font-weight: 600; }
.hud-tl .hint {
  margin: 12px 0 0;
  font-size: 11px;
  color: rgba(140, 155, 190, 0.72);
  transition: opacity 0.35s ease;
}
body.zoomed .hud-tl .sub,
body.zoomed .map-count,
body.zoomed .hud-tl .hint {
  opacity: 0;
}

/* Subject Legend Pills */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: auto;
}
.subj-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 18, 30, 0.72);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.subj-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}
.subj-pill.active {
  border-color: currentColor;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
}
.subj-pill .pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.subj-pill .pill-dot-all {
  background: conic-gradient(#f4c76a, #ff9d6b, #63b4ff, #79e4f2, #86f0bf, #e5b3ff, #ff86aa, #f4c76a);
}

/* Search sits with the right-side tools on wide screens. */
.search-wrap {
  position: fixed;
  top: 68px;
  right: 24px;
  width: 238px;
  z-index: 30;
  transition: right 0.35s ease;
}
#global-search {
  width: 100%;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 18, 30, 0.76);
  backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#global-search::placeholder { color: rgba(140, 155, 190, 0.72); }
#global-search:focus {
  border-color: rgba(255, 231, 168, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 231, 168, 0.1);
}
.sres {
  margin-top: 8px;
  max-height: 350px;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.72);
  padding: 6px;
}
.sres-count {
  padding: 4px 10px 6px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.search-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.search-item:hover { background: rgba(255, 255, 255, 0.07); }
.search-item-title { font-size: 13px; font-weight: 500; }
.search-item-tag { font-size: 11px; white-space: nowrap; opacity: 0.9; }

/* Top-Right Floating Action Pills */
.hud-tr {
  position: fixed;
  top: 22px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 25;
  transition: right 0.35s ease;
}
.hud-pill {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 18, 30, 0.78);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.hud-pill:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
}
.hud-pill-gold {
  border-color: rgba(255, 231, 168, 0.48);
  background: rgba(255, 231, 168, 0.11);
  color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 231, 168, 0.12);
}
.hud-pill-gold:hover {
  background: rgba(255, 231, 168, 0.2);
  border-color: var(--gold);
}
.hud-pill-icon {
  width: 36px;
  padding: 0;
  justify-content: center;
}

/* Bottom-Left Minimalist Zoom & Rotation Bar */
.zoom-bar {
  position: fixed;
  left: 24px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 20;
}
.zoom-bar button {
  height: 34px;
  min-width: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(14, 18, 30, 0.8);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.zoom-bar button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
}
.zoom-bar button[aria-pressed="true"] {
  border-color: rgba(255, 231, 168, 0.5);
  color: var(--gold);
}

/* Bottom-Right Credit */
.credit {
  position: fixed;
  right: 24px;
  bottom: 22px;
  font-size: 11px;
  color: rgba(140, 155, 190, 0.65);
  z-index: 15;
  transition: opacity 0.25s;
}
body.panel-open .credit { opacity: 0; pointer-events: none; }
.credit a { color: var(--muted); text-decoration: none; }
.credit a:hover { color: var(--gold); text-decoration: underline; }

/* Hover Tooltip */
.tip {
  position: fixed;
  pointer-events: none;
  z-index: 45;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  font-size: 12px;
  max-width: 260px;
}
.tip-name { font-weight: 600; color: var(--ink); }
.tip-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Right Floating Editorial Detail Panel */
.panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 356px;
  max-width: calc(100vw - 28px);
  background: rgba(11, 15, 26, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72);
  display: flex;
  flex-direction: column;
  z-index: 35;
  overflow: hidden;
}
.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
.panel-subj {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 24px;
}
.p-name {
  margin: 4px 0 14px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
}

/* Knowledge Chain Tree (知识链路) */
.chain-title {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 8px;
  font-weight: 600;
}
.chain-dir {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0;
}
.chain-tree {
  position: relative;
  padding-left: 14px;
  margin: 4px 0 10px;
  border-left: 1px dashed rgba(140, 155, 190, 0.3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chain-node {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  transition: background 0.12s, border-color 0.12s;
}
.chain-node:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}
.chain-node-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.chain-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--pre);
  flex-shrink: 0;
}
.chain-dot-lead { border-color: var(--lead); }
.chain-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  flex-shrink: 0;
}
.chain-me {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 231, 168, 0.55);
  background: rgba(255, 231, 168, 0.09);
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.chain-me-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  flex-shrink: 0;
}

.p-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.p-meta strong { color: var(--ink); font-family: var(--mono); font-weight: 600; margin-left: 4px; }
.p-sec { margin-top: 14px; }
.p-sec-lbl { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.p-sec ul { margin: 0; padding-left: 16px; color: var(--ink); }
.p-sec li { margin-bottom: 4px; font-size: 12.5px; }

/* Shared Buttons & Badges (used in Modals & Book View) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(140, 155, 190, 0.14);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-cyan { background: rgba(99, 180, 255, 0.14); border-color: rgba(99, 180, 255, 0.4); color: var(--cyan); }
.badge-purple { background: rgba(229, 179, 255, 0.14); border-color: rgba(229, 179, 255, 0.4); color: var(--purple); }
.badge-green { background: rgba(127, 224, 168, 0.14); border-color: rgba(127, 224, 168, 0.4); color: var(--green); }
.badge-amber { background: rgba(244, 199, 106, 0.14); border-color: rgba(244, 199, 106, 0.4); color: var(--amber); }
.badge-red { background: rgba(255, 111, 111, 0.14); border-color: rgba(255, 111, 111, 0.4); color: var(--red); }

.btn-primary {
  border: 1px solid rgba(255, 231, 168, 0.48);
  background: linear-gradient(135deg, rgba(255, 231, 168, 0.2), rgba(142, 162, 255, 0.22));
  color: var(--gold);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.15s;
}
.btn-primary:hover { background: linear-gradient(135deg, rgba(255, 231, 168, 0.3), rgba(142, 162, 255, 0.32)); }
.btn-ghost {
  border: 1px solid var(--line-strong);
  background: rgba(14, 18, 30, 0.72);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.btn-close:hover { color: var(--ink); border-color: var(--line); }

.mini-btn {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--gold); color: var(--gold); }
.mini-btn-accent {
  border-color: rgba(142, 162, 255, 0.5);
  background: rgba(142, 162, 255, 0.14);
  color: var(--pre);
}

/* Modals (Book Catalog, Diagnose, Settings) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 11, 0.76);
  backdrop-filter: blur(8px);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-shell {
  width: 920px;
  max-width: 100%;
  max-height: 90vh;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.78);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-wide { width: 1080px; }
.modal-sm { width: 520px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 26, 44, 0.55);
}
.modal-title-group { display: flex; align-items: center; gap: 12px; }
.modal-icon { font-size: 22px; }
.modal-header h2 { margin: 0; font-size: 17px; font-family: var(--serif); }
.modal-header p { margin: 2px 0 0; font-size: 12px; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 24px 26px; }

/* Book Toolbar & Chapters */
.book-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 13, 0.55);
}
.book-toolbar select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--ink);
  font-size: 12px;
}
.book-stats { display: flex; gap: 8px; margin-left: auto; }
.stat-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.stat-pill strong { color: var(--gold); margin-left: 4px; font-family: var(--mono); }
.chapter-block {
  background: rgba(20, 26, 44, 0.45);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.chapter-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.chapter-block-title { font-size: 14px; font-weight: 700; color: var(--gold); }
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.topic-card {
  background: rgba(5, 7, 13, 0.65);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.topic-card:hover { border-color: rgba(255, 231, 168, 0.45); }
.topic-card-name { font-weight: 600; font-size: 13px; }
.topic-card-desc {
  font-size: 11.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

/* Diagnose Stepper, Upload & Quiz */
#diagnose-modal, #settings-modal { grid-template-columns: minmax(0, 1fr); }
#diag-body input { min-width: 0; }
.diagnosis-upload-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 520px) {
  #diagnose-modal { padding: 10px; }
  #diag-body { padding: 14px; }
  #diag-stepper { gap: 8px; padding-inline: 12px; }
  #diag-stepper .step-num { flex-shrink: 0; }
  #diag-stepper .step-line { display: none; }
  #diag-body .demo-grid { grid-template-columns: 1fr; }
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 13, 0.5);
}
.step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.step.active { color: var(--gold); font-weight: 600; }
.step.active .step-num { background: var(--gold); border-color: var(--gold); color: #05070d; }
.step.done { color: var(--green); }
.step.done .step-num { background: var(--green); border-color: var(--green); color: #05070d; }
.step-line { width: 32px; height: 1px; background: var(--line-strong); }

.upload-zone {
  border: 1.5px dashed rgba(255, 231, 168, 0.4);
  border-radius: 12px;
  background: rgba(20, 26, 44, 0.4);
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--gold);
  background: rgba(255, 231, 168, 0.06);
}
.upload-preview-img { max-height: 220px; max-width: 100%; border-radius: 10px; border: 1px solid var(--line-strong); margin-bottom: 10px; }

.demo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.demo-card {
  text-align: left; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(20, 26, 44, 0.55);
  color: var(--ink); cursor: pointer;
}
.demo-card:hover { border-color: var(--gold); background: var(--surface-hover); }
.demo-card-title { font-weight: 700; font-size: 13px; margin: 5px 0; }
.demo-card-desc { font-size: 11px; color: var(--muted); }

.trace-chain {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; border-radius: 10px;
  background: rgba(5, 7, 13, 0.65); border: 1px solid var(--line); margin-bottom: 14px;
}
.trace-node {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 7px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface);
}
.trace-node.current { border-color: var(--cyan); background: rgba(99,180,255,0.16); color: #bae6fd; }
.trace-node.weak { border-color: var(--red); background: rgba(255,111,111,0.14); color: #fecaca; }
.trace-node.mastered { border-color: var(--green); background: rgba(127,224,168,0.14); color: #a7f3d0; }
.trace-node.root { border-color: var(--gold); background: rgba(255,231,168,0.16); color: var(--gold); }
.trace-arrow { color: var(--muted); font-size: 12px; }

.quiz-box { background: rgba(20, 26, 44, 0.55); border: 1px solid var(--line-strong); border-radius: 12px; padding: 18px; }
.quiz-prompt { font-size: 15px; font-weight: 600; margin: 10px 0 14px; white-space: pre-wrap; }
.quiz-choices { display: grid; gap: 8px; }
.quiz-choice {
  width: 100%; text-align: left; padding: 11px 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: rgba(5, 7, 13, 0.6);
  color: var(--ink); font-size: 14px; cursor: pointer; display: flex; gap: 10px;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--gold); background: var(--surface-hover); }
.quiz-choice.correct { border-color: var(--green); background: rgba(127,224,168,0.16); color: #a7f3d0; }
.quiz-choice.wrong { border-color: var(--red); background: rgba(255,111,111,0.16); color: #fecaca; }
.quiz-feedback {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: rgba(5, 7, 13, 0.72); border-left: 3px solid var(--gold); font-size: 13px;
}

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.form-group input, .form-group select {
  width: 100%; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: rgba(5, 7, 13, 0.78);
  color: var(--ink); font-size: 13px; outline: none;
}
.form-group input:focus { border-color: var(--gold); }
.settings-tip {
  padding: 10px 12px; border-radius: 9px;
  background: rgba(255, 231, 168, 0.08); border: 1px solid rgba(255, 231, 168, 0.25);
  font-size: 12px; color: var(--gold); margin-bottom: 16px;
}
.modal-footer-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 900px) {
  .search-wrap { right: 16px; width: clamp(188px, calc(30vw - 20px), 238px); }
  .hud-tr { right: 16px; }
  .demo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .hud-tl {
    top: 14px;
    right: 14px;
    left: 14px;
    max-width: none;
  }

  .hud-tl h1 {
    margin: 0;
    font-size: 25px;
  }

  .hud-tl .sub {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
  }

  .map-count,
  .hud-tl .hint {
    display: none;
  }

  .legend {
    position: absolute;
    top: 167px;
    left: 0;
    right: 0;
    gap: 5px;
    max-width: 430px;
  }

  .subj-pill {
    flex: none;
    padding: 4px 8px;
  }

  .search-wrap {
    top: 97px;
    right: 14px;
    left: 14px;
    width: auto;
    transition: none;
  }

  .hud-tr {
    top: 141px;
    right: 14px;
    left: 14px;
  }

  .zoom-bar {
    right: 12px;
    bottom: 40px;
    left: 12px;
    justify-content: center;
  }

  .credit {
    right: 8px;
    bottom: 12px;
    left: 8px;
    text-align: center;
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  .zoom-bar { bottom: 42px; }
}

body.topic-selected .legend,
body.topic-selected .hud-tr,
body.topic-selected .search-wrap { visibility: hidden; }

.chain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 8px;
}
.chain-header .chain-title { margin: 0; }
.chain-header a { text-decoration: none; }

body.relations-mode {
  overflow-y: auto;
  background: radial-gradient(ellipse at 44% 0%, #152039 0%, var(--space) 65%);
}
body.relations-mode > :not(#map-loading):not(#relations-page) { display: none; }

.relations-page {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 56px);
}
.relations-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.relations-top a, .relations-credit a {
  color: #b4c8f6;
  text-underline-offset: 3px;
}
.relations-page h1 {
  margin: 24px 0 26px;
  font: 700 clamp(25px, 5vw, 38px)/1.25 var(--serif);
}
.relation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px minmax(0, .85fr) 26px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.relation-column { min-width: 0; }
.relation-column h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--pre);
}
.relation-column h2 span { margin-left: 7px; font-size: 13px; color: var(--muted); }
.relation-current h2 { color: var(--gold); }
.relation-after h2 { color: var(--lead); }
.relation-column ul { list-style: none; padding: 0; margin: 0; }

.relation-card {
  padding: 14px;
  margin: 0 0 10px;
  overflow-wrap: anywhere;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-inline-start: 2px solid var(--pre);
  border-radius: 8px;
}
.relation-current .relation-card { border-inline-start-color: var(--gold); }
.relation-after .relation-card { border-inline-start-color: var(--lead); }
.relation-card a, .relation-card strong {
  font-size: 15px;
  color: var(--ink);
  font-weight: 650;
  text-underline-offset: 3px;
}
.relation-card a:hover { color: var(--gold); }
.relation-meta, .relation-empty { color: var(--muted); font-size: 13px; }
.relation-card p { margin: 8px 0 0; color: #c2cce0; font-size: 14px; }

.relation-connector {
  position: relative;
  margin-top: 53px;
  height: 1px;
  background: #7f91ba;
}
.relation-connector::after {
  content: '';
  position: absolute;
  top: -4px;
  right: 0;
  width: 8px;
  height: 8px;
  border-top: 1px solid #a8b8db;
  border-right: 1px solid #a8b8db;
  transform: rotate(45deg);
}
.relations-credit {
  color: var(--muted);
  margin-top: 28px;
  font-size: 13px;
}

@media (max-width: 700px) {
  .relation-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .relation-connector {
    width: 1px;
    height: 22px;
    margin: 0 auto;
  }
  .relation-connector::after { top: auto; bottom: 0; right: -4px; transform: rotate(135deg); }
}

.relations-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  margin: 24px 0 26px;
}
.relations-heading h1 { margin: 0; }
.relation-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #0c1220;
}
.relation-switch button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #b4c3de;
  padding: 7px 12px;
  font: 500 14px/1.4 var(--sans);
  cursor: pointer;
}
.relation-switch button[aria-pressed="true"] {
  background: #253252;
  color: #edf2ff;
  border-color: #46547a;
}
.relation-layout[hidden], .relation-stars[hidden] { display: none; }

.relation-stars-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: #a7b6d1;
  font-size: 13px;
}
.relation-stars-tools[hidden] { display: none; }
.relation-stars-tools button { padding: 6px 11px; }
.relation-stars-tools button:disabled { opacity: 0.42; cursor: default; }

.relation-stars {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(115px, .52fr) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 420px;
  padding: 26px 20px;
  border: 1px solid #29364e;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(72, 108, 170, .2), transparent 55%),
    radial-gradient(circle, rgba(156, 188, 236, .18) 0.6px, transparent 1px) 3px 7px / 29px 31px,
    #080f1d;
}
.relation-stars canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}
.relation-star-group { min-width: 0; --star-color: var(--pre); }
.relation-star-group[data-star-direction="after"] { --star-color: var(--lead); }
.relation-star-group h2 { margin: 0 0 10px; color: var(--star-color); font-size: 14px; }
.relation-star-group h2 span { padding-left: 5px; color: var(--muted); font-size: 12px; }
.relation-star-group ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.relation-star-group .relation-stars-dense { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.relation-star-node, .relation-star-center {
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.relation-star-node {
  position: relative;
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.relation-star-node > span:last-child {
  padding: 4px 7px;
  border: 1px solid rgba(145, 168, 204, .15);
  border-radius: 8px;
  background: #0d1728;
}
[data-star-direction="before"] .relation-star-node {
  margin-inline-start: auto;
  flex-direction: row-reverse;
  text-align: right;
}
.relation-star-node:hover, .relation-star-node:focus-visible { color: var(--star-color); }
.relation-star-node:focus-visible, .relation-star-center:focus-visible {
  outline: 1px solid var(--star-color);
  outline-offset: 1px;
}
.relation-stars .relation-star-dragging {
  z-index: 3;
  cursor: grabbing;
}
.relation-star-dragging > span:last-child {
  border-color: var(--star-color);
  box-shadow: 0 5px 24px #050912;
}
.relation-star-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--star-color);
  box-shadow: 0 0 11px var(--star-color);
}
.relation-star-center {
  --star-color: var(--gold);
  position: relative;
  display: grid;
  justify-self: center;
  justify-items: center;
  max-width: 100%;
  border-radius: 8px;
  padding: 4px;
  gap: 6px;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--gold);
}
.relation-star-center .relation-star-dot { width: 13px; height: 13px; box-shadow: 0 0 20px var(--gold); }
.relation-star-center strong, .relation-star-center .relation-meta {
  padding-inline: 5px;
  border-radius: 5px;
  background: #101827;
}
.relation-star-center strong { padding: 4px 8px; font-size: 16px; }

@media (max-width: 700px) {
  .relation-stars { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 30px; }
  .relation-star-group h2 { margin-bottom: 8px; }
  .relation-star-group ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-star-direction="before"] .relation-star-node {
    margin-inline-start: 0;
    flex-direction: row;
    text-align: left;
  }
  .relation-star-node { padding-inline: 3px; gap: 6px; }
  .relation-star-node > span:last-child { padding-inline: 5px; }
  .relation-star-center { align-self: center; }
}

.diagnosis-report {
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: #111a2b;
  overflow-wrap: anywhere;
}
.diagnosis-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.diagnosis-report-header h3, .diagnosis-report-content h4 { margin: 0; }
.diagnosis-report-content { padding: 16px 18px; }
.diagnosis-report-content h3 { margin: 22px 0 8px; color: var(--gold); font-size: 15px; }
.diagnosis-report-content p { margin: 6px 0; white-space: pre-wrap; }
.report-note { color: var(--muted); font-size: 13px; }
.report-note a { color: #aec9ff; }
.report-plan { padding-inline-start: 22px; }
.report-plan li { margin-bottom: 12px; padding-inline-start: 4px; }
.report-evidence {
  padding: 12px 14px;
  margin: 0 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #0b1323;
}
.report-result { margin-inline-start: 6px; font-size: 12px; }
.report-result.pass { color: var(--green); }
.report-result.review { color: var(--gold); }
.diagnosis-report-content footer { margin-top: 18px; }
