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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-text: #3730a3;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --amber-text: #92400e;
  --green: #10b981;
  --green-light: #ecfdf5;
  --green-text: #065f46;
  --rose: #f43f5e;
  --rose-light: #fff1f2;
  --rose-text: #9f1239;
  --border: #e0e0e0;
  --bg: #f5f5f5;
  --card: #fff;
  --text: #222;
  --muted: #666;
  --dim: #888;
  --header-bg: #1e1e2e;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ── Nav ──────────────────────────────────────────── */

nav {
  background: var(--header-bg);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  font-weight: 900;

  div {
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
}

nav::-webkit-scrollbar {
  display: none;
}

nav a {
  color: var(--dim);
  text-decoration: none;
  font-size: 0.75rem;
  padding: 1rem .7rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-family: monospace;
  font-weight: normal;
}

nav a:hover {
  color: #cdd6f4;
}

nav a.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
}

nav a.brand {
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  margin-right: 4px;
  padding-right: 18px;
  border-right: 1px solid #313244;
  border-bottom: none;
  display: flex;
  gap: .5rem;
  align-items: center;
}

nav a.brand img {
  height: 2rem;
  display: inline-block;
  line-height: 0;
}

/* ── Layout ───────────────────────────────────────── */

header {
  position: absolute;
  top: 0;
  z-index: 1000;
  width: 100%;
}

main {
  max-width: 700px;
  margin: 3rem auto 0;
  padding: 32px 20px 0;
}

footer {
  max-width: 700px;
  margin: 0 auto;
  padding: 1rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;

  svg * {
    fill: var(--primary-dark);
  }

  a {
    display: flex;
    gap: .5rem;
    text-decoration: none;
    align-items: center;
    color: var(--muted);
  }
}

h1 {
  font-size: 4rem;
  margin: 0 0 .5rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 .5rem;
}

.intro,
.subtitle {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 0.9rem;
  line-height: 1.7;

  code {
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 4px;
    font-family: monospace;
  }
}

.intro {
  line-height: 1.5;
  margin: auto auto 2rem;
  max-width: 540px;
}

.center {
  text-align: center;
}

.install {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 2rem auto;
  max-width: 400px;

  pre {
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 6px;
    text-align: left;
  }
}

/* ── Cards ───────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.1);
}

.card-name {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-text);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Scene card ───────────────────────────────────── */

.scene {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;

  &:not(:last-child) {
    margin-bottom: 1rem;
  }
}

.scene h2 {
  margin: 0 0 3px;
  font-size: 0.95rem;
  color: #444;
}

.scene .desc {
  font-size: 0.81rem;
  color: var(--dim);
  margin: 0 0 16px;
  line-height: 1.5;
}

/* ── Grid / Groups ────────────────────────────────── */

.grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.groups {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.group-wrap {
  flex: 1;
  min-width: 120px;
}

.group-label {
  font-size: 0.72rem;
  color: var(--dim);
  font-family: monospace;
  margin-bottom: 6px;
}

.group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  background: #f9f9f9;
  border: 1px dashed #ddd;
  border-radius: 6px;
  transition: background 0.18s, border-color 0.18s;
}

.group.hl,
.group.focus {
  background: var(--amber-light);
  border-color: var(--amber);
  border-style: solid;
}

/* ── Items ────────────────────────────────────────── */

.item {
  padding: 10px 14px;
  border-radius: 6px;
  border: 2px solid #ddd;
  background: #fafafa;
  font-size: 0.82rem;
  font-family: monospace;
  cursor: default;
  transition: ease-in-out .25s;
}

.item .idx {
  font-size: .7rem;
  opacity: .5;
  margin-left: 4px;
}

/* selected / highlighted */
.item.focus,
.item.hl {
  border-color: var(--amber);
  background: var(--amber-light);
  color: var(--amber-text);
  transform: translateY(-5px)
}

/* source element */
.item.src {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-text);
  font-weight: 600;
  transform: translateY(-5px)
}

/* newly created */
.item.new {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green-text);
  transform: translateY(-5px)
}

/* mutated via callback */
.item.changed {
  border-color: var(--rose);
  background: var(--rose-light);
  color: var(--rose-text);
  transform: translateY(-5px)
}

.item.badge::after {
  content: attr(data-badge);
  font-size: .65rem;
  background: var(--rose);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.item.badge.badge-hot::after {
  background: var(--rose);
}

.item.badge.badge-new::after {
  background: var(--green);
}

.item.badge.badge-sale::after {
  background: var(--amber);
}

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

.legend {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 2px solid;
  flex-shrink: 0;
}

.dot.hl,
.dot.focus {
  border-color: var(--amber);
  background: var(--amber-light);
}

.dot.src {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dot.new {
  border-color: var(--green);
  background: var(--green-light);
}

.dot.changed {
  border-color: var(--rose);
  background: var(--rose-light);
}

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

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button {
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.81rem;
  cursor: pointer;
  transition: background 0.15s;
  font-family: system-ui, sans-serif;
}

button:hover {
  background: var(--primary-dark);
}

button.ghost {
  background: #e5e7eb;
  color: #374151;
}

button.ghost:hover {
  background: #d1d5db;
}

/* ── Count badge ──────────────────────────────────── */

.count {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.79rem;
  color: var(--muted);
  margin-top: 8px;
}

.count strong {
  color: var(--primary-text);
  font-size: 1rem;
}

/* ── Code blocks ──────────────────────────────────── */

pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 13px 16px;
  border-radius: 6px;
  font-size: 0.79rem;
  overflow-x: auto;
  margin: 14px 0 0;
  line-height: 1.65;
}

.kw {
  color: #cba6f7;
}

.fn {
  color: #89b4fa;
}

.str {
  color: #a6e3a1;
}

.cm {
  color: #6c7086;
}

.num {
  color: #fab387;
}

code {
  font-size: 0.8rem;
  background: #f0f0f0;
  padding: .25rem .5rem;
  border-radius: 4px;
  color: #555;
  font-family: monospace;
}

/* ── Stacks ───────────────────────────────────────── */

.stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.stack-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stack-label {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--dim);
  width: 90px;
  flex-shrink: 0;
  text-align: right;
}

.stack-row.active .stack-label {
  color: var(--primary-text);
  font-weight: 600;
}

.stack-row.active .item {
  border-color: var(--primary);
  background: var(--primary-light);
}