:root {
  color-scheme: dark;
  --bg: #08090d;
  --ink: #f5f0ea;
  --muted: #b6adbe;
  --pink: #ff4fa8;
  --aqua: #43e3d6;
  --gold: #ffd166;
  --violet: #8e6cff;
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(13, 15, 22, 0.78);
  --panel-strong: rgba(20, 22, 31, 0.92);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: linear-gradient(180deg, rgba(5, 6, 10, 0.88), rgba(5, 6, 10, 0));
}

.brand,
.nav-actions,
.hero-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 223, 236, 0.62);
  border-radius: 50%;
  overflow: hidden;
  background: #050509;
  box-shadow: 0 0 18px rgba(255, 209, 228, 0.2);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2.55);
}

.nav-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary,
.secondary {
  min-height: 38px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary,
.secondary {
  border-radius: 999px;
  padding: 0 16px;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.42);
}

.hero {
  min-height: min(820px, 96svh);
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(22px, 4vw, 64px);
  padding: 108px clamp(18px, 5vw, 76px) 68px;
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(9, 9, 14, 0.48), transparent 25%, transparent 67%, #090a0f),
    linear-gradient(90deg, rgba(9, 9, 14, 0.86), rgba(15, 8, 20, 0.65) 43%, rgba(20, 8, 24, 0.22) 100%),
    url("./assets/lab.png");
  background-position: center;
  background-size: cover;
}

.hero-copy {
  width: min(760px, 100%);
}

.hero .eyebrow,
.brand-mark {
  color: var(--pink);
}

.hero h1 {
  font-size: clamp(48px, 6.8vw, 116px);
  line-height: 0.9;
  letter-spacing: -0.06em;
  white-space: normal;
}

.hero-presave {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
  padding: 12px 16px;
  border: 1px solid var(--pink);
  background: var(--pink);
  color: #160710;
  font-weight: 800;
  text-decoration: none;
}

.hero-presave:hover {
  background: #ff8fc8;
}

.hero-comic {
  margin: 0;
  border: 1px solid #824365;
  background: #0b0a0e;
  box-shadow: 8px 8px 0 #3a182c;
}

.hero-comic img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-comic figcaption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #824365;
  color: #ffc7e4;
  font: 700 11px/1.4 ui-monospace, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    background-image:
      linear-gradient(180deg, rgba(9, 9, 14, 0.78), rgba(12, 9, 17, 0.69) 50%, #090a0f),
      url("./assets/lab.png");
  }
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--aqua);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", Inter, sans-serif;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: normal;
  white-space: nowrap;
  font-size: clamp(46px, 10.5vw, 150px);
  line-height: 0.82;
}

