:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #5b6069;
  --line: #d9dce1;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --canvas-bg: #ffffff;
  --trace: #2f6fed;
  --circle: rgba(27, 29, 33, 0.18);
  --radius: rgba(27, 29, 33, 0.45);
  --input-path: #e8663a;
  --bar: #7aa2f7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1d2026;
    --ink: #e8eaed;
    --muted: #9aa0aa;
    --line: #2f333b;
    --accent: #5b8dff;
    --accent-ink: #0d1017;
    --canvas-bg: #0f1114;
    --trace: #5b8dff;
    --circle: rgba(232, 234, 237, 0.16);
    --radius: rgba(232, 234, 237, 0.4);
    --input-path: #ff8a5c;
    --bar: #5b8dff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.topbar h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.01em;
}

.tagline {
  margin: 4px 0 20px;
  color: var(--muted);
  max-width: 52ch;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

.stage {
  flex: 1 1 420px;
  min-width: 300px;
}

canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  background: var(--canvas-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
}

#spectrum {
  margin-top: 10px;
  aspect-ratio: auto;
  height: 60px;
  cursor: default;
  border-radius: 8px;
}

.hint,
.controls .field span {
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  margin: 8px 2px 0;
}

.spectrum-caption {
  margin-top: 6px;
}

.controls {
  flex: 0 1 260px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

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

button {
  flex: 1 1 auto;
  min-width: 5.5rem;
  padding: 8px 12px;
  font: inherit;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

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

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

select,
input[type="range"] {
  width: 100%;
  font: inherit;
}

select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.toggles {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 10px 12px;
}

.toggles legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

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

canvas:focus-visible {
  border-color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.footer {
  margin-top: 28px;
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

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