.character-guide-page {
  min-width: 0;
  overflow-x: hidden;
  background: #07090d;
}

.guide-site-header {
  position: absolute;
  background: linear-gradient(to bottom, rgba(3, 4, 7, 0.96), rgba(3, 4, 7, 0.38), transparent);
}

.guide-header-nav { align-items: center; }

.guide-header-nav span {
  color: #756e60;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font: 0.7rem/1.2 Arial, sans-serif;
}

.guide-hero {
  position: relative;
  min-height: 64svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  padding: 10rem clamp(1.25rem, 6vw, 6rem) 6rem;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(7, 9, 13, 0.04), rgba(7, 9, 13, 0.48) 70%, #07090d 99%),
    radial-gradient(circle at 50% 45%, rgba(154, 102, 43, 0.22), transparent 26rem),
    linear-gradient(135deg, #050609, #0b0f17 50%, #050609);
}

.guide-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0.46;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.74), transparent 24% 76%, rgba(0, 0, 0, 0.74)),
    repeating-linear-gradient(90deg, transparent 0 11.5%, rgba(219, 182, 96, 0.065) 11.6%, transparent 11.8% 23%),
    repeating-linear-gradient(0deg, transparent 0 7.9rem, rgba(219, 182, 96, 0.035) 8rem),
    radial-gradient(circle at center, transparent 0 25%, #000 84%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0 73%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0 73%, transparent 100%);
}

.guide-hero::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(86vw, 62rem);
  height: 7rem;
  transform: translateX(-50%);
  background:
    linear-gradient(90deg, transparent, rgba(201, 162, 82, 0.24) 38%, rgba(238, 216, 139, 0.6) 50%, rgba(201, 162, 82, 0.24) 62%, transparent) bottom / 100% 1px no-repeat,
    linear-gradient(to bottom, transparent, rgba(201, 162, 82, 0.44)) center / 1px 100% no-repeat;
}

