:root {
  --bg: #f6f9ff;
  --bg-soft: #eef5ff;
  --surface: #ffffff;
  --surface-2: #fbfdff;
  --ink: #172033;
  --muted: #5a6b83;
  --line: #dfe8f3;
  --line-strong: #c8d7e8;
  --accent: #0d8fc7;
  --accent-2: #d6a52f;
  --danger: #d64545;
  --success: #0da678;
  --shadow-sm: 0 2px 10px rgba(24, 55, 92, 0.06);
  --shadow-md: 0 10px 34px rgba(24, 55, 92, 0.11);
  --radius: 8px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "Consolas", "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse 60% 45% at 12% 8%, rgba(13, 143, 199, 0.10), transparent 70%),
    radial-gradient(ellipse 45% 40% at 88% 12%, rgba(214, 165, 47, 0.10), transparent 70%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 42%, #f5f8ff 100%);
  font-family: var(--font);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.skip-link {
  position: fixed;
  left: -999px;
  top: 8px;
  z-index: 300;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.skip-link:focus {
  left: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 20px;
  background: rgba(251, 253, 255, 0.92);
  border-bottom: 1px solid rgba(200, 215, 232, 0.75);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: #fff;
  background: linear-gradient(135deg, #0d8fc7, #37b2a8 62%, #d6a52f);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(13, 143, 199, 0.28);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.main-nav {
  display: flex;
  gap: 3px;
  margin-left: 8px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.main-nav a:hover {
  color: var(--ink);
  background: var(--bg-soft);
}

.main-nav a.active {
  color: #075e85;
  background: #e6f4fb;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.search-wrap {
  position: relative;
  flex: 0 1 320px;
  margin-left: auto;
}

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 143, 199, 0.12);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--bg-soft);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.progress-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.nav-toggle {
  display: none;
}

main {
  min-height: calc(100vh - 180px);
}

.page {
  width: 100%;
}

/* Home galaxy */
.home-hero {
  position: relative;
  width: 100%;
  height: min(720px, calc(100vh - 64px));
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 75% 62% at 22% 12%, rgba(255, 255, 255, 0.85), transparent 68%),
    linear-gradient(135deg, #eef7ff 0%, #f8fbf8 52%, #fdf7ea 100%);
}

.galaxy-shell {
  position: absolute;
  inset: 0;
}

#galaxy-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.galaxy-tools {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.galaxy-tools > * {
  pointer-events: auto;
}

.galaxy-intro {
  min-width: 210px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(200, 215, 232, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.galaxy-intro h1 {
  margin: 0 0 3px;
  font-size: 20px;
  letter-spacing: 0;
}

.galaxy-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.galaxy-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(200, 215, 232, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tool-btn:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.tool-btn.active {
  background: #e6f4fb;
  color: #075e85;
}

.tool-btn .tool-ico {
  width: 14px;
  height: 14px;
}

.galaxy-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.galaxy-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 12px;
  min-width: 208px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(200, 215, 232, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7);
}

.legend-title {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.galaxy-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(200, 215, 232, 0.8);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.galaxy-filter-panel {
  position: absolute;
  top: 76px;
  left: 14px;
  z-index: 24;
  width: min(340px, calc(100% - 28px));
  padding: 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

.filter-panel-title {
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 800;
}

.filter-group {
  margin-bottom: 11px;
}

.filter-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chapter-toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chapter-filter-pill {
  min-width: 0;
  text-align: center;
}

.chapter-filter-pill.active {
  border-color: var(--chapter-color);
  background: var(--chapter-soft);
  color: var(--ink);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.filter-grid select {
  width: 100%;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(13, 143, 199, 0.45);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(13, 143, 199, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(13, 143, 199, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 143, 199, 0); }
}

.node-panel {
  position: absolute;
  top: 70px;
  right: 14px;
  bottom: 14px;
  z-index: 30;
  display: none;
  width: min(430px, calc(100% - 28px));
  overflow: auto;
  padding: 0;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

.node-panel.open {
  display: block;
  animation: panel-in 0.18s ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.node-panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.node-panel-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.node-panel-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.panel-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--muted);
}

.panel-close:hover {
  color: var(--ink);
  background: #dcecf6;
}

.node-panel-body {
  padding: 14px 16px 18px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-soft);
  color: #34566d;
  font-size: 12px;
  font-weight: 600;
}

.badge.chapter-badge {
  color: #fff;
}

.badge.warn {
  background: #fdeaea;
  color: var(--danger);
}

.badge.gold {
  background: #faf0d4;
  color: #8a5d0e;
}

.panel-section {
  margin-top: 14px;
}

.panel-section h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  font-size: 13px;
  color: #31475c;
}

.panel-section h3::before {
  content: "";
  width: 4px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
}

.panel-section p,
.panel-section li {
  font-size: 13px;
  color: #3d5064;
}

.panel-section ul,
.panel-section ol {
  margin: 5px 0 0;
  padding-left: 20px;
}

.panel-section li {
  margin: 3px 0;
}

.formula-line {
  display: block;
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid #e7eef6;
  border-radius: 6px;
  background: #f8fbff;
  color: #20384b;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.warn-block {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--danger);
  border-radius: 0 6px 6px 0;
  background: #fff8f7;
}

.warn-block strong {
  display: block;
  margin-bottom: 3px;
  color: var(--danger);
  font-size: 12px;
}

.warn-block li {
  color: #7c4242;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.btn:hover {
  border-color: var(--accent);
  background: #eef8fd;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #0a7fb3;
}

.btn.active {
  border-color: var(--success);
  background: #e9f9f2;
  color: #087252;
}

.btn[data-mastery="weak"].active {
  border-color: var(--danger);
  background: #fdeaea;
  color: #a93434;
}

.btn[data-mastery="learning"].active {
  border-color: var(--accent-2);
  background: #fdf4d7;
  color: #8a5d0e;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.related-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.related-chip:hover {
  border-color: var(--accent);
  background: #eef8fd;
  color: var(--ink);
}

.related-chip.active {
  border-color: var(--accent);
  background: #e6f4fb;
  color: #075e85;
}

.related-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* Relation list in node panel */
.relation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.relation-item {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  transition: border-color 0.12s, background 0.12s;
  text-decoration: none;
  color: inherit;
}

.relation-item:hover {
  border-color: var(--accent);
  background: #eef8fd;
  text-decoration: none;
}

.relation-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.relation-node-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.relation-type-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: #34566d;
  font-size: 11px;
  font-weight: 600;
}

.relation-desc {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Home below graph */
.home-band {
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 20px 16px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.stat-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 19px;
  font-weight: 700;
}

.stat-num {
  display: block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 38px 0 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-link {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.chapter-card {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 16px 16px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.chapter-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.chapter-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--chapter-color);
}

.chapter-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}

.chapter-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--chapter-soft);
  color: var(--chapter-color);
  font-size: 18px;
  font-weight: 700;
}

.chapter-card h3 {
  margin: 0;
  font-size: 15px;
}

.chapter-card .en {
  color: var(--muted);
  font-size: 11px;
}

.chapter-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.chapter-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--chapter-color);
  font-weight: 700;
}

.utility-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.utility-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.utility-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.utility-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e6f4fb, #fbf2d6);
  color: #0d6e93;
  font-size: 20px;
  font-weight: 800;
}

