/* ════════════════════════════════════════════════════════════════
   YOU ARE DOWNSTREAM — The Allied Paper Superfund Ledger
   Self-contained stylesheet (this page does not load /assets/site.css).
   Aesthetic: decaying industrial ledger — aged paper, water stains,
   chemical burns, iridescent oil sheens over polluted teal.
   ════════════════════════════════════════════════════════════════ */

:root {
  --ledger-paper: #e8dfc8;
  --paper-stain:  #cfc0a0;
  --sepia-ink:    #3a3026;
  --charcoal:     #1b1d1c;
  --pcb-teal:     #0f4a44;
  --pcb-teal-deep:#062e2b;
  --sick-yellow:  #c9b458;
  --antique-gold: #8f7a3d;
  --burn:         #6e4a2a;
  --warning-red:  #8c2f22;
  --bone:         #d8d2c0;
  --faded:        #9a917c;

  --serif: 'EB Garamond', Georgia, serif;
  --display: 'Playfair Display', Georgia, serif;
  --mono: 'DM Mono', 'Courier New', monospace;
  --typewriter: 'Special Elite', 'Courier New', monospace;

  --sheen: conic-gradient(from 180deg,
      rgba(15, 74, 68, 0.55), rgba(90, 60, 140, 0.35),
      rgba(40, 110, 70, 0.45), rgba(201, 180, 88, 0.25),
      rgba(15, 74, 68, 0.55));

  --noise: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22300%22 height=%22300%22%3E%3Cfilter id=%22n%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%220.9%22 numOctaves=%222%22 stitchTiles=%22stitch%22/%3E%3C/filter%3E%3Crect width=%22300%22 height=%22300%22 filter=%22url(%23n)%22 opacity=%220.5%22/%3E%3C/svg%3E');
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}

body {
  margin: 0;
  color: var(--bone);
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.65;
  background:
    linear-gradient(180deg,
      #23201a 0%,
      var(--charcoal) 12%,
      #14201e 34%,
      var(--pcb-teal-deep) 62%,
      #041d1b 84%,
      #020f0e 100%);
  overflow-x: hidden;
}

/* fine grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  background-image: var(--noise);
  background-size: 280px 280px;
  opacity: 0.07;
  mix-blend-mode: overlay;
}

::selection { background: var(--pcb-teal); color: var(--ledger-paper); }

a { color: var(--sick-yellow); }
a:hover { color: var(--ledger-paper); }

/* ───────────────────────── return link ───────────────────────── */
.return-link {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 60;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--faded);
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(154, 145, 124, 0.3);
  background: rgba(27, 29, 28, 0.6);
  backdrop-filter: blur(6px);
}
.return-link:hover { color: var(--sick-yellow); border-color: var(--antique-gold); }

/* ───────────────────── sediment-core rail ────────────────────── */
#sediment-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 66px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(143, 122, 61, 0.35);
  background: linear-gradient(180deg,
    #a89a78 0%, #8f8161 8%,
    #6e6248 18%, #4c4436 30%,
    #33352e 45%, #21322e 60%,
    #123430 75%, var(--pcb-teal-deep) 90%, #031513 100%);
  overflow: hidden;
}
#sediment-rail::after {
  content: "";
  position: absolute; inset: 0;
  background-image: var(--noise);
  background-size: 160px 160px;
  opacity: 0.25;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.rail-title {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-align: center;
  color: rgba(27, 29, 28, 0.8);
  padding: 0.7rem 0 0.4rem;
  position: relative;
  z-index: 2;
}
.rail-strata { flex: 1; display: flex; flex-direction: column; position: relative; z-index: 2; }
.rail-stratum {
  flex: 1;
  position: relative;
  border-top: 1px dashed rgba(232, 223, 200, 0.18);
  transition: background 0.6s ease;
}
.rail-stratum span {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(232, 223, 200, 0.5);
  white-space: nowrap;
  transition: color 0.5s ease;
}
.rail-stratum.active { background: rgba(201, 180, 88, 0.14); }
.rail-stratum.active span { color: var(--sick-yellow); }

