:root {
  /* DESIGN typography token preservation: IBM Plex Mono** for circuit labels */
  --design-font-token: "Mono**";
  --lapis: #123E7C;
  --ruby: #D9256E;
  --vellum: #F3D9A4;
  --amethyst: #8F3DFF;
  --emerald: #00E6A8;
  --void: #130B24;
  --oxblood: #4A2419;
  --serif-display: "Cormorant Garamond", Georgia, serif;
  --serif-body: "Libre Baskerville", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Space Mono", monospace;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--void); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--vellum);
  font-family: var(--serif-body);
  background:
    radial-gradient(circle at 82% 10%, rgba(143, 61, 255, .34), transparent 34rem),
    radial-gradient(circle at 24% 88%, rgba(217, 37, 110, .26), transparent 30rem),
    linear-gradient(135deg, var(--void), #211033 48%, #070411);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  background-image:
    repeating-linear-gradient(37deg, rgba(243, 217, 164, .06) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(94deg, rgba(74, 36, 25, .34) 0 2px, rgba(19, 11, 36, .2) 2px 6px),
    radial-gradient(circle at 20% 20%, rgba(243, 217, 164, .08), transparent 13rem);
  mix-blend-mode: overlay;
}

.crt-haze {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.055) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, transparent, rgba(0, 230, 168, .055), transparent);
  opacity: .42;
  animation: scanDrift 9s linear infinite;
}

.focus-lens {
  position: fixed;
  width: 260px;
  height: 260px;
  margin: -130px 0 0 -130px;
  border-radius: 50%;
  z-index: 9;
  pointer-events: none;
  border: 1px solid rgba(0, 230, 168, .65);
  background: radial-gradient(circle, rgba(243, 217, 164, .13), rgba(0, 230, 168, .08) 42%, transparent 70%);
  box-shadow: 0 0 42px rgba(0, 230, 168, .25), inset 0 0 38px rgba(143, 61, 255, .2);
  opacity: .8;
  transform: translate3d(78vw, 24vh, 0) scale(.72);
  transition: opacity .35s ease;
}

.manuscript-shell {
  position: relative;
  z-index: 1;
  width: min(1600px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 58px);
}

.top-band {
  display: grid;
  grid-template-columns: minmax(260px, 430px) 1fr auto;
  gap: clamp(18px, 3vw, 42px);
  align-items: end;
  padding: clamp(20px, 3vw, 42px);
  border: 1px solid rgba(243, 217, 164, .26);
  border-radius: 30px 30px 8px 8px;
  background:
    linear-gradient(120deg, rgba(74, 36, 25, .82), rgba(18, 62, 124, .42)),
    radial-gradient(circle at 20% 0%, rgba(217, 37, 110, .22), transparent 24rem);
  box-shadow: 0 26px 90px rgba(0,0,0,.42), inset 0 1px rgba(243, 217, 164, .2);
}

.folio-mark, .folio-kicker, .theorem-card span, .chapter-glyphs button, .lens-window span, .annotation span, .fragment-grid span {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .18em;
}

.folio-mark { margin: 0 0 5px; color: var(--emerald); font-size: .72rem; }

h1 {
  margin: 0;
  color: var(--vellum);
  font-family: var(--serif-display);
  font-size: clamp(4.4rem, 10vw, 10.5rem);
  font-weight: 700;
  letter-spacing: .055em;
  line-height: .76;
  text-shadow: 0 3px 0 var(--oxblood), 0 0 34px rgba(243, 217, 164, .22), 0 0 76px rgba(143, 61, 255, .24);
}

.neon-rule { height: 3px; background: rgba(243, 217, 164, .14); overflow: hidden; border-radius: 999px; align-self: center; }
.neon-rule span { display: block; height: 100%; width: 48%; background: linear-gradient(90deg, var(--ruby), var(--emerald), var(--amethyst)); box-shadow: 0 0 24px var(--emerald); animation: ruleWake 4.8s ease-in-out infinite alternate; }

