:root {
  color-scheme: dark;
  --bg: #02030a;
  --panel: rgba(9, 14, 31, 0.72);
  --panel-strong: rgba(9, 14, 31, 0.9);
  --line: rgba(156, 220, 255, 0.2);
  --text: #f4fbff;
  --muted: #9fb6c7;
  --cyan: #3be8ff;
  --violet: #8f6dff;
  --gold: #ffe66d;
  --pink: #ff4fd8;
  --green: #46f2a6;
  --danger: #ff5c7a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 12%, rgba(59, 232, 255, 0.14), transparent 30rem),
    radial-gradient(ellipse at 84% 18%, rgba(255, 79, 216, 0.12), transparent 26rem),
    radial-gradient(ellipse at 62% 110%, rgba(124, 92, 255, 0.18), transparent 34rem),
    radial-gradient(ellipse at 8% 88%, rgba(70, 242, 166, 0.08), transparent 24rem),
    linear-gradient(168deg, #050818 0%, #02030a 42%, #050220 100%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

.universe-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 620px;
  overflow: hidden;
}

.universe-shell::before {
  content: "";
  position: absolute;
  inset: -22%;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 56% 36% at 26% 22%, rgba(59, 232, 255, 0.10), transparent 70%),
    radial-gradient(ellipse 50% 34% at 76% 72%, rgba(124, 92, 255, 0.13), transparent 70%),
    radial-gradient(ellipse 42% 28% at 62% 16%, rgba(255, 79, 216, 0.08), transparent 70%),
    radial-gradient(ellipse 38% 26% at 14% 78%, rgba(70, 242, 166, 0.06), transparent 70%);
  mix-blend-mode: screen;
  animation: aurora-drift 38s ease-in-out infinite alternate;
}

.universe-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(1, 2, 8, 0.6) 100%);
}

@keyframes aurora-drift {
  0% {
    transform: translate3d(-2%, -1%, 0) rotate(-1.6deg) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translate3d(2%, 2%, 0) rotate(1deg) scale(1.06);
    opacity: 1;
  }
  100% {
    transform: translate3d(-1%, 3%, 0) rotate(2.2deg) scale(1.02);
    opacity: 0.78;
  }
}

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

#universeCanvas.dragging {
  cursor: grabbing;
}

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.node-label {
  position: absolute;
  max-width: 170px;
  padding: 3px 6px;
  border: 1px solid rgba(159, 222, 255, 0.26);
  border-radius: 7px;
  color: #f8fdff;
  background: linear-gradient(160deg, rgba(8, 14, 32, 0.78), rgba(3, 6, 16, 0.6));
  box-shadow: 0 0 18px rgba(59, 232, 255, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: 10px;
  white-space: normal;
  text-shadow: 0 0 7px rgba(59, 232, 255, 0.4);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(10px);
}

.node-label.hot {
  border-color: rgba(255, 230, 109, 0.55);
  box-shadow: 0 0 26px rgba(255, 230, 109, 0.2), inset 0 1px 0 rgba(255, 246, 180, 0.14);
  text-shadow: 0 0 8px rgba(255, 230, 109, 0.45);
}

.node-label.hover {
  max-width: 210px;
  padding: 2px 6px;
  border-color: rgba(59, 232, 255, 0.42);
  background: rgba(3, 7, 18, 0.74);
  box-shadow: 0 0 18px rgba(59, 232, 255, 0.18);
  font-size: 9px;
  line-height: 1.25;
}

.hud {
  position: absolute;
  z-index: 3;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, rgba(13, 20, 44, 0.72), rgba(4, 8, 22, 0.55));
  box-shadow:
    0 14px 42px rgba(0, 0, 0, 0.36),
    0 0 26px rgba(59, 232, 255, 0.06),
    inset 0 1px 0 rgba(159, 222, 255, 0.14);
  backdrop-filter: blur(18px) saturate(1.35);
}

.top-hud {
  top: 10px;
  left: 10px;
  right: auto;
  width: min(690px, calc(100vw - 20px));
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 8px;
}

