:root {
  --bg: 190 12% 8%;
  --surface: 193 50% 13%;
  --foreground: 180 14% 91%;
  --muted: 187 3% 45%;
  --stroke: 171 54% 18%;
  --accent-signal: 200 80% 48%;
  --accent-signal-light: 190 63% 67%;
  --accent-signal-deep: 170 55% 54%;
  --accent-warm: 21 76% 57%;
  --paper: 43 20% 92%;
  --paper-bright: 37 25% 94%;
  --paper-shade: 40 19% 88%;
  --ink: 240 8% 5%;
  --ink-60: 240 5% 36%;
  --ink-fade: 44 4% 52%;
  --rule: rgba(11,11,13,0.18);
  --rule-soft: rgba(255,255,255,0.08);
  --font-display: 'Instrument Serif', ui-serif, Georgia, serif;
  --font-heading: 'General Sans', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'General Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(circle at 76% 8%, rgba(61, 215, 179, 0.18), transparent 30vw),
    linear-gradient(180deg, #0d191c 0%, #071012 48%, #030608 100%) fixed;
  color: hsl(var(--foreground));
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, input { font-family: inherit; }
img, canvas { display: block; max-width: 100%; }
figure { margin: 0; }

.article-shell {
  min-height: 100vh;
  overflow-x: clip;
}

.article-hero {
  position: relative;
  padding: clamp(128px, 17vh, 180px) clamp(1.4rem, 4vw, 4rem) clamp(56px, 8vh, 92px);
  border-bottom: 1px solid var(--rule-soft);
}

.article-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(61,215,179,0.55), transparent);
}

.article-hero-inner {
  width: min(1220px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.88fr);
  gap: clamp(40px, 7vw, 92px);
  align-items: center;
}

.article-hero-inner > *,
.article-body-grid > * {
  min-width: 0;
}

.article-kicker,
.section-kicker,
.rail-label,
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1.4;
  text-transform: uppercase;
}

.article-kicker {
  color: hsl(var(--accent-signal-deep));
  margin: 0 0 16px;
}

.article-title {
  margin: 0;
  color: hsl(var(--foreground));
  font-family: var(--font-heading);
  font-size: clamp(2.35rem, 6.1vw, 5.75rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.94;
  max-width: 10.8ch;
}

.article-title em {
  color: hsl(var(--accent-signal-deep));
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.article-dek {
  max-width: 66ch;
  margin: 24px 0 0;
  color: hsl(var(--foreground) / 0.72);
  font-size: clamp(1.02rem, 1.4vw, 1.18rem);
  line-height: 1.72;
}

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

.article-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid rgba(244,250,250,0.14);
  border-radius: 999px;
  background: rgba(244,250,250,0.04);
  color: hsl(var(--foreground));
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.article-button:hover {
  border-color: rgba(61,215,179,0.5);
  background: rgba(61,215,179,0.08);
  transform: translateY(-1px);
}

.article-button svg {
  width: 14px;
  height: 14px;
}

.hero-instrument {
  position: relative;
  min-width: 0;
  min-height: 520px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), transparent 34%),
    radial-gradient(circle at 34% 26%, rgba(61,215,179,0.2), transparent 36%),
    #061012;
  box-shadow: 0 30px 120px -54px rgba(61, 215, 179, 0.45);
}

.hero-instrument canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.instrument-frame {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(244,250,250,0.13);
  border-radius: 6px;
  pointer-events: none;
}

.instrument-caption {
  position: absolute;
  left: 38px;
  right: 38px;
  bottom: 26px;
  display: flex;
  justify-content: flex-start;
  gap: 20px;
  color: rgba(244,250,250,0.62);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  line-height: 1.5;
  text-transform: uppercase;
}
.instrument-caption strong,
.instrument-metrics strong { color: hsl(var(--accent-signal-deep)); font-weight: 600; }

.instrument-caption span,
.instrument-metrics span {
  min-width: 0;
}

.article-body-wrap {
  background:
    linear-gradient(rgba(11,11,13,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11,11,13,0.025) 1px, transparent 1px),
    hsl(var(--paper));
  background-size: 24px 24px;
  color: hsl(var(--ink));
  padding: 0 clamp(1.2rem, 4vw, 4rem) 80px;
}

