body.page-galaxy {
  color-scheme: dark;
  min-height: 100vh;
  margin: 0;
  color: #e5e7eb;
  background: #050816;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
}

.page-galaxy .site-header {
  display: none;
}

body.page-galaxy .main-galaxy {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.galaxy-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 5;
  padding: 0.75rem 1rem;
  background: linear-gradient(to bottom, rgba(5, 8, 22, 0.82), rgba(5, 8, 22, 0));
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.galaxy-header__inner {
  width: min(1200px, 94%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.galaxy-brand {
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #f8fafc;
  text-decoration: none;
  text-shadow: 0 0 18px rgba(125, 211, 252, 0.35);
}

.galaxy-nav a {
  color: rgba(226, 232, 240, 0.85);
  text-decoration: none;
  font-size: 0.9rem;
}

.galaxy-nav a:hover {
  color: #fff;
}

.galaxy-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

#starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  filter: saturate(1.15);
}

.nebula {
  position: absolute;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(closest-side at 20% 30%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(closest-side at 78% 22%, rgba(236, 72, 153, 0.18), transparent 55%),
    radial-gradient(closest-side at 62% 78%, rgba(56, 189, 248, 0.16), transparent 55%);
  filter: blur(40px);
  opacity: 0.9;
  animation: nebula-drift 28s ease-in-out infinite alternate;
}

@keyframes nebula-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.05); }
}

.graph-surface {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.galaxy-edit-fab {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 13;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 11px;
  border: 1px solid rgba(125, 211, 252, 0.38);
  background: rgba(8, 12, 32, 0.78);
  color: #e0f2fe;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 6px 22px rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.galaxy-edit-fab:hover {
  background: rgba(14, 20, 48, 0.92);
  border-color: rgba(125, 211, 252, 0.55);
}

.galaxy-edit-fab--on {
  border-color: rgba(74, 222, 128, 0.5);
  color: #bbf7d0;
  background: rgba(6, 42, 30, 0.72);
}

.galaxy-edit-fab--on:hover {
  border-color: rgba(74, 222, 128, 0.65);
}

.galaxy-edit-fab__icon {
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.92;
}

.edit-unlock-hint {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(203, 213, 225, 0.88);
}

.ctx-menu {
  position: absolute;
  z-index: 12;
  min-width: 156px;
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(8, 12, 32, 0.92);
  backdrop-filter: blur(14px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 16px 40px rgba(0, 0, 0, 0.5);
}

.ctx-menu__item {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(226, 232, 240, 0.95);
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  cursor: pointer;
}

.ctx-menu__item:hover {
  background: rgba(56, 189, 248, 0.16);
}

.ctx-menu__split {
  margin: 0.35rem 0;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.ctx-menu__item--danger {
  color: #fecaca;
}

.ctx-menu__item--danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

.ctx-hint {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 11;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.5);
  background: rgba(44, 27, 92, 0.7);
  color: #ede9fe;
  font-size: 0.82rem;
  backdrop-filter: blur(8px);
}

.node-hover {
  position: absolute;
  z-index: 10;
  max-width: 280px;
  pointer-events: none;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  background: linear-gradient(145deg, rgba(8, 12, 28, 0.94), rgba(14, 18, 42, 0.9));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 12px 34px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(4px) scale(0.985);
  transition: opacity 0.16s ease, transform 0.18s ease;
}

.node-hover:not([hidden]) {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.node-hover__title {
  font-size: 0.96rem;
  color: #f8fafc;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.node-hover__meta {
  margin-top: 0.2rem;
  font-size: 0.76rem;
  color: rgba(167, 243, 208, 0.95);
}

.node-hover__summary {
  margin-top: 0.42rem;
  font-size: 0.8rem;
  line-height: 1.42;
  color: rgba(226, 232, 240, 0.88);
}


.galaxy-hud {
  position: fixed;
  right: 1rem;
  top: 4.5rem;
  z-index: 6;
  width: min(300px, 92vw);
}

.hud-card {
  padding: 1rem 1rem 0.9rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 20px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
}

.hud-title {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.65);
  margin: 0 0 0.6rem;
}

.hud-label {
  display: block;
  font-size: 0.8rem;
  color: rgba(226, 232, 240, 0.75);
  margin-bottom: 0.35rem;
}

.hud-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.55);
  color: #f8fafc;
  padding: 0.55rem 0.65rem;
  outline: none;
}

