.codex-body {
  background:
    linear-gradient(90deg, rgba(7,16,20,.98) 0 26rem, rgba(10,20,24,.96) 26rem 100%),
    var(--night);
}

.codex-header { position: relative; z-index: 5; }
.codex-shell {
  width: min(calc(100% - 3rem), var(--max));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 19rem minmax(0, 1fr);
  gap: clamp(3rem, 7vw, 7rem);
}

.codex-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 5rem 0 3rem;
  align-self: start;
}

.codex-sidebar h1 {
  font-size: 3.6rem;
  line-height: .9;
}

.codex-intro { color: var(--muted); font-size: .88rem; line-height: 1.6; margin: 1.7rem 0 2rem; }
.codex-index { display: grid; gap: 0; }
.codex-index a {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: .4rem;
  padding: .56rem 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: #aab5b3;
  text-decoration: none;
  font-size: .86rem;
}
.codex-index a:hover, .codex-index a:focus-visible { color: var(--gold-bright); }
.codex-index span { color: var(--gold); font-family: ui-monospace, monospace; font-size: .72rem; }
.archive-key { margin-top: 2rem; display: grid; gap: .45rem; color: #6f8081; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; }
.archive-key span { display: flex; align-items: center; gap: .55rem; }
.archive-key i { width: .45rem; height: .45rem; display: inline-block; border-radius: 50%; }
.key-public { background: var(--cyan); }
.key-locked { border: 1px solid var(--gold); }

.codex-entries { border-left: 1px solid rgba(255,255,255,.08); padding-left: clamp(2rem, 5vw, 5rem); }
.codex-lead { min-height: 31rem; display: flex; flex-direction: column; justify-content: center; padding: 5rem 0; }
.codex-lead h2 { max-width: 16ch; }
.codex-lead > p:last-child { max-width: 46rem; color: #aeb9b7; font-size: 1.05rem; }

.codex-entry { padding: 5rem 0; border-top: 1px solid var(--line); scroll-margin-top: 1rem; }
.entry-heading { display: grid; grid-template-columns: 3rem 1fr; gap: 1.2rem; align-items: start; }
.entry-number { color: var(--gold); font-family: ui-monospace, monospace; font-size: .8rem; margin-top: .5rem; }
.entry-type { margin: 0; color: var(--cyan); font-size: .7rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.entry-heading h2 { margin: .25rem 0 2.2rem; font-size: clamp(2.5rem, 5vw, 4rem); }
.entry-content { margin-left: 4.2rem; max-width: 48rem; }
.entry-content > p { color: #b5bfbd; font-size: 1rem; }

.definition-grid { margin-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid rgba(255,255,255,.08); }
.definition-grid div { padding: 1.25rem 1rem 1.25rem 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.definition-grid div:nth-child(even) { padding-left: 1.25rem; border-left: 1px solid rgba(255,255,255,.08); }
.definition-grid strong, .definition-grid span { display: block; }
.definition-grid strong { color: var(--gold-bright); font-family: "Cormorant Garamond", serif; font-size: 1.4rem; }
.definition-grid span { color: var(--muted); font-size: .82rem; line-height: 1.5; }

.play-sequence { list-style: none; padding: 0; margin: 2rem 0; counter-reset: sequence; }
.play-sequence li { display: grid; grid-template-columns: 6rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.play-sequence strong { color: var(--gold-bright); }
.play-sequence span { color: var(--muted); font-size: .9rem; }
.codex-note { margin-top: 2rem; padding: 1.2rem 1.4rem; border-left: 2px solid var(--cyan); background: rgba(115,200,196,.06); color: #aebbb9; font-size: .9rem; }
.codex-note strong { color: var(--cyan); }

.system-record { margin-top: 2rem; padding: 1.3rem 1.5rem; border: 1px solid rgba(115,200,196,.25); background: rgba(5,16,19,.7); font-family: ui-monospace, monospace; font-size: .82rem; }
.system-record > span { color: var(--cyan); font-size: .68rem; letter-spacing: .1em; }
.system-record p { margin: .7rem 0 0; display: flex; justify-content: space-between; color: #788c8d; }
.system-record strong { color: var(--ink); }
.gold-text { color: var(--gold-bright) !important; }

.coming-list { margin-top: 2rem; border-top: 1px solid rgba(255,255,255,.08); }
.coming-list span { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid rgba(255,255,255,.08); color: #b6c0be; }
.coming-list strong { color: var(--gold); font-family: ui-monospace, monospace; font-size: .72rem; text-transform: uppercase; }
.term-list { margin: 2rem 0 0; }
.term-list div { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.term-list dt { color: var(--gold-bright); font-family: "Cormorant Garamond", serif; font-size: 1.3rem; }
.term-list dd { margin: 0; color: var(--muted); font-size: .9rem; }

.locked-entry { opacity: .72; }
.locked-record { margin-top: 2rem; min-height: 11rem; display: grid; place-items: center; align-content: center; border: 1px dashed rgba(217,184,102,.35); text-align: center; }
.locked-record span { color: var(--gold); font-size: 2rem; }
.locked-record strong, .locked-record small { display: block; }
.locked-record strong { color: var(--gold-bright); font-family: "Cormorant Garamond", serif; font-size: 1.5rem; }
.locked-record small { color: var(--muted); }
.codex-footer { position: relative; z-index: 2; }

@media (max-width: 900px) {
  .codex-body { background: var(--night); }
  .codex-shell { grid-template-columns: 1fr; gap: 0; }
  .codex-sidebar { position: static; height: auto; padding: 4rem 0 2rem; }
  .codex-sidebar h1 { font-size: 3.2rem; }
  .codex-index { grid-template-columns: 1fr 1fr; column-gap: 1.5rem; }
  .archive-key { display: none; }
  .codex-entries { border-left: 0; padding-left: 0; }
  .codex-lead { min-height: auto; padding: 4rem 0; }
}

@media (max-width: 560px) {
  .codex-shell { width: min(calc(100% - 2rem), var(--max)); }
  .codex-index { grid-template-columns: 1fr; }
  .entry-heading { grid-template-columns: 2rem 1fr; gap: .6rem; }
  .entry-content { margin-left: 2.6rem; }
  .definition-grid { grid-template-columns: 1fr; }
  .definition-grid div:nth-child(even) { padding-left: 0; border-left: 0; }
  .play-sequence li, .term-list div { grid-template-columns: 1fr; gap: .25rem; }
  .coming-list span { display: grid; }
}
