.codex-page {
  min-height: 100vh;
  background: #eee1c7;
  color: #171220;
}

.codex-halftone {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image: radial-gradient(rgba(23, 16, 42, 0.3) 0.7px, transparent 0.7px);
  background-size: 8px 8px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.codex-header {
  width: min(1280px, calc(100% - 3rem));
  border-bottom-color: rgba(255, 255, 255, 0.14);
}

.codex-header .site-nav .active {
  color: var(--gold);
}

.codex-header .site-nav .active::after {
  right: 0;
  left: 0;
  background: var(--gold);
}

.codex-page::before {
  position: absolute;
  z-index: -2;
  top: 0;
  right: 0;
  left: 0;
  height: 39rem;
  content: "";
  background:
    radial-gradient(circle at 78% 14%, rgba(72, 231, 255, 0.14), transparent 22rem),
    linear-gradient(118deg, transparent 0 59%, rgba(244, 123, 32, 0.15) 59% 70%, transparent 70%),
    #16112a;
}

.codex-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 23rem;
  gap: 4rem;
  align-items: center;
  width: min(1280px, calc(100% - 3rem));
  min-height: 25rem;
  margin: 0 auto;
  padding: 3.4rem 0 4.7rem;
}

.codex-hero-copy {
  position: relative;
  z-index: 1;
}

.codex-hero h1 {
  margin: 0;
  color: var(--cream);
  font-family: var(--display);
  font-size: clamp(4rem, 8vw, 7rem);
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 0.86;
  text-transform: uppercase;
}

.codex-hero h1 mark {
  color: var(--orange-hot);
  text-shadow: 4px 4px 0 #8f202c;
}

.codex-hero-copy > p:last-of-type {
  max-width: 47rem;
  margin: 1.35rem 0 0;
  color: #c5bbd2;
  font-size: 1.02rem;
}

.archive-stats {
  display: flex;
  gap: 0;
  margin: 2rem 0 0;
}

