/* ============================================================
   TESSURAE · hi-fi shared system
   Dark glassmorphism on photographic backgrounds.
   Deep plum · muted moss · metallic gold on near-black.
   Mobile-first. Codex structure preserved.
   ============================================================ */

:root {
  /* --- ink (light text on dark) --- */
  --ink:           #f3ead2;
  --ink-2:         rgba(243, 234, 210, 0.86);
  --ink-3:         rgba(243, 234, 210, 0.68);
  --ink-faint:     rgba(243, 234, 210, 0.52);
  --ink-quiet:     rgba(243, 234, 210, 0.36);
  --ink-ghost:     rgba(243, 234, 210, 0.12);

  /* --- glass surfaces (dark panels) --- */
  --glass:         rgba(14, 10, 18, 0.62);
  --glass-soft:    rgba(28, 22, 36, 0.48);
  --glass-deep:    rgba(8, 6, 12, 0.78);
  --glass-edge:    rgba(243, 234, 210, 0.10);
  --glass-edge-2:  rgba(243, 234, 210, 0.18);

  /* --- deep plum (signature) --- */
  --plum:          #6b3592;
  --plum-deep:     #3d1f5c;
  --plum-bright:   #9b6cc3;
  --plum-soft:     rgba(107, 53, 146, 0.22);
  --plum-veil:     rgba(107, 53, 146, 0.10);
  --plum-glow:     rgba(155, 108, 195, 0.42);

  /* --- muted moss --- */
  --moss:          #8aae8e;
  --moss-deep:     #4d6e54;
  --moss-bright:   #b4d2a8;
  --moss-soft:     rgba(138, 174, 142, 0.22);
  --moss-glow:     rgba(180, 210, 168, 0.32);

  /* --- metallic gold (foil) --- */
  --gold:          #d4a84b;
  --gold-deep:     #b8893d;
  --gold-bright:   #f0d989;
  --gold-soft:     rgba(212, 168, 75, 0.22);
  --gold-glow:     rgba(240, 217, 137, 0.42);
  --gold-foil:     linear-gradient(135deg,
                       #b8893d 0%,
                       #d4a84b 25%,
                       #f0d989 50%,
                       #d4a84b 75%,
                       #8c6624 100%);
  --gold-rule:     linear-gradient(90deg,
                       transparent 0%,
                       rgba(212, 168, 75, 0.3) 12%,
                       rgba(240, 217, 137, 0.8) 50%,
                       rgba(212, 168, 75, 0.3) 88%,
                       transparent 100%);

  /* --- accents --- */
  --crimson:       #c8616f;
  --crimson-soft:  rgba(200, 97, 111, 0.18);
  --rose:          #d89aa8;

  /* --- type --- */
  --display:       'Cinzel', 'Trajan Pro', Georgia, serif;
  --serif:         'EB Garamond', Georgia, 'Times New Roman', serif;
  --body:          'Inter', -apple-system, system-ui, sans-serif;
  --hand:          'Caveat', cursive;
  --mono:          'JetBrains Mono', ui-monospace, monospace;

  /* --- scale --- */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 14px;
  --r-4: 20px;

  --shadow-deep:    0 22px 70px rgba(0, 0, 0, 0.55);
  --shadow-card:    0 10px 30px -10px rgba(0, 0, 0, 0.6),
                    0 0 0 1px var(--glass-edge);
  --shadow-foil:    0 4px 16px -6px rgba(240, 217, 137, 0.5);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  background: #050307;
}

body {
  font-family: var(--body);
  color: var(--ink);
  background: transparent;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

/* page background image (per surface) */
body::before {
  content: "";
  position: fixed;
  inset: -20px;
  z-index: -2;
  background-image: var(--page-bg-image, none);
  background-position: var(--page-bg-position, center);
  background-size: cover;
  background-repeat: no-repeat;
  opacity: var(--page-bg-opacity, 0.85);
  filter: var(--page-bg-filter, saturate(0.95) brightness(0.6));
  transform: scale(1.02);
}

/* darkening veil */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(61, 31, 92, 0.18), transparent 60%),
    linear-gradient(180deg, rgba(5, 3, 7, 0.5) 0%, rgba(5, 3, 7, 0.3) 40%, rgba(5, 3, 7, 0.7) 100%);
  pointer-events: none;
}