.rail-marker {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  height: 2px;
  background: var(--sick-yellow);
  box-shadow: 0 0 8px rgba(201, 180, 88, 0.8);
  z-index: 3;
  transition: top 0.1s linear;
}
.rail-stains { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.rail-stain {
  position: absolute;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,
    rgba(15, 74, 68, 0.55), rgba(110, 74, 42, 0.35) 55%, transparent 72%);
  filter: blur(1px);
  animation: stain-bloom 2.4s ease forwards;
}
@keyframes stain-bloom {
  from { transform: scale(0.2); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.rail-burden {
  position: relative;
  z-index: 2;
  padding: 0.55rem 0.25rem 0.8rem;
  text-align: center;
  border-top: 1px solid rgba(232, 223, 200, 0.25);
  background: rgba(2, 15, 14, 0.55);
}
.rail-burden-label {
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--faded);
}
.rail-burden-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  color: var(--sick-yellow);
  margin: 0.15rem 0;
}
.rail-burden-unit {
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faded);
  line-height: 1.5;
}

/* mobile progress bar */
#rail-mobile {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 60;
  background: rgba(232, 223, 200, 0.12);
}
#rail-mobile-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--antique-gold), var(--sick-yellow), var(--pcb-teal));
}

/* ─────────────────────────── layout ──────────────────────────── */
#ledger { margin-left: 66px; }

section, #hero {
  padding: 6rem clamp(1.25rem, 6vw, 5.5rem);
  max-width: 1060px;
}

h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: 0.01em;
  color: var(--ledger-paper);
  margin: 0.4rem 0 1.6rem;
}
.stratum-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--antique-gold);
  border-bottom: 1px dashed rgba(143, 122, 61, 0.45);
  padding-bottom: 0.5rem;
}
.layer-lede {
  font-size: 1.22rem;
  max-width: 46em;
  color: var(--bone);
}
.layer-lede em { color: var(--sick-yellow); font-style: italic; }

/* ─────────────────────────── hero ────────────────────────────── */
#hero {
  position: relative;
  min-height: 100vh;
  max-width: none;
  display: flex;
  align-items: flex-end;
  padding-bottom: 5rem;
}
.hero-image {
  position: absolute; inset: 0;
  background-image: url('hero-downstream.jpg');
  background-size: cover;
  background-position: center 30%;
}
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(27,29,28,0.25) 0%, rgba(27,29,28,0.35) 45%, rgba(20,32,30,0.92) 88%, #14201e 100%),
    radial-gradient(90% 60% at 50% 100%, rgba(6,46,43,0.55), transparent 70%);
}
#molecule-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  mix-blend-mode: screen;
  opacity: 0.55;
}
.hero-content { position: relative; z-index: 2; max-width: 760px; }
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--sick-yellow);
  margin-bottom: 1.1rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(3rem, 9vw, 6rem);
  line-height: 0.98;
  letter-spacing: 0.01em;
  margin: 0 0 0.8rem;
  color: var(--ledger-paper);
  text-shadow: 0 2px 18px rgba(0,0,0,0.65);
}
.hero-dek {
  font-family: var(--mono);
  font-size: clamp(0.8rem, 1.6vw, 0.95rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone);
  margin-bottom: 1.4rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}
