:root {
  --bg: #fbf6ee;
  --bg-alt: #f3ecdf;
  --surface: #ffffff;
  --ink: #1f1c17;
  --muted: #6b6457;
  --line: #e6dccb;
  --accent: #d9774a;       /* warm clay */
  --accent-ink: #ffffff;
  --leaf: #5f9e5a;         /* bamboo */
  --leaf-soft: #e3efd9;
  --hl: #ffe2a8;
  --term-bg: #1d1b18;
  --term-ink: #e9e4d8;
  --term-dim: #8f887a;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 12px 32px -12px rgba(40, 30, 10, .18);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16140f;
    --bg-alt: #1d1a14;
    --surface: #24211a;
    --ink: #f3ede1;
    --muted: #aba291;
    --line: #353025;
    --accent: #ee8a5c;
    --accent-ink: #1a120c;
    --leaf: #8cc785;
    --leaf-soft: #23301f;
    --hl: #5a4320;
    --term-bg: #0f0e0b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; }
a { color: inherit; }
code, pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
:not(pre) > code {
  font-size: .88em;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  padding: .08em .4em;
  border-radius: 6px;
}
h1, h2, h3 { font-family: Fredoka, Inter, sans-serif; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2.5rem, 5.4vw, 4.2rem); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

/* NAV */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.nav-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font: 700 1.5rem Fredoka, sans-serif; text-decoration: none;
}
.brand img { border-radius: 8px; }
.brand.small { font-size: 1.1rem; gap: 8px; }
.nav-links { display: flex; gap: 22px; margin-left: auto; }
.nav-links a { text-decoration: none; color: var(--muted); font-weight: 500; font-size: .95rem; }
.nav-links a:hover { color: var(--ink); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 999px;
  font: 600 1rem Inter, sans-serif; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 22px -10px var(--accent); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-small { padding: 8px 14px; font-size: .9rem; gap: 8px; }
.copy code { font-size: .85rem; background: none; border: 0; padding: 0; }
.copy-label {
  font-size: .75rem; font-weight: 600; color: var(--muted);
  border-left: 1px solid var(--line); padding-left: 10px;
}
.copy.copied .copy-label { color: var(--leaf); }

.eyebrow {
  margin: 0 0 12px;
  color: var(--leaf); font-weight: 600; font-size: .85rem;
  letter-spacing: .08em; text-transform: uppercase;
}

/* HERO */
.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center;
  padding: 72px 0 96px;
}
.hl {
  background: linear-gradient(transparent 58%, var(--hl) 58%, var(--hl) 92%, transparent 92%);
  padding: 0 .1em;
}
.lede { font-size: 1.15rem; color: var(--muted); margin: 24px 0 32px; max-width: 34em; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cta.center { justify-content: center; }
.fine { color: var(--muted); font-size: .85rem; margin-top: 20px; }

/* DEMO */
.demo { position: relative; }
.desk {
  position: relative;
  aspect-ratio: 5 / 4;
  border-radius: 22px;
  background:
    radial-gradient(120% 80% at 80% 0%, #ffd9b0 0%, transparent 60%),
    radial-gradient(90% 80% at 0% 100%, #bfe0c0 0%, transparent 60%),
    linear-gradient(160deg, #f8e7cf, #e8eedb);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .desk {
    background:
      radial-gradient(120% 80% at 80% 0%, #5a3a22 0%, transparent 60%),
      radial-gradient(90% 80% at 0% 100%, #24402a 0%, transparent 60%),
      linear-gradient(160deg, #2a241b, #1b231b);
  }
}
.term {
  position: absolute; left: 6%; top: 8%; width: 70%; height: 66%;
  background: var(--term-bg); color: var(--term-ink);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .55);
  display: flex; flex-direction: column;
}
.term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; background: rgba(255, 255, 255, .06);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.term-title { margin-left: 10px; font: 500 .75rem "JetBrains Mono", monospace; color: var(--term-dim); }
.term-body {
  flex: 1; padding: 12px 14px; overflow: hidden;
  font: .78rem/1.55 "JetBrains Mono", monospace;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.term-line { white-space: pre-wrap; word-break: break-word; animation: lineIn .25s ease; }
.term-line.dim { color: var(--term-dim); }
.term-line.user { color: #f0c38e; }
.term-line.tool { color: #9fd49a; }
.term-line.warn { color: #ffcf6e; }
.term-line.ok { color: #9fd49a; }
@keyframes lineIn { from { opacity: 0; transform: translateY(4px); } }

.pet-wrap {
  position: absolute; right: 4%; bottom: 3%;
  width: 34%; display: flex; flex-direction: column; align-items: center;
  transition: transform .2s;
}
.pet-wrap.shake { animation: shake .5s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px) rotate(-2deg); }
  40%, 80% { transform: translateX(6px) rotate(2deg); }
}
.bubble {
  position: relative;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 12px;
  font: 600 .85rem/1.3 Inter, sans-serif; text-align: center;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .35);
  margin-bottom: 6px; min-width: 70%;
  display: flex; flex-direction: column; gap: 2px;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px;
  background: inherit; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.bubble-sub { font-weight: 500; font-size: .72rem; color: var(--muted); }
.bubble-sub:empty { display: none; }
.bubble.pop { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.04); } }

.demo-controls {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px;
  margin-top: 16px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 .85rem Inter, sans-serif; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sound-toggle .waves { display: none; }
.sound-toggle[aria-pressed="true"] .waves { display: inline; }
.sound-toggle[aria-pressed="true"] .mute-x { display: none; }

/* SPRITES */
.sprite {
  aspect-ratio: 1;
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: auto;
}
.sprite-hero { width: 100%; }
.sprite-card { width: 140px; margin: 0 auto 8px; }
.sprite-state { width: 120px; margin: 0 auto; }
.sprite-flow { width: 72px; }
.sprite-final { width: 160px; margin: 0 auto 8px; }

/* SECTIONS */
.section { padding: 96px 0; }
.section-alt { background: var(--bg-alt); }
.section-lede { color: var(--muted); font-size: 1.1rem; max-width: 40em; margin: 16px 0 40px; }

.states-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px;
}
.state-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px 18px; text-align: center;
  transition: transform .2s, box-shadow .2s;
}
.state-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.state-card h3 { font-size: 1.05rem; margin-top: 6px; }
.state-card p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.state-card .tag {
  display: inline-block; margin-top: 10px;
  font: 500 .7rem "JetBrains Mono", monospace;
  background: var(--leaf-soft); color: var(--leaf);
  padding: 3px 8px; border-radius: 999px;
}
.state-card .tag.sound { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

.chars-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.char-card {
  font: inherit; color: inherit; text-align: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 14px;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.char-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.char-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.char-card p { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }

.diy {
  margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
}
.diy p { color: var(--muted); margin: 10px 0 0; }

.code {
  position: relative; margin: 0;
  background: var(--term-bg); color: var(--term-ink);
  border-radius: 12px; padding: 16px 18px; overflow-x: auto;
  font-size: .85rem; line-height: 1.6;
}
.code .c { color: #f0c38e; }
.copy-mini {
  position: absolute; top: 8px; right: 8px;
  font: 600 .72rem Inter, sans-serif; color: var(--term-dim);
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
}
.copy-mini:hover { color: var(--term-ink); }
.copy-mini.copied { color: #9fd49a; }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 40px; }
.feature {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
}
.feature p { color: var(--muted); font-size: .92rem; margin: 8px 0 0; }
.ficon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--leaf-soft); font-size: 1.25rem; margin-bottom: 14px;
}

.how { display: grid; grid-template-columns: 1fr 1.2fr; gap: 48px; align-items: center; }
.how .section-lede { margin-bottom: 0; }
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.flow-step {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; align-items: center;
  min-width: 130px; text-align: center;
}
.flow-k { font: 600 .95rem Fredoka, sans-serif; }
.flow-v { font: .75rem "JetBrains Mono", monospace; color: var(--muted); }
.flow-arrow { color: var(--accent); font-size: 1.4rem; font-weight: 700; }
.flow-pet { padding: 8px 16px 12px; }

/* INSTALL */
.tabs {
  display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 32px 0 20px;
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px; padding: 4px;
}
.tab {
  font: 600 .9rem Inter, sans-serif; color: var(--muted);
  background: none; border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 28px 12px; max-width: 820px;
}
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding-left: 44px; margin-bottom: 22px; }
.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font: 700 .85rem Fredoka, sans-serif; display: grid; place-items: center;
}
.steps p { margin: 0 0 10px; }
.steps a { color: var(--accent); }

/* FINAL */
.final { text-align: center; padding-top: 72px; }
.final h2 { max-width: 16em; margin: 0 auto 28px; }

.footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: .88rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.footer a { color: var(--muted); }

/* RESPONSIVE */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; gap: 40px; }
  .features { grid-template-columns: repeat(2, 1fr); }
  .chars-grid { grid-template-columns: repeat(3, 1fr); }
  .how, .diy { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .nav-inner > .btn { margin-left: auto; }
  .section { padding: 64px 0; }
  .features { grid-template-columns: 1fr; }
  .copy code { font-size: .72rem; }
  .copy { max-width: 100%; }
  .desk { aspect-ratio: 4 / 5; }
  .term { left: 5%; width: 90%; top: 5%; height: 52%; }
  .pet-wrap { width: 52%; right: 24%; }
  .states-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sprite-state { width: 96px; }
  .chars-grid { grid-template-columns: repeat(2, 1fr); }
  .sprite-card { width: 110px; }
  .panel { padding: 20px 18px 6px; }
  .steps li { padding-left: 38px; }
  .flow-arrow { transform: rotate(90deg); }
  .flow { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

/* keep long one-liners (brew command) from widening the hero grid on phones */
.hero > *, .how > *, .diy > * { min-width: 0; }
.copy { max-width: 100%; overflow: hidden; }
.copy code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
