:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111a2b;
  --recessed: #0e1626;
  --ink: #f2f5f9;
  --body: #c9d2df;
  --muted: #8d99ab;
  --rule: #223047;
  --teal: #2dd4bf;
  --teal-wash: #123c3a;
  --amber: #f5b04c;
  --amber-wash: #3a2b16;
  --focus: #7ee6d8;
  --button-ink: #071512;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --recessed: #eceff0;
  --ink: #131c21;
  --body: #33424a;
  --muted: #55666e;
  --rule: #d5dcd9;
  --teal: #0e7a6e;
  --teal-wash: #dcefeb;
  --amber: #8a5508;
  --amber-wash: #f5ead5;
  --focus: #0e7a6e;
  --button-ink: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--body);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.68;
  transition: background-color 260ms ease, color 260ms ease;
}

a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

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

.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.backdrop__hash {
  position: absolute;
  top: -0.22em;
  right: -0.12em;
  color: color-mix(in srgb, var(--rule) 44%, transparent);
  font-family: var(--mono);
  font-size: clamp(11rem, 31vw, 30rem);
  font-weight: 700;
  letter-spacing: -0.08em;
  line-height: 0.8;
  transform: rotate(-7deg);
  user-select: none;
}

.backdrop__hash--second {
  top: auto;
  right: auto;
  bottom: -0.18em;
  left: -0.22em;
  color: color-mix(in srgb, var(--rule) 34%, transparent);
  font-size: clamp(8rem, 23vw, 22rem);
  transform: rotate(4deg);
}

.backdrop__disc {
  position: absolute;
  display: block;
  border-radius: 50%;
  opacity: 0.72;
}

.backdrop__disc--teal {
  width: clamp(10rem, 24vw, 23rem);
  aspect-ratio: 1;
  right: -9rem;
  top: 42vh;
  background: var(--teal-wash);
}

.backdrop__disc--amber {
  width: clamp(7rem, 15vw, 15rem);
  aspect-ratio: 1;
  left: -6rem;
  top: 17vh;
  background: var(--amber-wash);
}

.utility {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2rem, 1020px);
  margin: 0 auto;
  padding: 1.2rem 0;
}

.wordmark {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
}

.wordmark span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
}

.theme-toggle,
.copy-button {
  appearance: none;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  color: var(--body);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.58rem 0.82rem;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, transform 180ms var(--ease);
}

.theme-toggle:hover {
  border-color: var(--teal);
  color: var(--ink);
}

main {
  position: relative;
  z-index: 1;
  width: min(100% - 2rem, 1020px);
  margin: clamp(1.5rem, 5vw, 4.8rem) auto clamp(3rem, 8vw, 7rem);
}

.packet {
  background: var(--panel);
  border: 1px solid var(--teal);
  border-radius: 4px;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--rule);
  overflow: clip;
}

.packet__hero,
.letter,
.truth,
.agenda,
.start,
.agent,
.return {
  padding: clamp(2rem, 6vw, 5.3rem);
}

.packet__hero {
  padding-bottom: clamp(2.5rem, 7vw, 5.5rem);
}

.kicker {
  margin-bottom: 1.5rem;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  text-wrap: balance;
}

h1 {
  max-width: 14ch;
  font-size: clamp(2.65rem, 8vw, 5.5rem);
  letter-spacing: -0.025em;
  line-height: 0.98;
}

h2 {
  max-width: 25ch;
  font-size: clamp(1.75rem, 4.3vw, 2.8rem);
  letter-spacing: -0.015em;
  line-height: 1.08;
}

.lede {
  max-width: 58ch;
  margin: 1.6rem 0 2.4rem;
  color: var(--body);
  font-size: clamp(1.05rem, 2.2vw, 1.28rem);
  line-height: 1.55;
  text-wrap: pretty;
}

.receipt {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--recessed);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.receipt div {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.78rem 1rem;
}

.receipt div + div {
  border-top: 1px solid var(--rule);
}

.receipt dt {
  color: var(--muted);
}

.receipt dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

code {
  font-family: var(--mono);
}

.status {
  display: inline-flex;
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.075em;
  line-height: 1.3;
  padding: 0.18rem 0.5rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.status--teal {
  background: var(--teal-wash);
  color: var(--teal);
}

.status--amber {
  background: var(--amber-wash);
  color: var(--amber);
}

.route {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--recessed);
  padding: 0 clamp(1rem, 5vw, 3rem);
}

