/* =====================================================================
   Lumorb · Celestial Atlas
   美学方向：天体制图 / 轨道观测台
   - 深海军墨底（非纯黑，带蓝调）
   - 暖金主星 + 冰蓝子节点
   - Syne（展示） + Space Grotesk（UI） + Space Mono（读数）
   - 玻璃拟态控制台，细金边
   ===================================================================== */

/* ---------- 设计 Token ---------- */
:root {
  /* 墨色阶（背景，带蓝调倾向，非纯黑） */
  --ink-void: oklch(0.085 0.028 264);
  --ink-deep: oklch(0.115 0.03 264);
  --ink: oklch(0.155 0.033 264);
  --ink-hi: oklch(0.21 0.038 264);
  --ink-line: oklch(0.32 0.045 264 / 0.45);

  /* 主星色（暖金） */
  --star: oklch(0.84 0.15 75);
  --star-hot: oklch(0.92 0.16 68);
  --star-soft: oklch(0.85 0.13 80 / 0.18);

  /* 轨道色（冰蓝 - 活跃子节点） */
  --orbit: oklch(0.82 0.085 215);
  --orbit-hot: oklch(0.92 0.09 205);
  --orbit-soft: oklch(0.82 0.08 215 / 0.16);

  /* 信号色（teal - pro 套餐） */
  --signal: oklch(0.78 0.15 165);
  --signal-hot: oklch(0.88 0.16 158);

  /* 信标色（暖琥珀 - pending/警告） */
  --beacon: oklch(0.78 0.14 45);
  --beacon-hot: oklch(0.88 0.15 38);

  /* 暗淡色（paused/离线） */
  --dim: oklch(0.52 0.025 250);
  --dim-soft: oklch(0.52 0.025 250 / 0.5);

  /* 连线 */
  --line: oklch(0.7 0.04 220 / 0.16);
  --line-hi: oklch(0.88 0.09 200 / 0.78);

  /* 文本 */
  --text: oklch(0.95 0.012 240);
  --text-dim: oklch(0.72 0.018 240);
  --text-faint: oklch(0.5 0.02 240);

  /* 字体 */
  --font-display: "Syne", "Space Grotesk", system-ui, sans-serif;
  --font-ui: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* 尺寸 */
  --panel-w: 320px;
  --radius: 14px;
  --radius-sm: 8px;

  /* 动效 */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --dur: 0.32s;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--ink-void);
  color: var(--text);
  overflow: hidden;
  position: fixed;
  inset: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  top: -100px; left: 16px;
  z-index: 1000;
  padding: 10px 18px;
  background: var(--star);
  color: var(--ink-void);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 16px; }

/* ---------- 背景宇宙层 ---------- */
.cosmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, var(--ink-deep), var(--ink-void) 70%);
}
.cosmos-aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  mix-blend-mode: screen;
  animation: drift 28s var(--ease-out-quart) infinite alternate;
}
.cosmos-aurora--a {
  width: 60vw; height: 60vw;
  top: -15%; left: -10%;
  background: radial-gradient(circle, var(--star-soft), transparent 65%);
}
.cosmos-aurora--b {
  width: 55vw; height: 55vw;
  bottom: -20%; right: -10%;
  background: radial-gradient(circle, var(--orbit-soft), transparent 65%);
  animation-delay: -14s;
  animation-duration: 34s;
}
.cosmos-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--ink-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ink-line) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.18;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 80%);
}
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6vw, -4vh) scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .cosmos-aurora { animation: none; }
}

/* ---------- 顶部 HUD ---------- */
.hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-orb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--star-hot), var(--star) 60%, oklch(0.6 0.12 70));
  box-shadow:
    0 0 14px var(--star-soft),
    0 0 28px oklch(0.84 0.15 75 / 0.35);
  flex-shrink: 0;
  animation: pulse-orb 3.6s var(--ease) infinite;
}
@keyframes pulse-orb {
  0%, 100% { box-shadow: 0 0 14px var(--star-soft), 0 0 28px oklch(0.84 0.15 75 / 0.35); }
  50%      { box-shadow: 0 0 18px var(--star-soft), 0 0 40px oklch(0.84 0.15 75 / 0.55); }
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-tld { color: var(--text-dim); font-weight: 600; }
.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--star);
  opacity: 0.85;
  margin-top: 2px;
}

