:root {
  --bg-deep: #02060e;
  --bg-mid: #07101c;
  --ink: #e8f4f8;
  --ink-muted: #8aa8b5;
  --accent: #5eead4;
  --accent-warm: #a78bfa;
  --line: rgba(94, 234, 212, 0.22);
  --panel: rgba(4, 10, 20, 0.82);
  --glass: rgba(6, 14, 28, 0.72);
  --font-display: "Orbitron", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg-deep);
  line-height: 1.7;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* —— Atmosphere —— */
.space-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 55% 40% at 50% 42%, rgba(88, 120, 255, 0.12), transparent 62%),
    radial-gradient(ellipse 40% 30% at 18% 78%, rgba(46, 196, 182, 0.08), transparent 55%),
    radial-gradient(ellipse 35% 28% at 82% 22%, rgba(167, 139, 250, 0.1), transparent 50%),
    linear-gradient(165deg, #01040a 0%, #07101c 45%, #030812 100%);
}

#stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.aurora {
  position: absolute;
  inset: -20% -10%;
  background:
    conic-gradient(from 200deg at 60% 40%, transparent 0deg, rgba(46, 196, 182, 0.07) 40deg, transparent 90deg),
    conic-gradient(from 40deg at 30% 70%, transparent 0deg, rgba(240, 160, 96, 0.05) 50deg, transparent 100deg);
  animation: aurora-drift 28s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes aurora-drift {
  from { transform: translate(-2%, 1%) rotate(-2deg); }
  to { transform: translate(3%, -2%) rotate(3deg); }
}

/* —— Top bar / brand —— */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(120, 160, 220, 0.12);
  backdrop-filter: blur(12px);
  background: rgba(2, 8, 16, 0.55);
  z-index: 5;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.unlock-btn {
  border: 1px solid rgba(46, 196, 182, 0.45);
  background: rgba(46, 196, 182, 0.12);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.unlock-btn:hover {
  background: rgba(46, 196, 182, 0.22);
  border-color: rgba(46, 196, 182, 0.7);
}

.unlock-btn.is-open {
  border-color: rgba(240, 160, 96, 0.55);
  background: rgba(240, 160, 96, 0.14);
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 12, 0.72);
  backdrop-filter: blur(6px);
  padding: 1rem;
}

.auth-modal[hidden] {
  display: none;
}

