:root {
  color-scheme: dark;
  --bg: #080b0f;
  --panel: #0d1217;
  --panel-raised: #121920;
  --ink: #f1eee7;
  --muted: #8f9aa3;
  --line: rgba(255, 255, 255, 0.11);
  --lime: #b8ff6a;
  --coral: #ff8f70;
  --blue: #7dc8ff;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, rgba(125, 200, 255, 0.12), transparent 34rem),
    radial-gradient(circle at 95% 5%, rgba(184, 255, 106, 0.08), transparent 28rem),
    var(--bg);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.22;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.11'/%3E%3C/svg%3E");
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1500px, calc(100% - 48px));
  min-height: 88px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(184, 255, 106, 0.44);
  border-radius: 50%;
  color: var(--lime);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: -0.04em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.topbar__actions {
  display: flex;
  gap: 22px;
  align-items: center;
}

.signal {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.signal i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 16px rgba(184, 255, 106, 0.68);
}

.button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.button--quiet {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.035);
}

kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.72fr);
  gap: 22px;
  width: min(1500px, calc(100% - 48px));
  margin: 24px auto 0;
}

.story-column {
  min-width: 0;
}

.scene-card,
.choice-panel,
.timeline-panel,
.inspector {
  border: 1px solid var(--line);
  background: rgba(13, 18, 23, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.23);
}

.scene-card {
  position: relative;
  display: grid;
  min-height: 430px;
  padding: clamp(28px, 5vw, 64px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  isolation: isolate;
}

.scene-card::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(110deg, rgba(8, 11, 15, 0.98) 0%, rgba(8, 11, 15, 0.84) 48%, rgba(8, 11, 15, 0.1) 100%),
    radial-gradient(circle at 83% 50%, rgba(125, 200, 255, 0.18), transparent 20rem);
  content: "";
}

.scene-card.is-advancing .relay {
  animation: relay-pulse 700ms ease;
}

.scene-card__copy {
  z-index: 2;
  align-self: center;
  max-width: 690px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--lime);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 650px;
  margin-bottom: 24px;
  font-size: clamp(40px, 6vw, 78px);
  font-weight: 560;
  letter-spacing: -0.065em;
  line-height: 0.94;
}

.scene-card__line {
  max-width: 630px;
  margin: 0;
  color: #c3c9cc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.55;
}

.scene-card__footer {
  z-index: 2;
  display: flex;
  align-self: end;
  justify-content: space-between;
  margin-top: 56px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fingerprint {
  display: inline-flex;
  gap: 7px;
}

.fingerprint code {
  color: var(--blue);
}

.orbital-view {
  position: absolute;
  top: 50%;
  right: -40px;
  width: min(42vw, 530px);
  aspect-ratio: 1;
  transform: translateY(-50%);
  opacity: 0.88;
}

.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(125, 200, 255, 0.19);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
}

.orbit--outer {
  width: 90%;
  height: 45%;
}

.orbit--inner {
  width: 66%;
  height: 66%;
  border-color: rgba(184, 255, 106, 0.12);
}

.relay {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%) rotate(17deg);
  filter: drop-shadow(0 0 32px rgba(125, 200, 255, 0.45));
}

.relay__core {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  transform: rotate(45deg);
  background: #162634;
}

.relay__wing {
  position: absolute;
  top: 14px;
  width: 66px;
  height: 16px;
  border: 1px solid rgba(125, 200, 255, 0.45);
  background:
    repeating-linear-gradient(90deg, rgba(125, 200, 255, 0.18) 0 8px, transparent 8px 11px),
    rgba(6, 17, 27, 0.9);
}

.relay__wing--left {
  right: 38px;
}

.relay__wing--right {
  left: 38px;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.star--one {
  top: 14%;
  left: 58%;
}

.star--two {
  right: 14%;
  bottom: 22%;
  opacity: 0.6;
}

.star--three {
  top: 60%;
  left: 22%;
  opacity: 0.4;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0;
}

.metric {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(13, 18, 23, 0.78);
}

.metric__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 13px;
}

.metric__header span {
  color: var(--muted);
  font-size: 12px;
}

.metric__header strong {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
  font-weight: 500;
}

.metric__track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.metric__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.metric__fill--trust {
  background: var(--lime);
}

.metric__fill--tension {
  background: var(--coral);
}

.metric__fill--valence {
  background: var(--blue);
}

.metric small {
  display: block;
  margin-top: 10px;
  color: #59636b;
  font-size: 10px;
}

.choice-panel,
.timeline-panel {
  margin-top: 12px;
  padding: clamp(24px, 4vw, 38px);
  border-radius: var(--radius-lg);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-heading h2,
.inspector h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 540;
  letter-spacing: -0.04em;
}