.hud-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: oklch(0.155 0.033 264 / 0.72);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--ink-line);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--beacon);
  box-shadow: 0 0 8px var(--beacon);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.status-dot.live { background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.status-dot.cache { background: var(--orbit); box-shadow: 0 0 8px var(--orbit); }
.status-dot.error { background: oklch(0.6 0.18 25); box-shadow: 0 0 8px oklch(0.6 0.18 25); }
.status-text { text-transform: uppercase; }
.refresh-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 50%;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), transform 0.4s var(--ease);
}
.refresh-btn:hover { color: var(--star); background: var(--star-soft); }
.refresh-btn:active { transform: rotate(180deg); }

/* ---------- 控制台（左侧玻璃面板） ---------- */
.console {
  position: fixed;
  top: 76px;
  left: 24px;
  bottom: 64px;
  width: var(--panel-w);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 20px;
  background: oklch(0.135 0.032 264 / 0.78);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius);
  box-shadow:
    0 24px 60px -20px oklch(0.05 0.02 264 / 0.8),
    inset 0 1px 0 oklch(0.4 0.05 264 / 0.18);
  overflow-y: auto;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.console.collapsed {
  transform: translateX(calc(-100% - 32px));
  opacity: 0;
  pointer-events: none;
}
.console::-webkit-scrollbar { width: 6px; }
.console::-webkit-scrollbar-track { background: transparent; }
.console::-webkit-scrollbar-thumb {
  background: var(--ink-line);
  border-radius: 3px;
}

.console-head { padding-bottom: 4px; }
.console-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.console-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

/* 搜索 */
.console-search {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 11px 32px 11px 36px;
  background: oklch(0.1 0.025 264 / 0.7);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  letter-spacing: 0.01em;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
#search::placeholder { color: var(--text-faint); }
#search:focus {
  outline: none;
  border-color: var(--star);
  background: oklch(0.12 0.03 264 / 0.9);
  box-shadow: 0 0 0 3px var(--star-soft);
}
.search-clear {
  position: absolute;
  right: 8px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.search-clear:hover { color: var(--text); background: var(--ink-hi); }

/* 分区 */
.console-section { display: flex; flex-direction: column; gap: 10px; }
.console-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* 图例 */
.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: default;
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.legend-item.is-main .legend-dot {
  width: 14px; height: 14px;
  box-shadow: 0 0 12px currentColor;
}
.legend-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* 开关 */
.toggles { display: flex; flex-direction: column; gap: 10px; }
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 34px; height: 20px;
  background: var(--ink-hi);
  border-radius: 100px;
  border: 1px solid var(--ink-line);
  transition: background 0.24s var(--ease), border-color 0.24s var(--ease);
  flex-shrink: 0;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.24s var(--ease-out-quart), background 0.24s var(--ease);
}
.switch input:checked ~ .switch-track {
  background: var(--star-soft);
  border-color: var(--star);
}
.switch input:checked ~ .switch-track::after {
  transform: translateX(14px);
  background: var(--star);
  box-shadow: 0 0 8px var(--star-soft);
}
.switch input:focus-visible ~ .switch-track {
  box-shadow: 0 0 0 3px var(--star-soft);
}
.switch-text { transition: color 0.2s var(--ease); }
.switch input:checked ~ .switch-text { color: var(--text); }

/* 按钮 */
.console-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  transition: all 0.2s var(--ease);
}
.btn-ghost {
  flex: 1;
  background: transparent;
  border-color: var(--ink-line);
  color: var(--text-dim);
}
.btn-ghost:hover {
  color: var(--star);
  border-color: var(--star);
  background: var(--star-soft);
}
.btn-icon {
  width: 38px;
  background: transparent;
  border-color: var(--ink-line);
  color: var(--text-dim);
}
.btn-icon:hover { color: var(--text); border-color: var(--text-dim); }

