:root {
  color-scheme: light;
  --page: #f7f6f2;
  --surface: #fcfcfb;
  --surface-2: #efeee8;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hair: #e1e0d9;
  --accent: #2a78d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 10px 30px rgba(11, 11, 11, 0.07);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #171716; --surface-2: #1f1f1d;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781; --hair: #2c2c2a;
    --accent: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #171716; --surface-2: #1f1f1d;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781; --hair: #2c2c2a;
  --accent: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--hair); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; }
.topbar nav { display: flex; gap: 18px; font-size: 15px; }
.topbar nav a { text-decoration: none; color: var(--ink-2); }
.topbar nav a:hover { color: var(--ink); }
@media (max-width: 560px) { .topbar nav .opt { display: none; } }

.hero { padding: 56px 0 28px; }
.eyebrow { font-family: var(--mono); font-size: 13px; color: var(--muted); margin: 0 0 12px; letter-spacing: 0.02em; }
.hero h1 { font-size: clamp(32px, 5.4vw, 60px); line-height: 1.04; letter-spacing: -0.035em; margin: 0 0 18px; max-width: 16ch; }
.lede { font-size: clamp(17px, 2vw, 20px); color: var(--ink-2); max-width: 46ch; margin: 0 0 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--hair); background: var(--surface); text-decoration: none; font-weight: 600; font-size: 15px; }
.btn-primary { background: var(--ink); color: var(--page); border-color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 8px; margin: 0; list-style: none; }
.chips a { display: inline-block; padding: 7px 12px; border-radius: 999px; background: var(--surface-2); text-decoration: none; font-size: 14px; color: var(--ink-2); }
.chips a:hover { color: var(--ink); }

