:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #0a0f16;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #bc8cff;
  --split: #ff7b72;
  --merge: #3fb950;
  --compare: #f2cc60;
  --sorted: #58a6ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  min-height: 100vh;
}
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header a { color: var(--accent); text-decoration: none; }
header a:hover { text-decoration: underline; }
header h1 { font-size: 1.3rem; }
.main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 36px; }
.controls, .stats, .explain {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.controls {
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
button {
  background: var(--accent);
  color: #08111b;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button:disabled { opacity: 0.45; cursor: default; }
.range-group { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 0.86rem; }
input[type=range] { accent-color: var(--accent); width: 140px; }
.stats {
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stat { min-width: 120px; }
.stat-value { font-size: 1.25rem; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px; }
.canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
canvas {
  display: block;
  width: 100%;
  border-radius: 10px;
}
.legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  gap: 24px;
  padding: 14px 16px;
  margin-top: 16px;
  font-size: 0.84rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }
.explain { margin-top: 20px; padding: 24px 28px; }
.explain h2 { color: var(--accent); margin-bottom: 12px; }
.explain p, .explain li { color: var(--muted); line-height: 1.7; font-size: 0.92rem; }
.explain ul { padding-left: 18px; margin-top: 12px; }
@media (max-width: 980px) {
  .range-group { margin-left: 0; width: 100%; justify-content: space-between; }
}
