:root {
  --void: #03040c;
  --ink: #f4f6ff;
  --dim: #a9b2d0;
  --glass: rgba(12, 16, 38, 0.62);
  --edge: rgba(255, 255, 255, 0.14);
  --band: 255, 184, 77;
  --accent: rgb(var(--band));
  --display: Unbounded, Commissioner, sans-serif;
  --body: Commissioner, system-ui, sans-serif;
  
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  min-height: 100vh;
  background: var(--void);
  color: var(--ink);
  font: 400 15px/1.45 var(--body);
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

h1, h2, p { margin: 0; }

button, select, input[type="text"] {
  font: inherit;
  color: inherit;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 9px 18px;
  backdrop-filter: blur(14px);
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s, transform 0.15s;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); box-shadow: 0 0 18px rgba(var(--band), 0.45); }
button:active { transform: scale(0.97); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 16px rgba(var(--band), 0.4); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

button.glow {
  background: var(--accent);
  border-color: var(--accent);
  color: #05060f;
  font-weight: 600;
  box-shadow: 0 0 26px rgba(var(--band), 0.55);
}
button.glow:hover { box-shadow: 0 0 42px rgba(var(--band), 0.85); }
button.ghost { background: transparent; }

/* ---------- Layers behind everything ---------- */

.sky.sky { position: fixed !important; inset: 0; width: 100vw; height: 100vh; transition: opacity 0.9s; }
.ambient {
  position: fixed;
  inset: -12%;
  width: 124%;
  height: 124%;
  filter: blur(70px) saturate(0);
  opacity: 0;
  transition: opacity 0.9s;
  pointer-events: none;
}
body[data-view="plate"] .sky { opacity: 0; pointer-events: none; }
body[data-view="plate"] .ambient { opacity: 0.35; }

.spectrum-line { display: none; }

/* ---------- Top bar ---------- */

.top {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px 10px;
}
.logo {
  font: 800 15px/1 var(--display);
  background: none;
  border: 0;
  padding: 6px 0;
  backdrop-filter: none;
  white-space: nowrap;
}
.logo:hover { box-shadow: none; }
.logo span { margin-left: 6px; color: var(--accent); }
.search { position: relative; flex: 1; display: flex; gap: 8px; max-width: 760px; margin-left: auto; }
.search-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: min(68vh, 620px);
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 4px;
  background: rgba(8, 11, 26, 0.97);
  border: 1px solid var(--edge);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
}
.search-list h3 { margin: 10px 8px 2px; font: 600 14px/1.2 var(--display); color: var(--accent); }
.search-list p { margin: 10px; color: var(--dim); }
.search-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  backdrop-filter: none;
}
.search-row:hover { background: rgba(255, 255, 255, 0.08); box-shadow: none; }
.search-row:active { transform: none; }
.search-row img { flex: none; width: 46px; height: 46px; border-radius: 7px; object-fit: cover; }
.search-row span { display: grid; gap: 1px; min-width: 0; }
.search-row strong { font-weight: 600; }
.search-row small { color: var(--dim); font-size: 12.5px; }
.search input { flex: 1; min-width: 0; }

.caption {
  position: fixed;
  left: 200px;
  top: 8px;
  z-index: 8;
  width: min(860px, calc(100vw - 480px));
  padding: 10px 22px;
  background: rgba(5, 7, 20, 0.86);
  border: 1px solid rgba(var(--band), 0.6);
  border-radius: 18px;
  box-shadow: 0 0 40px rgba(var(--band), 0.35);
  font-size: 17px;
  line-height: 1.3;
  backdrop-filter: blur(16px);
}

/* ---------- Landing ---------- */