.hero p:not(.eyebrow) {
  max-width: 650px;
  margin: 26px 0 0;
  color: #ded7df;
  font-size: clamp(18px, 2.6vw, 25px);
  line-height: 1.42;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.primary {
  background: var(--pink);
  border-color: var(--pink);
  color: #12060d;
  font-weight: 900;
}

.secondary {
  background: rgba(67, 227, 214, 0.1);
  border-color: rgba(67, 227, 214, 0.4);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero-key {
  display: grid;
  gap: 3px;
  align-content: center;
  min-width: 188px;
  min-height: 58px;
  padding: 9px 15px 10px;
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.05;
  text-align: left;
  text-transform: uppercase;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -2px 0 rgba(0, 0, 0, 0.62),
    0 5px 0 rgba(0, 0, 0, 0.82),
    0 14px 30px rgba(0, 0, 0, 0.38);
}

.hero-key span,
.hero-key small {
  display: block;
}

.hero-key span {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.hero-key small {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.07em;
  white-space: normal;
}

.hero-key.primary {
  color: #12060d;
  background:
    linear-gradient(180deg, rgba(255, 126, 194, 0.98), rgba(255, 79, 168, 0.96) 55%, rgba(172, 31, 104, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 5px);
  border-color: rgba(255, 115, 188, 0.95);
}

.hero-key.primary small {
  color: #260717;
}

.hero-key.secondary {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(47, 51, 61, 0.94), rgba(17, 20, 27, 0.96) 56%, rgba(7, 9, 13, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 5px);
  border-color: rgba(67, 227, 214, 0.48);
}

.hero-key.secondary small {
  color: var(--aqua);
}

.universe-fragment {
  position: relative;
  overflow: hidden;
  padding: clamp(86px, 9vw, 128px) clamp(18px, 6vw, 72px) clamp(64px, 8vw, 118px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(8, 9, 13, 0.22), rgba(8, 9, 13, 0.58) 48%, rgba(8, 9, 13, 0.78) 100%),
    linear-gradient(90deg, rgba(5, 6, 10, 0.9), rgba(5, 6, 10, 0.52) 44%, rgba(5, 6, 10, 0.02)),
    radial-gradient(circle at 74% 58%, rgba(182, 78, 255, 0.3), transparent 26%),
    radial-gradient(circle at 16% 76%, rgba(255, 79, 168, 0.11), transparent 28%),
    url("./assets/themachine.png") 86% 68% / cover no-repeat,
    #08090d;
}

.universe-fragment::before {
  content: "[ OK ] descending_to_THE_MACHINE.basement :: memory_trace active";
  position: absolute;
  top: 28px;
  right: clamp(18px, 6vw, 72px);
  color: rgba(67, 227, 214, 0.24);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.universe-fragment::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(115deg, transparent 0 42%, rgba(255, 79, 168, 0.12) 49%, transparent 56% 100%);
  background-size: 82px 82px;
  mask-image: radial-gradient(ellipse at 58% 45%, #000 14%, transparent 78%);
  opacity: 0.76;
}

.fragment-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
}

.fragment-lead {
  max-width: 830px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(28px, 3.8vw, 52px);
  font-weight: 800;
  line-height: 1.02;
}

.fragment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  gap: clamp(28px, 4.6vw, 64px);
  align-items: start;
  max-width: 1120px;
  margin-top: clamp(26px, 4vw, 46px);
}

.fragment-copy {
  display: grid;
  gap: 16px;
}

.fragment-copy p {
  margin: 0;
  color: rgba(232, 226, 236, 0.88);
  font-size: clamp(15px, 1.12vw, 17px);
  line-height: 1.62;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.52);
}

.fragment-copy-accent {
  padding-left: clamp(18px, 3vw, 32px);
  border-left: 1px solid rgba(67, 227, 214, 0.34);
}

.fragment-statement {
  color: var(--gold);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(17px, 1.55vw, 23px);
  font-weight: 800;
  line-height: 1.1;
}

.fragment-question {
  color: var(--ink);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(18px, 1.7vw, 25px);
  font-weight: 800;
  line-height: 1.14;
  max-width: 620px;
}

@keyframes labFlarePulse {
  0%,
  15%,
  100% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(0.45);
  }

  23% {
    opacity: 0.58;
    transform: translate3d(calc(-50% + 2px), calc(-50% - 1px), 0) scale(1);
  }

  28% {
    opacity: 0.22;
    transform: translate3d(calc(-50% - 1px), calc(-50% + 1px), 0) scale(0.72);
  }

  36% {
    opacity: 0.82;
    transform: translate3d(calc(-50% + 1px), calc(-50% + 2px), 0) scale(1.22);
  }

  48% {
    opacity: 0.08;
    transform: translate3d(-50%, -50%, 0) scale(0.52);
  }
}

.lab-bridge {
  position: relative;
  overflow: hidden;
  border-top: 1px solid rgba(67, 227, 214, 0.16);
  border-bottom: 1px solid rgba(255, 79, 168, 0.14);
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 79, 168, 0.12), transparent 34%),
    #05060a;
}

