:root {
  color-scheme: dark;
  --bg: #15100e;
  --surface: #1f1714;
  --ink: #f3e6d8;
  --muted: #c4ad98;
  --accent: #ff8a3d;
  --accent-ink: #1b0d05;
  --line: #3a2a22;
  --focus: #ffd08a;

  --ol: #0c0705;
  --rock: #2b1e18;
  --rock-dark: #1b1310;
  --rock-rim: #c2541e;
  --floor: #201612;
  --floor-line: #3d2a1f;
  --lava: #ff6a1f;
  --lava-hot: #ffb347;
  --lava-core: #fff0bf;
  --ember: #ffb056;
  --spark: #ffd27a;
  --steam: rgba(240, 228, 214, 0.55);
  --smoke: #3a2e29;
  --shadow: rgba(0, 0, 0, 0.45);
  --rim: #ff9a4a;
  --rim-cool: #8cc4e2;

  --skin: #d9926e;
  --cheek: #e06a4e;
  --beard: #efe4d4;
  --beard-shade: #b5a38c;
  --boot: #2b1d16;
  --pants: #3b2c25;
  --leather: #7a4a2c;
  --leather-dark: #4e2d1a;
  --cap1: #c2361f;
  --cap2: #93281e;
  --cap3: #b04a1e;
  --coat1: #3f4b53;
  --coat2: #4d4136;
  --coat3: #5c3b2b;
  --mitt1: #6b4a32;
  --mitt2: #57463b;

  --steel: #5f6064;
  --steel-dark: #37383c;
  --wood: #7a4e30;
  --wood-dark: #4f301c;
  --pcb: #2f6a4c;
  --chip: #2a2624;
  --cable: #2f2c2c;
  --led: #7be08f;
  --brass: #d9a441;

  --device: #24211f;
  --screen: #eef1f2;
  --ui-ink: #2c3236;
  --ui-line: #c6cfd5;
  --ui-a: #f0a25a;
  --ui-b: #7fb7a8;
  --ui-c: #a9bccc;
  --accent-ui: #e0662a;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-sine: cubic-bezier(0.37, 0, 0.63, 1);
  --ease-quad: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-in-circ: cubic-bezier(0.55, 0, 1, 0.45);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background:
    radial-gradient(120% 70% at 18% 100%, rgba(255, 106, 31, 0.16), transparent 60%),
    radial-gradient(80% 60% at 85% 0%, rgba(140, 196, 226, 0.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.site-header,
.site-footer {
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand svg {
  width: 26px;
  height: 26px;
  flex: none;
}

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 14px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  text-decoration: none;
}

.footer-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
}

@media (hover: hover) and (pointer: fine) {
  .header-link,
  .footer-nav a {
    transition: color 160ms ease;
  }

  .header-link:hover,
  .footer-nav a:hover {
    color: var(--ink);
    text-decoration: underline;
  }

  .contact a {
    transition: background-color 160ms ease, box-shadow 160ms ease;
  }

  .contact a:hover {
    background: #ffa05c;
    box-shadow: 0 0 0 1px rgba(255, 210, 150, 0.35) inset, 0 8px 28px -8px rgba(255, 106, 31, 0.75);
  }
}

.page-home {
  display: block;
  min-height: 100svh;
}

.hero {
  position: relative;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  margin: 0;
}

.scene svg {
  display: block;
  width: 100%;
  height: 100%;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(12, 8, 6, 0.84) 0%, rgba(12, 8, 6, 0.6) 20%, rgba(12, 8, 6, 0) 42%);
}

.overlay {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: end;
  gap: 12px 48px;
  padding: clamp(4px, 1.5svh, 20px) var(--gutter) 0;
  max-width: 1320px;
  width: 100%;
  margin-inline: auto;
}

.intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 1.1rem + 2.6vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}

.intro h1 em {
  font-style: italic;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(255, 106, 31, 0.4), 0 2px 14px rgba(0, 0, 0, 0.6);
}

