/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg-0: #05060f;
  --bg-1: #0a0d1f;
  --bg-2: #10142b;
  --panel-bg: rgba(15, 18, 38, 0.78);
  --panel-border: rgba(255, 255, 255, 0.10);
  --panel-border-strong: rgba(255, 255, 255, 0.18);
  --text-0: #f4f6fb;
  --text-1: #c3c8dc;
  --text-2: #8b91ac;
  --accent: #7ea6ff;
  --accent-2: #b48bff;
  --accent-warm: #ffb454;
  --success: #6ee7b7;
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
  --shadow-md: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --blur: blur(22px);
  --font-display: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-0: #eef1fb;
  --bg-1: #e4e8f7;
  --bg-2: #d9defb;
  --panel-bg: rgba(255, 255, 255, 0.86);
  --panel-border: rgba(20, 24, 50, 0.10);
  --panel-border-strong: rgba(20, 24, 50, 0.18);
  --text-0: #12142a;
  --text-1: #343a5c;
  --text-2: #676d90;
  --accent: #3f63d6;
  --accent-2: #7a4fd6;
  --accent-warm: #d9822b;
  --shadow-lg: 0 24px 60px -24px rgba(30, 34, 70, 0.35);
  --shadow-md: 0 12px 32px -16px rgba(30, 34, 70, 0.30);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
::selection { background: var(--accent); color: #06070f; }

/* ==========================================================================
   Background layers
   ========================================================================== */
#bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 8%, rgba(126, 166, 255, 0.10), transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(180, 139, 255, 0.07), transparent 60%),
    var(--bg-0);
  transition: background 0.4s ease;
}

#webgl-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
}
#webgl-container canvas {
  display: block;
  cursor: grab;
}
#webgl-container canvas:active {
  cursor: grabbing;
}

/* ==========================================================================
   App chrome
   ========================================================================== */
.app-shell {
  position: relative;
  z-index: 5;
  height: 100%;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.app-shell > * { pointer-events: auto; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}
.brand .mark {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e6, var(--accent-warm) 55%, #b9540e 100%);
  box-shadow: 0 0 14px 2px rgba(255, 180, 84, 0.65);
  flex: none;
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 0;
  /* Always floats directly over the (always-dark) 3D canvas, never a themed panel */
  color: #f4f6fb;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.brand .tagline {
  font-size: 0.72rem;
  color: rgba(244, 246, 251, 0.65);
  letter-spacing: 0.03em;
  display: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
@media (min-width: 720px) {
  .brand .tagline { display: inline; }
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Glass surfaces */
.glass {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-md);
}

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-1);
  width: 36px; height: 36px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.icon-btn.glass, .text-btn.glass { background: var(--panel-bg); }
.icon-btn:hover { background: rgba(255,255,255,0.10); color: var(--text-0); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active { color: var(--accent); background: rgba(126,166,255,0.16); }
.icon-btn svg { width: 18px; height: 18px; }

.speed-pill { padding: 6px 8px 6px 14px; }
.speed-pill label {
  font-size: 0.68rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 6px;
  white-space: nowrap;
}
.speed-pill input[type="range"] {
  width: 90px;
  accent-color: var(--accent);
}
.speed-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  color: var(--text-1);
  width: 34px;
  text-align: right;
}

.toggle-group {
  display: flex;
  border-radius: 999px;
  overflow: hidden;
  padding: 3px;
  gap: 2px;
}
.toggle-group button {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.toggle-group button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05070f;
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--text-1);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  padding: 9px 15px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.18s ease, color 0.18s ease;
}
.text-btn:hover { background: rgba(255,255,255,0.10); color: var(--text-0); }
.text-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05070f;
}
.text-btn.primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ==========================================================================
   Realistic-scale explanation banner
   ========================================================================== */
#scale-banner {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  max-width: min(560px, 90vw);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-1);
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-align: center;
}
#scale-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
#scale-banner strong { color: var(--text-0); }
#scale-banner .hint {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-2);
}
.scale-banner-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.scale-banner-actions .text-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border-strong);
  font-size: 0.72rem;
  padding: 7px 12px;
}
.scale-banner-actions .text-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* ==========================================================================
   Settings drawer
   ========================================================================== */
#settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(300px, 86vw);
  z-index: 30;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(.2,.8,.2,1);
  padding: 22px 20px;
  overflow-y: auto;
  border-left: 1px solid var(--panel-border);
}
#settings-drawer.open { transform: translateX(0); }
#settings-drawer h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 4px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--panel-border);
  gap: 10px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--text-1);
}
.switch {
  position: relative;
  width: 42px; height: 24px;
  flex: none;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.switch.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch.on::after { transform: translateX(18px); }

.qmark {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--panel-border-strong);
  color: var(--text-2);
  font-size: 0.62rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  flex: none;
  position: relative;
}
.qmark:hover, .qmark:focus-visible { color: var(--accent); border-color: var(--accent); }

#backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 12, 0.45);
  backdrop-filter: blur(2px);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#backdrop.visible { opacity: 1; pointer-events: auto; }

/* ==========================================================================
   Tooltip popover (shared, positioned via JS)
   ========================================================================== */
#tooltip-popover {
  position: fixed;
  z-index: 90;
  max-width: 280px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-1);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
#tooltip-popover.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ==========================================================================
   Planet detail panel
   ========================================================================== */
#detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(540px, 100vw);
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.36s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
  border-left: 1px solid var(--panel-border);
  padding: 24px 24px 40px;
}
#detail-panel.open { transform: translateX(0); }

.detail-close {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 5;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeScaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.detail-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 0 18px;
  animation: fadeSlideUp 0.5s cubic-bezier(.2,.8,.2,1) both;
}
.detail-hero .orb {
  width: 92px; height: 92px;
  border-radius: 50%;
  margin-bottom: 14px;
  box-shadow: 0 0 40px 4px var(--orb-glow, rgba(255,255,255,0.25)), inset -14px -10px 24px rgba(0,0,0,0.35);
  animation: fadeScaleIn 0.55s cubic-bezier(.2,.8,.2,1) both;
}
.detail-hero h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 4px;
}
.detail-hero .subtitle {
  font-size: 0.78rem;
  color: var(--text-2);
  letter-spacing: 0.03em;
}

.detail-facts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 20px;
}
.fact-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  line-height: 1.5;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.03);
  animation: fadeSlideUp 0.45s cubic-bezier(.2,.8,.2,1) both;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
  animation: fadeSlideUp 0.5s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: 60ms;
}
.stat-card {
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.03);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--panel-border-strong);
}
.stat-card .label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.stat-card .value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-0);
  font-variant-numeric: tabular-nums;
}
.stat-card.wide { grid-column: 1 / -1; }

.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin: 4px 0 10px;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  animation: fadeSlideUp 0.5s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: 120ms;
}

/* ==========================================================================
   Comparator modal
   ========================================================================== */
#compare-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#compare-modal.open { opacity: 1; pointer-events: auto; }
#compare-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 12, 0.55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 26px 26px 30px;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
}
#compare-modal.open .modal-card { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
}

.compare-selectors {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}
.compare-selectors select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border-strong);
  background: rgba(255,255,255,0.04);
  color: var(--text-0);
  font-size: 0.86rem;
}
.vs-badge {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--text-2);
  text-align: center;
}

.compare-visual {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 40px;
  min-height: 140px;
  margin-bottom: 22px;
  padding: 10px 0;
}
.compare-orb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.compare-orb {
  border-radius: 50%;
  box-shadow: 0 0 30px 2px var(--orb-glow, rgba(255,255,255,0.2)), inset -10px -8px 18px rgba(0,0,0,0.35);
  animation: fadeScaleIn 0.5s cubic-bezier(.2,.8,.2,1) both;
  transition: width 0.4s cubic-bezier(.2,.8,.2,1), height 0.4s cubic-bezier(.2,.8,.2,1);
}
.compare-orb-wrap .name { font-size: 0.78rem; color: var(--text-1); font-weight: 600; }
.compare-orb-wrap .type { font-size: 0.66rem; color: var(--text-2); text-align: center; }

.compare-rows { display: flex; flex-direction: column; gap: 12px; }
.compare-row { animation: fadeSlideUp 0.4s cubic-bezier(.2,.8,.2,1) both; }
.compare-row .metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 6px;
}
.compare-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.compare-bar-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.compare-bar-item .bar-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.compare-bar-item .bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(.2,.8,.2,1);
}
.compare-bar-item .bar-value {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  min-width: 64px;
  text-align: right;
  white-space: nowrap;
}