.project { padding: 56px 0; border-top: 1px solid var(--hair); }
.project:first-of-type { border-top: 0; }
.p-head { display: grid; grid-template-columns: 1fr; gap: 6px 32px; margin-bottom: 22px; }
@media (min-width: 900px) { .p-head { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: end; } }
.p-num { font-family: var(--mono); font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.p-head h2 { font-size: clamp(26px, 3.4vw, 40px); line-height: 1.08; letter-spacing: -0.025em; margin: 0; }
.p-head p.cap { margin: 0; color: var(--ink-2); font-size: 18px; max-width: 52ch; }

/* Video frames */
.clip { margin: 0; }
.frame { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); }
.frame video, .frame img { display: block; width: 100%; height: 100%; object-fit: cover; background: #000; }
.r16x9 { aspect-ratio: 16 / 9; }
.r9x16 { aspect-ratio: 9 / 16; }
.contain video { object-fit: contain; }
.clip figcaption { font-size: 15px; color: var(--ink-2); margin-top: 10px; }
.clip figcaption b { color: var(--ink); font-weight: 600; }
.sound { position: absolute; right: 10px; bottom: 10px; height: 34px; padding: 0 12px; border-radius: 999px; border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; font: 600 13px var(--sans); cursor: pointer; }
.sound[hidden] { display: none; }

.grid { display: grid; gap: 22px; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
@media (min-width: 720px) { .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.lead-clip { margin-bottom: 22px; }

/* Row of vertical clips */
.verticals { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .verticals { grid-auto-flow: column; grid-auto-columns: 72%; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; } .verticals .clip { scroll-snap-align: start; } }
.verticals .frame { max-height: 78vh; }

/* Placeholders for clips to be added */
.ph { aspect-ratio: 16 / 4; min-height: 120px; border-radius: var(--radius); border: 2px dashed var(--hair); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 16px; color: var(--muted); }
.ph strong { color: var(--ink-2); font-size: 16px; }
.ph span { font-family: var(--mono); font-size: 12px; }

.about-grid { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .about-grid { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); } }
.about-text p { margin: 0 0 12px; font-size: 18px; color: var(--ink-2); max-width: 56ch; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-content: start; }
.stat { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 14px; }
.stat-v { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-l { display: block; font-size: 14px; color: var(--ink-2); }
.chips.tools { margin-top: 22px; }
.chips.tools li { padding: 7px 12px; border-radius: 999px; background: var(--surface-2); font-size: 14px; color: var(--ink-2); }
.facts { display: grid; gap: 18px; grid-template-columns: 1fr; margin-top: 22px; }
@media (min-width: 720px) { .facts { grid-template-columns: 1fr 1fr; } }
.facts p { margin: 0; color: var(--ink-2); }
.fact-k { font-family: var(--mono); font-size: 13px; color: var(--muted) !important; margin-bottom: 4px !important; }
.contact { padding: 64px 0 80px; border-top: 1px solid var(--hair); }
.contact h2 { font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.03em; margin: 0 0 12px; }
.contact p { color: var(--ink-2); max-width: 52ch; margin: 0 0 22px; font-size: 18px; }
footer { padding: 24px 0 40px; color: var(--muted); font-size: 14px; }

/* ---------- Diagram styles (placeholder content until the real steps are written) ---------- */
.dg { --n: 5; }
.dg-tag { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.dg-step b { display: block; font-weight: 600; }
.dg-step span { display: block; color: var(--ink-2); font-size: 14px; }

/* A: cards + arrows */
.dg-a ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .dg-a ol { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 30px; } }
.dg-a li { position: relative; background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.dg-a li .k { font-family: var(--mono); font-size: 12px; color: var(--accent); margin-bottom: 6px; display: block; }
.dg-a li:not(:last-child)::after { content: "→"; position: absolute; color: var(--muted); font-size: 20px; left: 50%; bottom: -27px; transform: translateX(-50%) rotate(90deg); }
@media (min-width: 820px) { .dg-a li:not(:last-child)::after { left: auto; right: -24px; bottom: auto; top: 50%; transform: translateY(-50%); } }

/* B: vertical timeline */
.dg-b ol { list-style: none; margin: 0; padding: 0 0 0 34px; position: relative; max-width: 640px; }
.dg-b ol::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--hair); }
.dg-b li { position: relative; padding: 0 0 22px; counter-increment: s; }
.dg-b li::before { content: counter(s); position: absolute; left: -34px; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--page); font: 600 12px/24px var(--sans); text-align: center; }
.dg-b ol { counter-reset: s; }

/* C: live pipeline, animated */
.dg-c { background: #0f1115; color: #fff; border-radius: var(--radius); padding: 28px 20px; overflow: hidden; }
.dg-c .dg-tag { color: #8a8f99; }
.dg-c ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: 1fr; position: relative; }
@media (min-width: 820px) { .dg-c ol { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); } .dg-c ol::before { content: ""; position: absolute; left: 6%; right: 6%; top: 22px; height: 2px; background: #2a2f38; } .dg-c ol::after { content: ""; position: absolute; top: 18px; left: 6%; width: 10px; height: 10px; border-radius: 50%; background: #5aa8ff; box-shadow: 0 0 14px 4px rgba(90,168,255,.7); animation: dgrun 5s linear infinite; } }
@keyframes dgrun { from { left: 6%; } to { left: 93%; } }
.dg-c li { position: relative; text-align: center; }
.dg-c .dot { display: block; width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; background: #1b1f27; border: 1px solid #2f3540; font: 600 15px/44px var(--mono); color: #8a8f99; animation: dglit 5s linear infinite; position: relative; z-index: 1; }
.dg-c li:nth-child(1) .dot { animation-delay: 0s; } .dg-c li:nth-child(2) .dot { animation-delay: 1s; } .dg-c li:nth-child(3) .dot { animation-delay: 2s; } .dg-c li:nth-child(4) .dot { animation-delay: 3s; } .dg-c li:nth-child(5) .dot { animation-delay: 4s; }
@keyframes dglit { 0%, 20% { background: #5aa8ff; color: #fff; border-color: #5aa8ff; box-shadow: 0 0 18px rgba(90,168,255,.6); } 21%, 100% { background: #1b1f27; color: #8a8f99; border-color: #2f3540; box-shadow: none; } }
.dg-c .dg-step span { color: #a7adb8; }
@media (prefers-reduced-motion: reduce) { .dg-c ol::after, .dg-c .dot { animation: none; } }

/* D: big numbers */
.dg-d ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 820px) { .dg-d ol { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); } }
.dg-d li { border-top: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 0 12px 12px; padding: 14px; }
.dg-d li .k { display: block; font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; margin-bottom: 10px; color: var(--accent); }

/* E: sketch */
.dg-e { font-family: "Caveat", "Comic Sans MS", cursive; }
.dg-e ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 6px; }
.dg-e li { border: 2px solid var(--ink); border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; padding: 10px 16px; background: var(--surface); transform: rotate(-1deg); }
.dg-e li:nth-child(even) { transform: rotate(1.2deg); }
.dg-e li b { font-size: 24px; font-weight: 700; }
.dg-e li span { font-size: 19px; color: var(--ink-2); }
.dg-e .arr { font-size: 30px; color: var(--ink-2); padding: 0 2px; }

/* Branching pipeline (SVG, animated) */
.dg-flow svg { display: block; width: 100%; height: auto; }
.dg-flow .flow-v { display: none; max-width: 440px; margin: 0 auto; }
@media (max-width: 700px) { .dg-flow .flow-h { display: none; } .dg-flow .flow-v { display: block; } }
.dg-flow .fe { fill: none; stroke: #2a2f38; stroke-width: 2; }
.dg-flow .fp { fill: #5aa8ff; filter: drop-shadow(0 0 6px rgba(90,168,255,.9)); opacity: 0; }
.dg-flow .fn { fill: #1b1f27; stroke: #2f3540; stroke-width: 1.5; }
.dg-flow .ft { fill: #e8ebf0; font: 600 15px var(--sans); }
.dg-flow .flow-v .ft { font-size: 13px; }

/* Flow diagrams v3: whole diagram fits the width; top-to-bottom version on phones */
.fx { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; }
.fx svg { display: block; width: 100%; height: auto; }
.fx .fx-v { display: none; }
@media (max-width: 700px) { .fx .fx-h { display: none; } .fx .fx-v { display: block; } }
.fx + .ph { margin-top: 18px; }