.article-body-grid {
  width: min(1220px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: clamp(34px, 6vw, 78px);
  align-items: start;
}

.article-rail {
  position: sticky;
  top: 118px;
  padding-top: 70px;
  font-family: var(--font-mono);
  color: hsl(var(--ink-fade));
}

.rail-label {
  color: hsl(var(--ink) / 0.42);
  margin-bottom: 18px;
}

.article-rail nav {
  display: grid;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--rule);
}

.article-rail a {
  color: hsl(var(--ink-60));
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.05em;
  line-height: 1.4;
}

.article-rail a {
  transition: color 160ms ease, padding-left 160ms ease;
}
.article-rail a:hover { color: hsl(var(--ink)); }
.article-rail nav a.is-active {
  color: hsl(var(--ink));
  font-weight: 600;
  position: relative;
  padding-left: 6px;
}
.article-rail nav a.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: hsl(var(--accent-signal));
  border-radius: 2px;
  box-shadow: 0 0 0 1px hsla(var(--accent-signal), 0.25);
}

.article-main {
  max-width: 860px;
  padding-top: 70px;
}

.article-main > section {
  scroll-margin-top: 116px;
  margin-bottom: 62px;
}

.article-main h2 {
  margin: 0 0 18px;
  color: hsl(var(--ink));
  font-family: var(--font-heading);
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.article-main h3 {
  margin: 28px 0 10px;
  color: hsl(var(--ink));
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.article-main p,
.article-main li {
  color: hsl(var(--ink-60));
  font-size: 1rem;
  line-height: 1.72;
}

.article-main p {
  margin: 0 0 16px;
}

.article-main a {
  color: hsl(var(--ink));
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.answer-card,
.equation-card,
.lab-card,
.reference-card,
.audio-card,
.table-card,
.related-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255,255,255,0.32);
  box-shadow: 0 18px 60px -52px rgba(11,11,13,0.34);
}

.answer-card {
  padding: clamp(22px, 3vw, 32px);
  background:
    linear-gradient(135deg, rgba(61,215,179,0.12), transparent 42%),
    rgba(255,255,255,0.38);
}

.answer-card p {
  margin: 0;
  color: hsl(var(--ink));
  font-size: clamp(1.14rem, 1.8vw, 1.34rem);
  line-height: 1.58;
  letter-spacing: -0.01em;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: hsl(var(--accent-signal-deep));
  margin-bottom: 14px;
}

.section-kicker::before {
  content: "";
  width: 30px;
  height: 1px;
  background: currentColor;
  opacity: 0.65;
}

.equation-card {
  margin: 24px 0;
  overflow: hidden;
}

.equation-display {
  padding: clamp(22px, 3vw, 34px);
  background: #071012;
  color: hsl(var(--foreground));
  font-family: var(--font-mono);
  font-size: clamp(1.04rem, 2vw, 1.42rem);
  line-height: 1.6;
  text-align: center;
  overflow-x: auto;
}

.symbol-grid,
.regime-grid,
.mechanism-grid,
.use-grid,
.related-grid {
  display: grid;
  gap: 14px;
}

.symbol-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 18px;
}

.symbol {
  min-height: 116px;
  padding: 16px;
  border: 1px solid rgba(11,11,13,0.12);
  border-radius: 6px;
  background: rgba(237,235,230,0.52);
}

.symbol dt {
  margin: 0 0 6px;
  color: hsl(var(--ink));
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
}

.symbol dd {
  margin: 0;
  color: hsl(var(--ink-60));
  font-size: 0.9rem;
  line-height: 1.55;
}

.regime-grid,
.use-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 20px 0 28px;
}

.regime-card,
.use-card,
.mechanism-card,
.related-card a {
  padding: 20px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255,255,255,0.28);
}

.regime-card h3,
.use-card h3,
.mechanism-card h3 {
  margin-top: 0;
}

.regime-card p,
.use-card p,
.mechanism-card p {
  margin-bottom: 0;
  font-size: 0.94rem;
}

.lab-card {
  margin: 26px 0 34px;
  overflow: hidden;
}

.lab-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule);
}

.lab-head strong {
  color: hsl(var(--ink));
  font-size: 1rem;
}

