:root {
  --bg: #191b20;
  --bg-mid: #242730;
  --surface: rgba(231, 220, 200, 0.94);
  --surface-strong: rgba(214, 196, 168, 0.96);
  --surface-soft: rgba(236, 225, 207, 0.72);
  --surface-dark: #1f2026;
  --ink: #181511;
  --ink-soft: #5f5449;
  --ink-inverse: #f7f1e6;
  --line: rgba(24, 21, 17, 0.15);
  --line-strong: rgba(24, 21, 17, 0.28);
  --rail: #c65a2e;
  --rail-deep: #8b3418;
  --signal: #f0b24b;
  --shadow: 0 21px 55px rgba(0, 0, 0, 0.24);
  --s-0: 8px;
  --s-1: 13px;
  --s-2: 21px;
  --s-3: 34px;
  --s-4: 55px;
  --s-5: 89px;
  --s-6: 144px;
  --radius-sm: 13px;
  --radius-md: 21px;
  --radius-lg: 34px;
  --max: 1680px;
  --measure: 55ch;
  --measure-wide: 89ch;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(198, 90, 46, 0.22), transparent 24%),
    radial-gradient(circle at 88% 14%, rgba(240, 178, 75, 0.12), transparent 18%),
    linear-gradient(180deg, #1b1d24 0%, var(--bg) 42%, var(--bg-mid) 100%);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  line-height: 1.62;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
code { font-family: "IBM Plex Mono", "Courier New", monospace; font-size: 0.92em; }
p, h1, h2, h3, ul, figure { margin: 0; }

.site-shell {
  width: min(var(--max), calc(100% - var(--s-2)));
  margin: 0 auto;
  padding: var(--s-1) 0 var(--s-4);
}

.page-flow { display: grid; gap: var(--s-3); }

.hero,
.gesture-band,
.failure-band,
.mechanism-band,
.architecture-band,
.focus-band,
.kernel-band,
.protocol-band,
.support-band,
.boundary-band,
.ops-band,
.final-exit {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero::before,
.gesture-band::before,
.mechanism-band::before,
.architecture-band::before,
.kernel-band::before,
.support-band::before,
.boundary-band::before,
.ops-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.34), transparent 45%),
    linear-gradient(180deg, transparent, rgba(203, 71, 34, 0.035));
  pointer-events: none;
}

.hero > *,
.gesture-band > *,
.mechanism-band > *,
.architecture-band > *,
.kernel-band > *,
.protocol-band > *,
.support-band > *,
.boundary-band > *,
.ops-band > *,
.final-exit > * {
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.618fr) minmax(360px, 1fr);
  gap: var(--s-3);
  align-items: stretch;
  padding: var(--s-3);
  margin-bottom: var(--s-3);
  background: linear-gradient(135deg, rgba(229, 215, 192, 0.98), rgba(205, 184, 152, 0.92));
}

.hero-copy {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: var(--s-1);
  max-width: var(--measure);
  text-align: left;
}

.hero-actions,
.exit-links { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.hero-actions { margin-top: var(--s-1); justify-content: flex-start; }

.hero-visual,
.gesture-visual,
.support-visual,
.kernel-visual {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #101217;
}

.hero-visual img,
.gesture-visual img,
.support-visual img,
.kernel-visual img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.hero-visual {
  align-self: stretch;
  display: grid;
  place-items: center;
}

.eyebrow,
.kicker,
.step-tag {
  font-family: "IBM Plex Mono", "Courier New", monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eyebrow,
.kicker { color: var(--rail-deep); font-size: 0.82rem; }

h1,
h2,
h3 { line-height: 1.03; letter-spacing: -0.045em; }

h1 {
  max-width: 10.5ch;
  font-size: clamp(3.4rem, 6.4vw, 6.4rem);
  line-height: 0.9;
}

h2 {
  max-width: 12ch;
  font-size: clamp(2rem, 3.8vw, 3.5rem);
}

h3 { font-size: clamp(1.06rem, 1.2vw, 1.2rem); line-height: 1.12; }
p, li { font-size: 1rem; line-height: 1.65; }

.hero-definition,
.hero-lead,
.principle,
.gesture-line,
.failure-copy,
.support-copy > p { max-width: var(--measure); }

.hero-definition { color: var(--rail-deep); font-size: 1.12rem; font-weight: 700; }
.hero-lead,
.gesture-step p,
.mechanism-panel p,
.mechanism-rail p,
.family p,
.focus-band p,
.kernel-copy p,
.support-copy > p,
.support-grid p,
.boundary-grid p,
.ops-grid p { color: var(--ink-soft); }

.button,
.exit-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--s-4);
  padding: var(--s-1) var(--s-2);
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  text-decoration: none;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.92rem;
}
.button.primary { background: var(--rail); border-color: transparent; color: #fff7ef; }
.button.secondary,
.exit-links a { background: rgba(242, 232, 217, 0.7); }

.gesture-band,
.failure-band,
.mechanism-band,
.architecture-band,
.kernel-band,
.protocol-band,
.support-band,
.boundary-band,
.ops-band {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 1.618fr);
  gap: var(--s-3);
  align-items: start;
  padding: var(--s-3);
}