.hero-standfirst {
  font-size: 1.25rem;
  font-style: italic;
  max-width: 40em;
  color: var(--ledger-paper);
  text-shadow: 0 1px 8px rgba(0,0,0,0.8);
}
.cta {
  display: inline-block;
  margin-top: 1.2rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.24em;
  text-decoration: none;
  color: var(--charcoal);
  background: linear-gradient(180deg, var(--sick-yellow), var(--antique-gold));
  padding: 0.85rem 1.8rem;
  border: 1px solid rgba(232, 223, 200, 0.5);
  position: relative;
  overflow: hidden;
}
.cta::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--sheen);
  opacity: 0;
  transition: opacity 0.4s ease;
  mix-blend-mode: color-burn;
}
.cta:hover::after { opacity: 0.6; }
.cta:hover { color: #000; }
.hero-credit {
  margin-top: 1.6rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  color: rgba(216, 210, 192, 0.62);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.hero-scroll-hint {
  position: absolute;
  bottom: 1.4rem; left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: var(--sick-yellow);
  font-size: 1.3rem;
  animation: hint-bob 2.6s ease-in-out infinite;
}
@keyframes hint-bob {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.5; }
  50% { transform: translate(-50%, 8px); opacity: 1; }
}

/* ──────────────────── ledger paper panels ────────────────────── */
.ledger-book,
.document-figure,
.excavation-instrument,
.advisory-instrument,
.estimator-instrument,
.translator-instrument,
.oracle-instrument,
.timeline-instrument,
#palimpsest,
#notebook,
#ou-detail {
  position: relative;
  background:
    radial-gradient(60% 40% at 85% 8%, rgba(110, 74, 42, 0.28), transparent 70%),
    radial-gradient(45% 32% at 10% 92%, rgba(15, 74, 68, 0.22), transparent 70%),
    linear-gradient(180deg, var(--ledger-paper), #ddd2b4 60%, var(--paper-stain));
  color: var(--sepia-ink);
  padding: 2rem clamp(1.2rem, 4vw, 2.6rem);
  margin: 2.4rem 0;
  border: 1px solid rgba(58, 48, 38, 0.4);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
}
/* torn / burned bottom edge */
.ledger-book::after,
#body-receipt.printed::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -9px;
  height: 10px;
  background: inherit;
  -webkit-mask-image: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22120%22 height=%2210%22%3E%3Cpath d=%22M0 0 L7 9 L15 2 L24 8 L33 3 L41 10 L52 1 L60 7 L69 3 L78 9 L88 2 L97 8 L107 3 L114 9 L120 0 Z%22 fill=%22black%22/%3E%3C/svg%3E');
          mask-image: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22120%22 height=%2210%22%3E%3Cpath d=%22M0 0 L7 9 L15 2 L24 8 L33 3 L41 10 L52 1 L60 7 L69 3 L78 9 L88 2 L97 8 L107 3 L114 9 L120 0 Z%22 fill=%22black%22/%3E%3C/svg%3E');
  -webkit-mask-size: 120px 10px;
          mask-size: 120px 10px;
}
/* faint ruling lines, like a ledger */
.ledger-book {
  background-image:
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(58, 48, 38, 0.12) 27px 28px),
    radial-gradient(60% 40% at 85% 8%, rgba(110, 74, 42, 0.28), transparent 70%),
    radial-gradient(45% 32% at 10% 92%, rgba(15, 74, 68, 0.22), transparent 70%),
    linear-gradient(180deg, var(--ledger-paper), #ddd2b4 60%, var(--paper-stain));
}

.instrument-heading {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--burn);
  border-bottom: 1px solid rgba(110, 74, 42, 0.45);
  padding-bottom: 0.5rem;
  margin-bottom: 1.1rem;
}
.instrument-note {
  font-size: 1.02rem;
  font-style: italic;
  color: rgba(58, 48, 38, 0.8);
  max-width: 44em;
}
.noscript-note {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--faded);
}

/* ─────────────────── layer 1 · ledger entries ────────────────── */
.entry {
  position: relative;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 1rem;
  padding: 1.05rem 0 1.0rem;
  border-bottom: 1px dashed rgba(58, 48, 38, 0.3);
}
.entry:last-child { border-bottom: none; }
.entry-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  color: var(--warning-red);
  padding-top: 0.3rem;
}
.entry-value { font-size: 1.12rem; max-width: 38em; }
.entry-value sup { font-family: var(--mono); font-size: 0.62em; }
.entry-value sup a { color: var(--burn); text-decoration: none; }
.entry-value sup a:hover { color: var(--warning-red); }
.margin-note {
  position: absolute;
  right: -1.2rem;
  top: 50%;
  transform: translateY(-50%) rotate(2.5deg);
  width: 150px;
  font-family: var(--typewriter);
  font-size: 0.8rem;
  line-height: 1.35;
  color: rgba(15, 74, 68, 0.92);
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
  pointer-events: none;
}
.entry:nth-child(even) .margin-note { transform: translateY(-50%) rotate(-2deg); }
.entry.noted .margin-note,
.entry:hover .margin-note {
  opacity: 1;
}
@media (hover: none) {
  .margin-note { opacity: 1; position: static; transform: rotate(-1deg); width: auto; grid-column: 2; margin-top: 0.3rem; }
}