.utility-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.utility-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* Chapter page */
.chapter-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb-sep {
  opacity: 0.55;
}

.chapter-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.chapter-hero-main {
  display: flex;
  gap: 16px;
}

.chapter-hero-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--chapter-soft);
  color: var(--chapter-color);
  font-size: 26px;
  font-weight: 800;
}

.chapter-hero h1 {
  margin: 0;
  font-size: 26px;
}

.chapter-hero .en {
  color: var(--muted);
  font-size: 13px;
}

.chapter-hero p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.chapter-exam {
  max-width: 320px;
  padding: 12px 14px;
  border-left: 4px solid var(--chapter-color);
  background: var(--chapter-soft);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
}

.chapter-exam strong {
  display: block;
  margin-bottom: 3px;
}

.chapter-subgraph {
  position: relative;
  height: 320px;
  margin: 18px 0;
  overflow: hidden;
  background: linear-gradient(135deg, #eef7ff, #fbf7ec);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chapter-subgraph canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chapter-subgraph-tip {
  position: absolute;
  left: 12px;
  bottom: 10px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(200, 215, 232, 0.8);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.knowledge-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-pill {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.filter-pill.active {
  border-color: var(--chapter-color);
  background: var(--chapter-soft);
  color: var(--ink);
}

.toolbar-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.knowledge-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.knowledge-card {
  display: flex;
  flex-direction: column;
  min-height: 164px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--chapter-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.knowledge-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.knowledge-card h3 {
  margin: 0 0 5px;
  font-size: 14.5px;
  line-height: 1.35;
}

.knowledge-card .desc {
  flex: 1;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.knowledge-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
}

.stars {
  color: var(--accent-2);
  font-size: 12px;
  letter-spacing: 0.5px;
}

.level-tag {
  display: inline-flex;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--bg-soft);
  color: #34566d;
  font-size: 11px;
  font-weight: 700;
}

/* Knowledge detail */
.knowledge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

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

.knowledge-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--chapter-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.knowledge-title h1 {
  margin: 0 0 6px;
  font-size: 25px;
}

.knowledge-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.knowledge-title .badge-row {
  justify-content: flex-end;
  max-width: 240px;
}

.section-block {
  margin-top: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.section-block h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  font-size: 16px;
}

.section-block h2 .sec-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 14px;
}

.section-block p,
.section-block li {
  color: #3d5064;
  font-size: 13.5px;
}

.section-block ul,
.section-block ol {
  margin: 6px 0 0;
  padding-left: 22px;
}

.section-block li {
  margin: 4px 0;
}

.property-list {
  list-style: none;
  padding: 0;
}

.property-list li {
  position: relative;
  padding: 7px 10px 7px 28px;
  margin: 5px 0;
  border-radius: 6px;
  background: #f7faff;
}

.property-list li::before {
  content: "∎";
  position: absolute;
  left: 11px;
  color: var(--accent);
  font-size: 13px;
}

.example-block {
  margin-top: 9px;
  padding: 12px 14px;
  border: 1px solid #e7eef6;
  border-radius: 7px;
  background: #f8fbff;
}

.example-block .q {
  margin: 0 0 5px;
  color: #1d4f68;
  font-weight: 700;
}

.example-block .a {
  margin: 0;
  color: var(--muted);
}

.example-block .a strong {
  color: var(--success);
}

.knowledge-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.aside-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.aside-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.aside-card .related-chip {
  width: 100%;
}

.mastery-panel {
  display: grid;
  gap: 8px;
}

.mastery-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.mastery-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mastery-btn.active {
  border-color: var(--success);
  background: #e9f9f2;
  color: #087252;
}

.mastery-btn[data-status="weak"].active {
  border-color: var(--danger);
  background: #fdeaea;
  color: #a93434;
}

.mastery-btn[data-status="learning"].active {
  border-color: var(--accent-2);
  background: #fdf4d7;
  color: #8a5d0e;
}

.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.prev-next a {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.prev-next a strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.prev-next a:last-child {
  text-align: right;
}

/* Methods page */
.method-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.page-subtitle {
  max-width: 760px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.symptom-box {
  margin-top: 22px;
  padding: 18px;
  background: linear-gradient(135deg, #ffffff, #f3f9fd);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.symptom-box h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.symptom-box > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.symptom-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.symptom-chip {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}

.symptom-chip:hover {
  border-color: var(--accent);
  background: #eef8fd;
  color: var(--ink);
}

.symptom-chip.active {
  border-color: var(--accent);
  background: #e0f1fa;
  color: #075e85;
}

.symptom-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f6fbff;
  border: 1px solid #d8ebf6;
  color: #34566d;
  font-size: 13px;
}

.symptom-result strong {
  color: #075e85;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.method-card {
  display: flex;
  flex-direction: column;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.method-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.method-card h3 {
  margin: 0;
  font-size: 16px;
}

.method-card .badge-row {
  flex: 0 0 auto;
}

.method-card > p {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 13px;
}

.method-steps {
  counter-reset: step;
  margin: 0;
  padding: 0;
  list-style: none;
}

.method-steps li {
  position: relative;
  margin: 7px 0;
  padding: 7px 10px 7px 38px;
  border-radius: 7px;
  background: #f7faff;
  color: #3d5064;
  font-size: 13px;
}

.method-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #dbeefa;
  color: #075e85;
  font-size: 11px;
  font-weight: 800;
}

.method-example {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent-2);
  border-radius: 0 6px 6px 0;
  background: #fdf8ea;
  color: #5d512c;
  font-size: 12.5px;
}

.method-example strong {
  color: #8a5d0e;
}

/* Topics page */
.topic-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.topic-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 18px;
  margin-top: 22px;
}

.topic-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.topic-tab:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.topic-tab.active {
  border-color: var(--topic-color);
  background: var(--topic-soft);
  color: var(--ink);
}

.topic-tab-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--topic-soft);
  color: var(--topic-color);
  font-weight: 800;
}

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

.topic-hero {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--topic-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.topic-hero h1 {
  margin: 0;
  font-size: 25px;
}

.topic-hero .subtitle {
  margin: 2px 0 9px;
  color: var(--topic-color);
  font-size: 13px;
  font-weight: 700;
}

.topic-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.topic-section {
  margin-top: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.topic-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.topic-section p {
  margin: 0;
  color: #3d5064;
  font-size: 13.5px;
}

.compare-wrap {
  margin-top: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.compare-wrap h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.compare-table th {
  padding: 9px 10px;
  background: var(--bg-soft);
  color: #34566d;
  text-align: left;
  font-size: 12px;
}

.compare-table td {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  color: #3d5064;
  vertical-align: top;
}

.topic-nodes {
  margin-top: 14px;
}

/* Search page */
.search-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.search-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.search-hero input {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  font-size: 14px;
}

.search-hero input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 143, 199, 0.12);
}

.search-results {
  margin-top: 18px;
}

.search-group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 20px 0 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.search-group-title .count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.result-item {
  display: block;
  padding: 13px 15px;
  margin-bottom: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.result-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.result-item h3 {
  margin: 0 0 4px;
  font-size: 14.5px;
}

.result-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.result-item .meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11.5px;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #fbeebd;
  color: #6b4d06;
}

/* Progress modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(23, 32, 51, 0.35);
  backdrop-filter: blur(3px);
}

.progress-modal {
  width: min(760px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

.progress-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.progress-modal h2 {
  margin: 0;
  font-size: 19px;
}

.progress-total {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-radius: 8px;
  background: var(--bg-soft);
}

.progress-ring {
  --progress: 0;
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), #dce7f1 0);
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--surface);
}

.progress-ring span {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.chapter-progress-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.chapter-progress {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chapter-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef6;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--chapter-color);
}

/* Directory panel */
.galaxy-dir-panel {
  position: absolute;
  top: 70px;
  left: 14px;
  bottom: 14px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  width: 280px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  transform: translateX(-310px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.2s ease;
  pointer-events: none;
}

.galaxy-dir-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.dir-panel-header {
  flex: 0 0 auto;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
}

.dir-search-wrap {
  position: relative;
}

.dir-search-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.dir-search-wrap input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--bg);
  color: var(--ink);
  font-size: 12.5px;
  transition: border-color 0.15s;
}

.dir-search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 143, 199, 0.1);
}