.section-head { display: grid; gap: var(--s-1); align-self: start; }
.section-head.compact { gap: var(--s-1); }

.gesture-visual,
.gesture-grid,
.gesture-line,
.failure-layout,
.mechanism-layout,
.family-grid,
.kernel-layout,
.protocol-rail,
.protocol-notes,
.support-copy,
.boundary-grid,
.ops-grid {
  grid-column: 2;
}

.gesture-grid,
.failure-layout,
.mechanism-layout,
.family-grid,
.focus-pair,
.kernel-layout,
.support-grid,
.boundary-grid,
.ops-grid { display: grid; gap: var(--s-2); }

.gesture-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr) minmax(0, 1fr); }

.gesture-step,
.mechanism-panel,
.mechanism-rail,
.family,
.focus-band,
.kernel-copy,
.support-grid article,
.boundary-grid article,
.ops-grid article {
  display: grid;
  align-content: start;
  gap: var(--s-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.48);
  padding: var(--s-2);
  text-align: left;
  justify-items: start;
}

.gesture-step,
.family,
.boundary-grid article,
.ops-grid article { min-height: var(--s-6); }

.gesture-step.throw,
.freeze-band {
  background: linear-gradient(180deg, rgba(198, 90, 46, 0.24), rgba(237, 224, 203, 0.7));
  border-color: rgba(198, 90, 46, 0.28);
}

.gesture-step.think,
.gesture-step.unearth,
.latent-band { background: rgba(236, 225, 207, 0.62); }
.step-tag { color: var(--rail-deep); font-size: 0.78rem; }

.gesture-line,
.principle {
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
  color: var(--rail-deep);
  font-weight: 700;
  text-align: left;
}

.failure-band { background: linear-gradient(180deg, rgba(44, 35, 29, 0.98), rgba(27, 25, 24, 0.98)); color: var(--ink-inverse); }
.failure-band .kicker { color: var(--signal); }
.failure-band h2 { max-width: 8ch; }
.failure-copy { color: var(--ink-inverse); font-size: clamp(1.25rem, 2vw, 1.65rem); line-height: 1.42; font-weight: 700; }
.failure-layout { grid-template-columns: minmax(0, 1.618fr) minmax(260px, 1fr); align-items: center; }
.failure-list,
.protocol-notes { margin: 0; padding-left: 1.2rem; }
.failure-list { color: var(--signal); }

.mechanism-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr) minmax(0, 1fr); align-items: stretch; }
.mechanism-panel.canonical { background: rgba(234, 220, 198, 0.82); }
.mechanism-panel.support { background: rgba(228, 219, 203, 0.72); }
.mechanism-rail { background: linear-gradient(90deg, rgba(198,90,46,.22), rgba(240,178,75,.24), rgba(198,90,46,.22)); }

.family-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.family-structural { background: rgba(233,217,192,.84); border-color: rgba(139,52,24,.24); }
.family-operational,
.family-historical,
.family-latent { background: rgba(231,220,201,.76); }

.focus-pair { grid-template-columns: minmax(0, 1.618fr) minmax(0, 1fr); gap: var(--s-3); }
.focus-band { padding: var(--s-3); }
.focus-band h2 { max-width: 12ch; }

.kernel-band,
.protocol-band,
.boundary-band,
.workstation-band { background: linear-gradient(180deg, rgba(226,212,187,.96), rgba(238,228,210,.96)); }
.kernel-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr); align-items: center; }
.kernel-copy { background: rgba(255,255,255,.34); }

.protocol-rail { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s-1); }
.protocol-rail span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(236, 225, 208, 0.82);
  padding: var(--s-1);
  text-align: center;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.82rem;
}