.guide-hero-mark {
  position: absolute;
  z-index: 0;
  width: min(78vw, 44rem);
  aspect-ratio: 1;
  pointer-events: none;
  opacity: 0.68;
  background: url("/assets/prologue-circles-emblem.webp") center / contain no-repeat;
  mix-blend-mode: screen;
  filter: saturate(0.86) brightness(0.82);
  transform: translateY(1rem);
  -webkit-mask-image: radial-gradient(circle, #000 56%, rgba(0, 0, 0, 0.94) 69%, transparent 91%);
  mask-image: radial-gradient(circle, #000 56%, rgba(0, 0, 0, 0.94) 69%, transparent 91%);
}

.guide-hero-inner {
  position: relative;
  z-index: 1;
  width: min(100%, 64rem);
}

.guide-volume {
  margin: 0;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font: 0.72rem/1.4 Arial, sans-serif;
}

.guide-hero h1 {
  max-width: 12ch;
  margin: 1.25rem auto 1.3rem;
  color: var(--bone);
  font-size: clamp(3.7rem, 8.5vw, 7.6rem);
  font-weight: normal;
  line-height: 0.9;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}

.guide-subtitle {
  margin: 0;
  color: #d4c8b4;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
}

.guide-introduction {
  width: min(100%, 42rem);
  margin: 1.4rem auto 0;
  color: #aaa08e;
  font-size: clamp(1rem, 1.5vw, 1.12rem);
  line-height: 1.75;
  text-wrap: balance;
}

.guide-content {
  position: relative;
  padding: clamp(4.5rem, 8vw, 7.5rem) clamp(1.1rem, 5vw, 5rem) clamp(6rem, 10vw, 9rem);
  background:
    radial-gradient(ellipse at 8% 12%, rgba(111, 74, 32, 0.1), transparent 28rem),
    radial-gradient(ellipse at 92% 34%, rgba(80, 59, 34, 0.075), transparent 26rem),
    linear-gradient(180deg, #07090d, #0a0c11 52%, #07090d);
}

.guide-tools,
.guide-directory,
.guide-footer {
  width: min(100%, 72rem);
  margin-inline: auto;
}

.guide-tools {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(19rem, 1.15fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}

.guide-notice {
  padding: 1.2rem 1.4rem;
  border-left: 1px solid rgba(201, 162, 82, 0.5);
  background: linear-gradient(90deg, rgba(201, 162, 82, 0.06), transparent);
}

.guide-notice p { margin: 0; color: #aaa08f; font-size: 0.95rem; line-height: 1.65; }
.guide-notice p + p { margin-top: 0.25rem; }
.guide-notice strong { color: #d7c8a9; font-weight: normal; letter-spacing: 0.04em; }

.guide-search label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font: 0.67rem/1.4 Arial, sans-serif;
}

.guide-search-field { position: relative; }

.guide-search-field input {
  width: 100%;
  min-width: 0;
  padding: 1rem 3rem 1rem 0;
  border: 0;
  border-bottom: 1px solid rgba(201, 162, 82, 0.42);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--bone);
  font: 1.15rem/1.4 Georgia, "Times New Roman", serif;
}

.guide-search-field input::placeholder { color: #777064; opacity: 1; }
.guide-search-field input:focus { border-color: var(--gold-bright); }

.guide-search-field span {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  width: 1.05rem;
  height: 1.05rem;
  border: 1px solid var(--gold);
  border-radius: 50%;
  transform: translateY(-62%);
  pointer-events: none;
}

.guide-search-field span::after {
  content: "";
  position: absolute;
  right: -0.42rem;
  bottom: -0.28rem;
  width: 0.55rem;
  height: 1px;
  background: var(--gold);
  transform: rotate(45deg);
}

.guide-search-status { margin: 0.75rem 0 0; color: #756e61; font-size: 0.85rem; }

.guide-search-results {
  margin-top: 1rem;
  border-top: 1px solid rgba(201, 162, 82, 0.2);
}

.guide-search-result {
  display: block;
  width: 100%;
  padding: 1rem 0.35rem;
  border: 0;
  border-bottom: 1px solid rgba(201, 162, 82, 0.12);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.guide-search-result:hover,
.guide-search-result:focus-visible { background: rgba(201, 162, 82, 0.045); outline: 0; }
.guide-search-result strong { display: block; color: var(--bone); font: normal 1rem/1.35 Georgia, serif; }
.guide-search-result span { display: block; margin-top: 0.22rem; color: #9c927f; font: 0.73rem/1.5 Arial, sans-serif; }

.guide-index {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: clamp(2.5rem, 5vw, 4.5rem);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.guide-index a {
  min-width: 0;
  padding: 1.25rem 1rem;
  border-right: 1px solid rgba(201, 162, 82, 0.15);
  color: #bbb09c;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font: 0.68rem/1.55 Arial, sans-serif;
}

.guide-index a:last-child { border-right: 0; }
.guide-index a:hover, .guide-index a:focus-visible { color: var(--bone); background: rgba(201, 162, 82, 0.05); }
.guide-index span { display: block; margin-bottom: 0.35rem; color: var(--gold); font-size: 0.6rem; }

.guide-directory { margin-top: clamp(3rem, 7vw, 6rem); }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.guide-division { scroll-margin-top: 1rem; border-bottom: 1px solid rgba(201, 162, 82, 0.22); }
.guide-division:first-child { border-top: 1px solid rgba(201, 162, 82, 0.22); }

.guide-division > summary {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr) 1.5rem;
  gap: 1.2rem;
  align-items: center;
  padding: clamp(1.6rem, 3.5vw, 2.5rem) 0;
  color: var(--bone);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
  line-height: 1.1;
}

.guide-division > summary h2,
.guide-territory > summary h3 {
  display: contents;
  margin: 0;
  color: inherit;
  font: inherit;
}

.division-number { color: var(--gold); font: 0.63rem/1 Arial, sans-serif; letter-spacing: 0.16em; }

.guide-division > summary i,
.guide-territory > summary i,
.character-group > summary i {
  position: relative;
  width: 1rem;
  height: 1rem;
}

.guide-division > summary i::before,
.guide-division > summary i::after,
.guide-territory > summary i::before,
.guide-territory > summary i::after,
.character-group > summary i::before,
.character-group > summary i::after {
  content: "";
  position: absolute;
  top: 50%; left: 0;
  width: 100%; height: 1px;
  background: var(--gold);
  transition: transform 180ms ease;
}

details:not([open]) > summary i::after { transform: rotate(90deg); }

.division-body { padding: 0 0 clamp(2rem, 5vw, 4rem) 4.4rem; }
.division-groups { display: grid; gap: 0.75rem; }

.guide-territory { border-top: 1px solid rgba(201, 162, 82, 0.12); }
.guide-territory > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1rem;
  gap: 1rem;
  align-items: center;
  padding: 1.5rem 0;
  color: #dacbac;
  cursor: pointer;
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
}

.territory-body { padding: 0 0 1.5rem clamp(0rem, 3vw, 2rem); }

.character-group {
  border-top: 1px solid rgba(201, 162, 82, 0.1);
  background: linear-gradient(90deg, rgba(201, 162, 82, 0.025), transparent 68%);
}

.character-group > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0.85rem;
  gap: 1rem;
  align-items: center;
  padding: 1.15rem 0.8rem;
  cursor: pointer;
}

.character-group > summary strong {
  display: block;
  color: #cfc3ae;
  font: normal 0.76rem/1.4 Arial, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.character-group > summary small {
  display: block;
  margin-top: 0.3rem;
  color: var(--gold);
  font: 0.61rem/1.4 Arial, sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.character-group ul { margin: 0; padding: 0 1rem 1.25rem; list-style: none; }

.character-entry {
  display: grid;
  grid-template-columns: minmax(12rem, 0.8fr) minmax(0, 1.2fr);
  gap: 1.5rem;
  padding: 0.78rem 0;
  border-top: 1px solid rgba(201, 162, 82, 0.08);
}

.character-name { color: #eee4d2; font-size: 1.02rem; line-height: 1.45; }
.character-role { color: #9e9483; font-size: 0.95rem; line-height: 1.55; }
.unspecified, .past-context { margin: 0; padding: 0 1rem 1.35rem; color: #777064; font-size: 0.9rem; font-style: italic; }
.past-context { padding: 0.8rem 0 1.4rem; letter-spacing: 0.03em; }

.guide-division-aljorana[open] {
  background: radial-gradient(ellipse at 85% 20%, rgba(35, 102, 75, 0.11), transparent 28rem);
}
.guide-division-aljorana .character-group { background: linear-gradient(90deg, rgba(27, 100, 72, 0.04), transparent 68%); }
.guide-division-aljorana .character-group > summary small { color: #9ebd94; }

.guide-division-past[open] {
  margin-top: 1rem;
  padding-inline: clamp(0rem, 2vw, 1.5rem);
  background:
    repeating-linear-gradient(0deg, transparent 0 4.9rem, rgba(184, 167, 133, 0.025) 5rem),
    linear-gradient(135deg, rgba(107, 96, 73, 0.055), transparent 66%);
  filter: sepia(0.08);
}
.guide-division-past > summary { color: #c8bdac; }
.guide-division-past .character-name { color: #cfc5b5; }

.guide-target-flash { animation: guide-flash 1.35s ease; }

@keyframes guide-flash {
  0%, 100% { background-color: transparent; }
  30% { background-color: rgba(201, 162, 82, 0.16); }
}

.guide-footer {
  margin-top: clamp(4rem, 8vw, 7rem);
  padding-top: 2rem;
  border-top: 1px solid rgba(201, 162, 82, 0.15);
}

.guide-footer a {
  color: var(--gold-bright);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font: 0.7rem/1.4 Arial, sans-serif;
}

@media (max-width: 820px) {
  .guide-site-header { padding: 1.15rem 1rem; }
  .guide-site-header .wordmark > span:last-child { display: none; }
  .guide-header-nav { justify-content: flex-end; flex-wrap: wrap; gap: 0.55rem 1rem; }
  .guide-header-nav a, .guide-header-nav span { font-size: 0.62rem; letter-spacing: 0.1em; }
  .guide-hero { min-height: 58svh; padding: 8rem 1.1rem 4.75rem; }
  .guide-hero h1 { font-size: clamp(3rem, 12vw, 5.6rem); }
  .guide-hero-mark {
    width: min(106vw, 31rem);
    opacity: 0.6;
    filter: saturate(0.78) brightness(0.76);
    transform: translateY(0.7rem);
    -webkit-mask-image: radial-gradient(circle, #000 54%, rgba(0, 0, 0, 0.92) 69%, transparent 90%);
    mask-image: radial-gradient(circle, #000 54%, rgba(0, 0, 0, 0.92) 69%, transparent 90%);
  }
  .guide-tools { grid-template-columns: 1fr; gap: 2rem; }
  .guide-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-index a:nth-child(2) { border-right: 0; }
  .guide-index a:nth-child(-n+2) { border-bottom: 1px solid rgba(201, 162, 82, 0.15); }
}

@media (max-width: 600px) {
  .guide-content { padding-inline: 1rem; }
  .guide-index { grid-template-columns: 1fr; }
  .guide-index a { border-right: 0; border-bottom: 1px solid rgba(201, 162, 82, 0.15); }
  .guide-index a:last-child { border-bottom: 0; }
  .guide-division > summary { grid-template-columns: 2rem minmax(0, 1fr) 1rem; gap: 0.65rem; font-size: clamp(1.25rem, 7vw, 1.8rem); }
  .division-body { padding-left: 0; }
  .territory-body { padding-left: 0.4rem; }
  .character-entry { grid-template-columns: 1fr; gap: 0.18rem; padding: 0.85rem 0; }
  .character-name { overflow-wrap: anywhere; }
  .character-role { overflow-wrap: anywhere; }
  .guide-search-results { max-height: 22rem; overflow-y: auto; }
  .guide-division-past[open] { padding-inline: 0.35rem; }
}

@media (max-width: 390px) {
  .guide-header-nav span { display: none; }
  .guide-site-header { justify-content: space-between; }
  .guide-header-nav { gap: 0.45rem 0.7rem; }
  .guide-header-nav a { font-size: 0.56rem; letter-spacing: 0.07em; }
  .guide-hero h1 { font-size: clamp(2.7rem, 14vw, 4rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .guide-target-flash { animation: none; }
}
