@font-face {
  font-family: "Atelier Sans";
  src: url("assets/fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-alt: #eae3d7;
  --text: #211d18;
  --text-soft: #575047;
  --muted: #746c61;
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --line-strong: color-mix(in srgb, var(--text) 20%, transparent);
  --accent: #a8463c;
  --accent-hover: #813129;
  --accent-soft: #f0d8d1;
  --on-accent: #fffaf4;
  --logo-tile: #f6eee3;
  --logo-line: rgba(33, 29, 24, 0.13);
  --logo-filter: none;
  --header: rgba(255, 253, 248, 0.88);
  --shadow-sm: 0 12px 32px rgba(83, 66, 43, 0.07), 0 3px 10px rgba(83, 66, 43, 0.04);
  --font-sans: "Atelier Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --page: min(100% - 48px, 1240px);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110e;
  --surface: #1c1814;
  --surface-alt: #27211b;
  --text: #f6f0e6;
  --text-soft: #d0c7ba;
  --muted: #a99e90;
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --line-strong: color-mix(in srgb, var(--text) 22%, transparent);
  --accent: #e77a6f;
  --accent-hover: #f29a90;
  --accent-soft: #492b27;
  --on-accent: #1b1310;
  --logo-tile: #221d19;
  --logo-line: rgba(246, 240, 230, 0.15);
  --logo-filter: brightness(1.85) saturate(0.8) contrast(1.05);
  --header: rgba(28, 24, 20, 0.9);
  --shadow-sm: 0 12px 34px rgba(3, 2, 1, 0.18), 0 3px 11px rgba(3, 2, 1, 0.12);
}

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

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 430;
  line-height: 1.62;
  font-optical-sizing: auto;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

* {
  scrollbar-color: var(--accent) var(--surface-alt);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--surface-alt);
}

::-webkit-scrollbar-thumb {
  border: 3px solid var(--surface-alt);
  border-radius: 999px;
  background: var(--accent);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  transform: translateY(-180%);
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.compact-header {
  position: sticky;
  top: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 32px, 1280px);
  min-height: 64px;
  margin: 16px auto 0;
  padding: 8px 10px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--header);
  box-shadow: var(--shadow-sm), inset 0 1px 0 color-mix(in srgb, var(--text) 7%, transparent);
  backdrop-filter: blur(22px) saturate(145%);
}

.compact-wordmark {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  padding-right: 12px;
  border-radius: 17px;
  text-decoration: none;
}

.compact-wordmark img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--logo-line);
  border-radius: 16px;
  background: var(--logo-tile);
  filter: var(--logo-filter);
  object-fit: contain;
  transform: scale(1.08);
}

.compact-wordmark span {
  display: grid;
  line-height: 1.15;
}

.compact-wordmark strong {
  font-size: 0.96rem;
}

.compact-wordmark small {
  color: var(--muted);
  font-size: 0.72rem;
}

.compact-nav {
  display: flex;
  gap: 4px;
}

.compact-nav a {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 680;
  text-decoration: none;
}

.compact-nav a[aria-current="page"] {
  background: var(--surface-alt);
  color: var(--text);
}

.document-page,
.error-page {
  width: var(--page);
  margin: 0 auto;
}

.document-page {
  padding: clamp(92px, 11vw, 154px) 0 clamp(88px, 10vw, 136px);
}

.document-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: clamp(40px, 7vw, 112px);
  align-items: end;
  padding-bottom: clamp(72px, 9vw, 122px);
}

.document-hero h1,
.error-page h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(3.6rem, 7.2vw, 6rem);
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 0.94;
  text-wrap: balance;
}

.document-hero p,
.error-copy {
  max-width: 43ch;
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(1.08rem, 1.4vw, 1.24rem);
}

.source-ledger {
  border-top: 1px solid var(--line-strong);
}

.source-section {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: clamp(38px, 6vw, 92px);
  padding: clamp(48px, 6vw, 82px) 0;
  border-bottom: 1px solid var(--line);
}

.source-section h2 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.85rem);
  font-weight: 640;
  letter-spacing: -0.028em;
  line-height: 1.02;
  text-wrap: balance;
}

.source-stack {
  display: grid;
  gap: 0;
  min-width: 0;
}

.source-entry {
  scroll-margin-top: 104px;
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1fr);
  gap: 30px;
  padding: 0 0 28px;
}

