:root {
  --bg-0: #070710;
  --bg-1: #0b0b1a;
  --ink: #edeefb;
  --soft: #9b9fc4;
  --faint: #6b6f92;
  --line: rgba(255, 255, 255, 0.09);
  --glass: rgba(255, 255, 255, 0.035);
  --glass-2: rgba(255, 255, 255, 0.06);
  --gold: #f5bd54;
  --gold-soft: #ffd98a;
  --violet: #8e7bff;
  --green: #6fe3a6;
  --danger: #ff7b8a;
  --radius: 18px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-0);
  color: var(--ink);
  font: 16px/1.7 "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}

#sky { position: fixed; inset: 0; z-index: 0; display: block; }
.topbar, .stage { position: relative; z-index: 1; }

/* glow wash behind content */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(142, 123, 255, 0.16), transparent 60%),
    radial-gradient(700px 460px at 12% 8%, rgba(245, 189, 84, 0.07), transparent 55%);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(10, 10, 22, 0.6);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 18px;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, var(--gold-soft), #fff 60%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar-right { color: var(--soft); font-size: 13px; font-weight: 500; }
.topbar-right b { color: var(--ink); font-weight: 600; }
.progress-track { height: 2px; background: rgba(255,255,255,0.06); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); transition: width .5s cubic-bezier(.4,0,.2,1); box-shadow: 0 0 12px rgba(245,189,84,.6); }

.stage { max-width: 1100px; margin: 0 auto; padding: 0 28px 120px; }

/* ---------- Menu / hero ---------- */
.hero { text-align: center; padding: 92px 0 44px; }
.hero .eyebrow { color: var(--gold-soft); font-size: 13px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; }
.hero h1 {
  font-family: "Space Grotesk", sans-serif; font-weight: 700;
  font-size: clamp(40px, 7vw, 66px); line-height: 1.02; margin: 14px 0 16px; letter-spacing: -1.2px;
  background: linear-gradient(180deg, #fff, #b9bce6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--soft); font-size: 18px; margin: 0 auto; max-width: 520px; }

.projects { display: grid; gap: 20px; max-width: 640px; margin: 8px auto 0; }
.card {
  position: relative; overflow: hidden;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 30px 28px; cursor: pointer; box-shadow: var(--shadow);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform .22s ease, border-color .22s ease, background .22s ease;
}
.card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(245,189,84,.16), transparent 70%); pointer-events: none;
}
.card:hover { transform: translateY(-3px); border-color: rgba(245,189,84,.35); background: var(--glass-2); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--gold-soft); background: rgba(245,189,84,.12); border: 1px solid rgba(245,189,84,.25);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 16px;
}
.card h2 { font-family: "Space Grotesk", sans-serif; margin: 0 0 10px; font-size: 26px; letter-spacing: -0.4px; }
.card .desc { margin: 0; color: var(--soft); font-size: 16px; }
.card .meta { margin-top: 20px; color: var(--faint); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.card .meta .go { margin-left: auto; color: var(--gold-soft); font-weight: 600; }

/* ---------- Reader ---------- */
.reader { display: grid; grid-template-columns: 248px 1fr; gap: 40px; padding-top: 36px; align-items: start; }
@media (max-width: 860px) { .reader { grid-template-columns: 1fr; gap: 20px; } }

.sidebar { position: sticky; top: 84px; }
.sidebar .proj-title { font-family: "Space Grotesk", sans-serif; font-size: 17px; font-weight: 600; margin: 0 0 2px; }
.sidebar .proj-sub { color: var(--faint); font-size: 12px; margin: 0 0 18px; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px;
  color: var(--soft); font-size: 14px; cursor: pointer; transition: background .15s ease, color .15s ease;
  position: relative;
}
.toc li:hover.is-unlocked { background: var(--glass); color: var(--ink); }
.toc li.current { background: linear-gradient(90deg, rgba(245,189,84,.14), transparent); color: var(--ink); font-weight: 600; }
.toc li.current::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.toc li.locked { color: var(--faint); cursor: default; }
.toc .ic { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 11px; border: 1px solid var(--line); }
.toc li.done .ic { color: var(--green); border-color: rgba(111,227,166,.4); background: rgba(111,227,166,.08); }
.toc li.current .ic { color: var(--gold); border-color: rgba(245,189,84,.5); }

@media (max-width: 860px) {
  .sidebar { position: static; }
  .toc { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
  .toc li { white-space: nowrap; }
  .sidebar .proj-title, .sidebar .proj-sub { display: none; }
}

/* main column */
.crumbs { font-size: 13px; margin-bottom: 14px; }
.crumbs a { color: var(--faint); cursor: pointer; text-decoration: none; transition: color .15s; }
.crumbs a:hover { color: var(--ink); }

.chapter-head .ch-num { color: var(--gold-soft); font-size: 13px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; }
.chapter-head h2 { font-family: "Space Grotesk", sans-serif; font-size: 34px; letter-spacing: -0.6px; margin: 6px 0 8px; }
.chapter-head .build { color: var(--soft); font-size: 16px; margin: 0; max-width: 60ch; }
.step-meter { display: flex; align-items: center; gap: 10px; margin: 22px 0 16px; color: var(--faint); font-size: 13px; }
.step-meter .bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.07); overflow: hidden; max-width: 220px; }
.step-meter .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--gold)); border-radius: 4px; transition: width .35s ease; }