.lab-bridge::before,
.lab-bridge::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.lab-bridge::before {
  background:
    linear-gradient(180deg, #090a0f 0%, rgba(9, 10, 15, 0.54) 10%, transparent 28%, transparent 72%, rgba(9, 10, 15, 0.56) 90%, #090a0f 100%),
    linear-gradient(90deg, #090a0f 0%, rgba(9, 10, 15, 0.48) 8%, transparent 24%, transparent 76%, rgba(9, 10, 15, 0.5) 92%, #090a0f 100%);
}

.lab-bridge::after {
  background:
    radial-gradient(circle at 50% 25%, rgba(255, 79, 168, 0.14), transparent 34%),
    radial-gradient(circle at 50% 45%, rgba(67, 227, 214, 0.08), transparent 42%),
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: auto, auto, 100% 5px;
  mix-blend-mode: screen;
  opacity: 0.68;
}

.lab-flares {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  mix-blend-mode: screen;
}

.lab-flares span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--c);
  opacity: 0;
  filter: blur(0.2px);
  box-shadow:
    0 0 calc(var(--s) * 2.2) var(--c),
    0 0 calc(var(--s) * 5.2) color-mix(in srgb, var(--c), transparent 30%);
  transform: translate3d(-50%, -50%, 0) scale(0.6);
  animation: labFlarePulse var(--t) ease-in-out infinite;
  animation-delay: var(--d);
}

.lab-flares span::before,
.lab-flares span::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: calc(var(--s) * 8);
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--c), transparent);
  opacity: 0.55;
  transform: translate(-50%, -50%);
}

.lab-flares span::after {
  width: 1px;
  height: calc(var(--s) * 7);
}

.lab-bridge > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.96) brightness(0.84) contrast(1.04);
}

.lab-terminal {
  position: relative;
  z-index: 3;
  container-type: inline-size;
  width: min(960px, calc(100% - 12px));
  margin: clamp(26px, 5vw, 64px) auto;
  scroll-margin-top: 62px;
}

.terminal-monitor {
  --terminal-photo: url("./assets/mr-pink-crt.png");
  position: relative;
  aspect-ratio: 1;
  background: var(--terminal-photo) center / contain no-repeat;
  filter: drop-shadow(0 20px 26px rgba(0, 0, 0, 0.67));
}

.terminal-keyboard-effects,
.terminal-keypress {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.terminal-keypress {
  background: var(--terminal-photo) center / 100% 100% no-repeat;
  animation: terminal-keypress 150ms ease-out both;
}

@keyframes terminal-keypress {
  0%, 38% {
    background-position: 50% 3px;
    filter: brightness(0.62);
  }

  100% {
    background-position: center;
    filter: brightness(1);
  }
}

.mr-pink-chat {
  position: absolute;
  inset: 11.6% 25.8% 50.4% 24.6%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: clamp(7px, 1.3vw, 14px);
  border-radius: 6% / 8%;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(205, 235, 183, 0.045) 3px 4px),
    radial-gradient(ellipse at 50% 3%, rgba(25, 40, 28, 0.85), rgba(10, 16, 12, 0.94) 82%);
  box-shadow: 0 0 14px 5px rgba(10, 16, 12, 0.7), inset 0 0 14px #10180f;
}

@container (max-width: 700px) {
  .terminal-monitor {
    left: 50%;
    width: min(164%, 780px);
    transform: translateX(-50%);
  }
}

@container (max-width: 850px) {
  .mr-pink-chat .chat-header {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
  }

  .mr-pink-chat .chat-header h2 {
    font-size: clamp(15px, 4.2cqw, 24px);
  }

}

