:root {
  color-scheme: dark;

  /* Palette */
  --bg-0: #060814;
  --bg-1: #0b0f26;
  --bg-2: #070a1b;

  --nebula-a: 255, 105, 180;
  --nebula-b: 120, 200, 255;
  --nebula-c: 170, 120, 255;
  --star-color: #dfe7ff;
  --shooting-color: #a3d0ff;
  --network-node: #85b6ff;
  --network-link: 180, 210, 255;

  --accent: #ff8adf;
  --accent-strong: #ff6bce;
  --accent-glow: rgba(255, 138, 223, 0.35);

  --text-main: #e9f1ff;
  --text-muted: #c2d2f2;
  --text-soft: #9bb0d6;

  --surface-0: rgba(12, 18, 32, 0.55);
  --surface-1: rgba(18, 26, 44, 0.75);
  --surface-2: rgba(26, 36, 58, 0.92);

  --border-1: rgba(120, 150, 210, 0.22);
  --border-2: rgba(140, 190, 255, 0.48);

  --link: #8ad8ff;
  --link-hover: #d1f0ff;

  --shadow-soft: 0 18px 45px rgba(6, 12, 24, 0.55);
  --glow: drop-shadow(0 0 8px rgba(140, 200, 255, 0.35));

  --star-density: 1;
  --network-density: 3;

  --heading-font: "Space Grotesk", ui-sans-serif, system-ui, Segoe UI, Roboto, Inter, Arial, sans-serif;
  --body-font: "Manrope", "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  color-scheme: light;

  --bg-0: #f1f2ff;
  --bg-1: #f8f5ff;
  --bg-2: #e3e7ff;
  --grid-color: rgba(108, 90, 150, 0.18);
  --grid-strong: #c6c6e3;
  --grid-weak: #d9dcf2;

  --accent: #5b6fff;
  --accent-strong: #354bff;
  --accent-glow: rgba(88, 115, 255, 0.25);

  --text-main: #1b1e2c;
  --text-muted: #4b5674;
  --text-soft: #5b6789;

  --surface-0: rgba(255, 255, 255, 0.7);
  --surface-1: rgba(255, 255, 255, 0.86);
  --surface-2: rgba(245, 246, 255, 0.95);

  --border-1: rgba(92, 98, 150, 0.2);
  --border-2: rgba(92, 98, 150, 0.35);

  --link: #3f52ff;
  --link-hover: #222d9c;

  --shadow-soft: 0 18px 45px rgba(60, 70, 110, 0.18);
  --glow: drop-shadow(0 0 12px rgba(90, 120, 210, 0.25));

  --nebula-a: 120, 140, 220;
  --nebula-b: 110, 160, 230;
  --nebula-c: 160, 150, 230;
  --star-color: #4d5d88;
  --shooting-color: #6f8bd4;
  --network-node: #5263a6;
  --network-link: 120, 140, 190;
  --star-density: 0.65;
  --network-density: 2.2;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--heading-font);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  color: var(--text-main);
  background: radial-gradient(100% 120% at 50% 0%, var(--bg-1), var(--bg-0) 65%) fixed;
  font-family: var(--body-font);
  transition: background 220ms ease, color 220ms ease;
}

body {
  position: relative;
  isolation: isolate;
}

#cosmo-nebula,
#cosmo-stars,
#cosmo-network {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  pointer-events: none;
  z-index: 0;
}

#cosmo-nebula { z-index: 0; }
#cosmo-stars { z-index: 1; }
#cosmo-network {
  z-index: 2;
  filter: var(--glow);
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: var(--surface-2);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px) saturate(130%);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--border-2);
  box-shadow: 0 20px 50px rgba(12, 6, 28, 0.45);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle.in-nav {
  position: relative;
  top: auto;
  right: auto;
  width: 36px;
  height: 36px;
  margin-left: 6px;
  box-shadow: none;
}

.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.cosmo-controls {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  display: inline-flex;
  gap: 8px;
  padding: 10px;
  background: rgba(10, 14, 30, 0.4);
  border: 1px solid rgba(140, 160, 255, 0.25);
  border-radius: 12px;
  backdrop-filter: blur(8px) saturate(120%);
  box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.03) inset;
}

.cosmo-controls button {
  pointer-events: auto;
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid rgba(140, 160, 255, 0.3);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(25,35,65,.8), rgba(15,22,45,.8));
  color: #eaf1ff;
  font-size: 13px;
  letter-spacing: .25px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, opacity .12s ease;
}

.cosmo-controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(70, 120, 255, .25);
  border-color: rgba(140, 180, 255, 0.6);
}

@media (max-width: 720px) {
  .theme-toggle { top: 12px; right: 12px; }
  .theme-toggle.in-nav { margin-left: 0; }
}

/* --- Global heading scale --- */
h1 {
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 1.1;
  margin: 0 0 12px;
  text-shadow: 0 8px 30px rgba(40,80,180,.25);
}

h2 {
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
  margin: 0 0 10px;
}

@media (prefers-reduced-motion: reduce) {
  #cosmo-nebula,
  #cosmo-stars,
  #cosmo-network { animation: none !important; }
}

body > *:not(#cosmo-nebula):not(#cosmo-stars):not(#cosmo-network):not(.theme-toggle) {
  position: relative;
  z-index: 3;
}

/* Keep nav links clean (no underline bleed) */
.site-header nav a {
  text-decoration: none;
}
.site-header nav a:hover,
.site-header nav a:focus,
.site-header nav a:active {
  text-decoration: none;
}

/* Link defaults */
a { color: var(--link); }
a:hover { color: var(--link-hover); }