/* ==========================================================================
   Language switcher (fixed corner flag pill + upward dropdown)
   ========================================================================== */
.lang-switcher {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 10;
}
.lang-switcher-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: rgba(0, 0, 0, 0.25);
  color: rgba(244, 246, 251, 0.85);
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.lang-switcher-btn:hover { opacity: 1; background: rgba(0, 0, 0, 0.4); }
.lang-switcher-btn .code { font-size: 0.62rem; letter-spacing: 0.04em; color: rgba(244, 246, 251, 0.7); text-transform: uppercase; }
.lang-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  min-width: 168px;
  background: rgba(8, 10, 20, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border-strong);
  border-radius: 14px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  box-shadow: 0 16px 44px rgba(0,0,0,0.55);
}
.lang-switcher:hover .lang-dropdown,
.lang-switcher:focus-within .lang-dropdown {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.lang-dropdown a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0.8rem;
  color: rgba(244, 246, 251, 0.8);
  text-decoration: none;
  white-space: nowrap;
}
.lang-dropdown a:hover { background: rgba(126,166,255,0.12); color: #f4f6fb; }
.lang-dropdown a.active { color: var(--accent); font-weight: 600; }

/* ==========================================================================
   Credits & legal modals + persistent footer links
   ========================================================================== */
.footer-links {
  position: fixed;
  right: 14px;
  bottom: 52px;
  z-index: 10;
  display: flex;
  gap: 8px;
}
.credits-link {
  display: inline-block;
  border: none;
  /* Always floats directly over the (always-dark) 3D canvas, never a themed panel */
  background: rgba(0, 0, 0, 0.25);
  color: rgba(244, 246, 251, 0.85);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.credits-link:hover { opacity: 1; background: rgba(0, 0, 0, 0.4); color: #f4f6fb; }

#credits-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#credits-modal.open { opacity: 1; pointer-events: auto; }
#credits-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 12, 0.55);
  backdrop-filter: blur(4px);
}
#credits-modal .modal-card {
  width: min(520px, 100%);
}
#credits-modal.open .modal-card { transform: translateY(0) scale(1); }

.legal-warning {
  background: rgba(255, 180, 84, 0.12);
  border: 1px solid rgba(255, 180, 84, 0.35);
  color: #ffcf94;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.legal-warning + .credits-list .credits-item p { color: var(--text-1); }

.credits-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.credits-item .credits-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 4px;
}
.credits-item p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-1);
}
.credits-item a {
  color: var(--accent);
  text-decoration: none;
}
.credits-item a:hover { text-decoration: underline; }

/* ==========================================================================
   Legend / planet name labels drawn by canvas use this for hit testing only;
   visual name tags are HTML positioned absolutely for crispness
   ========================================================================== */
#label-layer {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.planet-label {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  color: var(--text-1);
  text-shadow: 0 1px 8px rgba(0,0,0,0.9), 0 0 16px rgba(0,0,0,0.5);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.25s ease;
  will-change: transform, opacity;
}

/* ==========================================================================
   Bottom hint bar
   ========================================================================== */
#bottom-hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.7rem;
  /* Always floats directly over the (always-dark) 3D canvas, never a themed panel */
  color: rgba(244, 246, 251, 0.75);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  padding: 7px 14px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.85;
  text-align: center;
  white-space: nowrap;
}

#scale-toggle-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 6;
}

/* ==========================================================================
   Loading veil
   ========================================================================== */