.route ol {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 850px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.route li {
  min-width: 0;
}

.route li + li {
  border-left: 1px solid var(--rule);
}

.route a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 4rem;
  padding: 0.75rem 1rem;
  color: var(--body);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.35;
  text-decoration: none;
}

.route a:hover {
  background: var(--panel);
  color: var(--ink);
}

.route span {
  color: var(--teal);
  font-size: 0.62rem;
  font-weight: 750;
}

.letter,
.truth,
.agenda,
.start,
.agent,
.return {
  border-bottom: 1px solid var(--rule);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.letter__body {
  max-width: 68ch;
  margin-top: 2.1rem;
}

.letter__body p {
  margin: 0 0 1rem;
  text-wrap: pretty;
}

.letter__body p:first-child {
  color: var(--ink);
  font-weight: 650;
}

.signature {
  padding-top: 0.7rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
}

.truth {
  background: var(--recessed);
}

.architecture {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.15fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 0.65rem;
  margin-top: 2.4rem;
}

.architecture__node {
  display: flex;
  min-height: 7.5rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.35;
  padding: 1rem;
  text-align: center;
}

.architecture__node small {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--body);
  font-family: var(--mono);
  font-size: 0.64rem;
  line-height: 1.5;
}

.architecture__node--active {
  border-color: var(--teal);
  background: var(--teal-wash);
}

.architecture__arrow {
  align-self: center;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 750;
  transform: rotate(-90deg);
}

.change-ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.change-ledger section {
  padding: 1.35rem 1.4rem 1.35rem 0;
}

.change-ledger section + section {
  border-left: 1px solid var(--rule);
  padding-right: 0;
  padding-left: 1.4rem;
}

.change-ledger h3 {
  margin: 0 0 0.8rem;
  color: var(--teal);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
}

.change-ledger ul {
  margin: 0;
  padding-left: 1.15rem;
}

.change-ledger li + li {
  margin-top: 0.45rem;
}

.truth__rows {
  margin-top: 2.4rem;
  border-top: 1px solid var(--rule);
}

.truth__row {
  display: grid;
  grid-template-columns: minmax(12rem, 0.75fr) minmax(0, 1.6fr);
  gap: clamp(1.2rem, 4vw, 3.6rem);
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.truth__row strong {
  color: var(--teal);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
}

.truth__row p {
  max-width: 60ch;
  margin: 0;
  text-wrap: pretty;
}

.agenda {
  background: var(--panel);
}

.agenda__intro {
  max-width: 69ch;
  margin: 2rem 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.18rem, 2.2vw, 1.48rem);
  line-height: 1.48;
  text-wrap: pretty;
}

.agenda__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 2.25rem;
  border-top: 1px solid var(--rule);
}

.agenda__grid article {
  padding: 1.4rem 1.5rem 1.4rem 0;
  border-bottom: 1px solid var(--rule);
}

.agenda__grid article:nth-child(even) {
  border-left: 1px solid var(--rule);
  padding-right: 0;
  padding-left: 1.5rem;
}

.agenda__grid h3,
.lab-proof h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
}

.agenda__grid p,
.lab-proof p {
  margin: 0.65rem 0 0;
  font-size: 0.96rem;
  line-height: 1.58;
  text-wrap: pretty;
}