.document-figure { padding: 1.1rem; }
.document-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(58, 48, 38, 0.5);
  filter: saturate(0.85) contrast(0.98);
}
.document-figure::before {
  content: "";
  position: absolute;
  top: -13px; left: 44px;
  width: 24px; height: 48px;
  border: 3px solid rgba(120, 118, 110, 0.85);
  border-radius: 12px / 18px;
  border-bottom: none;
  z-index: 3;
  transform: rotate(-4deg);
}
.document-figure figcaption {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: rgba(58, 48, 38, 0.85);
  padding-top: 0.8rem;
}

/* ─────────────────── layer 2 · excavation ────────────────────── */
#site-canvas {
  display: block;
  width: 100%;
  height: 340px;
  background:
    radial-gradient(80% 100% at 50% 0%, rgba(15, 74, 68, 0.35), transparent 70%),
    linear-gradient(180deg, #d9cfae, #cbbd97);
  border: 1px solid rgba(58, 48, 38, 0.45);
  cursor: pointer;
  touch-action: manipulation;
}
.instrument-caption {
  font-family: var(--typewriter);
  font-size: 0.88rem;
  color: var(--pcb-teal);
  padding: 0.7rem 0 0.2rem;
  min-height: 2.2em;
}
.slider-row { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; }
.slider-row label,
.estimator-controls label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--burn);
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, var(--pcb-teal), var(--sick-yellow), var(--warning-red));
  outline-offset: 4px;
  border-radius: 3px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--sepia-ink);
  border: 2px solid var(--ledger-paper);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--sepia-ink);
  border: 2px solid var(--ledger-paper);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

#ou-list {
  list-style: none;
  padding: 0;
  margin: 1.6rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
#ou-list button {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  padding: 0.65rem 0.9rem;
  min-height: 44px;
  background: rgba(232, 223, 200, 0.07);
  color: var(--bone);
  border: 1px solid rgba(154, 145, 124, 0.4);
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease;
}
#ou-list button:hover { border-color: var(--sick-yellow); }
#ou-list button[aria-pressed="true"] {
  background: rgba(201, 180, 88, 0.16);
  border-color: var(--sick-yellow);
  color: var(--sick-yellow);
}
#ou-detail { min-height: 6rem; }
.ou-detail-placeholder {
  font-family: var(--typewriter);
  font-size: 0.9rem;
  color: rgba(58, 48, 38, 0.55);
}
.ou-file-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.7rem;
  border-bottom: 1px solid rgba(110, 74, 42, 0.45);
  padding-bottom: 0.5rem;
  margin-bottom: 0.8rem;
}
.ou-file-id {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--warning-red);
}
.ou-file-name {
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--sepia-ink);
}
.ou-file-status {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pcb-teal);
  border: 1px solid rgba(15, 74, 68, 0.5);
  padding: 0.2rem 0.5rem;
}
.ou-file-body p { margin: 0.5rem 0; max-width: 44em; }
.ou-file-note {
  font-family: var(--typewriter);
  font-size: 0.85rem;
  color: var(--pcb-teal);
  margin-top: 0.9rem;
}

/* ─────────────────── layer 3 · body burden ───────────────────── */
.advisory-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
}
.advisory-controls label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--burn);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 240px;
}
select {
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
  color: var(--sepia-ink);
  background: rgba(232, 223, 200, 0.85);
  border: 1px solid rgba(58, 48, 38, 0.5);
}
#advisory-card { min-height: 5rem; }
.advisory-label {
  border: 2px solid var(--sepia-ink);
  padding: 1.1rem 1.2rem;
  background: rgba(232, 223, 200, 0.65);
}
.advisory-label-head {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: rgba(58, 48, 38, 0.75);
  margin-bottom: 0.55rem;
}
.advisory-level {
  font-family: var(--mono);
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}
.advisory-level.danger { color: var(--warning-red); }
.advisory-level.caution { color: var(--burn); }
.advisory-gloss {
  font-style: italic;
  font-size: 1.05rem;
  color: rgba(58, 48, 38, 0.9);
  max-width: 42em;
}

