:root {
  --bg-0: #060b19;
  --bg-1: #0b1736;
  --bg-2: #153067;

  --glass-1: rgba(20, 43, 89, 0.68);
  --glass-2: rgba(12, 27, 58, 0.82);
  --glass-line: rgba(157, 201, 255, 0.35);

  --ink-main: #2f241b;
  --ink-body: #433225;
  --paper-1: #e8ddc8;
  --paper-2: #d5c5a7;
  --paper-line: rgba(104, 77, 53, 0.24);

  --text-main: #eaf3ff;
  --text-dim: #a2bde3;
  --accent: #84cfff;
  --accent-deep: #4ea6ea;
  --space-1: 0.38rem;
  --space-2: 0.62rem;
  --space-3: 0.9rem;
  --space-4: 1.2rem;
}

* {
  box-sizing: border-box;
}

.view-hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(90% 70% at 14% 8%, #214a8f 0%, transparent 54%),
    radial-gradient(80% 70% at 86% 18%, #1a356f 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1) 40%, var(--bg-0));
  color: var(--text-main);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  border-bottom: 1px solid var(--glass-line);
  background:
    linear-gradient(180deg, var(--glass-1), var(--glass-2)),
    radial-gradient(90% 120% at 50% -30%, rgba(180, 221, 255, 0.18), rgba(180, 221, 255, 0));
  backdrop-filter: blur(10px) saturate(1.08);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
  box-shadow: 0 10px 26px rgba(3, 10, 26, 0.46);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(183, 223, 255, 0.88), transparent);
}

.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0.66rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  margin: 0;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: clamp(0.98rem, 1.28vw, 1.22rem);
  color: var(--text-main);
}

.menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.42rem 0.92rem;
}

.menu a {
  position: relative;
  text-decoration: none;
  color: var(--text-dim);
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-variant-caps: all-small-caps;
  font-size: clamp(0.72rem, 0.86vw, 0.95rem);
  letter-spacing: 0.045em;
  font-weight: 600;
  opacity: 0.9;
  transition: color 0.16s ease, opacity 0.16s ease;
  outline: none;
}

.menu a + a::before {
  content: "|";
  position: absolute;
  left: -0.66rem;
  color: rgba(140, 171, 214, 0.7);
}

.menu a:hover,
.menu a:focus-visible,
.menu a.active {
  color: var(--text-main);
  opacity: 1;
}

.menu a.active::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -0.42rem;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(132, 205, 255, 0), rgba(132, 205, 255, 1), rgba(132, 205, 255, 0));
  box-shadow: 0 0 10px rgba(132, 205, 255, 0.28);
}

.split-layout {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
}

.split-layout::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  background: linear-gradient(
    180deg,
    rgba(170, 209, 255, 0.08),
    rgba(170, 209, 255, 0.36) 14%,
    rgba(170, 209, 255, 0.18) 50%,
    rgba(170, 209, 255, 0.34) 86%,
    rgba(170, 209, 255, 0.08)
  );
  pointer-events: none;
  z-index: 1;
}

.left-half {
  position: relative;
  padding: 0;
  border-right: 0;
  background:
    linear-gradient(180deg, rgba(16, 36, 80, 0.38), rgba(8, 20, 47, 0.7)),
    radial-gradient(42% 36% at 16% 12%, rgba(129, 199, 255, 0.2), transparent 74%),
    radial-gradient(46% 42% at 82% 82%, rgba(97, 132, 216, 0.22), transparent 74%);
}

.art-placeholder {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 56px);
  overflow: hidden;
  background: #0b1737;
}

.art-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0.8;
  mix-blend-mode: screen;
  filter: saturate(0.86) contrast(1.14) hue-rotate(8deg) brightness(0.93);
}

.art-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(112deg, rgba(210, 235, 255, 0.16) 0%, rgba(210, 235, 255, 0) 28%),
    radial-gradient(120% 16% at 50% 0, rgba(184, 226, 255, 0.14), transparent 82%),
    radial-gradient(34% 20% at 50% 95%, rgba(111, 216, 255, 0.3), rgba(111, 216, 255, 0)),
    linear-gradient(180deg, rgba(6, 14, 34, 0.1) 0%, rgba(6, 14, 34, 0.56) 100%);
}

.magic-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
}

.location-stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.sigil,
.sigil-core,
.spire {
  display: none;
}

.spire {
  position: absolute;
  bottom: 20%;
  width: 0;
  height: 0;
  border-left: 28px solid transparent;
  border-right: 28px solid transparent;
  border-bottom: 200px solid rgba(229, 240, 255, 0.22);
  filter: drop-shadow(0 0 10px rgba(155, 206, 255, 0.18));
}

.spire-a {
  left: 50%;
  transform: translateX(-50%);
}