.auth-card {
  width: min(22rem, 100%);
  background: rgba(8, 22, 32, 0.96);
  border: 1px solid rgba(46, 196, 182, 0.35);
  border-radius: 1rem;
  padding: 1.35rem 1.25rem 1.2rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.auth-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.auth-desc {
  color: var(--ink-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.auth-field input {
  width: 100%;
  border: 1px solid rgba(46, 196, 182, 0.28);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  border-radius: 0.55rem;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
  outline: none;
}

.auth-field input:focus {
  border-color: rgba(46, 196, 182, 0.7);
}

.auth-error {
  color: #ff8f8f;
  font-size: 0.82rem;
  margin-top: 0.55rem;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.auth-cancel,
.auth-ok {
  border: 0;
  border-radius: 0.5rem;
  padding: 0.5rem 0.95rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
}

.auth-cancel {
  background: transparent;
  color: var(--ink-muted);
}

.auth-ok {
  background: rgba(46, 196, 182, 0.85);
  color: #041018;
  font-weight: 600;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-decoration: none;
  background: linear-gradient(120deg, #f2fbfd 10%, var(--accent) 55%, var(--accent-warm) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--ink-muted);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
}

.search-wrap input {
  width: min(240px, 42vw);
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(46, 196, 182, 0.35);
  background: rgba(8, 24, 32, 0.75);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.15);
}

.search-wrap input::placeholder {
  color: rgba(138, 168, 181, 0.7);
}

/* —— Stage: graph + reader —— */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - 8.5rem);
  position: relative;
}

/* 仅打开节点详情时才占右侧栏，未解锁/关闭时不留空 */
.stage:has(#reader:not([hidden])) {
  grid-template-columns: 1fr minmax(280px, 380px);
}

.graph-pane {
  position: relative;
  min-width: 0; /* grid 子项默认 min-width:auto 会撑破，开详情后点偏 */
  min-height: calc(100vh - 8.5rem);
  height: 100%;
  overflow: hidden;
}

#graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

.cluster-panel {
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: min(17.5rem, calc(100% - 2rem));
  max-height: min(62vh, 28rem);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem 0.75rem 0.75rem;
  border-radius: 0.85rem;
  background: var(--glass);
  border: 1px solid rgba(140, 170, 220, 0.16);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 3;
}

.cluster-head h2 {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.cluster-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.cluster-list {
  list-style: none;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-right: 0.15rem;
}

.cluster-item {
  display: grid;
  grid-template-columns: 0.55rem 1fr auto;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  padding: 0.42rem 0.45rem;
  border-radius: 0.45rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.cluster-item:hover,
.cluster-item.is-active {
  background: rgba(120, 160, 255, 0.12);
}

.cluster-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.cluster-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.92;
}

.cluster-count {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.cluster-clear {
  border: 1px solid rgba(140, 170, 220, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  cursor: pointer;
}

.cluster-clear:hover {
  background: rgba(94, 234, 212, 0.12);
}

.cluster-panel[hidden] {
  display: none;
}

.graph-tools {
  position: absolute;
  right: 1rem;
  top: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  z-index: 3;
  max-width: calc(100% - 2rem);
}

.tool-btn {
  border: 1px solid rgba(160, 190, 255, 0.22);
  background: rgba(8, 16, 32, 0.7);
  color: rgba(230, 240, 255, 0.88);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tool-btn:hover {
  border-color: rgba(94, 234, 212, 0.45);
}

.tool-btn.is-on {
  background: rgba(94, 234, 212, 0.16);
  border-color: rgba(94, 234, 212, 0.45);
  color: #dffcf7;
}

.node-tip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  max-width: min(18rem, 70vw);
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(160, 190, 255, 0.25);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  font-size: 0.78rem;
  line-height: 1.45;
}

.node-tip .tip-title {
  color: #f2f8ff;
  font-weight: 500;
}

.node-tip .tip-cat {
  margin-top: 0.2rem;
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.ask-panel {
  position: absolute;
  right: 1rem;
  top: 3.6rem;
  width: min(22rem, calc(100% - 2rem));
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem 0.8rem 0.8rem;
  border-radius: 0.85rem;
  background: var(--glass);
  border: 1px solid rgba(140, 170, 220, 0.18);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  z-index: 4;
  overflow: auto;
}

.ask-panel[hidden] {
  display: none;
}

.ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ask-head h2 {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

.ask-hint {
  font-size: 0.72rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

#ask-input {
  width: 100%;
  resize: vertical;
  min-height: 4.5rem;
  border: 1px solid rgba(140, 170, 220, 0.22);
  border-radius: 0.55rem;
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.65rem;
  outline: none;
}

#ask-input:focus {
  border-color: rgba(94, 234, 212, 0.55);
}

.ask-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ask-answer {
  font-size: 0.86rem;
  line-height: 1.55;
  color: rgba(232, 244, 248, 0.95);
  white-space: pre-wrap;
  padding: 0.55rem 0.15rem;
  border-top: 1px solid rgba(140, 170, 220, 0.12);
}

.ask-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-bottom: 0.2rem;
}

.ask-ref {
  border: 1px solid rgba(140, 170, 220, 0.28);
  background: rgba(94, 234, 212, 0.08);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.ask-ref:hover {
  background: rgba(94, 234, 212, 0.18);
}

.ask-ref .hop {
  opacity: 0.65;
  margin-left: 0.25rem;
}

.graph-hint {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  pointer-events: none;
  opacity: 0.85;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(4, 10, 18, 0.4);
  border: 1px solid rgba(140, 170, 220, 0.12);
  backdrop-filter: blur(6px);
  z-index: 2;
}

.reader-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  margin-bottom: 0.2rem;
}

.reader {
  border-left: 1px solid rgba(140, 170, 220, 0.16);
  background: var(--panel);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 8.5rem);
  overflow: hidden;
  min-width: 0;
  z-index: 2; /* 低于图谱工具层，避免盖住可点区域造成点偏错觉 */
}

.reader[hidden] {
  display: none;
}

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid rgba(46, 196, 182, 0.15);
}

.reader-head h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.icon-btn {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: rgba(46, 196, 182, 0.12);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(46, 196, 182, 0.28);
}

.note-body {
  padding: 1rem 1.15rem 0.5rem;
  overflow: auto;
  flex: 1;
  font-size: 0.95rem;
}

.note-body h1,
.note-body h2,
.note-body h3 {
  margin: 0.85rem 0 0.45rem;
  line-height: 1.35;
  color: #f2fbfd;
}

.note-body h1 { font-size: 1.25rem; }
.note-body h2 { font-size: 1.08rem; color: var(--accent); }
.note-body h3 { font-size: 1rem; }

.note-body p {
  margin: 0.45rem 0;
  color: rgba(232, 244, 248, 0.9);
}

.note-body ul {
  margin: 0.4rem 0 0.6rem 1.1rem;
}

.note-body li {
  margin: 0.2rem 0;
}

.note-body code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(46, 196, 182, 0.12);
  color: #9aeee3;
}

.wiki-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(46, 196, 182, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.wiki-link:hover {
  color: var(--accent-warm);
  border-bottom-color: rgba(240, 160, 96, 0.55);
}

.note-links {
  padding: 0.75rem 1.15rem 1.25rem;
  border-top: 1px solid rgba(46, 196, 182, 0.12);
  overflow: auto;
  max-height: 38%;
}

.note-links h3 {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0.55rem 0 0.4rem;
}

.link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid rgba(46, 196, 182, 0.35);
  background: rgba(46, 196, 182, 0.08);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  background: rgba(46, 196, 182, 0.22);
  border-color: var(--accent);
}

/* —— Footer —— */
.site-footer {
  padding: 0.9rem clamp(1rem, 3vw, 2rem) 1.15rem;
  border-top: 1px solid rgba(46, 196, 182, 0.15);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}

.footer-brand,
.beian a {
  font-size: 0.8rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  text-decoration: none;
}

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

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .search-wrap {
    grid-column: 1 / -1;
    order: 3;
  }

  .search-wrap input {
    width: 100%;
  }

  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(48vh, 1fr);
  }

  .stage:has(#reader:not([hidden])) {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(48vh, 1fr) auto;
  }

  .cluster-panel {
    max-height: 38vh;
    width: min(15rem, calc(100% - 2rem));
  }

  .graph-tools {
    top: auto;
    bottom: 3.2rem;
  }

  .reader {
    border-left: 0;
    border-top: 1px solid rgba(140, 170, 220, 0.16);
    max-height: 46vh;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    letter-spacing: 0.14em;
    text-indent: 0.14em;
  }
}