#loading-veil {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(126, 166, 255, 0.12), transparent 60%),
    var(--bg-0);
  transition: opacity 0.6s ease;
}
.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.loading-orb {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e6, var(--accent-warm) 55%, #b9540e 100%);
  box-shadow: 0 0 40px 8px rgba(255, 180, 84, 0.55);
  animation: loadingPulse 1.8s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px 8px rgba(255, 180, 84, 0.5); }
  50% { transform: scale(1.12); box-shadow: 0 0 56px 14px rgba(255, 180, 84, 0.75); }
}
.loading-bar {
  width: 200px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.25s ease;
}
.loading-text {
  font-size: 0.76rem;
  color: var(--text-2);
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   WebGL unsupported fallback
   ========================================================================== */
#webgl-fallback {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(126, 166, 255, 0.10), transparent 60%),
    var(--bg-0);
  padding: 24px;
}
#webgl-fallback.visible { display: flex; }
.fallback-inner {
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.fallback-inner .loading-orb { animation: none; }
.fallback-inner h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 6px 0 0;
  color: var(--text-0);
}
.fallback-inner p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-1);
}
.fallback-inner .fallback-hint {
  font-size: 0.78rem;
  color: var(--text-2);
}
#loading-veil.hidden { opacity: 0; pointer-events: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 720px) {
  header.topbar { padding: 12px 12px; gap: 8px; }
  .brand h1 { font-size: 1.05rem; }
  .speed-pill input[type="range"] { width: 64px; }
  .topbar-controls { gap: 6px; }
  .text-btn span.full { display: none; }
  #detail-panel {
    width: 100%;
    top: auto;
    bottom: 0;
    height: min(78vh, 620px);
    right: 0;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
  }
  #detail-panel.open { transform: translateY(0); }
  #settings-drawer { width: 100%; }
  .compare-visual { gap: 20px; }
  .compare-selectors { grid-template-columns: 1fr auto 1fr; gap: 8px; }
  .modal-card { padding: 20px 16px 24px; }
  #scale-banner { top: auto; bottom: 64px; }
  #bottom-hint { display: none; }
  .footer-links {
    bottom: 100px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  .credits-link { font-size: 0.64rem; padding: 4px 8px; }
  #scale-toggle-dock { bottom: 54px; }
}

@media (max-width: 420px) {
  .compare-bars { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ==========================================================================
   Static content pages (À propos, Glossaire, articles) — shared shell
   ========================================================================== */
html.static-page, .static-page body { overflow-y: auto; overflow-x: hidden; height: auto; min-height: 100%; }
.static-page {
  overflow-y: auto; overflow-x: hidden; min-height: 100%;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(126, 166, 255, 0.10), transparent 60%),
    var(--bg-0);
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
}
.page-header .brand { display: flex; align-items: baseline; gap: 10px; }
.page-header .brand .mark {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e6, var(--accent-warm) 55%, #b9540e 100%);
  box-shadow: 0 0 14px 2px rgba(255, 180, 84, 0.65);
}
.page-header h1 { font-family: var(--font-display); font-size: 1.1rem; margin: 0; letter-spacing: 0.06em; }
.back-link {
  font-size: 0.8rem;
  color: var(--text-2);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border-strong);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}
.back-link:hover { color: var(--text-0); border-color: var(--accent); background: rgba(126,166,255,0.08); }

.prose-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.prose-main.wide { max-width: 1040px; }
.prose-main.wide .lede,
.prose-main.wide p,
.prose-main.wide ul { max-width: none; }
.prose-main h1.title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 0 0 6px;
}
.prose-main .lede {
  font-size: 1.05rem;
  color: var(--text-1);
  line-height: 1.65;
  margin: 0 0 40px;
  max-width: 60ch;
}
.prose-main section { margin-bottom: 40px; }
.prose-main h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 14px;
  color: var(--text-0);
}
.prose-main h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  margin: 22px 0 10px;
  color: var(--text-0);
}
.prose-main p {
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--text-1);
  margin: 0 0 14px;
  max-width: 68ch;
}
.prose-main ul { margin: 0 0 14px; padding-left: 1.2em; max-width: 62ch; }
.prose-main li {
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--text-1);
  margin-bottom: 6px;
}
.prose-main strong { color: var(--text-0); font-weight: 600; }
.prose-main a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(126,166,255,0.35); }
.prose-main a:hover { color: var(--text-0); border-color: var(--text-0); }

.prose-entry {
  margin-bottom: 36px;
  padding: 22px 24px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
}
.prose-entry h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}
.prose-entry h2 .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex: none;
}
.prose-entry p:last-child { margin-bottom: 0; }

a.prose-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 28px;
  padding: 12px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05070f;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: none;
}

.prose-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 40px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.prose-footer a {
  font-size: 0.72rem;
  color: var(--text-2);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
}
.prose-footer a:hover { color: var(--text-0); }