.spire-b {
  left: calc(50% - 120px);
  border-left-width: 22px;
  border-right-width: 22px;
  border-bottom-width: 150px;
  opacity: 0.84;
}

.spire-c {
  left: calc(50% + 76px);
  border-left-width: 18px;
  border-right-width: 18px;
  border-bottom-width: 120px;
  opacity: 0.76;
}

.location-mark {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(0.74rem, 0.9vw, 0.9rem);
  text-transform: uppercase;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.07em;
  color: rgba(221, 238, 255, 0.9);
  text-shadow: 0 0 12px rgba(151, 205, 255, 0.24);
}

.sigil {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(130, 212, 255, 0.34);
  box-shadow: 0 0 24px rgba(128, 208, 255, 0.15), inset 0 0 20px rgba(128, 208, 255, 0.12);
}

.sigil-a {
  width: min(58%, 360px);
  aspect-ratio: 1;
}

.sigil-b {
  width: min(42%, 250px);
  aspect-ratio: 1;
}

.sigil-core {
  width: 14px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(173, 235, 255, 0.95), rgba(131, 206, 255, 0.46));
  box-shadow: 0 0 16px rgba(121, 207, 255, 0.5);
}

.magic-mark {
  position: absolute;
  bottom: 14%;
  margin: 0;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(0.84rem, 1vw, 1rem);
  text-transform: uppercase;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
  color: rgba(209, 238, 255, 0.9);
  text-shadow: 0 0 12px rgba(118, 202, 255, 0.26);
}

.name-block {
  position: absolute;
  left: 1.12rem;
  bottom: 1rem;
  z-index: 2;
  max-width: min(78%, 540px);
}

.name-script {
  margin: 0;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(1.44rem, 3.2vw, 2.7rem);
  font-weight: 700;
  color: #e5f1ff;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 12px rgba(4, 10, 24, 0.74);
}

.voice {
  margin: 0.24rem 0 0;
  font-size: clamp(0.8rem, 0.9vw, 0.92rem);
  color: #b8cde8;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(4, 10, 24, 0.54);
}

.right-half {
  position: relative;
  padding: 0;
  background: transparent;
}

.paper-panel {
  width: 100%;
  min-height: calc(100vh - 56px);
  position: relative;
  padding: calc(var(--space-4) + 0.1rem) calc(var(--space-4) + 0.16rem) calc(var(--space-3) + 0.24rem);
  background:
    radial-gradient(70% 50% at 88% 20%, rgba(114, 88, 65, 0.16), rgba(114, 88, 65, 0)),
    radial-gradient(60% 42% at 70% 82%, rgba(159, 136, 110, 0.13), rgba(159, 136, 110, 0)),
    linear-gradient(180deg, var(--paper-1), var(--paper-2));
  color: var(--ink-main);
  box-shadow:
    inset 0 18px 30px rgba(255, 248, 231, 0.22),
    inset 0 0 0 1px rgba(242, 231, 210, 0.36);
}

.paper-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(88, 64, 44, 0.03) 0,
      rgba(88, 64, 44, 0.03) 1px,
      rgba(88, 64, 44, 0) 1px,
      rgba(88, 64, 44, 0) 41px
    ),
    radial-gradient(130% 18% at 50% -6%, rgba(255, 249, 236, 0.56), rgba(255, 249, 236, 0)),
    radial-gradient(120% 16% at 50% 106%, rgba(142, 111, 81, 0.16), rgba(142, 111, 81, 0));
}

.panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  padding-bottom: calc(var(--space-2) + 0.04rem);
  border-bottom: 1px solid var(--paper-line);
}

.panel-title {
  margin: 0;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  text-transform: uppercase;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  font-size: clamp(0.82rem, 0.88vw, 0.9rem);
  color: #4a3425;
  opacity: 0.9;
}

.character-switch {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.16rem;
  border: 1px solid rgba(126, 95, 66, 0.22);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(246, 237, 220, 0.7), rgba(225, 206, 178, 0.58));
  max-width: min(68%, 980px);
}

#character-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.58rem 0.74rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  max-width: min(100%, 1060px);
}

.chip-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.26rem;
}

.chip-group-label {
  position: static;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(0.6rem, 0.7vw, 0.72rem);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.05em;
  color: rgba(85, 58, 36, 0.7);
  margin: 0;
  padding: 0;
}

.chip-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.18rem;
  border: 1px solid rgba(126, 95, 66, 0.22);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(246, 237, 220, 0.7), rgba(225, 206, 178, 0.58));
  max-width: 100%;
}

.chip {
  border: 1px solid rgba(110, 83, 56, 0.36);
  border-radius: 999px;
  padding: 0.3rem 0.78rem;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(0.66rem, 0.78vw, 0.8rem);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  color: #4f3929;
  background: linear-gradient(180deg, rgba(243, 232, 210, 0.74), rgba(222, 202, 172, 0.74));
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
  outline: none;
}