/* page bg variants */
.bg-home    { --page-bg-image: url('../assets/bg-home.png');         --page-bg-opacity: 0.7; --page-bg-filter: saturate(1.05) brightness(0.65); }
.bg-cogcore { --page-bg-image: url('../assets/bg-neural.png');       --page-bg-opacity: 0.78; --page-bg-filter: saturate(1.0) brightness(0.7); }
.bg-health  { --page-bg-image: url('../assets/bg-health.png');       --page-bg-opacity: 0.7; --page-bg-filter: saturate(1.02) brightness(0.6); }
.bg-reading { --page-bg-image: url('../assets/bg-reading-room.png'); --page-bg-opacity: 0.85; --page-bg-filter: saturate(0.95) brightness(0.55); }
.bg-rituals { --page-bg-image: url('../assets/bg-neural.png');       --page-bg-opacity: 0.8; --page-bg-filter: saturate(0.85) brightness(0.5); }
.bg-archive { --page-bg-image: url('../assets/bg-archive.png');      --page-bg-opacity: 0.72; --page-bg-filter: saturate(1.0) brightness(0.6); }

/* ============================================================
   FOIL UTILITIES
   ============================================================ */
.foil {
  background: var(--gold-foil);
  background-size: 250% 250%;
  background-position: 50% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
@keyframes foil-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.foil-shimmer {
  background: var(--gold-foil);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: foil-shimmer 6s ease-in-out infinite alternate;
}

.gold-rule {
  height: 1px;
  background: var(--gold-rule);
  border: none;
  margin: 24px 0;
}

/* ============================================================
   PAGE SHELL
   ============================================================ */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 14px 80px;
}
@media (min-width: 720px)  { .shell { padding: 22px 28px 96px; } }
@media (min-width: 1024px) { .shell { padding: 26px 40px 120px; } }

/* ============================================================
   TOPBAR + HAMBURGER DRAWER
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: -16px -14px 22px;
  background: rgba(8, 6, 12, 0.65);
  border-bottom: 1px solid var(--glass-edge);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
@media (min-width: 720px)  { .topbar { margin: -22px -28px 28px; padding: 14px 28px; } }
@media (min-width: 1024px) { .topbar { margin: -26px -40px 36px; padding: 16px 40px; } }

.topbar .brand {
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.topbar .brand .mark {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: var(--gold-foil);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--gold-glow);
}
.topbar .crumb {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--ink-faint);
  justify-self: center;
  text-align: center;
}
.topbar .crumb b {
  color: var(--gold);
  font-weight: 600;
  margin-left: 4px;
}
.topbar .clock {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  white-space: nowrap;
  padding: 5px 10px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: rgba(8, 6, 12, 0.4);
}
@media (max-width: 540px) {
  .topbar .clock { display: none; }
  .topbar .crumb { font-size: 9px; letter-spacing: 0.28em; }
  .topbar .brand { font-size: 14px; letter-spacing: 0.18em; }
}

.hamburger {
  appearance: none;
  background: rgba(8, 6, 12, 0.4);
  border: 1px solid var(--glass-edge-2);
  border-radius: var(--r-2);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.18s, border-color 0.18s;
}
.hamburger:hover { background: var(--plum-soft); border-color: var(--plum-bright); }
.hamburger:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hamburger .lines {
  width: 18px;
  height: 13px;
  position: relative;
}
.hamburger .lines::before,
.hamburger .lines::after,
.hamburger .lines i {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--ink-2);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease, top 0.2s ease, bottom 0.2s ease;
}
.hamburger .lines::before { top: 0; }
.hamburger .lines i { top: 50%; transform: translateY(-50%); display: block; }
.hamburger .lines::after { bottom: 0; }
.hamburger.open .lines::before { top: 50%; transform: translateY(-50%) rotate(45deg); }
.hamburger.open .lines::after { bottom: 50%; transform: translateY(50%) rotate(-45deg); }
.hamburger.open .lines i { opacity: 0; }

/* DRAWER */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(2, 1, 4, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 90vw);
  background:
    radial-gradient(ellipse at top right, rgba(107, 53, 146, 0.18), transparent 50%),
    rgba(8, 6, 12, 0.92);
  border-right: 1px solid var(--gold-soft);
  box-shadow: var(--shadow-deep), 12px 0 0 -8px rgba(212, 168, 75, 0.15);
  padding: 30px 26px 26px;
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(.2, .7, .2, 1);
  z-index: 50;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 16px;
  margin-bottom: 18px;
  position: relative;
}
.drawer-head::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--gold-rule);
}
.drawer-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-weight: 500;
}
.drawer-head .close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 6px;
}
.drawer-head .close:hover { color: var(--gold); }