.brand-block {
  flex: 1;
  min-width: 0;
}

.brand-sub {
  margin: 4px 0 0;
  color: #c8dce8;
  font-size: 11px;
  line-height: 1.4;
}

.brand-source {
  margin: 4px 0 0;
  color: var(--cyan);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  opacity: 0.75;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(18px, 1.85vw, 25px);
  line-height: 1;
  letter-spacing: 0.02em;
  background: linear-gradient(92deg, #ffffff 0%, #9be8ff 48%, #cdb8ff 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(59, 232, 255, 0.35));
}

h2 {
  font-size: 14px;
  line-height: 1.15;
  letter-spacing: 0;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, auto));
  gap: 4px;
}

.metric-strip span {
  display: grid;
  gap: 1px;
  min-width: 64px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.metric-strip strong {
  color: var(--text);
  font-size: 13px;
  text-shadow: 0 0 10px rgba(59, 232, 255, 0.4);
}

.command-deck {
  top: 64px;
  left: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: min(520px, calc(100vw - 20px));
  padding: 4px;
  border-radius: 8px;
}

.mode-button,
.icon-button {
  min-height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.mode-button {
  min-width: 58px;
  padding: 4px 7px;
  font-size: 11px;
}

.mode-button:hover,
.mode-button.active,
.icon-button:hover {
  border-color: rgba(59, 232, 255, 0.72);
  background: linear-gradient(150deg, rgba(59, 232, 255, 0.2), rgba(124, 92, 255, 0.15));
  box-shadow: 0 0 18px rgba(59, 232, 255, 0.24), inset 0 0 10px rgba(59, 232, 255, 0.08);
  text-shadow: 0 0 8px rgba(59, 232, 255, 0.55);
}

.mode-button.accent {
  border-color: rgba(255, 230, 109, 0.44);
  color: #fff6b4;
}

.lens-panel {
  top: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  width: 160px;
  padding: 7px;
  border-radius: 8px;
}

.field,
.range-field {
  display: grid;
  gap: 7px;
}

label {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 27px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  padding: 4px 7px;
  font-size: 11px;
  color: var(--text);
  background: rgba(4, 8, 20, 0.92);
}

input[type="range"] {
  accent-color: var(--cyan);
}

.detail-panel {
  top: 156px;
  right: 10px;
  width: min(230px, calc(100vw - 20px));
  max-height: calc(100vh - 206px);
  padding: 8px;
  border-radius: 8px;
  overflow: auto;
}

.detail-panel.is-idle {
  width: min(170px, calc(100vw - 20px));
  max-height: none;
  padding: 8px;
}

.detail-panel.is-idle .panel-head {
  margin-bottom: 3px;
}

.detail-panel.is-idle h2 {
  font-size: 12px;
}

.detail-panel.is-idle #detailSubtitle {
  font-size: 10px;
  line-height: 1.25;
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 16px;
}

#detailSubtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 10px;
}

.stat-card {
  min-height: 38px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
}

.quote-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.quote-card {
  padding: 8px;
  border-left: 2px solid var(--cyan);
  border-radius: 7px;
  background: linear-gradient(150deg, rgba(59, 232, 255, 0.08), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 0 14px rgba(59, 232, 255, 0.05);
}

.quote-card p {
  color: #e9f8ff;
  font-size: 12px;
}

.quote-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.top-list {
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  border-radius: 8px;
}

.top-node {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 5px 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  text-align: left;
}

.top-node:hover,
.top-node.active {
  border-color: rgba(255, 230, 109, 0.64);
  background: rgba(255, 230, 109, 0.08);
}

.rank-orb {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #06111a;
  background: radial-gradient(circle at 32% 28%, #fff6c8, var(--gold) 58%, #d9a93f);
  font-weight: 800;
  animation: orb-pulse 2.8s ease-in-out infinite;
}

@keyframes orb-pulse {
  0%,
  100% {
    box-shadow: 0 0 7px rgba(255, 230, 109, 0.4);
  }
  50% {
    box-shadow: 0 0 15px rgba(255, 230, 109, 0.78);
  }
}

.top-node span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #edfaff;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-node strong {
  color: var(--gold);
  font-size: 12px;
}

.insight-btn {
  border-color: rgba(70, 242, 166, 0.44);
  color: #a8ffd8;
}

.insight-btn:hover {
  border-color: rgba(70, 242, 166, 0.8) !important;
  background: linear-gradient(150deg, rgba(70, 242, 166, 0.18), rgba(59, 232, 255, 0.12)) !important;
  box-shadow: 0 0 18px rgba(70, 242, 166, 0.22) !important;
  text-shadow: 0 0 8px rgba(70, 242, 166, 0.6) !important;
}

.insight-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(1, 3, 12, 0.62);
  backdrop-filter: blur(6px);
  padding: 20px;
}

