:root {
  --bg-0: #040815;
  --bg-1: #0a1327;
  --panel: rgba(10, 19, 39, 0.9);
  --line: rgba(153, 210, 255, 0.16);
  --line-strong: rgba(153, 210, 255, 0.28);
  --text: #f4f7ff;
  --muted: #aab7d3;
  --cyan: #66d6ff;
  --mint: #a7f0d5;
  --violet: #b2a8ff;
  --amber: #ffc97c;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }

body {
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
  background:
    radial-gradient(circle at 15% 22%, rgba(34, 87, 170, 0.16), transparent 24%),
    radial-gradient(circle at 80% 68%, rgba(28, 168, 153, 0.14), transparent 22%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: radial-gradient(circle at center, black 42%, transparent 90%);
  pointer-events: none;
}

.page-shell {
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.hero,
.card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px;
  padding: 26px;
  margin-bottom: 22px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  right: -100px;
  bottom: -140px;
  background: radial-gradient(circle, rgba(102, 214, 255, 0.16), transparent 68%);
}

.eyebrow,
.panel-label {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.hero h1,
.section-head h2,
.section-head h3,
.notes-grid h4 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.04em;
}

.hero h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.5rem, 5.2vw, 5rem);
  line-height: 0.92;
}

.hero-text,
.readout-note,
.guardrails,
.notes-grid p,
.source-list {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.hero-text { max-width: 65ch; margin-top: 16px; }

.hero-note {
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(8, 16, 31, 0.76);
}

.hero-notes {
  display: grid;
  align-content: center;
  gap: 14px;
}

.hero-note span {
  display: block;
  color: var(--cyan);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  font-weight: 700;
}

.hero-note strong { font-size: 1.03rem; }

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.88fr);
  gap: 22px;
  align-items: start;
}

.controls-panel {
  display: grid;
  gap: 20px;
}

.notes-panel,
.sources-panel {
  grid-column: 1 / -1;
}

.card { padding: 22px; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.section-head.compact {
  justify-content: flex-start;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.swatch-density { background: var(--cyan); }
.swatch-real { background: var(--mint); }
.swatch-imag { background: var(--violet); }
.swatch-potential { background: var(--amber); }

.canvas-stack {
  margin-top: 18px;
  border: 1px solid rgba(153, 210, 255, 0.12);
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 58%, rgba(102, 214, 255, 0.09), transparent 32%),
    linear-gradient(180deg, rgba(5, 11, 23, 0.96), rgba(5, 12, 22, 0.98));
}

#wave-canvas,
#measurement-canvas {
  display: block;
  width: 100%;
}

#wave-canvas { height: 470px; }
#measurement-canvas {
  height: 180px;
  border-top: 1px solid rgba(153, 210, 255, 0.1);
  background: rgba(255, 255, 255, 0.015);
}

.canvas-note {
  padding: 14px 18px;
  border-top: 1px solid rgba(153, 210, 255, 0.08);
  border-bottom: 1px solid rgba(153, 210, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.canvas-note p { margin: 0; color: var(--muted); line-height: 1.55; }

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field span {
  font-size: 0.94rem;
  font-weight: 600;
}

select,
input[type="range"],
button,
output {
  font: inherit;
}

select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(4, 10, 21, 0.88);
}

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

output {
  color: var(--cyan);
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  color: #05121b;
  background: linear-gradient(135deg, #8ae7ff, #ffd388);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

button.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.readout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.readout-grid dt {
  margin-bottom: 6px;
  color: var(--cyan);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.readout-grid dd {
  margin: 0;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 600;
}

.guardrails,
.source-list {
  padding-left: 18px;
}

.guardrails li + li,
.source-list li + li {
  margin-top: 10px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.notes-grid article {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(153, 210, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
}

.notes-grid h4 {
  margin: 0 0 10px;
  font-size: 1.18rem;
}

.source-list a {
  color: #d8f4ff;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

@media (max-width: 1160px) {
  .hero,
  .dashboard {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .page-shell {
    width: min(calc(100vw - 14px), 1480px);
    padding-top: 10px;
  }

  .hero,
  .card {
    padding: 18px;
  }

  .section-head,
  .legend {
    flex-direction: column;
    align-items: flex-start;
  }

  #wave-canvas { height: 390px; }
  #measurement-canvas { height: 160px; }

  .readout-grid,
  .notes-grid {
    grid-template-columns: 1fr;
  }
}