.hero {
  position: relative;
  z-index: 3;
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 22px;
  padding: 0 28px 24px;
  transition: opacity 0.6s, transform 0.9s;
  background: linear-gradient(0deg, rgba(3, 4, 12, 0.95) 0%, rgba(3, 4, 12, 0.35) 45%, transparent 72%);
}
.hero-main { display: flex; gap: 36px; align-items: flex-end; justify-content: space-between; flex: 1; min-height: 0; }
.hero-words { flex: 1; min-width: 0; display: grid; gap: 16px; justify-items: start; align-self: flex-end; }
.hero h1 {
  font: 800 clamp(42px, 7.2vw, 118px)/0.98 var(--display);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.hero-sub { max-width: 58ch; font-size: clamp(16px, 1.4vw, 20px); text-shadow: 0 1px 12px #000; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
button.big { padding: 15px 30px; font-size: 18px; }
body[data-view="diving"] .hero, body[data-view="diving"] .about { opacity: 0; transform: scale(1.06); pointer-events: none; }

.proof { margin: 0; flex: 0 0 min(40vh, 34vw); display: grid; gap: 10px; align-self: flex-end; }
.proof .blink { border-radius: 16px; box-shadow: 0 0 60px rgba(150, 175, 225, 0.4), 0 0 0 1px rgba(214, 224, 240, 0.6); }
.proof .blink b { font: 800 clamp(24px, 3vw, 42px)/1 var(--display); top: 12px; left: 16px; }
.proof .ring { width: 16%; border-width: 3px; }
.proof figcaption { font-size: 14px; line-height: 1.4; text-shadow: 0 1px 8px #000; }

.blink { position: relative; aspect-ratio: 1; overflow: hidden; background: #000; }
.blink img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.blink b {
  position: absolute;
  top: 6px;
  left: 8px;
  font: 600 13px/1 var(--display);
  color: #fff;
  text-shadow: 0 0 10px #000, 0 0 3px #000;
}
.blink .plate-b, .blink .label-b { visibility: hidden; }
body[data-blink="b"] .blink .plate-b, body[data-blink="b"] .blink .label-b { visibility: visible; }
body[data-blink="b"] .blink .label-a { visibility: hidden; }
.blink.place .ring { display: none; }
.blink .ring {
  position: absolute;
  left: var(--ax);
  top: var(--ay);
  width: 22%;
  aspect-ratio: 1;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px #fff;
}
body[data-blink="b"] .blink .ring { left: var(--bx); top: var(--by); }
.blink .ring { border-color: #ffb84d; box-shadow: 0 0 14px #ffb84d; }

.presets-title { font: 600 15px/1.2 var(--display); color: var(--dim); }
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; width: 100%; }
.presets button {
  --tint: 255, 255, 255;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  text-align: left;
  border-radius: 16px;
  border-color: rgba(var(--tint), 0.5);
  background: linear-gradient(160deg, rgba(var(--tint), 0.24), rgba(8, 10, 26, 0.78) 70%);
}
.presets button:hover {
  border-color: rgb(var(--tint));
  box-shadow: 0 0 34px rgba(var(--tint), 0.6);
  transform: translateY(-3px);
}
.presets .blink { border-radius: 10px; }
.card-words { display: grid; gap: 4px; min-width: 0; }
.presets strong { font: 600 14px/1.2 var(--display); color: rgb(var(--tint)); }
.presets small { color: var(--ink); font-size: 12.5px; line-height: 1.3; }

.about {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 22px;
  padding: 56px 28px 40px;
  background: rgba(3, 4, 12, 0.95);
}
.about h2 { font: 800 clamp(26px, 3.6vw, 52px)/1.08 var(--display); }
.about .lead { max-width: 70ch; font-size: 18px; color: var(--dim); }
.table-wrap { overflow-x: auto; }
.results { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 16px; }
.results th { text-align: left; color: var(--dim); font-weight: 500; font-size: 13px; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--edge); vertical-align: bottom; }
.results td { padding: 14px 14px 14px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.results td:first-child { font: 600 15px/1.2 var(--display); }
.results td:nth-child(4) { color: #ffb84d; font-weight: 600; }
.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.columns h3 { margin: 0 0 8px; font: 600 17px/1.2 var(--display); }
.columns p { color: var(--dim); }

/* ---------- Observatory ---------- */

.observatory {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px 26px;
  height: calc(100vh - 66px);
  padding: 4px 28px 14px;
  animation: arrive 0.8s ease-out;
}
@keyframes arrive { from { opacity: 0; transform: scale(1.04); } }

.plate-wrap { min-height: 0; min-width: 0; display: flex; gap: 12px; align-items: stretch; }
.plates { min-width: 0; height: 100%; display: flex; gap: 12px; }
body[data-layout="compare"] .plates { flex: 1; align-items: center; }
body[data-layout="compare"] .plate-frame { flex: 1 1 0; height: auto; min-width: 0; }
.arrays {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.arrays button {
  --tint: 255, 255, 255;
  position: relative;
  padding: 0;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border-color: rgba(var(--tint), 0.5);
  backdrop-filter: none;
}
.arrays button:hover, .arrays button[aria-pressed="true"] {
  border-color: rgb(var(--tint));
  box-shadow: 0 0 22px rgba(var(--tint), 0.75);
  color: inherit;
}
.arrays canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.arrays b {
  position: absolute;
  left: 7px;
  bottom: 5px;
  font: 600 11px/1 var(--display);
  color: rgb(var(--tint));
  text-shadow: 0 0 6px #000, 0 0 2px #000;
}
.arrays .empty canvas { opacity: 0.15; }
.plate-frame {
  position: relative;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  flex: none;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 70px rgba(var(--band), 0.42), 0 0 0 1px rgba(var(--band), 0.55);
  transition: box-shadow 0.25s;
}
#plate, #plate-b { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.plate-hint {
  position: absolute;
  right: 12px;
  bottom: 9px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 0 4px #000;
  pointer-events: none;
}
.plate-date {
  position: absolute;
  top: 14px;
  left: 18px;
  font: 800 clamp(20px, 3vw, 42px)/1.05 var(--display);
  color: #fff;
  text-shadow: 0 0 22px rgba(var(--band), 0.95), 0 2px 8px #000;
  pointer-events: none;
}
.plate-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18%;
  text-align: center;
  color: var(--dim);
  pointer-events: none;
}

.side {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: 18px;
  backdrop-filter: blur(22px);
}
.object-kind { color: var(--accent); font-weight: 600; transition: color 0.2s; }
.object h2 { font: 800 clamp(22px, 2vw, 30px)/1.1 var(--display); }
.note { color: var(--dim); font-size: 13px; }
.progress { color: var(--accent); margin-top: 6px; font-size: 14px; }
.progress:empty { display: none; }

.motion-result:empty { display: none; }
.big-number {
  font: 800 clamp(34px, 3.4vw, 50px)/1 var(--display);
  color: var(--accent);
  text-shadow: 0 0 30px rgba(var(--band), 0.8);
}
.big-words { font: 600 18px/1.2 var(--display); color: var(--accent); }
.big-number small { font-size: 0.36em; font-weight: 600; margin-left: 4px; }
.motion-result table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.motion-result td { padding: 2px 0; }
.motion-result td:first-child { color: var(--dim); }
.motion-result td:last-child { text-align: right; }
.motion-result p { margin-top: 6px; font-size: 13px; line-height: 1.35; }

.chart { margin-top: 8px; min-height: 150px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: rgba(255, 255, 255, 0.1); stroke-width: 0.6; }
.chart .tick, .chart .axis { fill: var(--dim); font-size: 11px; }
.chart .feature { stroke: rgba(255, 255, 255, 0.28); stroke-width: 0.7; stroke-dasharray: 2 3; }
.chart .feature-label { fill: var(--ink); font-size: 10px; }
.chart .error { stroke: rgba(255, 255, 255, 0.22); stroke-width: 0.6; }
.chart .point { fill: rgba(255, 255, 255, 0.8); }
.chart .flagged { fill: none; stroke: var(--dim); stroke-width: 0.8; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.chart .area { stroke: none; fill: var(--accent); opacity: 0.16; }

.tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.tool { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.tool input { accent-color: var(--accent); width: 16px; height: 16px; }
.tool select { padding: 4px 10px; }
.tool select option { color: #05060f; }
.tool.wide input { width: 110px; }
.side .object { order: 0; }
.side .tools { order: 3; }
.side .measure { order: 4; }
.side > .note { order: 5; }
body.negative #plate, body.negative #plate-b, body.negative .arrays canvas, body.negative .film-tile canvas {
  filter: invert(1) hue-rotate(180deg);
}
.plates:fullscreen { background: #000; justify-content: center; align-items: center; }
.plates:fullscreen .plate-frame { height: 100vh; }
.segment { display: inline-flex; }
.segment button { border-radius: 0; margin-left: -1px; padding: 7px 14px; font-size: 14px; }
.segment button:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.segment button:last-child { border-radius: 0 999px 999px 0; }
.segment button[aria-pressed="true"] { position: relative; z-index: 1; }

.deck { grid-column: 1 / -1; display: grid; gap: 8px; }
.lock {
  position: absolute;
  left: 18px;
  bottom: 34px;
  padding: 5px 12px;
  border: 1px solid #ffb84d;
  border-radius: 999px;
  background: rgba(3, 4, 12, 0.78);
  color: #ffb84d;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 0 18px rgba(255, 184, 77, 0.5);
  pointer-events: none;
}
.chooser { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chooser strong { flex: none; color: #ffb84d; }
.chooser-list { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.chooser-list button { flex: none; padding: 5px 12px; font-size: 13px; }
.chooser-list button:first-child { border-color: #ffb84d; color: #ffb84d; font-weight: 600; }
body.picking #plate { cursor: cell; box-shadow: inset 0 0 0 2px #ffb84d; }
.guide { display: flex; gap: 14px; align-items: center; justify-content: space-between; }
.explain { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; }
.try { flex: none; display: flex; gap: 8px; }
.try button { padding: 8px 15px; font-size: 14px; font-weight: 600; }
.try button.try-main { border-color: var(--accent); }
.hero-help { color: var(--accent); font-weight: 600; text-shadow: 0 1px 10px #000; }
.range { flex: none; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.range label { display: flex; gap: 5px; align-items: center; color: var(--dim); }
.range select { padding: 5px 8px; font-size: 13px; max-width: 128px; color: var(--ink); }
.range select option { color: #05060f; }
.range button { padding: 5px 11px; font-size: 13px; }
.timeline, .bands { display: flex; gap: 14px; align-items: center; }
.timeline #play { min-width: 92px; }
.film { flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.film-tile {
  flex: none;
  position: relative;
  width: 62px;
  height: 62px;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  background: #000;
  backdrop-filter: none;
}
.film-tile canvas { display: block; width: 100%; height: 100%; }
.film-tile span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 3px;
  font-size: 10.5px;
  line-height: 1.15;
  text-align: center;
  color: #fff;
  background: rgba(3, 4, 12, 0.72);
}
.film-tile[aria-pressed="true"] { border: 2px solid var(--accent); }

.band-track { position: relative; flex: 1; min-width: 0; height: 30px; }
.band-scale {
  position: absolute;
  inset: 5px 0;
  display: flex;
  border-radius: 999px;
  overflow: hidden;
}
.band-scale span { flex: 1; background: rgba(214, 224, 240, 0.28); }
.band-scale span.array-start { border-left: 2px solid var(--void); }
.band-track input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: ew-resize;
}
.band-track input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 30px;
  border-radius: 7px;
  background: #fff;
  border: 2px solid #05060f;
  box-shadow: 0 0 16px #fff;
}
.band-track input::-moz-range-thumb {
  width: 12px;
  height: 28px;
  border-radius: 7px;
  background: #fff;
  border: 2px solid #05060f;
  box-shadow: 0 0 16px #fff;
}
.bands output { flex: 0 0 120px; text-align: right; font: 600 15px/1 var(--display); color: var(--accent); }

body.embed .top, body.embed .spectrum-line { display: none; }
body.embed .observatory { height: 100vh; }

/* The Aladin controls follow the same visual language. */
.aladin-container, .aladin-imageCanvas { background: var(--void) !important; }
.aladin-imageCanvas { filter: brightness(1.5) saturate(0) contrast(1.05); background: var(--void) !important; }
.aladin-logo-container { opacity: 0.5; }

@media (max-width: 1000px) {
  .caption { left: 16px; width: calc(100vw - 32px); top: auto; bottom: 12px; }
  .top { flex-wrap: wrap; padding: 14px 16px 8px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  #tour { margin-left: auto; }
  .hero { padding: 40vh 16px 16px; min-height: 0; }
  .hero-main { flex-direction: column; align-items: stretch; }
  .proof { flex: none; width: 100%; max-width: 420px; }
  .presets { grid-template-columns: 1fr; }
  .about { padding: 36px 16px 28px; }
  .columns { grid-template-columns: 1fr; }
  .observatory { display: flex; flex-direction: column; height: auto; padding: 4px 16px 16px; }
  .plate-wrap { flex-direction: column; }
  .plates { height: auto; flex-direction: column; }
  .plate-frame { height: auto; width: 100%; }
  .arrays { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: none; }
  .arrays canvas { aspect-ratio: 1; height: auto; }
  .side { overflow: visible; }
  .timeline { align-items: flex-start; flex-wrap: wrap; }
  .range { flex-wrap: wrap; }
  .bands { flex-wrap: wrap; }
  .guide { flex-direction: column; align-items: stretch; }
  .try { flex-wrap: wrap; }
  .band-track { flex: 1 1 100%; order: 3; }
  .bands output { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .observatory { animation: none; }
  * { transition: none !important; }
}