@container (max-width: 500px) {
  .mr-pink-chat .chat-prompts {
    display: none;
  }

  .mr-pink-chat .chat-notice {
    font-size: 10px;
  }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-header .eyebrow {
  display: none;
}

.chat-header h2 {
  margin: 0;
  font-size: clamp(24px, 2.5vw, 34px);
  line-height: 0.95;
}

.chat-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid rgba(67, 227, 214, 0.34);
  border-radius: 999px;
  color: var(--aqua);
  background: rgba(67, 227, 214, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 12px var(--aqua);
}

.chat-live[data-ready="false"]::before {
  background: var(--muted);
  box-shadow: none;
}

.chat-status {
  position: absolute;
  inset: 63.1% 14.1% 32.4% 13.2%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.4fr);
  align-items: center;
  margin: 0;
  padding: 0 0.7cqw;
  border-radius: 3px;
  background: radial-gradient(ellipse at 50% 45%, #51090e, #24080b 78%);
  box-shadow: inset 0 2px 7px #130406, inset 0 0 5px #6a171c;
  color: #ff7e78;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  text-transform: uppercase;
}

.chat-status > div {
  min-width: 0;
  border-right: 1px solid rgba(255, 112, 101, 0.17);
}

.chat-status dt {
  color: #f49992;
  font-size: clamp(6px, 0.95cqw, 10px);
  line-height: 1;
  letter-spacing: 0.06em;
}

.chat-status dd {
  margin: 2px 0 0;
  font-size: clamp(7px, 1.25cqw, 12px);
  line-height: 1;
  font-weight: 800;
  text-shadow: 0 0 5px #ff443d;
}

.chat-status .connection-timer-status {
  border: 0;
}

.connection-timer-status svg {
  display: block;
  width: clamp(29px, 5.8cqw, 61px);
  height: auto;
  margin: 0 auto;
  overflow: visible;
  fill: none;
  stroke: #ffb2a7;
  stroke-width: 2.1;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2px #ff3939) drop-shadow(0 0 3px #ff3939);
}

.connection-window-status[data-state="unstable"] dd,
.connection-window-status[data-state="detected"] dd {
  color: #ffe1b6;
}

@container (max-width: 610px) {
  .chat-status {
    inset-inline: 20.8%;
  }
}

.chat-prompts button,
.chat-form input,
.chat-form button,
.chat-message span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.chat-log {
  position: relative;
  display: grid;
  gap: 10px;
  align-content: start;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  scrollbar-color: rgba(255, 79, 168, 0.56) rgba(255, 255, 255, 0.08);
}

.chat-message {
  display: grid;
  gap: 5px;
  width: fit-content;
  max-width: min(94%, 56ch);
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.chat-message.user {
  justify-self: end;
  border-color: rgba(255, 79, 168, 0.28);
  background: rgba(255, 79, 168, 0.12);
}

.chat-message.pink {
  justify-self: start;
  border-color: rgba(67, 227, 214, 0.28);
  background: rgba(6, 18, 24, 0.66);
}

.terminal-prompt {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid rgba(67, 227, 214, 0.28);
  border-radius: 8px;
  background: rgba(0, 10, 13, 0.66);
  box-shadow: inset 0 0 18px rgba(67, 227, 214, 0.06);
  color: var(--aqua);
  font-family: "Space Mono", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.terminal-prompt i {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--aqua);
  box-shadow: 0 0 12px rgba(67, 227, 214, 0.7);
  animation: terminalBlink 0.85s steps(2, start) infinite;
}

.terminal-prompt.thinking span::after {
  content: " receiving signal";
  color: var(--gold);
}

.chat-message span {
  color: var(--aqua);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-message.user span {
  color: var(--gold);
}

.chat-message p {
  margin: 0;
  color: rgba(245, 240, 234, 0.88);
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.chat-message.is-writing p::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  border-radius: 999px;
  background: rgba(245, 240, 234, 0.88);
  vertical-align: -0.12em;
  animation: chatCursorBlink 0.92s ease-in-out infinite;
}

.typing-indicator {
  width: fit-content;
}

.typing-indicator p {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(245, 240, 234, 0.72);
}

.typing-indicator i {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-style: normal;
}

.typing-indicator b {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(67, 227, 214, 0.78);
  animation: chatTypingDot 1.15s ease-in-out infinite;
}

.typing-indicator b:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-indicator b:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes terminalBlink {
  0%,
  45% {
    opacity: 1;
  }

  46%,
  100% {
    opacity: 0;
  }
}

@keyframes chatCursorBlink {
  0%,
  52% {
    opacity: 1;
  }

  53%,
  100% {
    opacity: 0;
  }
}

@keyframes chatTypingDot {
  0%,
  60%,
  100% {
    opacity: 0.34;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-prompts button {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(67, 227, 214, 0.26);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(67, 227, 214, 0.08);
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-prompts button:disabled,
.chat-form input:disabled,
.chat-form button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.reopen-connection {
  min-height: 40px;
  border: 1px solid rgba(67, 227, 214, 0.46);
  border-radius: 6px;
  color: var(--aqua);
  background: rgba(67, 227, 214, 0.08);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reopen-connection:hover {
  border-color: rgba(67, 227, 214, 0.78);
  background: rgba(67, 227, 214, 0.14);
}

.chat-form input,
.chat-form button {
  min-height: 40px;
  border-radius: 6px;
}

.chat-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--ink);
  background: rgba(5, 6, 10, 0.64);
  padding: 0 12px;
  outline: none;
}

.chat-form input:focus {
  border-color: rgba(67, 227, 214, 0.62);
  box-shadow: 0 0 0 3px rgba(67, 227, 214, 0.12);
}

.chat-form button {
  border: 1px solid rgba(255, 79, 168, 0.72);
  color: #15070f;
  background: var(--pink);
  padding: 0 13px;
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
}

.site-footer {
  position: relative;
  overflow: hidden;
  --footer-content-width: min(100%, 1360px);
  padding: clamp(38px, 5vw, 64px) clamp(16px, 3.6vw, 48px) 24px;
  border-top: 1px solid rgba(67, 227, 214, 0.18);
  background:
    linear-gradient(180deg, rgba(8, 9, 13, 0.92), rgba(5, 6, 10, 0.98)),
    radial-gradient(circle at 14% 18%, rgba(255, 79, 168, 0.12), transparent 28%),
    radial-gradient(circle at 82% 72%, rgba(67, 227, 214, 0.1), transparent 30%),
    #05060a;
}

.site-footer::before {
  content: "[ END_OF_MAP ] saving listener.session :: legacy_trace complete";
  position: absolute;
  top: 18px;
  right: clamp(18px, 5vw, 56px);
  color: rgba(67, 227, 214, 0.22);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.site-footer::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 62px 62px;
  mask-image: linear-gradient(180deg, #000, transparent 78%);
  opacity: 0.72;
}

.footer-grid,
.footer-bottom {
  position: relative;
  z-index: 1;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row;
  gap: clamp(14px, 1.7vw, 20px);
  align-items: stretch;
  width: var(--footer-content-width);
  margin: 0 auto;
}

.footer-brand,
.footer-disclaimer {
  grid-column: 1 / -1;
}

.footer-brand,
.footer-panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(12, 14, 20, 0.68);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.26);
}

.footer-brand {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: clamp(16px, 2vw, 22px);
}

.footer-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 223, 236, 0.52);
  border-radius: 50%;
  background: #050509;
  box-shadow: 0 0 22px rgba(255, 79, 168, 0.18);
}

.footer-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2.55);
}

