:root {
  --bg: #0c1214;
  --panel: #141d21;
  --panel-border: #27363c;
  --text: #e9f1f2;
  --muted: #9bb0b5;
  --accent: #5fd3c4;
  --accent-strong: #9af0e3;
  --focus: #ffd166;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}

header, footer {
  padding: 1rem 1.25rem 0.5rem;
}

footer {
  color: var(--muted);
  font-size: 0.9rem;
  padding-top: 0;
}

footer p {
  margin: 0;
  max-width: 70ch;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  align-items: start;
  gap: 1rem;
  padding: 0.5rem 1.25rem 1rem;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: #071026;
  cursor: crosshair;
  touch-action: none;
  image-rendering: auto;
}

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: 0.9rem;
}

.tool-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
}

.tool-group label:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tool-group input {
  accent-color: var(--accent);
  margin: 0;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input {
  accent-color: var(--accent);
  margin: 0;
}

.checkbox-row label {
  font-size: 0.9rem;
  color: var(--muted);
}

.control-row label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.control-row label em {
  font-style: italic;
  margin-right: auto;
}

.map-label {
  font-size: 0.9rem;
  color: var(--muted);
}

canvas.map {
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #0f171a;
  cursor: crosshair;
  image-rendering: auto;
}

.control-row output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

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

select, button {
  font: inherit;
  color: var(--text);
  background: #1b262b;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

button {
  cursor: pointer;
}

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

button[aria-pressed="true"] {
  background: var(--accent);
  color: #06201c;
  border-color: var(--accent);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.5rem;
}

.button-row button {
  padding: 0.4rem 0.4rem;
  font-size: 0.9rem;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8em;
  padding: 0.05em 0.35em;
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #1b262b;
}

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

@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
  }
}