/* Slim legal-links row (mentions légales, confidentialité, cookies, contact) on static content pages */
.legal-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 32px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.legal-footer a {
  font-size: 0.68rem;
  color: var(--text-2);
  text-decoration: none;
  opacity: 0.75;
}
.legal-footer a:hover { color: var(--text-0); opacity: 1; }

/* Topic hero illustration on glossary article pages */
.topic-hero {
  width: 100%;
  max-width: 420px;
  margin: 0 auto 32px;
  display: block;
}
.topic-hero svg { width: 100%; height: auto; display: block; }
.topic-hero img { width: 100%; height: auto; display: block; border-radius: 20px; aspect-ratio: 900 / 480; object-fit: cover; }
.topic-hero figcaption {
  font-size: 0.68rem;
  color: var(--text-2);
  text-align: right;
  margin-top: 6px;
}
.topic-hero figcaption a { color: var(--text-2); }

/* Secondary in-article photo, smaller than the topic-hero, placed inside a section */
.inline-figure {
  width: 100%;
  max-width: 380px;
  margin: 6px auto 20px;
  display: block;
}
.inline-figure img { width: 100%; height: auto; display: block; border-radius: 16px; }
.inline-figure figcaption {
  font-size: 0.68rem;
  color: var(--text-2);
  text-align: right;
  margin-top: 6px;
}
.inline-figure figcaption a { color: var(--text-2); }

/* Deep-link back into the 3D exploration app from a glossary detail page */
.probe-3d-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--accent); text-decoration: none;
  border: none; margin: 4px 0 22px;
}
.probe-3d-link:hover { color: var(--text-0); }

/* "À lire aussi" cross-links grid on glossary article pages */
.crosslinks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.crosslinks a {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-1);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.crosslinks a:hover { color: var(--text-0); border-color: var(--accent); background: rgba(126,166,255,0.06); }

/* Glossary hover dropdown on the persistent footer link */
.glossary-nav { position: relative; }
.glossary-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  min-width: 190px;
  background: rgba(8, 10, 20, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border-strong);
  border-radius: 14px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  box-shadow: 0 16px 44px rgba(0,0,0,0.55);
}
.glossary-nav:hover .glossary-dropdown,
.glossary-nav:focus-within .glossary-dropdown {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.glossary-dropdown a {
  display: block;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 0.76rem;
  /* Dropdown background is always dark regardless of theme, so text stays fixed light */
  color: rgba(244, 246, 251, 0.75);
  text-decoration: none;
  white-space: nowrap;
}
.glossary-dropdown a:hover { background: rgba(126,166,255,0.12); color: #f4f6fb; }

@media (max-width: 720px) {
  .prose-footer { padding: 0 16px 32px; }
  .prose-main { padding: 40px 16px 64px; }
}

/* Topic-card grid used on glossary category/sub-category hub pages */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.topic-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.topic-card:hover { border-color: var(--accent); background: rgba(126,166,255,0.06); transform: translateY(-2px); }
.topic-card .icon { width: 34px; height: 34px; color: var(--accent); }
.topic-card .icon svg { width: 100%; height: 100%; }
.topic-card h2 { font-family: var(--font-display); font-size: 1rem; margin: 0; color: var(--text-0); }
.topic-card p { font-size: 0.82rem; line-height: 1.55; color: var(--text-2); margin: 0; }

.breadcrumb {
  font-size: 0.76rem;
  color: var(--text-2);
  margin: -28px 0 28px;
}
.breadcrumb a { color: var(--text-2); text-decoration: none; border-bottom: 1px solid transparent; }
.breadcrumb a:hover { color: var(--text-0); border-color: var(--text-0); }
.breadcrumb .sep { margin: 0 6px; opacity: 0.5; }

/* Affiliate disclosure banner shown near the top of Observer guide pages */
.affiliate-disclosure {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  margin: 0 0 28px;
  border-radius: var(--radius-sm);
  background: rgba(255,180,84,0.08);
  border: 1px solid rgba(255,180,84,0.25);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-2);
}
.affiliate-disclosure svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--accent-warm); }

