:root {
  --bg: #f4efe9;
  --ink: #1d2628;
  --muted: #6b7472;
  --line: rgba(29, 38, 40, .07);
  --accent: #2a7b74;
  --rose: #cf7266;
  --glow: rgba(226, 150, 136, .22);

  /* embryo palette (read by embryo.js) */
  --cell-in: #fffaf6;
  --cell-out: #f1cfc6;
  --cell-mem: #d4958a;
  --nuc: #f7e1da;
  --nuc-rim: #c27a70;
  --nucleolus: #b0645b;
  --granule: #c08378;
  --zona: rgba(214, 160, 148, .16);
  --zona-edge: rgba(190, 120, 108, .5);
  --guide: rgba(29, 38, 40, .2);
  --sweep: rgba(42, 123, 116, .07);
  --cavity: rgba(255, 252, 249, .55);
  --cavity-edge: rgba(212, 149, 138, .35);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1113;
    --ink: #ebe5df;
    --muted: #87918e;
    --line: rgba(235, 229, 223, .05);
    --accent: #62c6b9;
    --rose: #ee9a8e;
    --glow: rgba(238, 154, 142, .10);

    --cell-in: #573739;
    --cell-out: #251a1c;
    --cell-mem: #e8978c;
    --nuc: #3a2729;
    --nuc-rim: #f0a59a;
    --nucleolus: #ffd3cb;
    --granule: #e6978d;
    --zona: rgba(240, 160, 148, .07);
    --zona-edge: rgba(240, 165, 154, .4);
    --guide: rgba(235, 229, 223, .2);
    --sweep: rgba(98, 198, 185, .08);
    --cavity: rgba(30, 22, 24, .55);
    --cavity-edge: rgba(232, 151, 140, .25);
  }
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(60vmax 60vmax at 72% 50%, var(--glow), transparent 60%),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
  background-position: center, center, center;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: .06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  .grain { mix-blend-mode: screen; opacity: .035; }
}

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.page {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding:
    max(clamp(16px, 3vw, 40px), env(safe-area-inset-top))
    max(clamp(16px, 4vw, 56px), env(safe-area-inset-right))
    max(clamp(16px, 3vw, 36px), env(safe-area-inset-bottom))
    max(clamp(16px, 4vw, 56px), env(safe-area-inset-left));
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.mark { width: 26px; height: 26px; }
.wordmark {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
}
.tld { color: var(--rose); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}
.pulse {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping {
  0% { transform: scale(1); opacity: .6; }
  80%, 100% { transform: scale(3.2); opacity: 0; }
}

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: clamp(24px, 5vw, 96px);
  min-height: 0;
}

.copy {
  max-width: 30rem;
  animation: rise 1.2s cubic-bezier(.2, .7, .2, 1) both;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 clamp(14px, 2.5vh, 28px);
  color: var(--accent);
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: currentColor;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, min(6.4vw, 11vh), 6.2rem);
  line-height: .98;
  letter-spacing: -.02em;
  text-wrap: balance;
}
h1 em {
  font-style: italic;
  color: var(--rose);
}



/* ---------- visualization ---------- */
.viz {
  position: relative;
  margin: 0;
  justify-self: center;
  width: min(100%, calc(100vh - 150px));
  width: min(100%, calc(100dvh - 150px));
  aspect-ratio: 1;
  animation: fade 1.6s ease both .2s;
}
.viz canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.bracket {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 0 solid var(--guide);
}
.bracket.tl { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.bracket.tr { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.bracket.bl { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.bracket.br { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

.hud { position: absolute; inset: 0; pointer-events: none; font-size: 10px; }
.hud > div {
  position: absolute;
  display: grid;
  gap: 4px;
}
.hud .k { color: var(--muted); }
.hud .v { color: var(--ink); font-size: 11px; }
.hud-tl { top: 28px; left: 28px; }
.hud-tr { top: 28px; right: 28px; text-align: right; }
.hud-bl { bottom: 28px; left: 28px; }
.hud-br { bottom: 28px; right: 28px; text-align: right; justify-items: end; }

.unit { text-transform: none; letter-spacing: .02em; }

.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips i {
  width: 14px;
  height: 2px;
  background: var(--guide);
  transition: background .6s ease;
}
.pips i.on { background: var(--rose); }

.scalebar { display: grid; justify-items: end; gap: 5px; }
.scalebar .bar {
  display: block;
  width: var(--scalebar, 60px);
  height: 5px;
  border: 1px solid var(--ink);
  border-top: 0;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- footer ---------- */
.bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 10px;
}

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  body {
    background-image:
      radial-gradient(70vmax 70vmax at 50% 30%, var(--glow), transparent 60%),
      linear-gradient(var(--line) 1px, transparent 1px),
      linear-gradient(90deg, var(--line) 1px, transparent 1px);
  }
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: center;
    justify-items: center;
    gap: clamp(8px, 2.5vh, 28px);
    text-align: center;
  }
  .viz {
    order: -1;
    width: min(100%, 60vh, 560px);
    width: min(100%, 60dvh, 560px);
  }
  .copy { justify-self: center; }
  .eyebrow { justify-content: center; }
  .eyebrow::after {
    content: "";
    width: 28px;
    height: 1px;
    background: currentColor;
  }
  h1 { font-size: clamp(2.2rem, min(10.5vw, 6.6vh), 4rem); }
  .hud-tl, .hud-tr { top: 14px; }
  .hud-bl, .hud-br { bottom: 14px; }
  .hud-tl, .hud-bl { left: 14px; }
  .hud-tr, .hud-br { right: 14px; }
  .bracket { width: 12px; height: 12px; }
}

@media (max-width: 520px) {
  .hud .k { display: none; }
  .hud .v { font-size: 10px; }
  .pips { display: none; }
  .status { font-size: 10px; }
}

@media (max-height: 560px) and (min-width: 821px) {
  .hud { display: none; }
  .viz { width: min(100%, calc(100vh - 110px)); width: min(100%, calc(100dvh - 110px)); }
}

@media (prefers-reduced-motion: reduce) {
  .copy, .viz { animation: none; }
  .pulse::after { animation: none; }
}
