:root {
  --bg:           #060b18;
  --bg-secondary: #0d1424;
  --bg-card:      rgba(255,255,255,0.025);
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(59,130,246,0.45);
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --text-subtle:  #94a3b8;
  --accent:       #3b82f6;
  --accent-light: #60a5fa;
  --accent-glow:  rgba(59,130,246,0.1);
  --bar-default:  #1e3a5f;
  --radius:       10px;
  --font-sans:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a    { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ─── Nav ───────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(6,11,24,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
}
.nav__back {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.2s;
  flex-shrink: 0;
}
.nav__back:hover { color: var(--accent); }
.nav__title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-subtle);
  flex: 1;
  text-align: center;
}
.nav__github {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.2s;
  flex-shrink: 0;
}
.nav__github:hover { color: var(--text); }

/* ─── Main ──────────────────────────────────────────────────────── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Algorithm tabs ────────────────────────────────────────────── */
.algo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}
.algo-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.algo-group__label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 2px;
  flex-shrink: 0;
}
.algo-btn {
  padding: 6px 15px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.algo-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--accent-glow);
}
.algo-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.algo-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Controls ──────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.controls__actions { display: flex; gap: 8px; flex-shrink: 0; }
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-subtle);
  transition: all 0.15s;
}
.ctrl-btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--accent-glow);
}
.ctrl-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ctrl-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ctrl-btn--primary:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent-light);
  box-shadow: 0 0 20px rgba(59,130,246,0.35);
}
.controls__sliders {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.slider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
input[type="range"] {
  -webkit-appearance: none;
  width: 110px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }
.slider-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 20px;
  text-align: right;
}
.controls__stats {
  display: flex;
  gap: 20px;
  margin-left: auto;
  flex-shrink: 0;
}
.stat {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.stat strong {
  color: var(--accent-light);
  font-weight: 500;
  margin-left: 6px;
  min-width: 40px;
  display: inline-block;
  text-align: right;
}

/* ─── Visualization ─────────────────────────────────────────────── */
.viz-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px 0;
}
.viz {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 300px;
  width: 100%;
}
.bar {
  flex: 1;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--bar-default);
  transition: background-color 0.08s ease;
}
.bar.comparing { background: #f59e0b; }
.bar.swapping  { background: #ef4444; }
.bar.pivot     { background: #8b5cf6; }
.bar.sorted    { background: #10b981; }
.bar.searching { background: #f59e0b; }
.bar.found     { background: #10b981; }
.bar.target    { background: #8b5cf6; }
.bar.checked   { background: #122032; }

/* ─── Info row ──────────────────────────────────────────────────── */
.info-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}
.info-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.info-card__header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.info-card__name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.info-card__badges { display: flex; gap: 8px; }
.badge {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}
.badge strong { color: var(--accent-light); font-weight: 500; }
.info-card__desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}
.status {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent-light);
  min-height: 18px;
}

/* ─── Legend ────────────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: nowrap;
}
.legend__item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .main         { padding: 16px 14px 48px; gap: 12px; }
  .viz          { height: 200px; }
  .info-row     { grid-template-columns: 1fr; }
  .controls     { gap: 12px; }
  .controls__stats { margin-left: 0; }
  .controls__sliders input[type="range"] { width: 80px; }
}