/* Affiliate product card grid, used on Observer pages and occasionally inserted into glossary fiches */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin: 20px 0 32px;
}
.product-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.product-card:hover { border-color: var(--panel-border-strong); background: rgba(255,255,255,0.05); transform: translateY(-2px); }
.wide .product-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin: 28px 0 36px; }
.wide .product-card { padding: 24px; border-radius: 22px; gap: 12px; max-width: 420px; justify-self: center; width: 100%; }
.wide .product-card-thumb { aspect-ratio: 1 / 1; border-radius: 16px; }
.wide .product-card-thumb svg { width: 32%; height: 32%; }
.wide .product-card-name { font-size: 1.05rem; }
.wide .product-card-desc { font-size: 0.88rem; }
.wide .product-card-price { font-size: 0.88rem; }
.product-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(126,166,255,0.14), rgba(180,139,255,0.14));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--accent);
}
.product-card-thumb svg { width: 40%; height: 40%; }
.product-card-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-0);
}
.product-card-desc {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-2);
  margin: 0;
}
.product-card-price {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-1);
}
a.product-card-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: auto;
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05070f;
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  border-bottom: none;
}

.product-card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }

.product-card-rating { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; }
.product-card-rating .stars { display: inline-flex; gap: 1px; }
.product-card-rating .star { position: relative; width: 12px; height: 12px; color: var(--panel-border-strong); }
.product-card-rating .star::before { content: "★"; position: absolute; inset: 0; }
.product-card-rating .star.is-full::before { color: var(--accent-warm); }
.product-card-rating .star.is-half::before {
  background: linear-gradient(90deg, var(--accent-warm) 50%, var(--panel-border-strong) 50%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.product-card-rating .value { color: var(--text-2); font-variant-numeric: tabular-nums; }

.product-card-audience { display: flex; flex-wrap: wrap; gap: 6px; }
.audience-badge {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--panel-border-strong); color: var(--text-2);
}
.audience-badge--debutant { color: var(--accent); border-color: rgba(126,166,255,0.4); }
.audience-badge--confirme { color: var(--accent-2); border-color: rgba(180,139,255,0.4); }
.audience-badge--enfant   { color: var(--accent-warm); border-color: rgba(255,180,84,0.4); }

.product-card-proscons { display: flex; flex-direction: column; gap: 4px; font-size: 0.74rem; line-height: 1.4; }
.product-card-pros, .product-card-cons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.product-card-pros li, .product-card-cons li { padding-left: 16px; position: relative; color: var(--text-2); }
.product-card-pros li::before { content: "+"; position: absolute; left: 0; color: var(--success); font-weight: 700; }
.product-card-cons li::before { content: "–"; position: absolute; left: 0; color: #eb8888; font-weight: 700; }

/* Tableau comparatif en haut des guides "Observer" — prefixe "product-compare-*"
   distinct des classes .compare-* du comparateur de planetes (app 3D), composant
   totalement different malgre le nom proche. */
.product-compare-wrap { overflow-x: auto; margin: 0 0 32px; border-radius: var(--radius-md); border: 1px solid var(--panel-border); }
.product-compare-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 480px; }
.product-compare-table th, .product-compare-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--panel-border); vertical-align: top; }
.product-compare-table thead th { font-family: var(--font-display); font-size: 0.85rem; color: var(--text-0); background: rgba(255,255,255,0.03); }
.product-compare-table tbody th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.product-compare-table tbody tr:last-child td, .product-compare-table tbody tr:last-child th { border-bottom: none; }
.product-compare-wrap a.product-compare-cta {
  display: inline-flex; align-items: center; justify-content: center; padding: 7px 14px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #05070f; font-weight: 600;
  font-size: 0.76rem; text-decoration: none; white-space: nowrap; border-bottom: none;
}
@media (max-width: 420px) { .product-compare-table { font-size: 0.74rem; } }

/* Compact "observe it yourself" callout inserted at the bottom of glossary fiches */
.observer-callout {
  margin: 8px 0 24px;
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(126,166,255,0.06);
  border: 1px solid var(--panel-border);
}
.observer-callout h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0 0 6px;
  color: var(--text-0);
}
.observer-callout p { font-size: 0.84rem; line-height: 1.55; color: var(--text-2); margin: 0 0 12px; }
