:root {
  --bg: #070a12;
  --panel: #0c1220;
  --panel-2: #10182b;
  --plaque: #efe4ca;
  --plaque-ink: #171311;
  --ink: #e7eef8;
  --muted: #98abc4;
  --rule: rgba(152, 171, 196, 0.24);
  --brass: #cfa156;
  --brass-hi: #ebd099;
  --cyan: #38bdf8;
  --emerald: #34d399;
  --violet: #a855f7;
  --crimson: #f43f5e;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  color: var(--ink);
  font: 1.03rem/1.62 Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(56, 189, 248, 0.09), transparent 36rem),
    radial-gradient(circle at 85% 12%, rgba(168, 85, 247, 0.08), transparent 32rem),
    radial-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1.3px) 0 0 / 8px 8px,
    var(--bg);
}

a {
  color: var(--cyan);
  text-underline-offset: 0.18em;
}
a:hover, a:focus-visible {
  color: var(--emerald);
}

code {
  font: 0.88em ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.math {
  text-transform: none;
  letter-spacing: 0.02em;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: var(--plaque);
  color: var(--plaque-ink);
  z-index: 30;
}
.skip:focus { left: 0.5rem; }

/* Seven emission lines of Argon across the top */
.spec-strip {
  position: relative;
  height: 10px;
  background: #03050a;
  border-bottom: 1px solid rgba(207, 161, 86, 0.4);
  overflow: hidden;
}
.spec-strip .line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
}
.spec-strip .l416 { left: 9%;  background: #8b5cf6; box-shadow: 0 0 8px #8b5cf6; }
.spec-strip .l455 { left: 21%; background: #3b82f6; box-shadow: 0 0 8px #3b82f6; }
.spec-strip .l477 { left: 29%; background: #0ea5e9; box-shadow: 0 0 8px #0ea5e9; }
.spec-strip .l488 { left: 34%; background: #22d3ee; box-shadow: 0 0 10px #22d3ee; width: 4px; }
.spec-strip .l515 { left: 44%; background: #10b981; box-shadow: 0 0 10px #10b981; width: 4px; }
.spec-strip .l697 { left: 82%; background: #f43f5e; box-shadow: 0 0 9px #f43f5e; }
.spec-strip .l750 { left: 92%; background: #be123c; box-shadow: 0 0 8px #be123c; }

.wrap {
  width: min(68rem, 100%);
  margin: 0 auto;
  padding: clamp(1.2rem, 3.5vw, 2.8rem) clamp(0.85rem, 3.5vw, 2.4rem) 3.4rem;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.2rem 2rem;
  align-items: end;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule);
}

.imprint {
  margin: 0 0 0.35rem;
  font: 700 0.76rem/1.4 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(2.15rem, 6.8vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0.35rem 0 0;
  font-style: italic;
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  color: var(--cyan);
}

.stamp-box {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.25rem 0.9rem;
  padding: 0.65rem 0.9rem;
  background: var(--panel);
  border: 1px solid rgba(207, 161, 86, 0.45);
  font: 0.78rem/1.35 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.stamp-box .k { color: var(--muted); }
.stamp-box .v { color: var(--brass-hi); text-align: right; font-weight: 700; }

.lede {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem 2.2rem;
  margin: 1.6rem 0 1.8rem;
}
.lede p { margin: 0; }

/* Bench instrument */
.bench-frame {
  background: var(--panel);
  border: 1px solid rgba(56, 189, 248, 0.32);
  box-shadow: 0 0 0 4px #060911, 0 20px 48px rgba(0, 0, 0, 0.65);
  margin: 0 0 2.4rem;
}

.bench-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.65rem 1rem;
  background: #080d18;
  border-bottom: 1px solid var(--rule);
  font: 700 0.74rem/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.badge {
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  border: 1px solid var(--muted);
  color: var(--muted);
}
.badge.lit {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.1);
}
.badge.laser {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(52, 211, 153, 0.12);
}
.badge.dark {
  border-color: var(--brass);
  color: var(--brass);
  background: rgba(207, 161, 86, 0.08);
}

.ampoule-stage {
  padding: 0.75rem 0.75rem 0.45rem;
  background: #05080f;
  border-bottom: 1px solid var(--rule);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

#ampoule {
  border: 1px solid rgba(152, 171, 196, 0.16);
  background: #060912;
  cursor: crosshair;
}

.static-tube {
  display: block;
  width: 100%;
  height: auto;
}

.stage-hint {
  margin: 0.45rem 0 0.1rem;
  text-align: center;
  font: italic 0.86rem/1.35 Georgia, serif;
  color: var(--muted);
}

.preset-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  padding: 0.75rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--rule);
}

button, input {
  font: inherit;
}

.preset, .act-btn {
  padding: 0.48rem 0.55rem;
  border: 1px solid rgba(152, 171, 196, 0.35);
  background: #090e1a;
  color: var(--ink);
  cursor: pointer;
  font: 700 0.74rem/1.25 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  text-align: center;
  min-width: 0;
  overflow-wrap: anywhere;
}
.preset:hover, .preset:focus-visible,
.act-btn:hover, .act-btn:focus-visible {
  border-color: var(--cyan);
  outline: 2px solid rgba(56, 189, 248, 0.35);
  outline-offset: 1px;
}
.preset[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--cyan);
  color: #fff;
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  border-bottom: 1px solid var(--rule);
}

.control-box {
  padding: 0.95rem 1rem;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

.slider-row label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.6rem;
  font: 700 0.78rem/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--ink);
}
.slider-row output {
  color: var(--brass-hi);
}
.slider-row input[type="range"] {
  width: 100%;
  margin: 0.35rem 0 0.15rem;
  accent-color: var(--cyan);
}
.scale-ends {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font: 0.69rem/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--muted);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.15rem;
}
.act-btn {
  flex: 1 1 10rem;
  border-color: rgba(207, 161, 86, 0.55);
  color: var(--brass-hi);
}
.act-btn[aria-pressed="true"] {
  background: rgba(52, 211, 153, 0.16);
  border-color: var(--emerald);
  color: var(--emerald);
}

.telemetry-box {
  padding: 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  background: #090e1a;
  min-width: 0;
}

.readout-dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.8rem;
}
.readout-dl div {
  min-width: 0;
}
.readout-dl dt {
  font: 700 0.68rem/1.25 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.readout-dl dd {
  margin: 0.15rem 0 0;
  font: 700 0.88rem/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.verdict {
  margin: 0;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--rule);
  font-style: italic;
  font-size: 0.94rem;
  color: #cbd8ea;
}

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

.scope-card {
  margin: 0;
  padding: 0.75rem;
  background: #070b14;
  min-width: 0;
}
.scope-card:first-child {
  border-right: 1px solid var(--rule);
}

.scope-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.6rem;
  margin-bottom: 0.45rem;
  font: 700 0.71rem/1.25 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.scope-head span:first-child { color: var(--ink); }

#paschen-plot {
  cursor: pointer;
  border: 1px solid rgba(152, 171, 196, 0.16);
}
#spectroscope {
  border: 1px solid rgba(152, 171, 196, 0.16);
}