.archive-stats div {
  min-width: 8.6rem;
  padding: 0 1.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.archive-stats div:first-child {
  padding-left: 0;
  border-left: 0;
}

.archive-stats dt,
.archive-stats dd {
  margin: 0;
  text-transform: uppercase;
}

.archive-stats dt {
  color: #7f748f;
  font-size: 0.57rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.archive-stats dd {
  margin-top: 0.25rem;
  color: var(--cream);
  font-family: var(--display);
  font-size: 1.4rem;
  letter-spacing: 0.06em;
}

.codex-emblem {
  position: relative;
  width: min(23rem, 31vw);
  aspect-ratio: 1;
  justify-self: end;
  border: 1px solid rgba(72, 231, 255, 0.18);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 2.85rem, rgba(72, 231, 255, 0.08) 2.9rem 3rem),
    radial-gradient(circle, rgba(23, 105, 194, 0.2), rgba(6, 5, 15, 0.35) 68%);
  box-shadow: inset 0 0 4rem rgba(72, 231, 255, 0.06), 0 0 4rem rgba(72, 231, 255, 0.08);
}

.codex-emblem::before,
.codex-emblem::after {
  position: absolute;
  content: "";
  background: rgba(72, 231, 255, 0.15);
}

.codex-emblem::before {
  top: 50%;
  right: -1.5rem;
  left: -1.5rem;
  height: 1px;
}

.codex-emblem::after {
  top: -1.5rem;
  bottom: -1.5rem;
  left: 50%;
  width: 1px;
}

.codex-emblem > span {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  color: var(--cream);
  font-family: var(--display);
  font-size: 5.4rem;
  font-style: italic;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 4px 4px 0 #1769c2;
  transform: translate(-53%, -62%);
}

.codex-emblem > small {
  position: absolute;
  z-index: 2;
  top: 61%;
  left: 50%;
  color: var(--gold);
  font: 900 0.55rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.25em;
  text-align: center;
  transform: translateX(-50%);
}

.codex-orbit {
  position: absolute;
  z-index: 3;
  border-radius: 50%;
}

.codex-orbit i {
  position: absolute;
  display: grid;
  place-items: center;
  width: 1.75rem;
  aspect-ratio: 1;
  border: 1px solid #ffbc2a;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 27%, #fff2a7, #f47b20 62%, #9b2522);
  box-shadow: 0 0 1rem rgba(244, 123, 32, 0.4);
  color: #a51d20;
  font-style: normal;
  font-size: 0.65rem;
}

.orbit-one {
  inset: 8%;
}

.orbit-one i {
  top: 7%;
  right: 10%;
}

.orbit-two {
  inset: 21%;
}

.orbit-two i:first-child {
  right: -2%;
  bottom: 12%;
}

.orbit-two i:last-child {
  top: 37%;
  left: -7%;
}

.orbit-three {
  inset: 34%;
}

.orbit-three i:nth-child(1) {
  top: -11%;
  left: 35%;
}

.orbit-three i:nth-child(2) {
  right: -18%;
  bottom: 5%;
}

.orbit-three i:nth-child(3) {
  bottom: -7%;
  left: -12%;
}

.codex-workspace {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 2.2rem;
  width: min(1280px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 0 0 6rem;
}

.archive-sidebar {
  position: relative;
  align-self: start;
  margin-top: -1.6rem;
  overflow: hidden;
  border: 1px solid rgba(23, 18, 32, 0.13);
  border-radius: 0.75rem;
  background: #fff9ea;
  box-shadow: 0 1.2rem 3rem rgba(70, 47, 22, 0.13);
}

.archive-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  background: var(--blue-deep);
  color: white;
}

.archive-label span,
.archive-label small {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.archive-label small {
  color: #8eecff;
}

.archive-label small.online::before,
.archive-label small.offline::before {
  display: inline-block;
  width: 0.42rem;
  aspect-ratio: 1;
  margin-right: 0.45rem;
  border-radius: 50%;
  content: "";
  background: var(--green);
  box-shadow: 0 0 0.5rem var(--green);
}

.archive-label small.offline::before {
  background: #ff796c;
  box-shadow: 0 0 0.5rem #ff796c;
}

.category-list {
  display: grid;
  padding: 0.55rem;
}

.category-button {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  gap: 0.7rem;
  align-items: center;
  width: 100%;
  padding: 0.78rem 0.65rem;
  border: 0;
  border-bottom: 1px solid rgba(23, 18, 32, 0.08);
  background: transparent;
  color: #5b5066;
  cursor: pointer;
  text-align: left;
}

.category-button:last-child {
  border-bottom: 0;
}

.category-button:hover,
.category-button:focus-visible {
  background: rgba(23, 105, 194, 0.07);
  color: var(--blue-deep);
  outline: none;
}

.category-button[aria-pressed="true"] {
  border-radius: 0.35rem;
  background: var(--orange);
  color: white;
  box-shadow: inset 4px 0 0 var(--gold);
}

.category-index {
  display: grid;
  place-items: center;
  width: 2.2rem;
  aspect-ratio: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 900 0.62rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.category-name {
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.category-count {
  font: 800 0.65rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.archive-privacy {
  display: flex;
  gap: 0.8rem;
  margin: 0.55rem;
  padding: 1rem;
  border-radius: 0.45rem;
  background: #ede4cf;
}

.archive-privacy > span {
  color: var(--blue);
}

.archive-privacy strong {
  color: #30263a;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.archive-privacy p {
  margin: 0.25rem 0 0;
  color: #736777;
  font-size: 0.72rem;
  line-height: 1.45;
}

.archive-content {
  min-width: 0;
}

.codex-tools {
  display: flex;
  align-items: end;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 2.2rem;
}

.codex-search {
  display: grid;
  flex: 1;
  gap: 0.45rem;
  max-width: 46rem;
}

.codex-search > span {
  color: #6d6073;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.codex-search > div {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 3.4rem;
  overflow: hidden;
  border: 2px solid #292038;
  border-radius: 0.45rem;
  background: #fffaf0;
  box-shadow: 5px 5px 0 rgba(41, 32, 56, 0.12);
}

.codex-search b {
  padding-left: 1rem;
  color: var(--orange);
  font-size: 1.35rem;
}

.codex-search input {
  min-width: 0;
  height: 100%;
  padding: 0.8rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: #21182b;
  font: 700 0.92rem var(--body);
}

.codex-search input::placeholder {
  color: #a79baa;
}

.codex-search > div:focus-within {
  border-color: var(--blue);
  box-shadow: 5px 5px 0 rgba(23, 105, 194, 0.18);
}

.codex-search button {
  align-self: stretch;
  padding: 0 1rem;
  border: 0;
  border-left: 1px solid #dfd4c4;
  background: transparent;
  color: var(--blue-deep);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.codex-search button:hover,
.codex-search button:focus-visible {
  background: #ede4d2;
  outline: none;
}

.search-hint {
  margin: 0 0 0.8rem;
  color: #897c8d;
  font-size: 0.68rem;
}

.search-hint kbd {
  padding: 0.12rem 0.35rem;
  border: 1px solid #b7a9b8;
  border-radius: 0.2rem;
  background: #fffaf0;
  color: #423749;
  font: 800 0.65rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 3px solid #21182b;
}

.results-heading p {
  margin: 0 0 0.15rem;
  color: var(--orange);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.results-heading h2 {
  margin: 0;
  color: #21182b;
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 0.95;
  text-transform: uppercase;
}

.results-heading > strong {
  color: #736678;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.entry-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 16.5rem;
  padding: 1.25rem;
  overflow: hidden;
  border: 1px solid rgba(33, 24, 43, 0.16);
  border-radius: 0.55rem;
  background: #fffaf0;
  color: #21182b;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 0.7rem 1.8rem rgba(80, 54, 28, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.entry-card::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 4.5rem;
  height: 0.35rem;
  content: "";
  background: var(--card-accent, var(--orange));
}

.entry-card::after {
  position: absolute;
  right: -1.6rem;
  bottom: -1.8rem;
  width: 6rem;
  aspect-ratio: 1;
  border: 1rem solid rgba(33, 24, 43, 0.025);
  border-radius: 50%;
  content: "";
}

.entry-card:hover,
.entry-card:focus-visible {
  z-index: 1;
  border-color: var(--card-accent, var(--orange));
  outline: none;
  box-shadow: 0 1.1rem 2.5rem rgba(65, 43, 22, 0.16);
  transform: translateY(-3px);
}

.category-timeline {
  --card-accent: #df2f2f;
}

.category-races {
  --card-accent: #1769c2;
}

.category-places {
  --card-accent: #2f8a52;
}

.category-characters {
  --card-accent: #9b6cff;
}

.codex-character {
  display: grid;
  flex: 0 1 15rem;
  gap: 0.45rem;
}

.codex-character > span {
  color: #6d6073;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.codex-character select {
  min-height: 3.4rem;
  padding: 0.8rem;
  border: 2px solid rgba(77, 225, 255, 0.24);
  border-radius: 0.45rem;
  background: rgba(6, 7, 20, 0.86);
  color: #f7f0df;
  cursor: pointer;
  font: 700 0.82rem var(--body);
}

.codex-character select:focus-visible {
  border-color: var(--blue);
  outline: 3px solid rgba(77, 225, 255, 0.16);
}

.category-techniques {
  --card-accent: #f47b20;
}

.category-factions {
  --card-accent: #138da0;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--card-accent, var(--orange));
  font-size: 0.58rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.entry-card.has-portrait {
  grid-template-columns: 7.5rem minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  column-gap: 1rem;
  min-height: 19rem;
}

.entry-card.has-portrait .card-topline,
.entry-card.has-portrait .card-footer {
  grid-column: 1 / -1;
}

.card-portrait {
  position: relative;
  z-index: 1;
  grid-row: 2 / span 2;
  align-self: stretch;
  min-height: 10.5rem;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid rgba(155, 108, 255, 0.38);
  border-radius: 0.35rem;
  background: #17142a;
  box-shadow: 0 0.75rem 1.6rem rgba(4, 2, 13, 0.3);
}

.card-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  filter: saturate(0.96) brightness(0.88);
  transition: filter 160ms ease, transform 200ms ease;
}

.entry-card:hover .card-portrait img,
.entry-card:focus-visible .card-portrait img {
  filter: saturate(1) brightness(0.96);
  transform: scale(1.025);
}

.entry-card.has-portrait h3,
.entry-card.has-portrait > p {
  grid-column: 2;
}

.featured-mark {
  color: #a16b00;
}

.entry-card h3 {
  margin: 1rem 0 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.entry-card > p {
  margin: 0.8rem 0 1.2rem;
  color: #746778;
  font-size: 0.82rem;
  line-height: 1.55;
}

.card-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(33, 24, 43, 0.09);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.card-tags span {
  padding: 0.2rem 0.4rem;
  border-radius: 0.2rem;
  background: #eee4d3;
  color: #675a6a;
  font-size: 0.52rem;
  font-weight: 850;
  text-transform: uppercase;
}

.card-open {
  flex: 0 0 auto;
  color: var(--card-accent, var(--orange));
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
}

.codex-empty {
  padding: 4rem 2rem;
  border: 2px dashed #b8a9af;
  border-radius: 0.6rem;
  color: #625568;
  text-align: center;
}

.codex-page [hidden] {
  display: none !important;
}

.codex-empty > span {
  display: grid;
  place-items: center;
  width: 4rem;
  aspect-ratio: 1;
  margin: 0 auto;
  border: 3px solid var(--orange);
  border-radius: 50%;
  color: var(--orange);
  font-family: var(--display);
  font-size: 2.2rem;
}

.codex-empty h3 {
  margin: 1rem 0 0;
  color: #2a2032;
  font-family: var(--display);
  font-size: 1.8rem;
  text-transform: uppercase;
}

.codex-empty p {
  margin: 0.35rem 0 1.2rem;
}

.codex-empty button {
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 0.3rem;
  background: var(--blue-deep);
  color: white;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.codex-footer {
  background: #171129;
  color: #91869e;
}

.entry-dialog {
  width: min(780px, calc(100% - 2rem));
  max-height: min(88vh, 900px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0.75rem;
  background: #fff9eb;
  color: #22182c;
  box-shadow: 0 3rem 8rem rgba(0, 0, 0, 0.55);
}

.entry-dialog::backdrop {
  background: rgba(7, 5, 15, 0.78);
  backdrop-filter: blur(5px);
}

.dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(88vh, 900px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--blue-deep);
  color: white;
}

.dialog-header span,
.dialog-header small {
  display: block;
  text-transform: uppercase;
}

.dialog-header span {
  color: #8feeff;
  font-size: 0.6rem;
  font-weight: 950;
  letter-spacing: 0.14em;
}

.dialog-header small {
  margin-top: 0.2rem;
  color: #cddbf0;
  font-size: 0.55rem;
  letter-spacing: 0.08em;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 2.4rem;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
  outline: none;
}

.dialog-body {
  overflow-y: auto;
  padding: clamp(1.3rem, 4vw, 2.5rem);
}

.dialog-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.4rem;
  border-bottom: 3px solid #24182e;
}

.dialog-heading-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.dialog-portrait {
  flex: 0 0 clamp(10rem, 24vw, 14rem);
  align-self: stretch;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(155, 108, 255, 0.45);
  border-radius: 0.5rem;
  background: #17142a;
  box-shadow: 0 1rem 2.5rem rgba(4, 2, 13, 0.32);
}

.dialog-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 20rem;
  max-height: 27rem;
  object-fit: contain;
  object-position: top center;
  filter: saturate(0.98) brightness(0.92);
}

.dialog-title-row h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.7rem, 8vw, 4.8rem);
  font-style: italic;
  letter-spacing: 0.01em;
  line-height: 0.9;
  text-transform: uppercase;
}

.dialog-title-row p {
  max-width: 35rem;
  margin: 0.9rem 0 0;
  color: #786a7b;
  font-size: 0.92rem;
}

.record-seal {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 4.2rem;
  aspect-ratio: 1;
  border: 2px solid #ffb52d;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff0a6, #f47b20 64%, #a32624);
  box-shadow: inset -0.4rem -0.5rem 0.8rem rgba(115, 24, 18, 0.25);
  color: #aa2525;
  font-size: 1.25rem;
}

.dialog-copy {
  margin: 1.5rem 0;
}

.dialog-copy p {
  margin: 0.85rem 0;
  color: #4e4254;
  line-height: 1.75;
}

.dialog-copy p:first-child::first-letter {
  float: left;
  margin: 0.1rem 0.35rem 0 0;
  color: var(--orange);
  font-family: var(--display);
  font-size: 3rem;
  line-height: 0.75;
}

.dialog-facts {
  margin: 1.7rem 0;
  padding: 1rem;
  border-left: 4px solid var(--orange);
  background: #eee4d2;
}

.dialog-facts h3,
.related-records h3 {
  margin: 0 0 0.75rem;
  color: #756777;
  font-size: 0.6rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dialog-facts dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 1.2rem;
  margin: 0;
}

.dialog-facts dl div {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(33, 24, 43, 0.1);
}

.dialog-facts dt,
.dialog-facts dd {
  margin: 0;
}

.dialog-facts dt {
  color: #8a7d8b;
  font-size: 0.55rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dialog-facts dd {
  margin-top: 0.15rem;
  color: #241a2d;
  font-weight: 850;
}

.dialog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.2rem 0;
}

.dialog-tags span {
  padding: 0.28rem 0.55rem;
  border: 1px solid #c9bbc5;
  border-radius: 999px;
  color: #6f6070;
  font-size: 0.58rem;
  font-weight: 850;
  text-transform: uppercase;
}

.atlas-jump {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  border-radius: 0.4rem;
  background: #12253b;
  color: #94f4ff;
  font-size: 0.7rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.atlas-jump b {
  color: var(--gold);
  font-size: 1.4rem;
}

.atlas-jump:hover,
.atlas-jump:focus-visible {
  background: var(--blue-deep);
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.related-records {
  margin-top: 1.7rem;
  padding-top: 1rem;
  border-top: 1px solid #d9ccbe;
}

.related-records > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.related-records button {
  padding: 0.55rem 0.7rem;
  border: 1px solid #bcaeb9;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--blue-deep);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 900;
}

.related-records button:hover,
.related-records button:focus-visible {
  border-color: var(--orange);
  color: var(--orange);
  outline: none;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid #dfd2c3;
  background: #eee4d2;
}

.dialog-footer button {
  padding: 0.7rem 0.9rem;
  border: 1px solid #9f929f;
  border-radius: 0.3rem;
  background: transparent;
  color: #4f4254;
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.dialog-footer button:first-child {
  border-color: var(--orange);
  background: var(--orange);
  color: white;
}

.dialog-footer button:hover,
.dialog-footer button:focus-visible {
  border-color: var(--blue);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (max-width: 1000px) {
  .codex-hero {
    grid-template-columns: minmax(0, 1fr) 17rem;
  }

  .codex-workspace {
    grid-template-columns: 1fr;
  }

  .archive-sidebar {
    margin-top: -1.6rem;
  }

  .category-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .category-button {
    grid-template-columns: auto 1fr auto;
    border-right: 1px solid rgba(23, 18, 32, 0.08);
  }

  .archive-privacy {
    display: none;
  }
}

@media (max-width: 760px) {
  .codex-page::before {
    height: 42rem;
  }

  .codex-hero {
    grid-template-columns: 1fr;
    gap: 1rem;
    min-height: 34rem;
    padding-top: 2.5rem;
  }

  .codex-emblem {
    position: absolute;
    top: 17rem;
    right: -4rem;
    width: 16rem;
    opacity: 0.34;
  }

  .codex-hero-copy > p:last-of-type {
    max-width: 31rem;
  }

  .archive-stats {
    flex-wrap: wrap;
  }

  .archive-stats div {
    min-width: 7rem;
    padding: 0 0.8rem;
  }

  .category-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .codex-tools {
    display: block;
  }

  .codex-character {
    margin-top: 1rem;
  }

  .search-hint {
    display: none;
  }

  .results-heading {
    align-items: start;
  }

  .entry-dialog {
    width: calc(100% - 1rem);
    max-height: calc(100vh - 1rem);
  }

  .dialog-shell {
    max-height: calc(100vh - 1rem);
  }

  .dialog-title-row {
    gap: 1rem;
  }

  .record-seal {
    width: 3rem;
  }

  .dialog-facts dl {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .codex-header,
  .codex-hero,
  .codex-workspace {
    width: min(100% - 1.5rem, 1280px);
  }

  .codex-hero h1 {
    font-size: 3.65rem;
  }

  .archive-stats div {
    min-width: 33.33%;
  }

  .archive-stats dd {
    font-size: 1rem;
  }

  .category-button {
    grid-template-columns: 1.8rem 1fr auto;
    gap: 0.45rem;
    padding: 0.65rem 0.45rem;
  }

  .category-index {
    width: 1.8rem;
  }

  .category-name {
    font-size: 0.66rem;
  }

  .entry-card {
    min-height: 15rem;
  }

  .entry-card.has-portrait {
    grid-template-columns: 6.25rem minmax(0, 1fr);
    min-height: 18rem;
  }

  .card-portrait {
    min-height: 9rem;
  }

  .dialog-title-row {
    flex-wrap: wrap;
  }

  .dialog-portrait {
    flex-basis: 8rem;
    max-width: 8rem;
  }

  .dialog-portrait img {
    min-height: 11rem;
    max-height: 14rem;
  }

  .dialog-title-row h2 {
    font-size: 2.5rem;
  }

  .record-seal {
    display: none;
  }

  .dialog-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-card {
    transition: none;
  }
}

/* Chronicle palette: low-glare archive surfaces without changing branding. */
.codex-page {
  background:
    radial-gradient(circle at 78% 8%, rgba(155, 108, 255, 0.2), transparent 30rem),
    radial-gradient(circle at 12% 36%, rgba(255, 122, 24, 0.1), transparent 24rem),
    linear-gradient(rgba(77, 225, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 225, 255, 0.025) 1px, transparent 1px),
    #090714;
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
  color: #f7f0df;
}

.codex-halftone {
  opacity: 0.12;
  background-image: radial-gradient(rgba(77, 225, 255, 0.28) 0.7px, transparent 0.7px);
}

.archive-stats dt,
.codex-search > span,
.codex-character > span,
.search-hint,
.results-heading > strong,
.entry-card > p,
.codex-empty,
.dialog-title-row p,
.dialog-copy p,
.dialog-facts h3,
.related-records h3,
.dialog-facts dt {
  color: #aaa3b8;
}

.archive-sidebar,
.entry-card,
.entry-dialog {
  border-color: rgba(77, 225, 255, 0.2);
  background: linear-gradient(135deg, rgba(19, 19, 46, 0.98), rgba(12, 11, 29, 0.98));
  color: #f7f0df;
  box-shadow: 0 1.2rem 3rem rgba(4, 2, 13, 0.34);
}

.archive-label,
.dialog-header {
  background: #0d1733;
}

.category-button {
  border-bottom-color: rgba(77, 225, 255, 0.1);
  color: #d8d1e2;
}

.category-button:hover,
.category-button:focus-visible {
  background: rgba(77, 225, 255, 0.08);
  color: var(--cyan);
}

.archive-privacy,
.dialog-facts {
  background: rgba(155, 108, 255, 0.08);
}

.archive-privacy strong,
.results-heading h2,
.codex-empty h3,
.dialog-facts dd {
  color: #f7f0df;
}

.archive-privacy p,
.card-tags span,
.dialog-tags span {
  color: #aaa3b8;
}

.codex-search > div {
  border-color: rgba(77, 225, 255, 0.24);
  background: rgba(6, 7, 20, 0.86);
  box-shadow: 5px 5px 0 rgba(77, 225, 255, 0.05);
}

.codex-search input {
  color: #f7f0df;
}

.codex-search input::placeholder {
  color: #777188;
}

.codex-search button {
  border-left-color: rgba(77, 225, 255, 0.18);
  color: var(--cyan);
}

.codex-search button:hover,
.codex-search button:focus-visible,
.search-hint kbd,
.card-tags span {
  background: rgba(77, 225, 255, 0.07);
}

.search-hint kbd,
.dialog-tags span,
.related-records button,
.dialog-footer button {
  border-color: rgba(77, 225, 255, 0.2);
  color: #c9c2d5;
}

.results-heading {
  border-bottom-color: rgba(77, 225, 255, 0.3);
}

.entry-card {
  border-color: rgba(77, 225, 255, 0.16);
}

.entry-card:hover,
.entry-card:focus-visible {
  border-color: rgba(77, 225, 255, 0.46);
  box-shadow: 0 1rem 2.3rem rgba(4, 2, 13, 0.38);
}

.card-footer,
.dialog-facts dl div,
.related-records,
.dialog-footer {
  border-color: rgba(77, 225, 255, 0.13);
}

.codex-empty {
  border-color: rgba(77, 225, 255, 0.24);
}

.dialog-facts dd {
  font-weight: 850;
}

.dialog-footer {
  background: #0d0c20;
}