.hud-input:focus {
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.hud-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.btn {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0.55rem 0.65rem;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary {
  color: #0b1224;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  color: #e5e7eb;
  background: rgba(2, 6, 23, 0.35);
  border-color: rgba(148, 163, 184, 0.25);
}

.btn-ghost:hover {
  border-color: rgba(125, 211, 252, 0.45);
}

.btn-danger {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(248, 113, 113, 0.35);
}

.btn-danger:hover {
  background: rgba(127, 29, 29, 0.5);
}

#btn-link.is-on {
  border-color: rgba(167, 139, 250, 0.65);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18);
}

.hud-hint {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: #c4b5fd;
}

.hud-tip {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(226, 232, 240, 0.55);
}

.hud-selection {
  margin-top: 0.7rem;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(2, 6, 23, 0.42);
}

.hud-selection__title {
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.9);
  margin-bottom: 0.35rem;
}

.hud-selection__content {
  font-size: 0.82rem;
  color: rgba(226, 232, 240, 0.92);
  line-height: 1.35;
  word-break: break-word;
}

.glass-dialog {
  width: min(640px, 94vw);
  max-height: min(86vh, 900px);
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 18px;
  color: #e5e7eb;
  background: rgba(10, 14, 35, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 30px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
}

#node-dialog {
  width: min(520px, 92vw);
}

.glass-dialog--compact {
  width: min(460px, 94vw);
}

.color-display {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 0.65rem;
  align-items: stretch;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.58);
  overflow: hidden;
  min-height: 124px;
  padding: 0.5rem;
}

.color-display::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 85% at 50% 50%, transparent 58%, rgba(1, 3, 12, 0.28) 100%);
  z-index: 3;
}

.color-display__main {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  min-height: 124px;
}

/**
 * 取色器必须落在可点击的可视区域内：原先把 input 移到屏外再 programmatic .click()，
 * Chromium / Edge 等会拒绝弹出原生色板，表现为「点预览没反应」。
 */
.color-display__main .color-button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 6;
  border: none;
  background: transparent;
  padding: 0;
  box-sizing: border-box;
}

.color-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: none;
}

.star-preview {
  --star-core: #7dd3fc;
  --star-halo: #7dd3fc;
  --star-core-rgb: 125, 211, 252;
  --star-halo-rgb: 125, 211, 252;
  width: 100%;
  height: 124px;
  border-radius: 12px;
  background:
    radial-gradient(closest-side at 20% 30%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(closest-side at 78% 22%, rgba(236, 72, 153, 0.18), transparent 55%),
    radial-gradient(closest-side at 62% 78%, rgba(56, 189, 248, 0.16), transparent 55%),
    linear-gradient(165deg, rgba(2, 6, 23, 0.98), rgba(5, 8, 22, 0.9));
  position: relative;
  overflow: hidden;
  animation: mini-nebula-drift 14s ease-in-out infinite alternate;
}

.star-preview::selection {
  background: transparent;
}

.star-preview > * {
  position: relative;
  z-index: 2;
}

.star-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 8% 18%, rgba(226, 232, 240, 0.52), transparent),
    radial-gradient(1px 1px at 14% 48%, rgba(226, 232, 240, 0.34), transparent),
    radial-gradient(1.2px 1.2px at 22% 72%, rgba(226, 232, 240, 0.44), transparent),
    radial-gradient(1px 1px at 31% 26%, rgba(226, 232, 240, 0.38), transparent),
    radial-gradient(1.1px 1.1px at 40% 61%, rgba(226, 232, 240, 0.42), transparent),
    radial-gradient(1px 1px at 52% 18%, rgba(226, 232, 240, 0.33), transparent),
    radial-gradient(1.2px 1.2px at 61% 44%, rgba(226, 232, 240, 0.48), transparent),
    radial-gradient(1px 1px at 69% 76%, rgba(226, 232, 240, 0.35), transparent),
    radial-gradient(1.1px 1.1px at 78% 28%, rgba(226, 232, 240, 0.4), transparent),
    radial-gradient(1px 1px at 86% 56%, rgba(226, 232, 240, 0.36), transparent),
    radial-gradient(1.2px 1.2px at 94% 22%, rgba(226, 232, 240, 0.46), transparent),
    radial-gradient(1px 1px at 96% 74%, rgba(226, 232, 240, 0.31), transparent),
    radial-gradient(1.4px 1.4px at 26% 52%, rgba(248, 250, 252, 0.42), transparent),
    radial-gradient(1.5px 1.5px at 74% 36%, rgba(248, 250, 252, 0.4), transparent);
  opacity: 0.88;
  animation: mini-star-twinkle 4.8s ease-in-out infinite;
  z-index: 0;
}

