.cosmic-web {
  --cw-border: rgba(160, 225, 250, 0.34);
  --cw-text: #f7fbff;
  --cw-muted: #bdd4e5;
  --cw-hud: rgba(16, 21, 33, 0.66);
  --cw-canvas-start: #05091e;
  --cw-canvas-mid: #10102a;
  --cw-canvas-end: #190d1f;
  --cw-particle-rgb: 40, 64, 106;
  --cw-filament-rgb: 110, 193, 228;
  --cw-ridge-rgb: 181, 78, 144;
  --cw-node-rgb: 255, 168, 96;
  --cw-core-rgb: 255, 247, 232;
  --cw-ambient-cool-rgb: 53, 102, 177;
  --cw-ambient-warm-rgb: 191, 42, 101;
  margin: 0 0 2.4em;
  color: var(--cw-text);
}

.dark-theme .cosmic-web {
  --cw-border: rgba(160, 225, 250, 0.25);
  --cw-muted: #aec8da;
  --cw-hud: rgba(5, 9, 24, 0.72);
}

.cosmic-web__stage {
  position: relative;
  isolation: isolate;
  height: clamp(214px, 33.3vw, 279px);
  overflow: hidden;
  border: 1px solid var(--cw-border);
  border-radius: 18px;
  background:
    radial-gradient(circle at 68% 72%, rgba(191, 42, 101, 0.18), transparent 48%),
    linear-gradient(145deg, var(--cw-canvas-start), var(--cw-canvas-end));
  box-shadow:
    0 22px 50px rgba(28, 22, 66, 0.2),
    0 0 28px rgba(110, 193, 228, 0.08),
    inset 0 1px rgba(255, 255, 255, 0.05);
  transition: border-color 0.22s ease;
}

.cosmic-web.is-sculpting .cosmic-web__stage {
  border-color: rgba(255, 168, 96, 0.58);
}

.dark-theme .cosmic-web__stage {
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.34),
    0 0 30px rgba(110, 193, 228, 0.07),
    inset 0 1px rgba(255, 255, 255, 0.04);
}

.cosmic-web__stage::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(3, 7, 24, 0.46), transparent 29%, transparent 69%, rgba(3, 5, 18, 0.32)),
    radial-gradient(circle at 50% 110%, transparent 41%, rgba(1, 3, 14, 0.32) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 24%);
  content: "";
  pointer-events: none;
}

.cosmic-web__canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.cosmic-web.is-sculpting .cosmic-web__canvas {
  cursor: grabbing;
}

.cosmic-web__readout {
  position: absolute;
  z-index: 3;
  top: 18px;
  right: 20px;
  left: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  color: var(--cw-text);
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.72);
}

.cosmic-web__kicker,
.cosmic-web__epoch {
  display: block;
}

.cosmic-web__kicker {
  margin-bottom: 3px;
  font-family: "Marcellus SC", serif;
  font-size: 0.82em;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.cosmic-web__epoch {
  color: var(--cw-muted);
  font-size: 0.72em;
  letter-spacing: 0.035em;
}

.cosmic-web__redshift {
  min-width: 4.7em;
  padding: 6px 10px;
  border: 1px solid var(--cw-border);
  border-radius: 999px;
  background: var(--cw-hud);
  color: var(--cw-text);
  font-size: 0.74em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  backdrop-filter: blur(7px);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
}

.cosmic-web__hint {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 14px;
  margin: 0;
  color: var(--cw-muted);
  font-size: 0.7em;
  letter-spacing: 0.02em;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.78);
  transition: opacity 0.25s ease;
}

.cosmic-web.is-engaged .cosmic-web__hint {
  opacity: 0;
}

@media all and (max-width: 600px) {
  .cosmic-web {
    margin-bottom: 2em;
  }

  .cosmic-web__stage {
    height: 203px;
    border-radius: 15px;
  }

  .cosmic-web__readout {
    top: 14px;
    right: 14px;
    left: 14px;
  }

  .cosmic-web__hint {
    right: 14px;
    bottom: 11px;
    left: 14px;
    text-align: right;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cosmic-web__stage,
  .cosmic-web__hint {
    transition: none;
  }
}
