:root {
  --ink: #222521;
  --muted: #6b6b61;
  --paper: #fffdf5;
  --paper-deep: #f4efdf;
  --forest: #142c29;
  --forest-soft: #21423d;
  --gold: #b78a34;
  --gold-pale: #e6d09d;
  --line: #ddd3ba;
  --shadow: 0 18px 50px rgba(20, 31, 28, .12);
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: #e9e5d9;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.72;
}

a { color: #245b67; text-underline-offset: 3px; }
a:hover { color: #8b5524; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 8px 12px;
  color: white;
  background: #000;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 270px;
  overflow-y: auto;
  padding: 32px 24px;
  color: #f5f2e8;
  background: var(--forest);
  border-right: 1px solid rgba(230, 208, 157, .18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  color: white;
  font-family: var(--sans);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--gold-pale);
  border: 1px solid rgba(230, 208, 157, .65);
  border-radius: 50%;
  font: 600 21px/1 var(--serif);
}

.brand strong { display: block; font-size: 20px; letter-spacing: .04em; }
.brand small { display: block; margin-top: 2px; color: #b8c8c3; font-size: 12px; }

.site-search {
  position: relative;
  margin: -12px 0 24px;
  font-family: var(--sans);
}

.site-search label {
  display: block;
  margin-bottom: 7px;
  color: #b8c8c3;
  font-size: 12px;
  letter-spacing: .04em;
}

.site-search input {
  width: 100%;
  padding: 10px 11px;
  color: white;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(230,208,157,.35);
  border-radius: 4px;
  font: 14px/1.3 var(--sans);
}

.site-search input::placeholder { color: #9db0aa; }
.site-search input:focus { outline: 2px solid var(--gold-pale); outline-offset: 2px; }

.search-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: min(390px, calc(100vw - 48px));
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 4px;
  box-shadow: 0 14px 30px rgba(0,0,0,.28);
}

.search-results a { display: block; padding: 10px 12px; color: var(--ink); border-bottom: 1px solid var(--line); text-decoration: none; }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a:focus { background: var(--paper-deep); }
.search-results strong, .search-results small { display: block; }
.search-results strong { font-size: 14px; }
.search-results small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.search-results p { margin: 0; padding: 12px; font-size: 13px; line-height: 1.45; }

.nav-heading {
  margin: 24px 10px 8px;
  color: #9db0aa;
  font: 600 11px/1.3 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.nav-link {
  display: block;
  margin: 3px 0;
  padding: 9px 10px;
  color: #f5f2e8;
  border-left: 2px solid transparent;
  border-radius: 0 5px 5px 0;
  font: 15px/1.35 var(--sans);
  text-decoration: none;
}

.nav-link.sub { padding-left: 24px; color: #d8dfdb; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #ffe4a5; background: rgba(183,138,52,.13); border-left-color: var(--gold); }

.mobile-bar { display: none; }

.main {
  width: min(1120px, calc(100% - 320px));
  min-height: calc(100vh - 72px);
  margin: 36px 36px 36px 306px;
  padding: clamp(28px, 5vw, 64px);
  background: var(--paper);
  border-top: 6px solid var(--gold);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: #80662f;
  font: 700 12px/1.4 var(--sans);
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1, h2, h3 { text-wrap: balance; }
h1 { margin: 0 0 18px; font-size: clamp(38px, 6vw, 66px); font-weight: 500; line-height: 1.05; letter-spacing: -.035em; }
h2 { margin: 48px 0 16px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 29px; line-height: 1.25; }
h3 { margin: 30px 0 10px; color: #254a44; font: 650 20px/1.35 var(--sans); }
p { max-width: 76ch; margin: 0 0 16px; }

.lead { max-width: 64ch; color: #4f554f; font-size: 20px; }

.page-header {
  position: relative;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.page-header::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  width: 88px;
  height: 3px;
  content: "";
  background: var(--gold);
}

.journal-cover {
  position: relative;
  min-height: 260px;
  margin: -10px 0 34px;
  overflow: hidden;
  background: var(--forest);
  border: 1px solid #28443e;
}

.journal-cover img {
  display: block;
  width: 100%;
  height: 300px;
  object-fit: cover;
  opacity: .74;
}

.journal-cover::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, rgba(20,44,41,.5), transparent 60%), linear-gradient(0deg, rgba(20,44,41,.48), transparent 55%);
}

.entry {
  max-width: 820px;
  margin: 0 0 28px;
  padding: 28px 30px;
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.entry time, .meta {
  color: var(--muted);
  font: 13px/1.4 var(--sans);
  letter-spacing: .04em;
}
.entry h2 { margin: 8px 0 12px; padding: 0; border: 0; font-size: 28px; }

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.character-card {
  display: block;
  min-height: 220px;
  padding: 26px;
  color: var(--ink);
  background: linear-gradient(145deg, #fffefa, #f3edda);
  border: 1px solid var(--line);
  border-radius: 5px;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}
.character-card:hover { color: var(--ink); transform: translateY(-3px); box-shadow: 0 12px 26px rgba(28,48,46,.11); }
.initial {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 30px;
  place-items: center;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 50%;
  font: 500 34px/1 var(--serif);
}
.character-card strong { display: block; font-size: 24px; }
.character-card span { color: var(--muted); font: 14px/1.5 var(--sans); }

.character-avatar {
  display: block;
  width: 88px;
  height: 88px;
  margin-bottom: 26px;
  object-fit: cover;
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(20,31,28,.16);
}
.avatar-bulin { object-position: 57% 43%; }
.avatar-meira { object-position: 58% 42%; }
.avatar-radomir { object-position: 50% 42%; }

.nav-group { margin: 3px 0; }
.nav-group > summary { position: relative; padding-right: 30px; cursor: pointer; list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { position: absolute; top: 9px; right: 11px; content: "›"; transition: transform .16s ease; }
.nav-group[open] > summary::after { transform: rotate(90deg); }
.nav-group-content { padding: 0 0 5px; }
.nav-group-content .nav-link { margin-left: 8px; }
.nav-empty { margin: 3px 10px 5px 32px; color: #91a59f; font: 12px/1.35 var(--sans); }

.profile-intro {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  margin: 30px 0 42px;
}

.portrait-placeholder {
  display: grid;
  aspect-ratio: 4 / 5;
  place-items: center;
  color: #dec688;
  background: var(--forest-soft);
  border: 1px solid #917432;
  font-size: 72px;
}

.portrait {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center top;
  border: 1px solid #917432;
  background: var(--forest-soft);
}

.facts {
  margin: 0;
  padding: 0;
  list-style: none;
}
.facts li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts strong { font-family: var(--sans); font-size: 14px; }

.resource-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 44px;
}

.resource-links a {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  padding: 20px;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 4px;
  text-decoration: none;
}
.resource-links a:hover { color: var(--ink); background: #eee4ca; }
.resource-links .resource-kicker { grid-row: 1 / span 2; align-self: center; color: #80662f; font: 700 11px/1.2 var(--sans); letter-spacing: .09em; text-transform: uppercase; }
.resource-links strong { font: 650 19px/1.3 var(--sans); }
.resource-links small { color: var(--muted); font: 13px/1.4 var(--sans); }

.longform { max-width: 850px; }
.longform h3 { margin-top: 40px; }
.section-intro { color: var(--muted); }

.biography-illustration {
  margin: 30px 0 34px;
  overflow: hidden;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(20,31,28,.1);
}
.biography-illustration a, .biography-illustration img { display: block; }
.biography-illustration img { width: 100%; height: auto; }
.biography-illustration figcaption { padding: 10px 14px; color: var(--muted); font: 13px/1.4 var(--sans); }

.summary-list { max-width: 850px; margin-top: 30px; }
.summary-item { margin: 0; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.summary-item:nth-child(odd) { background: #faf6e9; }

.back-link { margin: -18px 0 28px; font-family: var(--sans); font-size: 14px; }
.button-link { display: inline-block; margin-right: 16px; padding: 10px 16px; color: white; background: var(--forest-soft); border-radius: 4px; font: 600 14px/1.4 var(--sans); text-decoration: none; }
.button-link:hover { color: white; background: #315b54; }
.pdf-actions { margin-bottom: 20px; font-family: var(--sans); font-size: 14px; }
.pdf-viewer { display: block; width: 100%; height: 78vh; min-height: 620px; border: 1px solid var(--line); background: var(--paper-deep); }

.character-sheet-preview { max-width: 900px; }
.character-sheet-preview figure { margin: 0 0 28px; background: white; border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(20,31,28,.12); }
.character-sheet-preview img { display: block; width: 100%; height: auto; }
.character-sheet-preview figcaption { padding: 9px 13px; color: var(--muted); border-top: 1px solid var(--line); font: 12px/1.4 var(--sans); }

.portrait-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
.portrait-gallery figure { margin: 0; background: var(--paper-deep); border: 1px solid var(--line); }
.portrait-gallery a { display: block; }
.portrait-gallery img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: center top; }
.portrait-gallery figcaption { padding: 9px 12px; color: var(--muted); font: 12px/1.4 var(--sans); }

.empty-state {
  max-width: 700px;
  margin-top: 36px;
  padding: 34px;
  background: var(--paper-deep);
  border: 1px dashed #b9a77b;
  text-align: center;
}
.empty-state strong { display: block; margin-bottom: 7px; font-size: 23px; }

.footer { margin-top: 64px; padding-top: 18px; color: var(--muted); border-top: 1px solid var(--line); font: 12px/1.5 var(--sans); }

@media (max-width: 900px) {
  body { font-size: 16px; }
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    color: white;
    background: var(--forest);
    font: 600 16px/1 var(--sans);
  }
  .menu-button { padding: 8px 11px; color: white; background: transparent; border: 1px solid #819991; border-radius: 4px; font: inherit; }
  .sidebar { width: min(330px, 88vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 12px 0 30px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .main { width: auto; min-height: calc(100vh - 51px); margin: 0; padding: 32px 22px 48px; border-top-width: 4px; box-shadow: none; }
  .character-grid { grid-template-columns: 1fr; }
  .resource-links { grid-template-columns: 1fr; }
  .character-card { min-height: 0; }
  .profile-intro { grid-template-columns: 110px minmax(0, 1fr); gap: 20px; }
  .portrait-placeholder { font-size: 45px; }
  .journal-cover img { height: 240px; }
  .pdf-viewer { height: 72vh; min-height: 520px; }
}

@media (max-width: 520px) {
  h1 { font-size: 40px; }
  .profile-intro { grid-template-columns: 1fr; }
  .portrait-placeholder { max-width: 150px; }
  .portrait { max-width: 180px; }
  .entry { padding: 22px 20px; }
  .portrait-gallery { grid-template-columns: 1fr; }
  .pdf-viewer { min-height: 460px; }
}

@media print {
  .sidebar, .mobile-bar, .skip-link { display: none !important; }
  body { background: white; }
  .main { width: auto; margin: 0; padding: 0; border: 0; box-shadow: none; }
}