.insight-overlay[hidden] {
  display: none;
}

.insight-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 82vh;
  border: 1px solid rgba(70, 242, 166, 0.28);
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(8, 16, 36, 0.92), rgba(4, 9, 24, 0.88));
  box-shadow:
    0 24px 72px rgba(0, 0, 0, 0.55),
    0 0 36px rgba(70, 242, 166, 0.08),
    inset 0 1px 0 rgba(70, 242, 166, 0.14);
  backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.insight-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(70, 242, 166, 0.16);
  flex-shrink: 0;
}

.insight-head h2 {
  font-size: 14px;
  background: linear-gradient(92deg, #ffffff 0%, #9be8ff 48%, #a8ffd8 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.insight-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 12.5px;
  color: #d4eaf4;
  scrollbar-width: thin;
  scrollbar-color: rgba(70, 242, 166, 0.3) transparent;
}

.insight-body h3 {
  margin: 18px 0 8px;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(59, 232, 255, 0.4);
}

.insight-body h3:first-child {
  margin-top: 0;
}

.insight-body p {
  margin: 0 0 10px;
}

.insight-body strong {
  color: #edf8ff;
}

.insight-body ol,
.insight-body ul {
  margin: 6px 0 12px;
  padding-left: 22px;
}

.insight-body li {
  margin-bottom: 5px;
}

.credit {
  position: absolute;
  right: 14px;
  bottom: 62px;
  z-index: 4;
  color: rgba(159, 182, 199, 0.55);
  font-size: 10px;
  letter-spacing: 0.04em;
  pointer-events: none;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.credit strong {
  color: rgba(185, 215, 230, 0.72);
  font-weight: 600;
}

@media (max-width: 960px) {
  .universe-shell {
    min-height: 720px;
  }

  .top-hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-strip span {
    min-width: 0;
  }

  .command-deck {
    top: 166px;
  }

  .lens-panel {
    top: 232px;
    left: 18px;
    right: auto;
    width: min(320px, calc(100vw - 36px));
  }

  .detail-panel {
    top: auto;
    left: 18px;
    right: 18px;
    bottom: 96px;
    width: auto;
    max-height: 280px;
  }

  .top-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .universe-shell {
    min-height: 760px;
  }

  .top-hud,
  .command-deck,
  .lens-panel,
  .top-list {
    left: 10px;
    right: 10px;
  }

  .top-hud {
    top: 10px;
    min-height: 118px;
    padding: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .metric-strip {
    gap: 6px;
  }

  .metric-strip strong {
    font-size: 17px;
  }

  .command-deck {
    top: 154px;
  }

  .mode-button {
    flex: 1 1 42%;
    min-width: 0;
  }

  .lens-panel {
    top: 294px;
    width: auto;
  }

  .detail-panel {
    left: 10px;
    right: 10px;
    top: 388px;
    bottom: 132px;
    max-height: none;
  }

  .range-field {
    display: none;
  }

  .detail-stats {
    grid-template-columns: 1fr;
  }

  .top-list {
    bottom: 10px;
    grid-template-columns: 1fr;
    max-height: 116px;
    overflow: auto;
  }
}