.chapter-glyphs { display: grid; grid-template-columns: repeat(2, minmax(92px, 1fr)); gap: 10px; }
.glyph {
  color: var(--vellum);
  background: rgba(19, 11, 36, .58);
  border: 1px solid rgba(243, 217, 164, .28);
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform .35s ease, border-color .35s ease, color .35s ease, background .35s ease;
}
.glyph.active, .glyph:hover { color: var(--void); background: var(--emerald); border-color: var(--emerald); transform: translateY(-2px); }

.reading-grid {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) minmax(260px, 390px);
  gap: clamp(16px, 2.2vw, 34px);
  padding-top: clamp(18px, 3vw, 40px);
}

.left-rail, .diagram-panel, .folio {
  position: relative;
  border: 1px solid rgba(243, 217, 164, .22);
  background:
    linear-gradient(145deg, rgba(74, 36, 25, .72), rgba(19, 11, 36, .8)),
    repeating-linear-gradient(42deg, transparent 0 9px, rgba(243, 217, 164, .035) 9px 10px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), 0 22px 70px rgba(0,0,0,.38);
}

.left-rail { min-height: 680px; border-radius: 10px 0 0 30px; padding: 190px 20px 24px; overflow: hidden; }
.margin-circuit { position: absolute; top: 0; left: 12px; width: 78px; height: 100%; fill: none; }
.margin-circuit path { stroke: var(--emerald); stroke-width: 3; filter: drop-shadow(0 0 8px rgba(0,230,168,.8)); stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: circuitWake 3s ease forwards .35s; }
.margin-circuit circle { fill: var(--void); stroke: var(--emerald); stroke-width: 3; opacity: .92; }

.annotation { position: relative; margin: 0 0 22px 44px; padding: 16px; border-left: 1px solid rgba(0,230,168,.45); opacity: .48; transition: opacity .45s ease, transform .45s ease; }
.annotation.active { opacity: 1; transform: translateX(8px); }
.annotation span { color: var(--ruby); font-size: .65rem; }
.annotation p { margin: 8px 0 0; font-size: .78rem; line-height: 1.65; color: rgba(243,217,164,.78); }

.folio-stack { min-height: 680px; perspective: 1200px; }
.folio {
  display: none;
  min-height: 680px;
  border-radius: 0 30px 30px 0;
  padding: clamp(32px, 5vw, 76px);
  overflow: hidden;
}
.folio::before { content: ""; position: absolute; inset: 18px; border: 1px solid rgba(243,217,164,.14); pointer-events: none; }
.folio::after { content: ""; position: absolute; inset: auto -18% 12% 46%; height: 2px; background: linear-gradient(90deg, transparent, var(--ruby), var(--amethyst), transparent); box-shadow: 0 0 30px var(--ruby); transform: rotate(-11deg); }
.folio.active { display: block; animation: folioIn .72s cubic-bezier(.2,.8,.2,1) both; }
.folio-kicker { color: var(--emerald); font-size: .78rem; margin-bottom: 20px; }
.folio h2 {
  max-width: 930px;
  margin: 0;
  font-family: var(--serif-display);
  color: var(--vellum);
  font-size: clamp(3.1rem, 7vw, 7.9rem);
  line-height: .88;
  font-weight: 600;
  letter-spacing: .01em;
}
.folio p { max-width: 760px; color: rgba(243,217,164,.86); font-size: clamp(1rem, 1.7vw, 1.34rem); line-height: 1.85; }
.lead { margin-top: 32px; }
.zoomable.sharp { color: #F3D9A4; text-shadow: 0 0 20px rgba(0,230,168,.42); }

.theorem-card { max-width: 660px; margin-top: 44px; padding: 24px 28px; border: 1px solid rgba(0,230,168,.38); background: rgba(18,62,124,.34); box-shadow: inset 0 0 38px rgba(0,230,168,.08); }
.theorem-card span { color: var(--emerald); font-size: .72rem; }
.theorem-card p { margin: 10px 0 0; font-family: var(--serif-display); font-size: clamp(1.5rem, 2.6vw, 2.5rem); line-height: 1.18; }

.research-list { display: grid; gap: 14px; max-width: 780px; margin: 40px 0 0; padding: 0; list-style: none; }
.research-list li { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 17px 20px; border: 1px solid rgba(243,217,164,.18); background: rgba(19,11,36,.44); }
.research-list strong { font-family: var(--serif-display); color: var(--emerald); font-size: 1.55rem; }
.research-list span { color: rgba(243,217,164,.76); font-family: var(--sans); }

.fragment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 46px; }
.fragment-grid div { min-height: 210px; padding: 22px; background: linear-gradient(150deg, rgba(18,62,124,.45), rgba(74,36,25,.55)); border: 1px solid rgba(143,61,255,.34); }
.fragment-grid span { color: var(--emerald); font-size: .72rem; }
.fragment-grid p { font-size: .96rem; line-height: 1.65; }