.lab-head span {
  color: hsl(var(--ink-fade));
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lab-canvas-wrap {
  min-height: 360px;
  background: #071012;
}

.lab-canvas-wrap canvas {
  width: 100%;
  height: 360px;
}

.lab-controls {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 22px;
  padding: 20px;
  border-top: 1px solid var(--rule);
  align-items: center;
}

.lab-controls-three {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 290px;
}

.control-line {
  display: grid;
  gap: 10px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: hsl(var(--ink));
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.control-label output {
  color: hsl(var(--accent-signal-deep));
}

.compact-slider {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
}

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

.metric-stack {
  display: grid;
  gap: 9px;
}

.meter-row {
  display: grid;
  grid-template-columns: 96px 1fr 44px;
  gap: 10px;
  align-items: center;
  color: hsl(var(--ink-fade));
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meter-track {
  height: 7px;
  border-radius: 99px;
  background: rgba(11,11,13,0.12);
  overflow: hidden;
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, hsl(var(--accent-signal-deep)), hsl(var(--accent-warm)));
}

.compare-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.compare-toggle button {
  border: 1px solid rgba(11,11,13,0.16);
  border-radius: 999px;
  background: rgba(255,255,255,0.35);
  color: hsl(var(--ink-60));
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
}

.compare-toggle button[aria-pressed="true"] {
  background: hsl(var(--ink));
  color: hsl(var(--paper-bright));
  border-color: hsl(var(--ink));
}

.mechanism-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 22px 0 30px;
}

.mechanism-card {
  min-height: 230px;
}

.flow-card {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--rule);
}

.flow-card div {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(61,215,179,0.12), transparent 60%),
    rgba(255,255,255,0.32);
  color: hsl(var(--ink));
  font-weight: 600;
  line-height: 1.2;
}

.flow-card div::after {
  content: "\2192";
  color: hsl(var(--accent-signal-deep));
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.flow-card div:last-child::after {
  /* Keep the arrow's grid row so the last box's title/subtitle align
     vertically with the prior boxes. Just hide it visually. */
  visibility: hidden;
}

.flow-card span {
  color: hsl(var(--ink-fade));
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.article-image-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 28px 0;
}

.article-image-row figure {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255,255,255,0.32);
}

.article-image-row img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  background: #071012;
}

.article-image-row figcaption {
  padding: 14px 16px 16px;
  color: hsl(var(--ink-60));
  font-size: 0.9rem;
  line-height: 1.5;
}

.timeline-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin: 24px 0 30px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--rule);
}

.timeline-strip article {
  min-height: 178px;
  padding: 18px;
  background: rgba(255,255,255,0.32);
}

