:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2230;
  --muted: #646a78;
  --line: #d9d5cc;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --box: #fbfaf7;
  --bar: #b9c3d3;
  --curve: #c2410c;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d11;
    --panel: #151820;
    --ink: #e4e8f0;
    --muted: #98a0b0;
    --line: #2a2f3a;
    --accent: #f0aa5a;
    --accent-ink: #14110c;
    --box: #0f1218;
    --bar: #3a4559;
    --curve: #f59e5b;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

header,
main,
footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

header h1 {
  margin: 20px 0 4px;
  font-size: 28px;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0 0 16px;
  max-width: 78ch;
  color: var(--muted);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  main {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stage,
.panel section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.panel {
  display: grid;
  gap: 12px;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 78vh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart {
  height: 170px;
}

.chart.short {
  height: 110px;
}

h2 {
  margin: 0 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.transport,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

button,
select {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: var(--accent);
}

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

#play[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

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

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

output {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 10px;
  margin: 8px 0 0;
}

.readout div {
  min-width: 0;
}

.readout dt {
  font-size: 12px;
  color: var(--muted);
}

.readout dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.legend {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.key {
  display: inline-block;
  width: 12px;
  height: 10px;
  margin: 0 2px 0 6px;
  vertical-align: baseline;
}

.key.bar {
  background: var(--bar);
}

.key.curve {
  height: 2px;
  vertical-align: middle;
  background: var(--curve);
}

.key.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
}

.key.dash {
  height: 0;
  border-top: 2px dashed var(--muted);
  vertical-align: middle;
}

.key.light {
  background: hsl(45 90% 50%);
}

.key.heavy {
  background: hsl(265 55% 55%);
}

#effusion-results[hidden],
#tracer-controls[hidden] {
  display: none;
}

.status,
.hint,
.note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

footer {
  margin-top: 16px;
  padding-bottom: 24px;
  color: var(--muted);
  font-size: 13px;
}

footer a {
  color: var(--accent);
}