.research-plan {
  display: grid;
  grid-template-columns: minmax(11rem, 0.7fr) minmax(0, 1.65fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  margin-top: 2.25rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0;
}

.research-plan__label {
  margin-bottom: 0.55rem;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.research-plan h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
}

.research-plan ol {
  margin: 0;
  padding-left: 1.25rem;
}

.research-plan li + li {
  margin-top: 0.65rem;
}

.research-plan strong {
  color: var(--ink);
}

.lab-proof {
  margin-top: 2.25rem;
  border: 1px solid var(--teal);
  border-radius: 4px;
  background: var(--teal-wash);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.lab-proof__label {
  margin-bottom: 0.75rem;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.section-heading--agent {
  align-items: flex-end;
}

.section-heading--agent h2 {
  max-width: 21ch;
}

.section-intro {
  max-width: 58ch;
  margin: 1rem 0 0;
  text-wrap: pretty;
}

.command-block {
  max-height: none;
  margin: 2rem 0 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--recessed);
  color: var(--body);
}

.doc-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.doc-map > div {
  padding: 1rem 1.2rem 1rem 0;
}

.doc-map > div:nth-child(even) {
  border-left: 1px solid var(--rule);
  padding-right: 0;
  padding-left: 1.2rem;
}

.doc-map > div:nth-child(n + 3) {
  border-top: 1px solid var(--rule);
}

.doc-map code {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
}

.doc-map p {
  max-width: 44ch;
  margin: 0.35rem 0 0;
  font-size: 0.94rem;
  line-height: 1.55;
}

.section-heading--agent p {
  max-width: 54ch;
  margin: 1rem 0 0;
}

.copy-button {
  flex: 0 0 auto;
  border-color: var(--teal);
  background: var(--teal);
  color: var(--button-ink);
  padding: 0.72rem 1rem;
}

.copy-button:hover {
  transform: translateY(-1px);
}

.copy-button[data-state="copied"] {
  border-color: var(--teal);
  background: var(--teal-wash);
  color: var(--teal);
}

.copy-button[data-state="error"] {
  border-color: var(--amber);
  background: var(--amber-wash);
  color: var(--amber);
}

.prompt-preview {
  margin-top: 2rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--recessed);
}

.prompt-preview summary {
  cursor: pointer;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.9rem 1rem;
}

.prompt-preview[open] summary {
  border-bottom: 1px solid var(--rule);
}

pre {
  max-height: 34rem;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  color: var(--body);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.agent__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.return {
  background: var(--teal-wash);
}

.return h2 {
  max-width: 23ch;
}

.return > p {
  max-width: 62ch;
  margin: 1.25rem 0 0;
  color: var(--body);
  text-wrap: pretty;
}

.return__line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.5rem;
  margin-top: 2rem;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 650;
}

.return__line span::before {
  content: "✓";
  margin-right: 0.45rem;
}

.packet__footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.4rem);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.64rem;
  line-height: 1.5;
}

.toast {
  position: fixed;
  z-index: 5;
  right: 1rem;
  bottom: 1rem;
  max-width: min(22rem, calc(100vw - 2rem));
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.7rem 0.85rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition: opacity 180ms ease, transform 260ms var(--ease);
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .route {
    padding: 0;
  }

  .route ol {
    grid-template-columns: repeat(2, 1fr);
  }

  .route li + li {
    border-left: 0;
  }

  .route li:nth-child(even) {
    border-left: 1px solid var(--rule);
  }

  .route li:nth-child(n + 3) {
    border-top: 1px solid var(--rule);
  }

  .section-heading,
  .section-heading--agent {
    align-items: flex-start;
    flex-direction: column;
    gap: 1.25rem;
  }

  .truth__row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .research-plan {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

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

  .architecture__node {
    min-height: 0;
  }

  .architecture__arrow {
    justify-self: center;
    transform: none;
  }

  .copy-button {
    width: 100%;
  }

  .packet__footer {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .utility,
  main {
    width: min(100% - 1.2rem, 1020px);
  }

  .utility {
    padding: 0.8rem 0;
  }

  main {
    margin-top: 1rem;
  }

  .packet__hero,
  .letter,
  .truth,
  .agenda,
  .start,
  .agent,
  .return {
    padding: 1.5rem 1.15rem;
  }

  h1 {
    font-size: clamp(2.5rem, 15vw, 3.4rem);
  }

  .receipt div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .route ol {
    grid-template-columns: 1fr;
  }

  .route li:nth-child(even) {
    border-left: 0;
  }

  .route li + li {
    border-top: 1px solid var(--rule);
  }

  .route a {
    min-height: 3.25rem;
  }

  .status--amber {
    margin-top: 0.45rem;
  }

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

  .change-ledger,
  .agenda__grid,
  .doc-map {
    grid-template-columns: 1fr;
  }

  .change-ledger section,
  .change-ledger section + section,
  .agenda__grid article,
  .agenda__grid article:nth-child(even),
  .doc-map > div,
  .doc-map > div:nth-child(even) {
    padding-right: 0;
    padding-left: 0;
  }

  .change-ledger section + section,
  .agenda__grid article:nth-child(even),
  .doc-map > div:nth-child(even) {
    border-left: 0;
    border-top: 1px solid var(--rule);
  }

  .doc-map > div:nth-child(n + 2) {
    border-top: 1px solid var(--rule);
  }
}

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