.timeline-strip span {
  display: block;
  margin-bottom: 12px;
  color: hsl(var(--accent-signal-deep));
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.timeline-strip strong {
  color: hsl(var(--ink));
  font-size: 1rem;
}

.timeline-strip p {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.compact-lab .lab-canvas-wrap,
.compact-lab .lab-canvas-wrap canvas {
  min-height: 260px;
  height: 260px;
}

.mechanism-card::before {
  content: attr(data-num);
  display: block;
  margin-bottom: 14px;
  color: hsl(var(--accent-signal-deep));
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table-card {
  overflow-x: auto;
  margin-top: 22px;
  /* Teal scrollbar on the comparison table when it overflows on
     narrow viewports. Firefox uses scrollbar-color; WebKit uses
     ::-webkit-scrollbar pseudo-elements. */
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--accent-signal-deep)) transparent;
}
.table-card::-webkit-scrollbar { height: 8px; }
.table-card::-webkit-scrollbar-track { background: transparent; }
.table-card::-webkit-scrollbar-thumb {
  background: hsl(var(--accent-signal-deep));
  border-radius: 4px;
}
.table-card::-webkit-scrollbar-thumb:hover { background: hsl(var(--accent-signal-light)); }

.comparison-table th,
.comparison-table td {
  padding: 15px 16px;
  border-bottom: 1px solid rgba(11,11,13,0.12);
  color: hsl(var(--ink-60));
  font-size: 0.92rem;
  text-align: left;
  vertical-align: top;
}

.comparison-table th {
  color: hsl(var(--ink));
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.comparison-table td:first-child {
  color: hsl(var(--ink));
  font-weight: 600;
}

.audio-card {
  overflow: hidden;
  margin-top: 22px;
}

.article-audio-row {
  display: grid;
  grid-template-columns: 1fr auto minmax(140px, 220px) 76px;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(11,11,13,0.1);
}

.article-audio-row:last-child { border-bottom: 0; }

.audio-title {
  color: hsl(var(--ink));
  font-weight: 600;
}

.audio-caption {
  color: hsl(var(--ink-fade));
  font-size: 0.9rem;
}

.audio-play {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(11,11,13,0.18);
  border-radius: 50%;
  background: hsl(var(--ink));
  color: hsl(var(--paper-bright));
  cursor: pointer;
}

.audio-play svg {
  width: 15px;
  height: 15px;
}

.audio-play .icon-pause,
.article-audio-row[data-state="playing"] .icon-play { display: none; }
.article-audio-row[data-state="playing"] .icon-pause { display: block; }

.audio-progress {
  height: 6px;
  border-radius: 99px;
  background: rgba(11,11,13,0.14);
  overflow: hidden;
  cursor: pointer;
}

.audio-progress-fill {
  width: 0%;
  height: 100%;
  background: hsl(var(--accent-signal-deep));
}

.audio-time {
  color: hsl(var(--ink-fade));
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.reference-card {
  padding: 22px;
}

.reference-card ul {
  margin: 0;
  padding-left: 20px;
}

.reference-card li + li { margin-top: 12px; }

.related-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.related-card {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.related-card a {
  display: grid;
  gap: 8px;
  min-height: 142px;
  color: hsl(var(--ink));
  text-decoration: none;
}

.related-card span {
  color: hsl(var(--accent-signal-deep));
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.related-card p {
  margin: 0;
  color: hsl(var(--ink-60));
  font-size: 0.92rem;
}

.callout {
  margin: 24px 0;
  padding: 20px 22px;
  border-left: 3px solid hsl(var(--accent-signal-deep));
  background: rgba(61,215,179,0.08);
  color: hsl(var(--ink));
}

.callout p {
  margin: 0;
  color: hsl(var(--ink));
}

.article-main ul,
.article-main ol {
  margin: 0 0 18px;
  padding-left: 22px;
}

.article-main li + li { margin-top: 8px; }

@media (max-width: 980px) {
  .article-hero-inner {
    grid-template-columns: 1fr;
  }
  .hero-instrument {
    min-height: 420px;
  }
  .article-body-grid {
    grid-template-columns: 1fr;
  }
  .article-rail {
    position: static;
    padding-top: 28px;
  }
  .article-rail nav {
    display: flex;
    overflow-x: auto;
    padding: 0 0 12px;
    border-left: 0;
    border-bottom: 1px solid var(--rule);
  }
  .article-rail a {
    flex: 0 0 auto;
  }
  .article-main {
    padding-top: 28px;
  }
  .symbol-grid,
  .regime-grid,
  .use-grid,
  .mechanism-grid,
  .related-grid {
    grid-template-columns: 1fr 1fr;
  }
  .lab-controls {
    grid-template-columns: 1fr;
  }
  .lab-controls-three,
  .flow-card,
  .timeline-strip {
    grid-template-columns: 1fr;
  }
  .article-image-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .article-hero {
    padding: 112px 20px 48px;
  }
  .article-hero-inner {
    width: 100%;
    max-width: 100%;
  }
  .article-hero-inner > div {
    width: 100%;
    max-width: min(100%, 350px);
  }
  .article-title {
    max-width: 10.5ch;
    font-size: clamp(2rem, 10.4vw, 2.85rem);
    line-height: 1;
    overflow-wrap: anywhere;
  }
  .article-dek {
    max-width: 34ch;
  }
  .hero-instrument {
    width: 100%;
    max-width: min(100%, 350px);
    min-height: 340px;
  }
  .article-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .article-button {
    width: 100%;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }
  .instrument-caption,
  .instrument-metrics {
    left: 28px;
    right: 28px;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 5px 12px;
    font-size: 9px;
  }
  .article-body-wrap {
    padding: 0 18px 60px;
  }
  .symbol-grid,
  .regime-grid,
  .use-grid,
  .mechanism-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }
  .lab-canvas-wrap,
  .lab-canvas-wrap canvas {
    min-height: 300px;
    height: 300px;
  }
  .article-audio-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "meta play"
      "progress progress"
      "time time";
  }
  .audio-meta { grid-area: meta; }
  .audio-play { grid-area: play; }
  .audio-progress { grid-area: progress; }
  .audio-time {
    grid-area: time;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