.estimator-controls { display: flex; flex-direction: column; gap: 1.15rem; margin: 1.2rem 0; }
.estimator-controls label { display: flex; flex-direction: column; gap: 0.45rem; }
.estimator-controls output {
  float: right;
  font-family: var(--mono);
  color: var(--pcb-teal);
  margin-left: 0.6rem;
}
button {
  font-family: var(--mono);
  letter-spacing: 0.18em;
  cursor: pointer;
}
#est-run, #translator-run, .notebook-buttons button {
  font-size: 0.78rem;
  padding: 0.8rem 1.5rem;
  min-height: 44px;
  background: var(--sepia-ink);
  color: var(--ledger-paper);
  border: 1px solid var(--burn);
  transition: background 0.3s ease;
  align-self: flex-start;
}
#est-run:hover, #translator-run:hover, .notebook-buttons button:hover { background: var(--pcb-teal-deep); }

#body-receipt { margin-top: 1.4rem; }
#body-receipt.printed {
  position: relative;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.8;
  background: linear-gradient(180deg, #f2ecd9, #e4dbc0);
  border: 1px solid rgba(58, 48, 38, 0.4);
  padding: 1.4rem 1.4rem 1.7rem;
  max-width: 30rem;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
}
.receipt-head { text-align: center; letter-spacing: 0.2em; border-bottom: 1px dashed var(--sepia-ink); padding-bottom: 0.6rem; margin-bottom: 0.8rem; }
.receipt-line { display: flex; justify-content: space-between; gap: 1rem; }
.receipt-line .dots { flex: 1; border-bottom: 1px dotted rgba(58,48,38,0.55); margin-bottom: 0.42em; }
.receipt-total { border-top: 1px dashed var(--sepia-ink); margin-top: 0.7rem; padding-top: 0.6rem; font-weight: 500; }
.receipt-tier { color: var(--warning-red); letter-spacing: 0.12em; }
.receipt-disclaimer {
  margin-top: 1rem;
  font-size: 0.7rem;
  line-height: 1.6;
  color: rgba(58, 48, 38, 0.75);
  border-top: 1px solid rgba(58,48,38,0.3);
  padding-top: 0.7rem;
}
.receipt-disclaimer a { color: var(--pcb-teal); }

/* ─────────────────── layer 4 · codex ─────────────────────────── */
#codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
  margin: 2.2rem 0;
}
.codex-card {
  position: relative;
  perspective: 1200px;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  min-height: 230px;
  cursor: pointer;
}
.codex-inner {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 230px;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0.1, 0.2, 1);
}
.codex-card.flipped .codex-inner { transform: rotateY(180deg); }
.codex-face {
  display: block;
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 1.1rem 1.15rem;
  border: 1px solid rgba(58, 48, 38, 0.45);
  overflow: hidden;
}
.codex-term, .codex-official, .codex-gloss { display: block; }
.codex-front {
  background:
    radial-gradient(50% 36% at 90% 6%, rgba(110, 74, 42, 0.22), transparent 70%),
    linear-gradient(180deg, var(--ledger-paper), var(--paper-stain));
  color: var(--sepia-ink);
}
.codex-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(70% 55% at 15% 90%, rgba(140, 47, 34, 0.28), transparent 70%),
    linear-gradient(180deg, #2a2320, #1d1a15);
  border-color: rgba(143, 122, 61, 0.5);
  color: var(--ledger-paper);
}
@media (prefers-reduced-motion: reduce) {
  .codex-inner { transition: none; transform: none !important; }
  .codex-face { position: absolute; transition: opacity 0.2s linear; }
  .codex-card .codex-back { opacity: 0; pointer-events: none; }
  .codex-card.flipped .codex-back { opacity: 1; transform: none; }
  .codex-card.flipped .codex-front { opacity: 0; }
}
.codex-term {
  font-family: var(--display);
  font-size: 1.22rem;
  margin-bottom: 0.5rem;
}
.codex-gloss { margin-top: 0.2rem; }
.codex-front .codex-term { color: var(--sepia-ink); }
.codex-back .codex-term { color: var(--sick-yellow); }
.codex-official {
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.6;
  color: rgba(58, 48, 38, 0.85);
}
.codex-gloss {
  font-style: italic;
  font-size: 1.0rem;
  line-height: 1.55;
  color: var(--bone);
}
.codex-flip-hint {
  position: absolute;
  bottom: 0.6rem; right: 0.8rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: rgba(58, 48, 38, 0.5);
}
.codex-back .codex-flip-hint { color: rgba(232, 223, 200, 0.4); }