.drawer ol.folios {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: folio;
}
.drawer ol.folios li {
  counter-increment: folio;
  position: relative;
  padding: 16px 0 16px 54px;
  border-bottom: 1px solid rgba(243, 234, 210, 0.06);
}
.drawer ol.folios li:last-child { border-bottom: none; }
.drawer ol.folios li::before {
  content: counter(folio, upper-roman);
  position: absolute;
  left: 0;
  top: 22px;
  width: 40px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold-deep);
  text-align: right;
  padding-right: 10px;
  border-right: 1px solid rgba(212, 168, 75, 0.2);
}
.drawer ol.folios li a {
  display: block;
  text-decoration: none;
  color: inherit;
}
.drawer ol.folios li b {
  display: block;
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.15;
}
.drawer ol.folios li small {
  display: block;
  margin-top: 4px;
  font-family: var(--body);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.drawer ol.folios li.active b {
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.drawer ol.folios li.active::before { color: var(--gold-bright); }
.drawer ol.folios li.active::after {
  content: "";
  position: absolute;
  left: 47px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--gold-foil);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--gold-glow);
}
.drawer ol.folios li:hover b { color: var(--gold-bright); }

.drawer .dedication {
  margin-top: auto;
  padding-top: 24px;
  position: relative;
  text-align: center;
  font-family: var(--hand);
  font-size: 20px;
  color: var(--plum-bright);
  line-height: 1.2;
}
.drawer .dedication::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gold-rule);
}
.drawer .dedication .orn {
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin: 0 12px;
  font-size: 13px;
  vertical-align: middle;
}

/* ============================================================
   SPINE TOC / chapter picker
   ============================================================ */
.layout-codex {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
@media (min-width: 900px) {
  .layout-codex { grid-template-columns: 140px 1fr; gap: 32px; }
}
@media (min-width: 1140px) {
  .layout-codex { grid-template-columns: 160px 1fr; gap: 44px; }
}

.spine-toc {
  display: none;
}
@media (min-width: 900px) {
  .spine-toc {
    display: block;
    position: sticky;
    top: 100px;
    align-self: start;
    padding-top: 32px;
    font-family: var(--display);
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ink-faint);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  .spine-toc .stem {
    border-left: 1px solid rgba(212, 168, 75, 0.3);
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .spine-toc .stem a {
    position: relative;
    color: inherit;
    text-decoration: none;
    padding: 2px 0;
    transition: color 0.18s;
    display: block;
  }
  .spine-toc .stem a small {
    display: block;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.18em;
    color: var(--gold-deep);
    margin-bottom: 3px;
  }
  .spine-toc .stem a:hover { color: var(--gold-bright); }
  .spine-toc .stem a.active {
    color: var(--gold-bright);
    font-weight: 700;
  }
  .spine-toc .stem a.active small { color: var(--gold-bright); }
  .spine-toc .stem a.active::before {
    content: "";
    position: absolute;
    left: -21px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--gold-foil);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(8, 6, 12, 1), 0 0 14px var(--gold-glow);
  }
}

.chapter-picker {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 14px 14px;
  margin: 0 -14px 14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chapter-picker::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .chapter-picker { display: none; } }
.chapter-picker a {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--glass-edge-2);
  border-radius: 999px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  background: rgba(8, 6, 12, 0.5);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.chapter-picker a small {
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--gold-deep);
  letter-spacing: 0.18em;
  margin-bottom: 1px;
}
.chapter-picker a.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--plum-soft), var(--gold-soft));
  color: var(--gold-bright);
  font-weight: 600;
}
.chapter-picker a.active small { color: var(--gold-bright); }