.scope-card figcaption {
  margin-top: 0.45rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Museum plaques */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
}

.plaque {
  background: var(--plaque);
  color: var(--plaque-ink);
  padding: clamp(1rem, 2.4vw, 1.55rem);
  border-top: 6px solid var(--cyan);
  min-width: 0;
  overflow-wrap: anywhere;
}
.plaque:nth-child(2) { border-top-color: var(--violet); }
.plaque.wide {
  grid-column: 1 / -1;
  border-top-color: var(--emerald);
}
.plaque h2 {
  margin: 0 0 0.55rem;
  font: 700 0.86rem/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #2c241d;
}
.plaque p {
  margin: 0 0 0.75rem;
  font-size: 0.98rem;
}
.plaque p:last-child { margin-bottom: 0; }
.plaque a {
  color: #0b5d7a;
  font-weight: 700;
}
.plaque a:hover, .plaque a:focus-visible {
  color: #063b4e;
}
.plaque .koan {
  padding-top: 0.65rem;
  border-top: 1px solid rgba(23, 19, 17, 0.2);
  font-size: 0.93rem;
  color: #3a3028;
}

footer {
  margin-top: 2.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--muted);
}
footer p { margin: 0 0 0.55rem; }
footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.55rem;
}

@media (max-width: 820px) {
  .masthead { grid-template-columns: 1fr; }
  .stamp-box { justify-self: start; }
  .lede { grid-template-columns: 1fr; gap: 0.9rem; }
  .preset-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls-grid { grid-template-columns: 1fr; }
  .control-box { border-right: 0; border-bottom: 1px solid var(--rule); }
  .scopes-grid { grid-template-columns: 1fr; }
  .scope-card:first-child { border-right: 0; border-bottom: 1px solid var(--rule); }
  .notes-grid { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .preset-bar { grid-template-columns: 1fr; }
  .readout-dl { grid-template-columns: 1fr; }
  .stamp-box { width: 100%; }
  .scale-ends { font-size: 0.62rem; }
}