.sigil-link { display: inline-block; margin-top: 28px; color: var(--void); background: linear-gradient(90deg, var(--emerald), var(--vellum)); padding: 15px 22px; border-radius: 999px; text-decoration: none; font-family: var(--mono); text-transform: uppercase; letter-spacing: .12em; box-shadow: 0 0 34px rgba(0,230,168,.28); }

.diagram-panel { min-height: 680px; border-radius: 30px 10px 30px 0; padding: 22px; overflow: hidden; }
.lens-window { position: relative; z-index: 1; padding: 20px; min-height: 150px; border: 1px solid rgba(0,230,168,.4); background: rgba(19,11,36,.58); }
.lens-window span { color: var(--emerald); font-size: .72rem; }
.lens-window p { margin: 12px 0 0; font-family: var(--serif-display); font-style: italic; font-size: 1.65rem; line-height: 1.15; }
.scholia-map { position: absolute; inset: 16% -10% 0 -2%; width: 116%; height: 80%; }
.trace { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 700; stroke-dashoffset: 700; animation: traceDraw 6s ease-in-out infinite alternate; }
.trace-one { stroke: var(--emerald); }
.trace-two { stroke: var(--ruby); animation-delay: .5s; }
.trace-three { stroke: var(--amethyst); animation-delay: 1s; }
.nodes circle { fill: var(--void); stroke: var(--vellum); stroke-width: 3; filter: drop-shadow(0 0 10px rgba(243,217,164,.5)); }

@keyframes scanDrift { from { transform: translateY(-12px); } to { transform: translateY(12px); } }
@keyframes ruleWake { from { transform: translateX(-12%); } to { transform: translateX(118%); } }
@keyframes circuitWake { to { stroke-dashoffset: 0; } }
@keyframes traceDraw { to { stroke-dashoffset: 0; } }
@keyframes folioIn { from { opacity: 0; transform: translateY(18px) rotateX(3deg) scale(.985); filter: blur(8px); } to { opacity: 1; transform: none; filter: blur(0); } }

@media (max-width: 1120px) {
  .top-band, .reading-grid { grid-template-columns: 1fr; }
  .chapter-glyphs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .left-rail, .diagram-panel, .folio { min-height: auto; border-radius: 24px; }
  .left-rail { padding-top: 34px; }
  .margin-circuit { opacity: .28; }
}

@media (max-width: 700px) {
  .manuscript-shell { padding: 14px; }
  .top-band { padding: 22px; }
  .chapter-glyphs, .fragment-grid { grid-template-columns: 1fr; }
  .folio { padding: 28px; }
  .folio h2 { font-size: 3rem; }
  .research-list li { grid-template-columns: 1fr; }
  .focus-lens { display: none; }
}