.lede {
  margin: 0 0 12px;
  max-width: 46ch;
  color: var(--muted);
  font-size: 1.02rem;
  text-wrap: pretty;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

.contact {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.contact a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 0 0 1px rgba(255, 210, 150, 0.25) inset, 0 6px 22px -8px rgba(255, 106, 31, 0.6);
  touch-action: manipulation;
  transition: transform 160ms var(--ease-out);
}

.contact a:active {
  transform: scale(0.97);
}

.contact span {
  color: var(--muted);
  font-size: 0.92rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.site-footer.stone-footer {
  margin-top: auto;
  justify-content: center;
  gap: 4px 28px;
  border-top: 0;
  padding-top: 8px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  color: #e6d3be;
  font-family: var(--serif);
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.9), 0 -1px 0 rgba(255, 190, 130, 0.12);
}

.stone-footer .footer-nav a {
  color: #f1dfca;
}

@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .hero {
    height: auto;
    min-height: 0;
  }

  .scene {
    position: relative;
  }

  .scene svg {
    height: auto;
  }

  .overlay {
    position: absolute;
    inset: 0;
    height: auto;
  }

  .intro {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .lede {
    margin-top: 2px;
  }

  .site-footer.stone-footer {
    font-size: 0.8rem;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

.scene.is-stacked .stage-right {
  transform: translate(-600px, 440px);
}

.scene.is-stacked .stone-layer {
  transform: translate(0, 440px);
}

.scene svg * {
  transform-box: view-box;
  transform-origin: 0 0;
}

.traveler {
  display: none;
}

.puff,
.sweat,
.splash {
  opacity: 0;
}

.splash {
  transition: opacity 120ms ease;
}

.ember {
  opacity: 0.8;
}

.smoke {
  fill: var(--smoke);
  opacity: 0.25;
}

.quench-steam,
.rack-steam {
  opacity: 0.45;
}

.shimmer {
  opacity: 0.18;
}

@media (prefers-reduced-motion: no-preference) {
  .in {
    animation: rise 700ms var(--ease-out) var(--d, 0ms) both;
  }

  .pop {
    animation: pop 650ms var(--ease-out) var(--d, 0ms) both;
  }

  .traveler {
    display: inline;
  }

  .mech-static {
    display: none;
  }

  .train {
    animation: spin 6s linear infinite;
  }

  .mech {
    animation: spin 20s linear infinite;
  }

  .tspin {
    animation: spin 0.7s linear infinite;
  }

  .bob {
    animation: breathe 1.4s var(--ease-sine) infinite alternate;
  }

  .gn-smith .bob,
  .gn-painter.scripted .bob {
    animation: none;
  }

  .gn-painter.walking .leg {
    animation: step 0.34s var(--ease-sine) infinite alternate;
  }

  .gn-painter.walking .leg-r {
    animation-delay: -0.34s;
  }

  .beard {
    animation: beard 1.4s var(--ease-sine) -0.3s infinite alternate;
  }

  .cap-sway {
    animation: sway 1.8s var(--ease-sine) infinite alternate;
  }

  .gn-pump .sweat {
    animation: sweat 2.4s var(--ease-out) infinite;
  }

  .gn-smith .sweat {
    animation: sweat 3.2s var(--ease-out) -1.1s infinite;
  }

  .gn-painter .sweat {
    animation: sweat 4.2s var(--ease-out) -2s infinite;
  }

  .quench-steam {
    animation: steam 3.2s var(--ease-out) infinite;
  }

  .rack-shake {
    animation: rattle 0.14s linear infinite;
  }

  .fan {
    animation: spin 0.32s linear infinite;
  }

  .fan-glow {
    animation: glow 0.6s var(--ease-sine) infinite alternate;
  }

  .led-fast {
    animation: blink 0.22s steps(1, end) infinite;
  }

  .needle {
    animation: needle 1.1s var(--ease-sine) infinite;
  }

  .rack-steam {
    animation: steam 1.6s var(--ease-out) infinite;
  }

  .rack-steam-2 {
    animation-delay: -0.8s;
  }

  .shimmer path {
    animation: shimmer 1.4s linear infinite;
  }

  .shimmer .shimmer-2 {
    animation-delay: -0.7s;
  }

  .shimmer {
    opacity: 1;
  }

  .caret {
    animation: blink 1.1s steps(1, end) infinite;
  }

  .ember {
    animation-name: ember;
    animation-timing-function: var(--ease-out);
    animation-iteration-count: infinite;
  }

  .smoke {
    animation: smoke 3.6s var(--ease-out) infinite;
  }

  .crack {
    animation: crack 1.6s var(--ease-sine) infinite alternate;
  }

  .flicker {
    animation: crack 1.3s var(--ease-sine) infinite alternate;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes pop {
  0% { opacity: 0; transform: translateY(14px) scale(0.9); }
  60% { opacity: 1; transform: translateY(-3px) scale(1.03); }
  100% { opacity: 1; transform: none; }
}

@keyframes install {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

@keyframes breathe {
  to { transform: translateY(-2px); }
}

@keyframes beard {
  to { transform: translateY(1.2px); }
}

@keyframes sway {
  from { transform: rotate(-3deg); }
  to { transform: rotate(3.5deg); }
}

@keyframes sweat {
  0%, 70% { opacity: 0; transform: translateY(0); }
  76% { opacity: 0.9; transform: translateY(1px); }
  100% { opacity: 0; transform: translateY(9px); }
}

@keyframes steam {
  0% { opacity: 0; transform: translate(0, 0) scale(0.5); }
  18% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(6px, -40px) scale(1.9); }
}

@keyframes step {
  from { transform: rotate(-12deg); }
  to { transform: rotate(12deg); }
}

@keyframes rattle {
  0%, 100% { transform: none; }
  25% { transform: translate(-0.9px, 0.5px); }
  50% { transform: translate(0.8px, -0.6px); }
  75% { transform: translate(-0.5px, -0.4px); }
}

@keyframes glow {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

@keyframes needle {
  0%, 100% { transform: rotate(46deg); }
  18% { transform: rotate(64deg); }
  34% { transform: rotate(52deg); }
  52% { transform: rotate(72deg); }
  70% { transform: rotate(57deg); }
  86% { transform: rotate(68deg); }
}

@keyframes shimmer {
  0% { opacity: 0; transform: translateY(0); }
  40% { opacity: 0.35; }
  100% { opacity: 0; transform: translateY(-18px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

@keyframes ember {
  0% { opacity: 0; transform: translate(0, 0); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0px), -170px); }
}

@keyframes smoke {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  20% { opacity: 0.35; }
  100% { opacity: 0; transform: translate(10px, -110px) scale(1.8); }
}

@keyframes crack {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.doc {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding: clamp(16px, 5svh, 56px) var(--gutter) 56px;
}

.doc h1 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 1.5rem + 2vw, 2.8rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.doc .updated {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 0.92rem;
}

.doc h2 {
  margin: 36px 0 8px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.25;
}

.doc h3 {
  margin: 24px 0 6px;
  font-size: 1.02rem;
  font-weight: 600;
}

.doc p,
.doc li {
  max-width: 68ch;
  text-wrap: pretty;
}

.doc p {
  margin: 0 0 14px;
}

.doc ul {
  margin: 0 0 14px;
  padding-left: 1.25em;
}

.doc li {
  margin-bottom: 6px;
}

.doc li::marker {
  color: var(--accent);
}

.doc a {
  color: var(--accent);
}

.doc .callout {
  margin: 0 0 28px;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px -18px rgba(255, 106, 31, 0.45);
}

.doc .callout p:last-child {
  margin-bottom: 0;
}

.lost {
  text-align: left;
}

.lost-gear {
  display: block;
  width: 72px;
  height: 72px;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 18px rgba(255, 106, 31, 0.35));
}

@media (prefers-reduced-motion: no-preference) {
  .lost-gear {
    animation: wobble 2.4s var(--ease-sine) infinite alternate;
  }
}

@keyframes wobble {
  from { transform: rotate(-14deg); }
  to { transform: rotate(10deg); }
}