.translator-row { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 0.9rem 0; }
#translator-input {
  flex: 1 1 300px;
  font-family: var(--mono);
  font-size: 0.88rem;
  padding: 0.75rem 0.85rem;
  min-height: 44px;
  color: var(--sepia-ink);
  background: rgba(232, 223, 200, 0.85);
  border: 1px solid rgba(58, 48, 38, 0.5);
}
#translator-output {
  font-size: 1.08rem;
  min-height: 2.4em;
  padding-top: 0.4rem;
}
#translator-output .unhoused {
  font-style: italic;
  color: var(--warning-red);
  border-bottom: 1px dotted var(--warning-red);
}
#translator-output .stock {
  font-family: var(--typewriter);
  font-size: 0.88rem;
  color: rgba(58, 48, 38, 0.7);
}

/* ─────────────────── layer 5 · oracle ────────────────────────── */
#oracle-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
#oracle-tabs button {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 0.6rem 0.85rem;
  min-height: 44px;
  background: rgba(58, 48, 38, 0.06);
  color: var(--sepia-ink);
  border: 1px solid rgba(58, 48, 38, 0.4);
  cursor: pointer;
}
#oracle-tabs button:hover { border-color: var(--pcb-teal); }
#oracle-tabs button[aria-selected="true"] {
  background: var(--pcb-teal-deep);
  color: var(--sick-yellow);
  border-color: var(--pcb-teal);
}
.testimony-framing {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--burn);
  margin-bottom: 0.9rem;
}
.testimony-line {
  font-size: 1.14rem;
  max-width: 42em;
  margin: 0.55rem 0;
  opacity: 0;
  transform: translateY(8px);
  animation: line-surface 0.9s ease forwards;
  animation-delay: calc(var(--i) * 0.45s);
}
@keyframes line-surface {
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .testimony-line { opacity: 1; transform: none; animation: none; }
}

/* audio toggle */
#audio-toggle {
  position: fixed;
  bottom: 1.1rem;
  right: 1.25rem;
  z-index: 60;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  padding: 0.6rem 0.9rem;
  min-height: 44px;
  background: rgba(27, 29, 28, 0.75);
  color: var(--faded);
  border: 1px solid rgba(154, 145, 124, 0.4);
  backdrop-filter: blur(6px);
}
#audio-toggle[aria-pressed="true"] {
  color: var(--sick-yellow);
  border-color: var(--antique-gold);
  box-shadow: 0 0 14px rgba(201, 180, 88, 0.25);
}

/* ─────────────────── layer 6 · inheritance ───────────────────── */
.timeline-instrument { overflow: hidden; }
#echo-timeline {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
#echo-timeline button {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  background: rgba(58, 48, 38, 0.05);
  color: var(--sepia-ink);
  border: 1px solid rgba(58, 48, 38, 0.4);
  cursor: pointer;
}
#echo-timeline button.projection { border-style: dashed; color: var(--pcb-teal); }
#echo-timeline button[aria-pressed="true"] {
  background: var(--sepia-ink);
  color: var(--sick-yellow);
}
#echo-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#echo-svg path {
  fill: none;
  stroke: var(--pcb-teal);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  opacity: 0.85;
}
#echo-detail { position: relative; z-index: 2; min-height: 5.4rem; padding-top: 1.1rem; }
.echo-event {
  font-size: 1.12rem;
  max-width: 44em;
}
.echo-event .echo-year {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--warning-red);
  margin-right: 0.6rem;
}
.echo-arrival {
  font-family: var(--typewriter);
  font-size: 0.88rem;
  color: var(--pcb-teal);
  margin-top: 0.6rem;
  max-width: 40em;
}
.echo-arrival .echo-year { color: var(--pcb-teal); }
.projection-flag {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--pcb-teal);
  border: 1px dashed var(--pcb-teal);
  padding: 0.1rem 0.4rem;
  margin-left: 0.6rem;
}