.chip.active {
  border-color: rgba(103, 74, 47, 0.56);
  color: #3d2b1f;
  background: linear-gradient(180deg, rgba(232, 215, 186, 0.98), rgba(205, 180, 145, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 246, 230, 0.42);
}

.chip:hover {
  border-color: rgba(100, 72, 47, 0.48);
}

.chip:focus-visible {
  border-color: rgba(95, 68, 45, 0.66);
  box-shadow: 0 0 0 2px rgba(156, 127, 93, 0.26);
}

.content-section {
  position: relative;
  z-index: 1;
  margin-top: calc(var(--space-3) + 0.04rem);
  padding-bottom: calc(var(--space-2) + 0.02rem);
  border-bottom: 1px solid var(--paper-line);
}

.content-section h3 {
  margin: 0 0 var(--space-2);
  display: flex;
  align-items: center;
  gap: 0.42rem;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(0.9rem, 0.95vw, 0.98rem);
  font-weight: 700;
  text-transform: uppercase;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.04em;
  color: #3b2b1f;
}

.content-section h3::before {
  content: "";
  width: 0.56rem;
  height: 0.56rem;
  flex: 0 0 0.56rem;
  background:
    linear-gradient(90deg, transparent 44%, #6d4b31 44%, #6d4b31 56%, transparent 56%),
    linear-gradient(0deg, transparent 44%, #6d4b31 44%, #6d4b31 56%, transparent 56%);
  opacity: 0.84;
}

.content-section p,
.content-section li {
  margin: 0 0 0.34rem;
  color: var(--ink-body);
  font-size: clamp(0.86rem, 0.9vw, 0.93rem);
  line-height: 1.58;
  max-width: 66ch;
}

#relationships-view .content-section p,
#relationships-view .content-section li {
  max-width: 72ch;
}

#magic-view .content-section p,
#magic-view .content-section li {
  max-width: 72ch;
}

#locations-view .content-section p,
#locations-view .content-section li {
  max-width: 72ch;
}

#relationships-view {
  display: block;
}

.rel-intro {
  border-bottom-color: var(--paper-line);
}

.rel-lead {
  font-size: clamp(0.91rem, 0.96vw, 1rem);
  font-weight: 500;
  color: var(--ink-body);
}

.relationship-grid {
  display: grid;
  gap: 0.9rem;
  margin-top: calc(var(--space-3) + 0.04rem);
}

.relationship-grid.two-up {
  grid-template-columns: 1fr 1fr;
}

.rel-card {
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.rel-card h3 {
  margin-top: 0;
}

.rel-rule {
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: calc(var(--space-2) + 0.02rem);
}

.content-section:first-of-type p {
  font-size: clamp(0.91rem, 0.96vw, 1rem);
  line-height: 1.62;
  max-width: 68ch;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  position: relative;
}

.stats-grid::after {
  content: "";
  position: absolute;
  left: calc(50% - 0.5px);
  top: 0.08rem;
  bottom: 0.08rem;
  width: 1px;
  background: linear-gradient(
    180deg,
    rgba(122, 90, 60, 0),
    rgba(122, 90, 60, 0.26) 14%,
    rgba(122, 90, 60, 0.12) 50%,
    rgba(122, 90, 60, 0.24) 86%,
    rgba(122, 90, 60, 0)
  );
  pointer-events: none;
}

.facts,
.bullets {
  list-style: none;
  margin: 0;
  padding: 0;
}

.facts li,
.bullets li {
  padding: 0.26rem 0;
  border-bottom: 1px solid rgba(113, 83, 56, 0.22);
}

.bullets li {
  position: relative;
  padding-left: 0.96rem;
}

.bullets li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #735037;
}

.quote p {
  font-style: italic;
}

@media (max-width: 1024px) {
  .split-layout {
    grid-template-columns: 1fr;
  }

  .split-layout::before,
  .stats-grid::after {
    display: none;
  }

  .left-half {
    border-right: 0;
    border-bottom: 1px solid rgba(154, 196, 251, 0.2);
  }

  .art-placeholder,
  .paper-panel {
    min-height: 58vh;
  }

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

  .relationship-grid.two-up {
    grid-template-columns: 1fr;
    gap: 0.56rem;
  }

}

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.58rem 0.78rem;
  }

  .menu {
    justify-content: flex-start;
    gap: 0.36rem 0.75rem;
  }

  .menu a + a::before {
    display: none;
  }

  .content-section p,
  .content-section li {
    max-width: none;
  }

  .name-block {
    max-width: min(92%, 540px);
  }

  .location-mark {
    white-space: normal;
    width: min(86%, 360px);
    text-align: center;
  }

  .chip-group {
    width: 100%;
  }

  #character-switch {
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .chip-group-pills {
    max-width: 100%;
  }
}