.star-preview::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 128px;
  height: 112px;
  margin-left: -64px;
  margin-top: -56px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.98) 0 2.6%, rgba(255, 255, 255, 0.5) 4.2%, rgba(var(--star-core-rgb), 0.16) 9%, transparent 15%),
    radial-gradient(circle at 50% 50%, rgba(var(--star-halo-rgb), 0.24) 0%, rgba(var(--star-halo-rgb), 0.14) 26%, rgba(var(--star-halo-rgb), 0.07) 48%, rgba(var(--star-halo-rgb), 0.025) 66%, transparent 86%);
  box-shadow:
    0 0 6px rgba(255, 255, 255, 0.45),
    0 0 22px rgba(var(--star-halo-rgb), 0.2),
    0 0 54px rgba(var(--star-halo-rgb), 0.12);
  z-index: 1;
  animation: mini-core-pulse 3.1s ease-in-out infinite;
}

.color-meta {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.2rem 0.1rem;
}

.color-meta__row {
  display: grid;
  grid-template-columns: auto 16px 1fr;
  align-items: center;
  gap: 0.35rem;
}

.color-meta__label {
  font-size: 0.72rem;
  color: rgba(226, 232, 240, 0.78);
}

.color-meta__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
}

.color-meta__swatch--glow {
  box-shadow:
    0 0 10px rgba(56, 189, 248, 0.28),
    0 0 8px rgba(0, 0, 0, 0.25);
}

.color-meta__hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  color: rgba(226, 232, 240, 0.9);
  letter-spacing: 0.01em;
}

@keyframes mini-nebula-drift {
  from {
    background-position: 0 0;
    filter: saturate(1.05);
  }
  to {
    background-position: -8px 4px;
    filter: saturate(1.2);
  }
}

@keyframes mini-star-twinkle {
  0%, 100% {
    opacity: 0.72;
  }
  50% {
    opacity: 0.92;
  }
}

@keyframes mini-core-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.glass-dialog::backdrop {
  background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.15), transparent 45%),
    rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(4px);
}

.dialog-body {
  padding: 1rem 1.05rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

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

.dialog-head h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.icon-btn {
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.35);
  color: #e5e7eb;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  cursor: pointer;
}

.field span {
  display: block;
  font-size: 0.8rem;
  color: rgba(226, 232, 240, 0.7);
  margin-bottom: 0.35rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.55);
  color: #f8fafc;
  padding: 0.55rem 0.65rem;
  outline: none;
  font: inherit;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.dialog-foot .spacer {
  flex: 1;
}

@media (max-width: 720px) {
  .galaxy-hud {
    right: 0.65rem;
    left: 0.65rem;
    width: auto;
    top: auto;
    bottom: 0.75rem;
  }
}