/* —— 道演展开 —— */
.dao-rail {
  position: absolute;
  left: 50%;
  bottom: 2.6rem;
  transform: translateX(-50%);
  z-index: 4;
  width: min(28rem, calc(100% - 2rem));
  padding: 0.7rem 0.85rem 0.65rem;
  border-radius: 0.85rem;
  background: rgba(4, 12, 24, 0.88);
  border: 1px solid rgba(160, 190, 255, 0.22);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dao-rail[hidden] {
  display: none;
}

.dao-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.dao-step {
  font-family: "Orbitron", "Noto Sans SC", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: rgba(220, 235, 255, 0.92);
}

.dao-poles {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.dao-chip {
  border: 1px solid rgba(160, 190, 255, 0.28);
  background: rgba(20, 36, 64, 0.7);
  color: rgba(230, 240, 255, 0.9);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dao-chip.dao-yin {
  border-color: rgba(120, 150, 220, 0.55);
  background: rgba(40, 60, 120, 0.45);
  color: #c8d8ff;
}

.dao-chip.dao-yang {
  border-color: rgba(240, 200, 140, 0.55);
  background: rgba(90, 60, 30, 0.4);
  color: #ffe6c0;
}

.dao-chip.dao-three {
  border-color: rgba(160, 230, 200, 0.45);
  background: rgba(30, 70, 55, 0.4);
  color: #d4f5e8;
}

.dao-three-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.dao-hint {
  margin: 0;
  font-size: 0.68rem;
  color: rgba(170, 190, 220, 0.65);
  letter-spacing: 0.04em;
}


/* —— 问大脑 · 道演思维导图 —— */
.ask-mindmap {
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.55rem 0.6rem;
  border-radius: 0.55rem;
  background: rgba(6, 14, 28, 0.55);
  border: 1px solid rgba(140, 170, 220, 0.18);
  max-height: 14rem;
  overflow: auto;
}
.ask-mindmap[hidden] { display: none; }
.ask-mindmap ul {
  list-style: none;
  margin: 0.15rem 0 0.15rem 0.7rem;
  padding: 0;
  border-left: 1px solid rgba(140, 170, 220, 0.22);
}
.ask-mindmap > ul { margin-left: 0; border-left: none; }
.ask-mm-node {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.12rem 0;
}
.ask-mm-role {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: rgba(170, 200, 240, 0.7);
  min-width: 1.6rem;
}
.ask-mm-btn {
  border: none;
  background: transparent;
  color: rgba(230, 240, 255, 0.92);
  font: inherit;
  cursor: pointer;
  text-align: left;
  padding: 0;
}
.ask-mm-btn:hover { color: #9ef0e0; text-decoration: underline; }
.ask-mm-btn.is-gap { color: rgba(255, 190, 140, 0.95); }
.ask-mm-btn.is-filled { color: rgba(160, 230, 190, 0.95); }
.ask-mm-tag {
  font-size: 0.62rem;
  padding: 0.05rem 0.3rem;
  border-radius: 999px;
  border: 1px solid rgba(160, 190, 255, 0.25);
  color: rgba(180, 200, 230, 0.8);
}
.ask-mm-tag.gap { border-color: rgba(255, 170, 100, 0.45); color: #ffc090; }
.ask-mm-tag.filled { border-color: rgba(120, 220, 170, 0.45); color: #9fe8c4; }

.ask-mm-fill {
  cursor: pointer;
  background: rgba(90, 50, 20, 0.35);
}
.ask-mm-fill:hover {
  border-color: rgba(255, 190, 120, 0.7);
  color: #ffe0b8;
}
.ask-mm-fill:disabled {
  opacity: 0.6;
  cursor: wait;
}