/* ============================================================
   GLASS PANELS
   ============================================================ */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge-2);
  border-radius: var(--r-3);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-card);
  position: relative;
}
.glass.deep { background: var(--glass-deep); }
.glass.plum-edge { border-color: rgba(155, 108, 195, 0.32); }
.glass.gold-edge { border-color: rgba(212, 168, 75, 0.32); }
.glass.moss-edge { border-color: rgba(138, 174, 142, 0.32); }
.glass.gold-corner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(135deg, var(--gold-foil) 0%, transparent 30%) padding-box;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  opacity: 0.7;
}

/* ============================================================
   CODEX BOOK STRUCTURE
   ============================================================ */
.codex-book {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.codex-page {
  background: var(--glass);
  border: 1px solid var(--glass-edge-2);
  border-radius: var(--r-3);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-card);
  padding: 28px 22px;
  position: relative;
  overflow: hidden;
}
@media (min-width: 720px)  { .codex-page { padding: 40px 44px; } }
@media (min-width: 1024px) { .codex-page { padding: 52px 60px; } }

/* gold corner ornament on each page */
.codex-page::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--gold-rule);
}

.codex-chapter-label {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  margin-bottom: 8px;
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.codex-chapter-title {
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 44px);
  margin: 0 0 8px;
  letter-spacing: 0.03em;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.05;
}
.codex-chapter-title .foil {
  display: inline-block;
}

.codex-chapter-sub {
  font-family: var(--hand);
  font-size: clamp(18px, 2.2vw, 22px);
  color: var(--plum-bright);
  margin: 0 0 24px;
  line-height: 1.2;
}

.codex-illum {
  float: left;
  width: 58px;
  height: 58px;
  margin: 6px 16px 6px 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 38px;
  line-height: 1;
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  border-left: 1px solid var(--gold);
  padding-left: 14px;
}
@media (min-width: 720px) {
  .codex-illum {
    width: 70px;
    height: 70px;
    font-size: 50px;
  }
}

.codex-prose {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-2);
  text-wrap: pretty;
}
@media (min-width: 720px) { .codex-prose { font-size: 17px; } }
.codex-prose p { margin: 0 0 14px; }
.codex-prose b, .codex-prose strong { color: var(--ink); font-weight: 600; }
.codex-prose em { font-style: italic; color: var(--gold-bright); }