/* palimpsest */
#palimpsest .palimpsest-strata { position: relative; }
.pal-official {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.9;
  color: rgba(58, 48, 38, 0.9);
  max-width: 46em;
}
.pal-annotated {
  font-family: var(--typewriter);
  font-size: 0.92rem;
  color: var(--pcb-teal);
  max-width: 44em;
  transform: rotate(-0.6deg);
  opacity: var(--pal2, 0.15);
  transition: opacity 0.4s linear;
}
.pal-mythic {
  font-style: italic;
  font-size: 1.22rem;
  line-height: 1.75;
  color: var(--sepia-ink);
  max-width: 40em;
  opacity: var(--pal3, 0.08);
  transition: opacity 0.4s linear;
}
@media (prefers-reduced-motion: reduce) {
  .pal-annotated, .pal-mythic { opacity: 1; }
}

/* notebook */
.notebook-controls { display: flex; flex-direction: column; gap: 0.8rem; }
#notebook-input {
  font-family: var(--typewriter);
  font-size: 0.95rem;
  padding: 0.8rem;
  color: var(--sepia-ink);
  background: rgba(232, 223, 200, 0.8);
  border: 1px solid rgba(58, 48, 38, 0.5);
  resize: vertical;
}
.notebook-buttons { display: flex; gap: 0.7rem; flex-wrap: wrap; }
#notebook-entries {
  list-style: none;
  padding: 0;
  margin: 1.3rem 0 0;
}
#notebook-entries li {
  position: relative;
  font-family: var(--typewriter);
  font-size: 0.92rem;
  padding: 0.7rem 2.4rem 0.7rem 0;
  border-bottom: 1px dashed rgba(58, 48, 38, 0.3);
}
#notebook-entries .entry-ts {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: rgba(58, 48, 38, 0.6);
  margin-bottom: 0.2rem;
}
#notebook-entries .entry-del {
  position: absolute;
  right: 0; top: 0.55rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  width: 34px; height: 34px;
  background: none;
  color: rgba(58, 48, 38, 0.55);
  border: 1px solid rgba(58, 48, 38, 0.3);
}
#notebook-entries .entry-del:hover { color: var(--warning-red); border-color: var(--warning-red); }

/* ─────────────────────────── footer ──────────────────────────── */
footer {
  margin-left: 66px;
  padding: 4rem clamp(1.25rem, 6vw, 5.5rem) 3rem;
  max-width: 1060px;
  border-top: 1px solid rgba(143, 122, 61, 0.35);
}
.version-stamp {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--antique-gold);
  margin-bottom: 2rem;
}
.apparatus-block { margin-bottom: 2.2rem; }
.apparatus-block h3 {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sick-yellow);
  margin: 0 0 0.7rem;
}
.apparatus-block p { max-width: 48em; color: var(--bone); font-size: 1.05rem; }
.notes-list {
  padding-left: 1.3rem;
  max-width: 48em;
}
.notes-list li {
  font-size: 0.95rem;
  color: var(--faded);
  margin-bottom: 0.7rem;
}
.notes-list li em { color: var(--bone); }
.footer-disclaimer {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  line-height: 1.8;
  color: var(--faded);
  max-width: 52em;
  margin: 2.4rem 0 1.4rem;
  border-top: 1px dashed rgba(154, 145, 124, 0.35);
  padding-top: 1.4rem;
}
.footer-tagline { font-size: 1.05rem; color: var(--bone); margin-bottom: 0.4rem; }
.footer-contact {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}
.colophon {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: rgba(154, 145, 124, 0.6);
  margin-top: 2.4rem;
}

/* ───────────────────────── responsive ────────────────────────── */
@media (max-width: 767px) {
  #sediment-rail { display: none; }
  #rail-mobile { display: block; }
  #ledger, footer { margin-left: 0; }
  section, #hero { padding-left: 1.15rem; padding-right: 1.15rem; }
  .entry { grid-template-columns: 1fr; gap: 0.25rem; }
  .margin-note { position: static; opacity: 1; transform: rotate(-1deg); width: auto; margin-top: 0.35rem; }
  #site-canvas { height: 260px; }
  h1 { font-size: clamp(2.6rem, 13vw, 3.6rem); }
  .return-link { top: 0.7rem; right: 0.8rem; }
}