/* step card */
.step {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 34px 36px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.step .kicker { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); background: rgba(245,189,84,.1); padding: 4px 10px; border-radius: 8px; }
.step h3 { font-family: "Space Grotesk", sans-serif; font-size: 25px; letter-spacing: -0.3px; margin: 14px 0 22px; }
.label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); margin: 26px 0 7px; display: flex; align-items: center; gap: 8px; }
.label::before { content: ""; width: 14px; height: 1px; background: var(--gold); opacity: .7; }
.adding { font-size: 18px; color: var(--ink); margin: 0; }
.step p { margin: 0; color: #cdcfe6; }

/* code block with window chrome */
.codewrap { margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #11111d; }
.codewrap .chrome { display: flex; align-items: center; gap: 7px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.02); }
.codewrap .chrome .d { width: 11px; height: 11px; border-radius: 50%; background: #3a3a52; }
.codewrap .chrome .fname { margin-left: 8px; color: var(--faint); font: 12px "JetBrains Mono", monospace; }
.codewrap pre { margin: 0; padding: 16px 18px; background: transparent; overflow-x: auto; }
.codewrap code { font: 13.5px/1.7 "JetBrains Mono", monospace; }
pre[class*="language-"] { text-shadow: none !important; }

.callout { padding: 14px 16px 14px 16px; border-radius: 12px; margin-top: 8px; display: flex; gap: 12px; align-items: flex-start; font-size: 15.5px; }
.callout .ci { flex: none; font-size: 16px; line-height: 1.5; }
.callout.see { background: rgba(142,123,255,.08); border: 1px solid rgba(142,123,255,.22); color: #d7d4ff; }
.callout.check { background: rgba(111,227,166,.08); border: 1px solid rgba(111,227,166,.22); color: #cdf6e2; }

details.recovery { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
details.recovery summary { cursor: pointer; color: var(--soft); font-size: 14px; font-weight: 500; list-style: none; }
details.recovery summary::-webkit-details-marker { display: none; }
details.recovery summary::before { content: "▸ "; color: var(--faint); }
details.recovery[open] summary::before { content: "▾ "; }
details.recovery ul { margin: 12px 0 0; padding-left: 20px; color: var(--soft); font-size: 14px; }
details.recovery li { margin: 6px 0; }
details.recovery code { font: 12.5px "JetBrains Mono", monospace; background: rgba(255,255,255,.06); padding: 1px 6px; border-radius: 5px; }

/* nav + beat */
.nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; }
.btn { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: var(--glass-2); color: var(--ink); padding: 13px 24px; border-radius: 12px; transition: all .16s ease; }
.btn:hover:not(:disabled) { border-color: rgba(255,255,255,.22); transform: translateY(-1px); }
.btn:disabled { opacity: .3; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #2a1c00; border-color: transparent; box-shadow: 0 10px 26px -12px rgba(245,189,84,.7); }

.beat { text-align: center; margin-top: 20px; padding: 24px; border-radius: var(--radius); background: linear-gradient(180deg, rgba(245,189,84,.12), rgba(245,189,84,.03)); border: 1px solid rgba(245,189,84,.3); }
.beat h3 { font-family: "Space Grotesk", sans-serif; margin: 0 0 6px; color: var(--gold-soft); font-size: 20px; }
.beat p { margin: 0; color: var(--soft); }

/* helper */
.helper { margin-top: 24px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--glass); }
.helper > summary { cursor: pointer; padding: 15px 20px; color: var(--soft); font-weight: 600; list-style: none; display: flex; align-items: center; gap: 9px; }
.helper > summary::-webkit-details-marker { display: none; }
.helper .body { padding: 0 20px 20px; }
.helper .hint { margin: 0 0 10px; color: var(--faint); font-size: 14px; }
.helper textarea { width: 100%; min-height: 120px; resize: vertical; background: #11111d; color: #e6e6ff; border: 1px solid var(--line); border-radius: 10px; padding: 13px; font: 13px/1.6 "JetBrains Mono", monospace; }
.helper .result { margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px; display: none; }
.helper .result.ok { display: block; background: rgba(111,227,166,.08); border: 1px solid rgba(111,227,166,.25); }
.helper .result.no { display: block; background: rgba(255,123,138,.08); border: 1px solid rgba(255,123,138,.25); }
.helper .result code { font-family: "JetBrains Mono", monospace; }
.helper .note { color: var(--faint); font-size: 12px; margin: 10px 0 0; }

.coming { text-align: center; padding: 60px 24px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--soft); }
.coming h3 { font-family: "Space Grotesk", sans-serif; color: var(--ink); margin: 0 0 6px; }

details.fullcode { margin-top: 12px; }
details.fullcode > summary { cursor: pointer; color: var(--soft); font-size: 13px; font-weight: 600; list-style: none; padding: 6px 2px; }
details.fullcode > summary::-webkit-details-marker { display: none; }
details.fullcode > summary::before { content: "▸ "; color: var(--faint); }
details.fullcode[open] > summary::before { content: "▾ "; }
details.fullcode .codewrap { margin-top: 8px; }
details.fullcode .codewrap pre { max-height: 460px; overflow: auto; }

.helper .hbtns { display: flex; gap: 10px; margin-top: 12px; }
.helper .voice { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: #cdcfe6; font-size: 14px; line-height: 1.6; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--faint); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.setup-cta { text-align: center; margin: 18px 0 0; color: var(--soft); font-size: 14px; }
.setup-cta a { color: var(--gold-soft); cursor: pointer; font-weight: 600; }
.setup { max-width: 720px; margin: 30px auto 0; }
.chat { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 24px; }
.bubble { max-width: 82%; padding: 13px 16px; border-radius: 16px; font-size: 15.5px; line-height: 1.6; animation: rise .25s ease; }
.bubble.bot { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; color: var(--ink); }
.bubble.you { align-self: flex-end; background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #2a1c00; border-bottom-right-radius: 5px; font-weight: 600; }
.bubble a { color: var(--gold-soft); }
.bubble.you a { color: #2a1c00; }
.setup-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.setup-controls textarea { width: 100%; min-height: 92px; background: #11111d; color: #e6e6ff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: 13px/1.6 "JetBrains Mono", monospace; }