.codex-aside {
  margin: 22px 0;
  border-left: 2px solid var(--moss);
  background: rgba(138, 174, 142, 0.08);
  padding: 14px 18px;
  font-family: var(--body);
  font-size: 13px;
  color: var(--ink-2);
  border-radius: 0 var(--r-2) var(--r-2) 0;
  line-height: 1.55;
}
.codex-aside b {
  display: block;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.26em;
  color: var(--moss-bright);
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
}
.codex-aside.plum {
  border-left-color: var(--plum-bright);
  background: var(--plum-veil);
}
.codex-aside.plum b { color: var(--plum-bright); }
.codex-aside.gold {
  border-left-color: var(--gold);
  background: rgba(212, 168, 75, 0.08);
}
.codex-aside.gold b {
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.codex-aside .quote {
  font-family: var(--hand);
  font-size: 19px;
  color: var(--ink);
  line-height: 1.3;
}
.codex-aside .source {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

.codex-ledger {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 18px;
  font-family: var(--body);
  font-size: 13px;
  margin: 18px 0;
  border-top: 1px solid rgba(212, 168, 75, 0.3);
  border-bottom: 1px solid rgba(212, 168, 75, 0.3);
  padding: 14px 0;
}
.codex-ledger .row { display: contents; }
.codex-ledger .row > * {
  padding: 6px 0;
  border-bottom: 1px solid rgba(243, 234, 210, 0.06);
}
.codex-ledger .row:last-child > * { border-bottom: none; }
.codex-ledger .row b {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 500;
}
.codex-ledger .row span { color: var(--ink-2); }
.codex-ledger .row em {
  font-style: normal;
  color: var(--gold-deep);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

.codex-mantra {
  text-align: center;
  padding: 38px 24px;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  background:
    linear-gradient(180deg, transparent 0%, rgba(8, 6, 12, 0.6) 100%);
  border: 1px solid rgba(212, 168, 75, 0.2);
  border-radius: var(--r-3);
  background: var(--gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  position: relative;
}
.codex-mantra::after {
  content: "";
  position: absolute;
  left: 30%; right: 30%;
  bottom: 14px;
  height: 1px;
  background: var(--gold-rule);
  opacity: 0.5;
}
.codex-mantra .orn {
  margin: 0 16px;
}

/* ============================================================
   PILLS / TAGS / DOTS / KBD
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--body);
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--glass-edge-2);
  border-radius: 999px;
  color: var(--ink-2);
  background: rgba(8, 6, 12, 0.4);
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.pill.plum    { border-color: var(--plum-bright); color: var(--plum-bright); background: var(--plum-soft); }
.pill.moss    { border-color: var(--moss); color: var(--moss-bright); background: var(--moss-soft); }
.pill.gold    { border-color: var(--gold); color: var(--gold-bright); background: var(--gold-soft); }
.pill.crimson { border-color: var(--crimson); color: var(--crimson); background: var(--crimson-soft); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-ghost);
  flex-shrink: 0;
}
.dot.live { background: var(--moss-bright); box-shadow: 0 0 0 3px rgba(180, 210, 168, 0.2), 0 0 10px var(--moss-glow); }
.dot.warn { background: var(--gold-bright); box-shadow: 0 0 0 3px rgba(240, 217, 137, 0.18); }
.dot.off  { background: var(--crimson); box-shadow: 0 0 0 3px rgba(200, 97, 111, 0.18); }

.kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid var(--glass-edge-2);
  border-radius: 4px;
  background: rgba(8, 6, 12, 0.5);
  color: var(--gold);
  margin: 0 2px;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

/* ============================================================
   HELPERS
   ============================================================ */
.stroke {
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
a.unstyled, a.unstyled:visited { color: inherit; text-decoration: none; }
.hand   { font-family: var(--hand); }
.serif  { font-family: var(--serif); }
.mono   { font-family: var(--mono); }
.display{ font-family: var(--display); }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--gold);
  color: var(--glass-deep);
  padding: 8px 14px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  z-index: 99;
  border-radius: var(--r-2);
}
.skip:focus { left: 12px; top: 12px; }

/* subtle settle (transform only — content stays visible) */
@keyframes settle {
  from { transform: translateY(10px); }
  to   { transform: translateY(0); }
}
.codex-page { animation: settle 0.5s ease both; }
.codex-page:nth-of-type(2) { animation-delay: 0.04s; }
.codex-page:nth-of-type(3) { animation-delay: 0.08s; }
.codex-page:nth-of-type(4) { animation-delay: 0.12s; }
.codex-page:nth-of-type(5) { animation-delay: 0.16s; }
@media (prefers-reduced-motion: reduce) {
  .codex-page { animation: none; }
  .drawer, .drawer-scrim { transition: none; }
  .foil-shimmer { animation: none; }
}