.protocol-notes { width: min(100%, var(--measure-wide)); }
.support-copy { display: grid; gap: var(--s-2); }
.support-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.boundary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ops-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.final-exit { display: grid; justify-items: center; text-align: center; gap: var(--s-2); margin-top: var(--s-3); padding: var(--s-3); }
.footer-stack { display: grid; gap: var(--s-1); justify-items: center; }
.machine-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .45rem .7rem;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: .78rem;
}
.machine-links a { text-decoration: none; }
.machine-links a:hover,
.machine-links a:focus-visible { color: var(--rail-deep); text-decoration: underline; }
.workstation-links { justify-content: flex-start; }

@media (max-width: 1100px) {
  .hero,
  .gesture-band,
  .failure-band,
  .mechanism-band,
  .architecture-band,
  .kernel-band,
  .protocol-band,
  .support-band,
  .boundary-band,
  .ops-band,
  .gesture-grid,
  .failure-layout,
  .mechanism-layout,
  .family-grid,
  .focus-pair,
  .kernel-layout,
  .support-grid,
  .boundary-grid,
  .ops-grid,
  .protocol-rail {
    grid-template-columns: 1fr;
  }
  .gesture-visual,
  .gesture-grid,
  .gesture-line,
  .failure-layout,
  .mechanism-layout,
  .family-grid,
  .kernel-layout,
  .protocol-rail,
  .protocol-notes,
  .support-copy,
  .boundary-grid,
  .ops-grid { grid-column: auto; }
  .hero-copy { max-width: var(--measure-wide); }
}

@media (max-width: 760px) {
  .site-shell { width: min(100%, calc(100% - var(--s-2))); }
  .hero,
  .gesture-band,
  .failure-band,
  .mechanism-band,
  .architecture-band,
  .kernel-band,
  .protocol-band,
  .support-band,
  .boundary-band,
  .ops-band,
  .final-exit { padding: var(--s-2); border-radius: var(--radius-md); }
  h1 { font-size: clamp(2.8rem, 14vw, 4.5rem); }
  h2 { font-size: clamp(1.8rem, 10vw, 2.7rem); }
  .hero-actions,
  .exit-links { flex-direction: column; width: 100%; }
  .button,
  .exit-links a { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero,
  .page-flow > section,
  .final-exit { animation: rise 520ms ease both; }
}

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

/* Patch: hero must stay a banner, kernel map must read larger. */
.hero {
  grid-template-columns: 1fr;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-3);
}

.hero-visual {
  width: 100%;
  border-radius: calc(var(--radius-lg) - 6px);
}

.hero-visual img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.hero-copy {
  max-width: min(100%, var(--measure-wide));
  padding-inline: var(--s-1);
}

.hero h1,
.hero-definition,
.hero-lead {
  max-width: var(--measure-wide);
}

.kernel-layout {
  grid-template-columns: minmax(0, 0.68fr) minmax(0, 1.32fr);
  align-items: start;
}

.kernel-visual {
  width: 100%;
  align-self: stretch;
}

.kernel-visual img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 1100px) {
  .hero,
  .kernel-layout {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    padding-inline: 0;
  }
}

/* Hotfix: kernel visual must not create a black dead panel. Keep the map large, but bound the frame to the image. */
.kernel-layout {
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1.58fr);
  align-items: center;
}

.kernel-copy {
  align-self: center;
}

.kernel-visual {
  align-self: center !important;
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  background: transparent;
  border-color: var(--line-strong);
}

.kernel-visual img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (min-width: 1101px) {
  .kernel-band {
    grid-template-columns: minmax(260px, 0.62fr) minmax(0, 1.38fr);
  }
}

/* OP target: kernel section as a real top-title + lower 38/62 row. */
.kernel-band {
  grid-template-columns: 1fr !important;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-3) var(--s-3);
}

.kernel-band > .section-head {
  grid-column: 1 / -1;
  justify-items: center;
  text-align: center;
  max-width: var(--measure-wide);
  margin-inline: auto;
}

.kernel-band > .section-head h2 {
  max-width: 16ch;
  margin-inline: auto;
}

.kernel-layout {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(360px, 0.62fr) minmax(0, 1fr) !important;
  gap: var(--s-2);
  align-items: center;
  width: 100%;
}

.kernel-copy {
  align-self: center;
  justify-self: stretch;
  padding: var(--s-2);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid var(--line);
  text-align: center;
  justify-items: center;
}

.kernel-copy p {
  max-width: 62ch;
  margin-inline: auto;
  text-align: center;
}

.kernel-visual {
  align-self: center !important;
  justify-self: stretch;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 0;
  border-radius: var(--radius-md);
  background: #101217;
  overflow: hidden;
}

.kernel-visual img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 1100px) {
  .kernel-layout {
    grid-template-columns: 1fr !important;
  }
}
