*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f1117;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  gap: 0;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
  color: #fff;
}

/* ── Algorithm tabs ─────────────────────────────────── */

.algo-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 18px;
}

.algo-tab {
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  background: #1e2130;
  border: 1px solid #2a2f45;
  color: #888;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.algo-tab:hover:not(:disabled) {
  background: #252a40;
  color: #bbb;
}

.algo-tab.active {
  background: #4a9eff22;
  border-color: #4a9eff;
  color: #4a9eff;
}

.algo-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Controls ───────────────────────────────────────── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #888;
}

.control-group label {
  min-width: 40px;
}

input[type="range"] {
  width: 100px;
  accent-color: #4a9eff;
  cursor: pointer;
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.size-val {
  min-width: 24px;
  text-align: right;
  color: #ccc;
  font-variant-numeric: tabular-nums;
}

button {
  background: #1e2130;
  color: #ccc;
  border: 1px solid #2a2f45;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) {
  background: #252a40;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button.primary {
  background: #4a9eff;
  color: #000;
  border-color: #4a9eff;
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: #6ab4ff;
}

button.primary:disabled {
  background: #1e3355;
  color: #4a6888;
  border-color: #1e3355;
}

/* ── Visualisation ──────────────────────────────────── */

.vis-area {
  width: 100%;
  max-width: 820px;
  height: 300px;
  background: #1e2130;
  border-radius: 12px;
  border: 1px solid #2a2f45;
  display: flex;
  align-items: flex-end;
  padding: 10px 10px 4px;
  gap: 2px;
  margin-bottom: 18px;
}

.bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  min-width: 2px;
  transition: background-color 0.04s linear;
}

/* ── Stats ──────────────────────────────────────────── */

.stats {
  display: flex;
  gap: 36px;
  font-size: 0.88rem;
  color: #666;
}

.stats .label {
  margin-right: 4px;
}

.stats .value {
  color: #e0e0e0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Legend ─────────────────────────────────────────── */

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
  font-size: 0.75rem;
  color: #666;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