.section-heading__note {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.choice:hover:not(:disabled) {
  border-color: rgba(184, 255, 106, 0.42);
  background: rgba(184, 255, 106, 0.055);
  transform: translateY(-2px);
}

.choice:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.choice__copy strong,
.choice__copy small {
  display: block;
}

.choice__copy strong {
  font-size: 14px;
  font-weight: 560;
}

.choice__copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.choice__arrow {
  color: var(--lime);
  font-size: 18px;
}

.choice:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item,
.timeline__empty {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  min-height: 72px;
}

.timeline__index {
  position: relative;
  padding-top: 3px;
  color: #57616a;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.timeline__index::after {
  position: absolute;
  top: 23px;
  bottom: 0;
  left: 6px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline li:last-child .timeline__index::after {
  display: none;
}

.timeline__copy {
  padding-bottom: 22px;
}

.timeline__copy p,
.timeline__empty p {
  max-width: 700px;
  margin: 7px 0 0;
  color: #b4bdc2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.48;
}

.event-type {
  color: var(--blue);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.event-type--choice {
  color: var(--lime);
}

.inspector {
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.inspector__intro,
.inspector-section,
.trace,
.formula {
  padding: 26px;
  border-bottom: 1px solid var(--line);
}

.inspector__intro h2 {
  margin-bottom: 12px;
}

.inspector__intro > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.inspector-section__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.inspector-section__heading h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.inspector-section__heading span {
  color: #59636b;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.memory-list {
  display: grid;
  gap: 9px;
}

.memory-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.memory-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.memory-card__rank {
  color: var(--lime);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.memory-card__header strong {
  color: var(--blue);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 500;
}

.memory-card p {
  margin: 12px 0;
  color: #c6cdd0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  line-height: 1.45;
}

.memory-card__components {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.memory-card__components span {
  padding: 3px 6px;
  border-radius: 4px;
  color: #6f7a82;
  background: rgba(255, 255, 255, 0.035);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
}

.inspector-empty {
  margin: 0;
  color: #6f7a82;
  font-size: 12px;
  line-height: 1.55;
}

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

.plan-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: center;
}

.plan-item__index {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(255, 143, 112, 0.32);
  border-radius: 50%;
  color: var(--coral);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.plan-item__copy strong,
.plan-item__copy small {
  display: block;
}

.plan-item__copy strong {
  font-size: 12px;
  font-weight: 560;
}

.plan-item__copy small {
  margin-top: 3px;
  color: #657079;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
}

.trace {
  padding: 0;
}

.trace summary {
  display: flex;
  justify-content: space-between;
  padding: 20px 26px;
  color: #aeb7bc;
  font-size: 12px;
  list-style: none;
  cursor: pointer;
}

.trace summary::-webkit-details-marker {
  display: none;
}

.trace[open] summary span:last-child {
  transform: rotate(45deg);
}

.trace-list {
  display: grid;
  gap: 8px;
  padding: 0 26px 24px;
}

.trace-row {
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.trace-row__heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.trace-row__heading strong,
.trace-row__heading span {
  font-size: 10px;
}

.trace-row__heading span {
  color: var(--lime);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.trace-row.is-rejected .trace-row__heading span {
  color: var(--coral);
}

.trace-row small {
  display: block;
  margin-top: 5px;
  color: #626e76;
  font-size: 9px;
  line-height: 1.45;
}

.formula {
  border-bottom: 0;
  background: rgba(184, 255, 106, 0.035);
}

.formula span,
.formula code {
  display: block;
}

.formula span {
  margin-bottom: 7px;
  color: var(--lime);
  font-size: 9px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.formula code {
  color: #879299;
  font-size: 9px;
  line-height: 1.5;
  white-space: normal;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  width: min(1500px, calc(100% - 48px));
  margin: 48px auto 0;
  padding: 26px 0 38px;
  border-top: 1px solid var(--line);
  color: #667079;
  font-size: 11px;
}

.page-footer p {
  margin: 0;
}

.page-footer strong {
  color: #9da6ab;
  font-weight: 500;
}

@keyframes relay-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 32px rgba(125, 200, 255, 0.45));
  }
  45% {
    filter: drop-shadow(0 0 48px rgba(255, 143, 112, 0.95));
    transform: translate(-50%, -50%) rotate(22deg) scale(1.08);
  }
}

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

  .inspector {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    max-height: none;
  }

  .inspector__intro,
  .trace,
  .formula {
    grid-column: 1 / -1;
  }

  .inspector-section:nth-of-type(1) {
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 700px) {
  .topbar,
  .workspace,
  .page-footer {
    width: min(100% - 24px, 1500px);
  }

  .topbar {
    min-height: 74px;
  }

  .brand small,
  .signal,
  .button--quiet kbd {
    display: none;
  }

  .button--quiet {
    padding: 9px 12px;
    font-size: 11px;
  }

  .workspace {
    margin-top: 12px;
  }

  .scene-card {
    min-height: 500px;
    padding: 28px 22px;
  }

  .scene-card::before {
    background:
      linear-gradient(180deg, rgba(8, 11, 15, 0.15), rgba(8, 11, 15, 0.96) 50%),
      radial-gradient(circle at 70% 10%, rgba(125, 200, 255, 0.2), transparent 18rem);
  }

  .scene-card__copy {
    align-self: end;
  }

  h1 {
    margin-bottom: 18px;
    font-size: clamp(42px, 14vw, 65px);
  }

  .orbital-view {
    top: 8%;
    right: -10%;
    width: 85vw;
    transform: none;
  }

  .scene-card__footer {
    margin-top: 30px;
  }

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

  .choice-grid,
  .inspector {
    grid-template-columns: 1fr;
  }

  .choice:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .inspector__intro,
  .trace,
  .formula {
    grid-column: auto;
  }

  .inspector-section:nth-of-type(1) {
    border-right: 0;
  }

  .section-heading {
    align-items: start;
  }

  .section-heading__note {
    display: none;
  }

  .page-footer {
    display: grid;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