.console-counts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* 收起后的展开按钮 */
.panel-expand {
  position: fixed;
  top: 76px;
  left: 24px;
  z-index: 25;
  width: 44px; height: 44px;
  display: flex;
  align-items: center; justify-content: center;
  background: oklch(0.135 0.032 264 / 0.78);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius);
  color: var(--text-dim);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.panel-expand:hover {
  color: var(--star);
  border-color: var(--star);
}

/* ---------- 舞台 ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 5;
}
.constellation {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.constellation.dragging { cursor: grabbing; }
.constellation.over-link { cursor: pointer; }
.constellation.over-main { cursor: default; }
.constellation:focus-visible {
  outline: 2px solid var(--star);
  outline-offset: -2px;
}

/* ---------- 悬停信息卡 ---------- */
.tooltip {
  position: fixed;
  z-index: 40;
  min-width: 200px;
  max-width: 280px;
  padding: 12px 14px;
  background: oklch(0.11 0.028 264 / 0.92);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px -8px oklch(0.04 0.02 264 / 0.85);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.tooltip[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}
.tooltip-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
  word-break: break-all;
}
.tooltip-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tooltip-chip {
  padding: 2px 7px;
  border-radius: 100px;
  border: 1px solid var(--ink-line);
  color: var(--text-dim);
}
.tooltip-chip.is-active { color: var(--orbit); border-color: var(--orbit); }
.tooltip-chip.is-pro { color: var(--signal); border-color: var(--signal); }
.tooltip-chip.is-enterprise { color: var(--star); border-color: var(--star); }
.tooltip-chip.is-pending { color: var(--beacon); border-color: var(--beacon); }
.tooltip-chip.is-paused { color: var(--dim); border-color: var(--dim); }
.tooltip-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ink-line);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tooltip-hint.is-main { color: var(--star); }

/* 焦点提示 */
.focus-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px 14px;
  background: oklch(0.135 0.032 264 / 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--ink-line);
  border-radius: 100px;
  font-size: 11.5px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.24s var(--ease);
  pointer-events: none;
}
.focus-hint.visible { opacity: 1; }
.focus-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--ink-hi);
  border: 1px solid var(--ink-line);
  border-radius: 4px;
  color: var(--text);
}

/* ---------- 右下读数 ---------- */
.readout {
  position: fixed;
  right: 24px;
  bottom: 64px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: oklch(0.135 0.032 264 / 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  pointer-events: none;
}
.readout-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-width: 110px;
}
.readout-key { color: var(--text-faint); letter-spacing: 0.1em; }
.readout-val { color: var(--orbit); }

/* ---------- 左下提示 ---------- */
.hint-bar {
  position: fixed;
  left: 24px;
  bottom: 22px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
.hint-item { display: inline-flex; align-items: center; gap: 5px; }
.hint-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--star);
  box-shadow: 0 0 5px var(--star);
}
.hint-sep { opacity: 0.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 50;
  padding: 12px 20px;
  background: oklch(0.13 0.04 264 / 0.92);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--star);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 12px 36px -8px oklch(0.04 0.02 264 / 0.9), 0 0 24px var(--star-soft);
  opacity: 0;
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease-out-quart);
  pointer-events: none;
}
.toast[data-visible="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-url {
  font-family: var(--font-mono);
  color: var(--star);
  font-weight: 700;
}

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  :root { --panel-w: calc(100vw - 32px); }
  .hud-top { padding: 14px 16px; }
  .brand-tag { display: none; }
  .console {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 52vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  }
  .console.collapsed {
    transform: translateY(calc(100% + 32px));
  }
  .panel-expand {
    top: auto;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 52px; height: 36px;
    border-radius: 100px;
  }
  .readout { display: none; }
  .hint-bar { display: none; }
  .focus-hint { bottom: auto; top: 64px; }
}

@media (max-width: 480px) {
  .brand-name { font-size: 16px; }
  .console-title { font-size: 22px; }
  .hud-status .status-text { display: none; }
}

/* ---------- 焦点可见 ---------- */
:focus-visible {
  outline: 2px solid var(--star);
  outline-offset: 2px;
}
button:focus-visible { outline-offset: 2px; }

/* ---------- 选区 ---------- */
::selection {
  background: var(--star-soft);
  color: var(--text);
}