.footer-brand h2,
.footer-panel h3 {
  margin: 0;
  line-height: 1;
}

.footer-brand h2 {
  font-size: clamp(28px, 3vw, 42px);
}

.footer-brand p:not(.eyebrow),
.footer-panel p,
.footer-list {
  color: rgba(224, 218, 230, 0.78);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.footer-brand p:not(.eyebrow) {
  margin: 12px 0 0;
}

.footer-panel {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: clamp(16px, 2vw, 20px);
}

.footer-panel h3 {
  color: var(--ink);
  font-size: 18px;
}

.footer-subtitle {
  margin-top: 22px;
}

.footer-links {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.footer-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid rgba(67, 227, 214, 0.32);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.footer-links a::after {
  content: "↗";
  color: var(--aqua);
}

.footer-contact a {
  border-color: rgba(255, 79, 168, 0.32);
}

.footer-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
}

.footer-list li {
  display: grid;
  gap: 3px;
}

.footer-list li > span:first-child {
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.language-select {
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid #824365;
  border-radius: 6px;
  background: #131217;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.language-select:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}

.footer-disclaimer p {
  margin: 14px 0 0;
  max-width: 112ch;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 18px;
  width: var(--footer-content-width);
  margin-top: 18px;
  margin-right: auto;
  margin-left: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(224, 218, 230, 0.58);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.footer-bottom span {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .topbar {
    position: absolute;
  }

}

@media (max-width: 1100px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-brand,
  .footer-disclaimer {
    grid-column: 1 / -1;
  }

}

@media (max-width: 760px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-brand,
  .footer-disclaimer {
    grid-column: auto;
  }

  .footer-brand {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 14px;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand > span:last-child {
    overflow: hidden;
    max-width: 120px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .hero {
    min-height: 88svh;
    padding: 112px 16px 54px;
    background-position: 58% center;
  }

  h1 {
    font-size: clamp(44px, 16vw, 74px);
  }

  .hero p:not(.eyebrow) {
    max-width: 100%;
    font-size: 18px;
  }

  .nav-actions {
    gap: 6px;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .secondary {
    width: 100%;
  }

  .hero-key {
    min-width: 0;
    width: min(100%, 320px);
  }

  .universe-fragment {
    padding: 54px 16px 58px;
    background-position: 86% 68%;
  }

  .universe-fragment::before {
    left: 16px;
    right: auto;
    max-width: calc(100% - 32px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .fragment-lead {
    font-size: 28px;
    line-height: 1.06;
  }

  .fragment-layout {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 28px;
  }

  .fragment-copy {
    gap: 16px;
  }

  .fragment-copy-accent {
    padding-left: 14px;
  }

  .site-footer {
    padding: 46px 16px 20px;
  }

  .site-footer::before {
    left: 16px;
    right: auto;
    max-width: calc(100% - 32px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-brand,
  .footer-disclaimer {
    grid-column: auto;
  }

  .footer-brand {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
  }

  .footer-mark {
    width: 46px;
    height: 46px;
  }

  .footer-bottom {
    flex-direction: column;
  }

  .chat-header {
    flex-wrap: wrap;
  }

  .chat-form input {
    font-size: 16px;
  }

  .chat-form input,
  .chat-form button {
    min-height: 44px;
  }

}

.story-reader {
  width: min(960px, 100% - 32px);
  margin: 0 auto;
  padding: clamp(48px, 8vw, 96px) 0;
  scroll-margin-top: 60px;
}

.story-reader .eyebrow {
  color: var(--pink);
}

.story-reader h2 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
}

.reader-intro {
  margin: 14px 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.volume-picker,
.chapter-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.volume-picker button,
.chapter-navigation button,
.chapter-index select {
  min-width: 0;
  border: 1px solid #74425c;
  border-radius: 6px;
  background: #161119;
  color: var(--ink);
  font: inherit;
}

.volume-picker button,
.chapter-navigation button {
  display: grid;
  gap: 6px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.volume-picker button[aria-pressed="true"],
.chapter-navigation .volume-transition {
  border-color: var(--pink);
  background: #321629;
}

.volume-picker span,
.chapter-navigation button {
  color: #ffadd7;
  font-size: 13px;
}

.volume-picker strong {
  font-size: clamp(16px, 3vw, 22px);
}

.volume-picker small {
  color: var(--muted);
  line-height: 1.4;
}

.chapter-card {
  margin-top: 16px;
  padding: clamp(16px, 4vw, 32px);
  border: 1px solid #74425c;
  border-radius: 8px;
  background: #100e15;
}

.chapter-index {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
}

.chapter-index select {
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  font-size: 16px;
}

#chapterTitle {
  margin: 0;
  font-size: clamp(26px, 5vw, 44px);
  line-height: 1.1;
  scroll-margin-top: 80px;
}

#chapterText {
  max-width: 67ch;
  font-size: clamp(16px, 2vw, 18px);
  line-height: 1.65;
}

.chapter-navigation {
  margin-top: 24px;
}

.chapter-navigation button {
  min-height: 54px;
}

.chapter-navigation strong {
  color: var(--ink);
  font-size: 14px;
}

.chapter-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 18px;
}

.chapter-links a {
  color: #ffadd7;
}

.story-reader :focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}

.chat-notice {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
