:root {
  --matter-blue: #54a8ff;
  --matter-blue-soft: rgba(84, 168, 255, 0.16);
  --matter-cyan: #5ee6d2;
  --matter-red: #ff715b;
  --matter-red-soft: rgba(255, 113, 91, 0.16);
  --matter-gold: #ffc857;
  --matter-purple: #b79cff;
  --matter-ink: #e9f1fb;
  --matter-muted: #9fb0c3;
  --matter-panel: rgba(18, 28, 42, 0.88);
  --matter-line: rgba(180, 208, 235, 0.25);
}

/* Interactive laboratories (constant-density and adiabatic MSW labs) */
.matter-lab-slide h2 {
  margin-bottom: 0.18em;
}

.matter-lab {
  --lab-bg: rgba(10, 18, 29, 0.94);
  display: grid;
  grid-template-columns: 18.5rem 1fr;
  grid-template-rows: auto 1fr;
  gap: 0.55rem 0.75rem;
  height: 37rem;
  padding: 0.55rem;
  border: 1px solid var(--matter-line);
  border-radius: 0.7rem;
  background: var(--lab-bg);
  box-shadow: 0 0.45rem 1.2rem rgba(0, 0, 0, 0.28);
  color: var(--matter-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.22;
}

.matter-lab * {
  box-sizing: border-box;
}

.matter-lab-controls {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.65rem;
  border: 1px solid rgba(180, 208, 235, 0.18);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.035);
}

.matter-lab-controls label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.5rem;
  color: var(--matter-muted);
  font-size: 0.82rem;
}

.matter-lab-controls label span {
  color: var(--matter-ink);
  font-variant-numeric: tabular-nums;
}

.matter-lab-controls input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--matter-blue);
}

.matter-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-top: auto;
}

.matter-presets button {
  min-height: 2rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid rgba(84, 168, 255, 0.48);
  border-radius: 0.35rem;
  background: rgba(84, 168, 255, 0.1);
  color: var(--matter-ink);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.matter-presets button:hover,
.matter-presets button:focus-visible {
  background: rgba(84, 168, 255, 0.26);
  outline: none;
}

.matter-presets button[data-action="play"] {
  grid-column: 1 / -1;
  border-color: rgba(94, 230, 210, 0.55);
  background: rgba(94, 230, 210, 0.1);
  color: var(--matter-cyan);
}

.matter-lab-readouts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.42rem;
}

.matter-lab-readouts > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 3.65rem;
  padding: 0.34rem 0.48rem;
  border: 1px solid rgba(180, 208, 235, 0.18);
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.035);
}

.matter-lab-readouts span {
  color: var(--matter-muted);
  font-size: 0.68rem;
}

.matter-lab-readouts b {
  margin-top: 0.15rem;
  color: var(--matter-blue);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.matter-lab-readouts .prob b {
  color: var(--matter-cyan);
}

.matter-lab-plots {
  display: grid;
  grid-template-columns: 1.38fr 1fr;
  gap: 0.6rem;
  min-height: 0;
}

.matter-lab figure {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0.28rem;
  border: 1px solid rgba(180, 208, 235, 0.17);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.025);
}

.matter-lab svg {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.matter-lab figcaption {
  margin: -0.2rem 0 0.15rem;
  color: var(--matter-muted);
  text-align: center;
  font-size: 0.68rem;
}

.matter-lab svg text {
  fill: var(--matter-muted);
  font-family: inherit;
  font-size: 12px;
}

.matter-lab svg .axis {
  stroke: rgba(190, 214, 236, 0.42);
  stroke-width: 1;
}

.matter-lab svg .grid {
  stroke: rgba(190, 214, 236, 0.12);
  stroke-width: 1;
}

.matter-lab svg .vacuum-line {
  fill: none;
  stroke: rgba(200, 214, 228, 0.5);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.matter-lab svg .matter-line {
  fill: none;
  stroke: var(--matter-blue);
  stroke-width: 3;
}

.matter-lab svg .envelope-line {
  fill: none;
  stroke: var(--matter-red);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.matter-lab svg .probe {
  stroke: var(--matter-gold);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.matter-lab svg .probe-dot {
  fill: var(--matter-gold);
  stroke: #fff;
  stroke-width: 1.2;
}

.matter-lab svg .branch {
  fill: none;
  stroke: var(--matter-blue);
  stroke-width: 3;
}

.matter-lab svg .bare-branch {
  fill: none;
  stroke: rgba(200, 214, 228, 0.46);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.matter-lab svg .state-dot {
  fill: var(--matter-gold);
  stroke: #fff;
  stroke-width: 1.4;
}

.matter-lab svg .electron-fill {
  fill: var(--matter-red-soft);
  stroke: var(--matter-red);
  stroke-width: 1.5;
}

.matter-lab svg .legend-label {
  font-size: 11px;
}

.adiabatic-lab {
  position: relative;
}

.adiabatic-progress {
  position: absolute;
  left: 19.8rem;
  right: 0.7rem;
  top: 5.05rem;
  z-index: 3;
  height: 0.18rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(180, 208, 235, 0.14);
}

.adiabatic-progress i {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  background: linear-gradient(90deg, var(--matter-cyan), var(--matter-blue));
}

.adiabatic-lab .matter-lab-plots {
  padding-top: 0.1rem;
}

@media (max-width: 900px) {
  .matter-lab {
    grid-template-columns: 15rem 1fr;
    font-size: 13px;
  }

  .matter-lab-plots {
    grid-template-columns: 1fr;
  }
}
