:root {
  --bg: #020617;
  --bg-panel: rgba(15, 23, 42, 0.8);
  --bg-strong: rgba(2, 6, 23, 0.95);
  --border: #1e293b;
  --text: #e2e8f0;
  --muted: #cbd5e1;
  --muted-2: #94a3b8;
  --accent: #8b5cf6;
  --accent-2: #a855f7;
  --accent-3: #6366f1;
  --shadow: 0 12px 45px rgba(0, 0, 0, 0.35);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background-color: var(--bg);
  color: var(--text);
  background-image: radial-gradient(1200px 600px at -10% -20%, rgba(168, 85, 247, 0.12), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(99, 102, 241, 0.1), transparent 60%),
    linear-gradient(135deg, #0b1020 0%, #050814 45%, #020617 100%);
  background-attachment: fixed;
}

button {
  font-family: inherit;
  background: transparent;
  border: none;
  color: inherit;
}

a {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

a:hover {
  color: #fff;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  color: #fff;
}

p {
  color: var(--muted);
}

.subtitle {
  margin: 0;
  color: var(--muted-2);
  font-size: 0.95rem;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: linear-gradient(155deg, rgba(99, 102, 241, 0.08), rgba(15, 23, 42, 0.9)), var(--bg-panel);
  border-radius: 1.15rem;
  padding: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #fff;
}

.panel h2 span.step-number {
  font-size: 0.72rem;
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  border: 1px solid rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.18);
}

.panel small {
  color: var(--muted-2);
  font-size: 0.8rem;
}

.card {
  margin-top: 0.8rem;
  background: var(--bg-panel);
  border-radius: 1.15rem;
  border: 1px solid var(--border);
  padding: 0.8rem;
  min-height: 3.3rem;
  position: relative;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.word-chip {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #334155;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.word-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-1px);
}

.word-chip.active {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.2), 0 10px 30px rgba(99, 102, 241, 0.16);
  transform: translateY(-1px);
}

.word-bubble {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(168, 85, 247, 0.4);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.24), rgba(168, 85, 247, 0.22));
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.bubble-key {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bubble-separator {
  color: var(--muted-2);
}

.bubble-value {
  color: #fff;
  font-weight: 600;
}

.word-bubble.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.input-hint {
  font-size: 0.8rem;
  color: var(--muted-2);
  margin-top: 0.4rem;
}

.flow-arrow {
  position: absolute;
  right: -0.2rem;
  top: 0.5rem;
  font-size: 1.3rem;
  color: #fff;
  opacity: 0.35;
}

.flow-arrow.down {
  display: none;
}

@media (max-width: 900px) {
  .flow-arrow {
    display: none;
  }
  .flow-arrow.down {
    display: block;
    position: static;
    margin-top: 0.25rem;
    text-align: center;
  }
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.step {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.step.visible {
  opacity: 1;
  transform: translateY(0);
}

.step-label {
  color: var(--muted-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.letters-row,
.numbers-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.letter-box,
.number-box {
  min-width: 1.6rem;
  text-align: center;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.35rem;
}

.letter-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: #fff;
}

.number-box {
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: #fff;
}

.equation {
  margin-top: 0.2rem;
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.equation-highlight {
  color: #fff;
  font-weight: 700;
}

.sum-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  margin-top: 0.3rem;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.sum-pill span.label {
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.sum-pill span.value {
  font-weight: 700;
  color: #fff;
}

.hash-table {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
}

.array-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.4rem;
  align-items: stretch;
}

.array-index {
  min-width: 2.2rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.4rem;
  background: var(--bg-strong);
  border: 1px solid var(--border);
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
}

.array-cell {
  border-radius: 0.45rem;
  background: var(--bg-strong);
  border: 1px solid var(--border);
  padding: 0.25rem 0.4rem;
  min-height: 1.4rem;
  display: flex;
  align-items: center;
}

.cell-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.cell-node {
  background: linear-gradient(150deg, rgba(99, 102, 241, 0.14), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 0.45rem;
  padding: 0.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 5rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.node-key {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e2e8f0;
}

.node-value {
  color: #fff;
  font-size: 0.82rem;
}

.node-arrow {
  color: #fff;
  font-weight: 700;
}

.node-null {
  color: var(--muted-2);
  font-size: 0.8rem;
}

.node-found {
  border-color: rgba(168, 85, 247, 0.8);
  background: radial-gradient(circle at 20% 20%, rgba(168, 85, 247, 0.2), rgba(15, 23, 42, 0.92));
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.25), 0 8px 20px rgba(99, 102, 241, 0.3);
}

.cell-empty {
  color: #64748b;
  font-size: 0.78rem;
}

.array-row.active .array-cell {
  border-color: rgba(139, 92, 246, 0.6);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(99, 102, 241, 0.12));
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}

.array-row.active .array-index {
  border-color: rgba(139, 92, 246, 0.7);
  color: #fff;
  background: rgba(139, 92, 246, 0.12);
}

.array-row.active .array-cell::after {
  content: "index used";
  margin-left: auto;
  font-size: 0.7rem;
  color: #fff;
  opacity: 0.9;
}

@keyframes collision-bump {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px);
  }
  40% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
  100% {
    transform: translateX(0);
  }
}

.array-cell.collision {
  animation: collision-bump 0.4s ease;
}

.collision-label {
  font-size: 0.78rem;
  color: #fff;
  margin-top: 0.35rem;
}

.use-case {
  background: linear-gradient(150deg, rgba(99, 102, 241, 0.1), rgba(2, 6, 23, 0.95));
  border-radius: 1.15rem;
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1rem;
  align-items: center;
}

@media (max-width: 900px) {
  .use-case {
    grid-template-columns: 1fr;
  }
}

.use-case h2 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  color: #fff;
}

.use-case p {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.use-case ul {
  margin: 0.1rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.85rem;
  color: var(--muted-2);
}

.use-case ul li {
  margin-bottom: 0.15rem;
}

.use-case-note {
  color: var(--muted);
  margin-top: 0.5rem;
}

.kv-table {
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: var(--bg-strong);
  padding: 0.6rem;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 9.5rem;
  overflow-y: auto;
  padding-right: 0.35rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
}

.kv-key {
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  text-transform: lowercase;
  color: var(--muted);
}

.kv-value {
  color: #fff;
  font-weight: 600;
}

.kv-caption {
  font-size: 0.72rem;
  color: var(--muted-2);
  text-align: right;
}

footer {
  color: var(--muted-2);
  border-top: 1px solid var(--border);
  background: transparent;
}

code {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 0.05rem 0.35rem;
  border-radius: 0.35rem;
  color: #fff;
}

.space-gradient-dark {
  background: radial-gradient(1200px 600px at -10% -20%, rgba(168, 85, 247, 0.15), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(99, 102, 241, 0.12), transparent 60%),
    linear-gradient(135deg, #1e1b4b 0%, #0b1020 60%, #070914 100%);
}

.starfield {
  background: radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 20%, rgba(255, 255, 255, 0.25) 50%, transparent 51%),
    radial-gradient(1px 1px at 60% 70%, rgba(255, 255, 255, 0.18) 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 80%, rgba(255, 255, 255, 0.28) 50%, transparent 51%);
  background-size: 400px 400px, 500px 500px, 600px 600px, 700px 700px;
  background-repeat: repeat;
}

.starfield-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: transparent;
}