.source-entry + .source-entry {
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.source-entry:last-child {
  padding-bottom: 0;
}

.source-entry h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.source-entry p,
.source-entry ul,
.source-entry dl {
  margin: 0;
  color: var(--text-soft);
}

.source-entry ul {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.source-entry li {
  overflow-wrap: anywhere;
}

.source-entry code {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.source-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  width: fit-content;
  margin-top: 16px;
  color: var(--accent-hover);
  font-weight: 700;
  text-underline-offset: 4px;
}

.facts-list {
  display: grid;
  gap: 14px;
}

.facts-list div {
  display: grid;
  grid-template-columns: minmax(130px, 0.42fr) minmax(0, 1fr);
  gap: 24px;
}

.facts-list dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.facts-list dd {
  margin: 0;
}

.error-page {
  display: grid;
  min-height: calc(100dvh - 174px);
  grid-template-columns: minmax(0, 1.28fr) minmax(260px, 0.72fr);
  gap: clamp(46px, 8vw, 130px);
  align-items: center;
  padding: clamp(76px, 10vw, 132px) 0;
}

.error-copy-wrap {
  display: grid;
  gap: 28px;
}

.error-mark {
  position: relative;
  isolation: isolate;
  display: grid;
  overflow: hidden;
  min-height: 290px;
  place-items: center;
  border-radius: 34px;
  background: var(--surface-alt);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 8%, transparent);
}

.error-mark span {
  position: relative;
  z-index: 1;
  animation: error-code-settle 520ms var(--ease-out) 480ms both;
}

.error-route {
  position: absolute;
  inset: 20px;
  width: calc(100% - 40px);
  height: calc(100% - 40px);
  pointer-events: none;
}

.error-route-base,
.error-route-stop {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.error-route-base {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.error-route-node {
  fill: var(--accent);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: error-node-arrive 240ms var(--ease-out) both;
}

.error-route-node--1 { animation-delay: 160ms; }
.error-route-node--2 { animation-delay: 320ms; }
.error-route-node--3 { animation-delay: 480ms; }
.error-route-node--4 { animation-delay: 640ms; }

.error-route-stop {
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0;
  animation: error-stop-appear 240ms var(--ease-out) 680ms both;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.page-action {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 180ms var(--ease-out), background-color 180ms var(--ease-out), transform 160ms var(--ease-out);
}

.page-action--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.compact-footer {
  display: flex;
  justify-content: space-between;
  width: var(--page);
  min-height: 110px;
  align-items: center;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.compact-footer p {
  margin: 0;
}

.compact-footer a {
  min-height: 44px;
  align-content: center;
  color: var(--text);
  font-weight: 700;
  text-underline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .compact-nav a,
  .compact-wordmark,
  .source-link,
  .compact-footer a {
    transition: color 180ms var(--ease-out), background-color 180ms var(--ease-out), transform 180ms var(--ease-out);
  }

  .compact-nav a:hover,
  .compact-wordmark:hover,
  .page-action:not(.page-action--primary):hover {
    background: var(--surface-alt);
  }

  .page-action--primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
  }

  .source-link:hover,
  .compact-footer a:hover {
    color: var(--accent-hover);
  }
}

@media (hover: none) and (pointer: coarse) {
  .page-action:active {
    transform: scale(0.97);
    transition-duration: 160ms;
  }
}

.page-action:focus-visible:active {
  transform: none;
}

@keyframes error-node-arrive {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes error-code-settle {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes error-stop-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 820px) {
  .document-hero,
  .source-section,
  .error-page {
    grid-template-columns: 1fr;
  }

  .document-hero {
    align-items: start;
  }

  .document-hero p {
    max-width: 58ch;
  }

  .source-section h2 {
    max-width: 16ch;
  }

  .error-page {
    min-height: auto;
  }

  .error-mark {
    min-height: 220px;
    grid-row: 1;
  }

  .error-route {
    inset: 14px;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
  }
}

@media (max-width: 600px) {
  :root {
    --page: min(100% - 32px, 1240px);
  }

  body {
    font-size: 17px;
  }

  .compact-header {
    top: 10px;
    width: calc(100% - 20px);
    min-height: 60px;
    margin-top: 10px;
    border-radius: 21px;
  }

  .compact-wordmark img {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .compact-wordmark small {
    display: none;
  }

  .compact-nav a {
    padding: 0 12px;
  }

  .compact-nav a:first-child {
    display: none;
  }

  .document-page {
    padding-top: 82px;
  }

  .document-hero h1,
  .error-page h1 {
    font-size: clamp(3rem, 14vw, 4.4rem);
  }

  .source-entry,
  .facts-list div {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .page-actions {
    display: grid;
  }

  .page-action {
    width: 100%;
  }

  .compact-footer {
    display: grid;
    gap: 8px;
    align-content: center;
  }
}

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

  .page-action:active {
    transform: none !important;
  }

  .error-route-node,
  .error-mark span,
  .error-route-stop {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .compact-header {
    background: var(--surface);
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .compact-header,
  .page-action,
  .error-mark {
    border: 2px solid currentColor;
    box-shadow: none;
  }

  .error-route-base {
    stroke-width: 2;
  }

  .error-route-stop {
    stroke-width: 3;
  }
}

@media print {
  .skip-link,
  .compact-header,
  .page-actions,
  .compact-footer {
    display: none !important;
  }

  .document-page,
  .error-page {
    width: 100%;
    padding: 0;
  }
}