.dir-search-wrap input::placeholder {
  color: #b0bec5;
}

.dir-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

.dir-tree::-webkit-scrollbar {
  width: 4px;
}

.dir-tree::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.dir-chapter {
  border-bottom: 1px solid #f0f4fa;
}

.dir-chapter:last-child {
  border-bottom: none;
}

.dir-chapter-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

.dir-chapter-head:hover {
  background: var(--bg-soft);
}

.dir-chapter-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.dir-chapter-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-chapter-count {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.dir-arrow {
  flex: 0 0 auto;
  width: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.18s ease;
}

.dir-chapter-head.collapsed .dir-arrow {
  transform: rotate(-90deg);
}

.dir-nodes {
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.dir-chapter-head.collapsed + .dir-nodes {
  max-height: 0 !important;
}

.dir-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 36px;
  transition: background 0.1s;
  text-decoration: none;
}

.dir-node:hover {
  background: #eef8fd;
}

.dir-node-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dir-node-label {
  flex: 1;
  font-size: 12px;
  color: #3d5064;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-node:hover .dir-node-label {
  color: var(--accent);
}

.dir-node-level {
  flex: 0 0 auto;
  font-size: 10px;
  color: #b0bec5;
  font-weight: 600;
}

/* Dir search highlight */
.dir-node.highlight {
  background: #f0f7ff;
}

.dir-node.highlight .dir-node-label {
  color: var(--accent);
  font-weight: 700;
}

.dir-node.muted {
  opacity: 0.35;
}

.dir-chapter.muted {
  opacity: 0.35;
}

/* Footer */
.site-footer {
  padding: 26px 20px 34px;
  border-top: 1px solid rgba(200, 215, 232, 0.7);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer p {
  margin: 3px 0;
}

/* Responsive */
@media (max-width: 1100px) {
  .chapter-grid,
  .knowledge-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .symptom-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .topbar {
    gap: 9px;
    padding: 0 12px;
  }

  .main-nav {
    position: absolute;
    top: 62px;
    left: 12px;
    right: 12px;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
  }

  .main-nav.open {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .search-wrap {
    flex: 1 1 auto;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .utility-grid,
  .method-grid,
  .topic-shell {
    grid-template-columns: 1fr;
  }

  .topic-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .knowledge-layout {
    grid-template-columns: 1fr;
  }

  .chapter-progress-list {
    grid-template-columns: 1fr;
  }

  .galaxy-legend {
    display: none;
  }

  .galaxy-dir-panel {
    width: 240px;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: 58px;
  }

  .brand {
    font-size: 15px;
  }

  .progress-btn {
    width: 36px;
    padding: 0;
  }

  .progress-count {
    display: none;
  }

  .search-wrap {
    max-width: 150px;
  }

  .home-hero {
    min-height: 520px;
    height: calc(100vh - 58px);
  }

  .galaxy-intro {
    min-width: 0;
    width: 100%;
  }

  .galaxy-intro h1 {
    font-size: 18px;
  }

  .galaxy-tools {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-direction: column;
  }

  .galaxy-toolbar {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .galaxy-filter-panel {
    top: 96px;
    width: calc(100% - 20px);
    left: 10px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .tool-btn {
    flex: 0 0 auto;
  }

  .node-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 74vh;
    border-radius: 10px 10px 0 0;
  }

  .stats-strip {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .stat-tile {
    min-height: 72px;
    padding: 11px;
  }

  .chapter-grid,
  .knowledge-list {
    grid-template-columns: 1fr;
  }

  .chapter-hero {
    flex-direction: column;
  }

  .chapter-exam {
    max-width: none;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .topic-tabs {
    grid-template-columns: 1fr;
  }

  .symptom-grid {
    grid-template-columns: 1fr 1fr;
  }

  .knowledge-title {
    flex-direction: column;
  }

  .knowledge-title .badge-row {
    justify-content: flex-start;
    max-width: none;
  }

  .prev-next {
    grid-template-columns: 1fr;
  }

  .compare-wrap {
    padding: 14px;
    overflow-x: auto;
  }

  .compare-table {
    min-width: 620px;
  }

  .galaxy-dir-panel {
    top: 56px;
    left: 10px;
    right: 10px;
    bottom: auto;
    width: auto;
    max-height: 60vh;
    transform: translateY(-110%);
    border-radius: 8px;
  }

  .galaxy-dir-panel.open {
    transform: translateY(0);
  }
}
