:root {
    --ink: #f4ecdc;
    --ink-dim: #c8bba3;
    --gold: #e6bd6e;
    --gold-hot: #ffd98f;
    --night: #05030a;
    --paper: #f3e7cf;
    --paper-ink: #261d14;
    --paper-dim: #6d5b45;
    --paper-rule: #d6c29c;
    --accent: #8c3a1c;
    --display: var(--gh-font-heading, "Cinzel", Georgia, serif);
    --serif: var(--gh-font-body, "Cormorant Garamond", Georgia, serif);
    --mono: "JetBrains Mono", ui-monospace, monospace;
  }
  * { box-sizing: border-box; }
  html { background: var(--night); }
  body { margin: 0; background: var(--night); color: var(--ink); font-family: var(--serif); font-size: 21px; line-height: 1.5; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
  a { color: var(--gold); }
  ::selection { background: var(--gold); color: var(--night); }

  /* ---------- the stage ---------- */
  .stage { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: #000; }
  .stage video, .stage .poster { position: absolute; inset: -2%; width: 104%; height: 104%; object-fit: cover; transform: translate3d(var(--px, 0), var(--py, 0), 0) scale(var(--zoom, 1)); will-change: transform; }
  .stage .poster { opacity: 0; transition: opacity .9s ease; }
  .stage .poster.on { opacity: 1; }
  .stage video { opacity: 0; transition: opacity 1.2s ease; }
  .stage.ready video { opacity: 1; }
  .stage.ready .poster { opacity: 0 !important; }
  .scrim { position: absolute; inset: 0; pointer-events: none;
    background:
      radial-gradient(ellipse 120% 90% at 50% 45%, transparent 45%, rgba(0,0,0,.72) 100%),
      linear-gradient(90deg, rgba(0,0,0,.62) 0%, rgba(0,0,0,.18) 38%, transparent 60%); }
  .grain { position: absolute; inset: -160px; pointer-events: none; opacity: .07; mix-blend-mode: overlay; background-size: 160px 160px; background-repeat: repeat; image-rendering: pixelated; animation: grain 1s steps(6) infinite; }
  @keyframes grain { 0%{transform:translate(0,0)} 20%{transform:translate(-40px,30px)} 40%{transform:translate(30px,-50px)} 60%{transform:translate(-50px,-10px)} 80%{transform:translate(40px,40px)} 100%{transform:translate(0,0)} }
  .bar { position: absolute; left: 0; right: 0; height: 9vh; background: #000; z-index: 2; transition: transform 1.4s cubic-bezier(.7,0,.2,1); }
  .bar.top { top: 0; } .bar.bot { bottom: 0; }
  body.moving .bar.top { transform: translateY(-100%); }
  body.moving .bar.bot { transform: translateY(100%); }
  .flare { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 52%, #fff8e6 0%, #ffd98f 18%, rgba(255,190,110,.5) 42%, rgba(255,170,90,0) 70%); mix-blend-mode: screen; }
  .door-glow { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 58%, var(--paper) 0%, var(--paper) 30%, rgba(243,231,207,0) 75%); }

  /* ---------- loader ---------- */
  .loader { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--night); transition: opacity 1.2s ease, visibility 1.2s; }
  .loader.done { opacity: 0; visibility: hidden; }
  .loader-inner { text-align: center; }
  .seal { width: 92px; height: 92px; margin: 0 auto 26px; position: relative; }
  .seal svg { width: 100%; height: 100%; animation: spin 14s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loader p { font-family: var(--mono); font-size: 12px; letter-spacing: .3em; color: var(--ink-dim); text-transform: uppercase; margin: 0; }
  .loader .pct { font-family: var(--display); font-size: 15px; color: var(--gold); letter-spacing: .25em; margin-top: 10px; }

  /* ---------- chrome ---------- */
  .topbar { position: fixed; inset: 0 0 auto 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: 18px 26px; pointer-events: none; }
  .topbar > * { pointer-events: auto; }
  .mark { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-family: var(--display); letter-spacing: .32em; font-size: 13px; }
  .mark svg { width: 26px; height: 26px; }
  .to-lib { font-family: var(--display); font-size: 11px; letter-spacing: .28em; color: var(--ink); text-decoration: none; padding: 10px 16px 9px; border: 1px solid rgba(230,189,110,.4); border-radius: 999px; background: rgba(5,3,10,.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background .3s, border-color .3s, color .3s; }
  .to-lib:hover { background: var(--gold); color: var(--night); border-color: var(--gold); }
  body.in-library .topbar .mark { color: var(--paper-ink); }
  body.in-library .to-lib { opacity: 0; pointer-events: none; }

  /* era timeline */
  .timeline { position: fixed; left: 26px; right: 26px; bottom: 22px; z-index: 20; height: 34px; transition: opacity .6s; }
  body.in-library .timeline, body.intro .timeline { opacity: 0; pointer-events: none; }
  .tl-track { position: absolute; left: 0; right: 0; top: 22px; height: 1px; background: rgba(244,236,220,.22); }
  .tl-fill { position: absolute; left: 0; top: 22px; height: 1px; width: 0; background: linear-gradient(90deg, #b48cff, var(--gold)); box-shadow: 0 0 10px var(--gold); }
  .tl-stop { position: absolute; top: 0; transform: translateX(-50%); background: none; border: 0; padding: 0 4px; cursor: pointer; color: var(--ink-dim); font-family: var(--mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; white-space: nowrap; transition: color .3s; }
  .tl-stop::after { content: ""; display: block; width: 7px; height: 7px; margin: 8px auto 0; border-radius: 50%; background: var(--night); border: 1px solid rgba(244,236,220,.5); transition: .3s; }
  .tl-stop.on { color: var(--gold-hot); }
  .tl-stop.on::after { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
  .tl-stop:hover { color: var(--ink); }

  /* ---------- scroll track + chapters ---------- */
  .track { position: relative; z-index: 5; height: 1500vh; }
  .chapters { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
  .ch { position: absolute; left: clamp(22px, 7vw, 120px); top: 50%; max-width: 560px; transform: translateY(-50%); opacity: 0; visibility: hidden; }
  .ch.live { pointer-events: auto; }
  .ch::before { content: ""; position: absolute; inset: -18% -22% -18% -40%; z-index: -2; pointer-events: none;
    background: radial-gradient(ellipse 60% 55% at 42% 50%, rgba(5,3,10,.72) 0%, rgba(5,3,10,.45) 45%, rgba(5,3,10,0) 75%); }
  .ch.hero::before { inset: -10% 10%; background: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(5,3,10,.32) 0%, rgba(5,3,10,0) 70%); }
  .ch.door::before { inset: -30% 20%; background: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(5,3,10,.5) 0%, rgba(5,3,10,0) 70%); }
  .ch .num { position: absolute; left: -.06em; top: -.62em; font-family: var(--display); font-weight: 800; font-size: clamp(140px, 22vw, 300px); line-height: 1; color: transparent; -webkit-text-stroke: 1px rgba(230,189,110,.22); z-index: -1; user-select: none; }
  .ch .eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--gold); margin: 0 0 14px; display: flex; align-items: center; gap: 12px; }
  .ch .eyebrow::before { content: ""; width: 34px; height: 1px; background: var(--gold); }
  .ch h2 { font-family: var(--display); font-weight: 600; font-size: clamp(34px, 4.6vw, 62px); line-height: 1.02; letter-spacing: .02em; margin: 0 0 18px; text-shadow: 0 2px 30px rgba(0,0,0,.6); }
  .ch h2 .w { display: inline-block; }
  .ch p { margin: 0 0 12px; font-size: clamp(19px, 1.5vw, 23px); text-shadow: 0 1px 16px rgba(0,0,0,.85); color: var(--ink); }
  .ch p.aside { font-style: italic; color: var(--ink-dim); font-size: clamp(17px, 1.3vw, 20px); }
  .ch em.k { color: var(--gold-hot); font-style: normal; }
  .ch .go { display: inline-flex; gap: 22px; flex-wrap: wrap; margin-top: 14px; }
  .ch .go a { position: relative; font-family: var(--display); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink); text-decoration: none; padding: 4px 0; }
  .ch .go a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--gold); transform-origin: left; transform: scaleX(.35); transition: transform .45s cubic-bezier(.2,.7,.2,1); }
  .ch .go a:hover::after { transform: scaleX(1); }
  .ch .go a span { color: var(--gold); margin-left: 6px; }

  .ch.hero { left: 0; right: 0; max-width: none; text-align: center; top: 46%; }
  .hero .kick { font-family: var(--mono); font-size: 12px; letter-spacing: .5em; text-transform: uppercase; color: var(--gold); margin: 0 0 20px; }
  .hero h1 { font-family: var(--display); font-weight: 600; font-size: clamp(54px, 11vw, 168px); line-height: .92; letter-spacing: .06em; margin: 0; text-shadow: 0 0 60px rgba(180,140,255,.45), 0 4px 30px rgba(0,0,0,.6); }
  .hero h1 .l { display: inline-block; opacity: 0; transform: translateY(.35em); filter: blur(10px); animation: rise 1.6s cubic-bezier(.2,.7,.1,1) forwards; }
  @keyframes rise { to { opacity: 1; transform: none; filter: blur(0); } }
  .hero .sub { max-width: 620px; margin: 26px auto 0; font-size: clamp(19px, 1.8vw, 24px); font-style: italic; color: var(--ink); text-shadow: 0 1px 16px #000; opacity: 0; animation: fade 1.4s 1.6s forwards; }
  .hero .by { margin-top: 14px; font-family: var(--display); font-size: 12px; letter-spacing: .4em; color: var(--ink-dim); opacity: 0; animation: fade 1.4s 1.9s forwards; }
  .hero .cue { margin-top: 46px; font-family: var(--mono); font-size: 11px; letter-spacing: .4em; color: var(--gold); opacity: 0; animation: fade 1s 2.4s forwards; }
  .hero .cue::after { content: ""; display: block; width: 1px; height: 56px; margin: 12px auto 0; background: linear-gradient(var(--gold), transparent); transform-origin: top; animation: drip 2.4s ease-in-out infinite; }
  @keyframes drip { 0%,100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
  @keyframes fade { to { opacity: 1; } }

  .ch.door { left: 0; right: 0; max-width: none; text-align: center; top: auto; bottom: 14vh; transform: none; }
  .door h2 { font-size: clamp(30px, 4vw, 54px); }
  .enter { display: inline-block; margin-top: 10px; font-family: var(--display); font-size: 13px; letter-spacing: .32em; text-decoration: none; color: var(--night); background: var(--gold); padding: 15px 30px 14px; border-radius: 2px; box-shadow: 0 0 0 0 rgba(255,217,143,.6); animation: pulse 2.4s infinite; }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,217,143,.55); } 70% { box-shadow: 0 0 0 22px rgba(255,217,143,0); } 100% { box-shadow: 0 0 0 0 rgba(255,217,143,0); } }

  /* ---------- the library ---------- */
  .library { position: relative; z-index: 10; background: var(--paper); color: var(--paper-ink); padding: 130px 24px 70px; }
  .library::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background-image: radial-gradient(rgba(120,80,30,.07) 1px, transparent 1px); background-size: 5px 5px; }
  .library a { color: var(--accent); }
  .lib { position: relative; max-width: 1060px; margin: 0 auto; }
  .lib-title { text-align: center; }
  .lib-title .kick { font-family: var(--mono); font-size: 11px; letter-spacing: .4em; color: var(--accent); text-transform: uppercase; }
  .lib-title h2 { font-family: var(--display); font-weight: 600; font-size: clamp(44px, 7vw, 92px); letter-spacing: .05em; line-height: 1; margin: 14px 0 12px; }
  .lib-title .tag { font-family: var(--display); font-size: 12px; letter-spacing: .3em; color: var(--paper-dim); margin: 0 0 54px; }
  blockquote { margin: 0 auto 30px; max-width: 760px; text-align: center; font-size: clamp(26px, 3.3vw, 38px); font-style: italic; line-height: 1.25; }
  blockquote cite { display: block; margin-top: 14px; font-style: normal; font-family: var(--display); font-size: 12px; letter-spacing: .3em; color: var(--paper-dim); }
  .bridge { max-width: 720px; margin: 0 auto 70px; text-align: center; padding: 16px 20px; border-top: 1px solid var(--paper-rule); border-bottom: 1px solid var(--paper-rule); color: var(--paper-dim); font-size: 19px; }
  .bridge strong { color: var(--paper-ink); font-weight: 600; }
  .lib-h { font-family: var(--display); font-size: 14px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); margin: 0 0 22px; display: flex; align-items: center; gap: 16px; }
  .lib-h::after { content: ""; flex: 1; height: 1px; background: var(--paper-rule); }

  .trail { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
  .trail a { display: flex; flex-direction: column; height: 100%; text-decoration: none; color: var(--paper-ink); background: #faf1de; border: 1px solid var(--paper-rule); border-radius: 3px; overflow: hidden; transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s; }
  .trail a:hover { transform: translateY(-6px); box-shadow: 0 18px 40px rgba(80,50,15,.18); }
  .trail .img { aspect-ratio: 4/3; background-size: cover; background-position: center; filter: saturate(.9); transition: filter .4s; }
  .trail a:hover .img { filter: saturate(1.15); }
  .trail .body { padding: 14px 14px 16px; }
  .trail .n { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .2em; }
  .trail .t { display: block; font-family: var(--display); font-size: 17px; font-weight: 600; line-height: 1.2; margin: 6px 0 6px; }
  .trail .d { color: var(--paper-dim); font-size: 16px; line-height: 1.35; }
  .trail li.book a { background: var(--paper-ink); color: var(--paper); border-color: var(--paper-ink); }
  .trail li.book .n { color: var(--gold); }
  .trail li.book .d { color: #d6c6a6; }
  .howto { margin: 0 0 70px; font-size: 19px; }

  .cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 56px; margin-bottom: 64px; }
  .bookbox p { margin: 0 0 12px; font-size: 20px; }
  .buy { display: inline-block; margin: 10px 18px 0 0; font-family: var(--display); font-size: 12px; letter-spacing: .24em; text-decoration: none; color: #fff !important; background: var(--accent); padding: 14px 22px 13px; border-radius: 2px; transition: transform .25s, box-shadow .25s; }
  .buy:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(140,58,28,.3); }
  .sub-link { display: inline-block; margin-top: 10px; font-family: var(--display); font-size: 12px; letter-spacing: .24em; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 2px; }
  .rooms { list-style: none; padding: 0; margin: 0; }
  .rooms li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px dotted var(--paper-rule); font-size: 19px; }
  .rooms a { text-decoration: none; font-weight: 500; }
  .rooms a:hover { text-decoration: underline; }
  .rooms small { color: var(--paper-dim); font-size: 15px; font-style: italic; text-align: right; }
  .not { display: flex; flex-wrap: wrap; gap: 9px; list-style: none; padding: 0; margin: 0 0 14px; }
  .not li { border: 1px solid var(--paper-rule); border-radius: 999px; padding: 5px 14px; font-size: 17px; color: var(--paper-dim); }
  .not li::before { content: "not "; color: var(--accent); font-style: italic; }
  .fine { color: var(--paper-dim); font-size: 16px; margin: 0; }
  .lib-foot { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--paper-rule); display: flex; flex-wrap: wrap; gap: 12px 26px; justify-content: center; font-family: var(--display); font-size: 12px; letter-spacing: .18em; }
  .lib-foot a { text-decoration: none; }
  .again { text-align: center; margin-top: 18px; font-size: 17px; }


  /* still mode: reduced motion or no video */
  body.still .stage video { display: none; }

  @media (max-width: 900px) { .trail { grid-template-columns: repeat(2, 1fr); } .trail li.book { grid-column: span 2; } .cols { grid-template-columns: 1fr; gap: 40px; } }
  @media (max-width: 700px) {
    body { font-size: 18px; }
    .topbar { padding: 14px 16px; }
    .mark span { display: none; }
    .ch { left: 16px; right: 16px; max-width: none; top: auto; bottom: 74px; transform: none; padding: 18px 18px 14px; background: rgba(5,3,10,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(230,189,110,.18); }
    .ch .num { display: none; }
    .ch h2 { font-size: 30px; }
    .ch p { font-size: 17px; }
    .ch p.aside { display: none; }
    .ch.hero, .ch.door { background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; }
    .ch.hero { top: 30%; bottom: auto; }
    .scrim { background: radial-gradient(ellipse 120% 90% at 50% 40%, transparent 40%, rgba(0,0,0,.75) 100%), linear-gradient(0deg, rgba(0,0,0,.65) 0%, transparent 50%); }
    .timeline { left: 12px; right: 12px; bottom: 14px; }
    .tl-stop { font-size: 0; padding: 0 6px; }
    .tl-stop::after { margin-top: 18px; }
    .trail { grid-template-columns: 1fr; } .trail li.book { grid-column: auto; }
    .rooms li { flex-direction: column; gap: 0; }
    .rooms small { text-align: left; }
  }
  @media (prefers-reduced-motion: reduce) {
    .grain, .seal svg, .hero .cue::after, .enter { animation: none; }
    .hero h1 .l, .hero .sub, .hero .by, .hero .cue { animation-duration: .01s; animation-delay: 0s; }
  }

  /* Ghost editor card widths (required by Ghost themes) */
  .kg-width-wide { width: min(1100px, 92vw); max-width: none; margin-left: 50%; transform: translateX(-50%); }
  .kg-width-full { width: 100vw; max-width: none; margin-left: 50%; transform: translateX(-50%); }
  .library .rooms li { align-items: baseline; }
