:root {
  --bg: #f4ecdc;
  --panel: #fbf6ec;
  --panel-2: #efe4cf;
  --ink: #2b2118;
  --ink-soft: #5e4d3b;
  --line: #d8c7a8;
  --accent: #8a2f1d;
  --accent-2: #3d5a4a;
  --gold: #a57a21;
  --link: #7a2a18;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 16px rgba(60, 40, 20, .06);
  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #16130f;
  --panel: #201b16;
  --panel-2: #2a231c;
  --ink: #eadfca;
  --ink-soft: #b3a38a;
  --line: #3e342a;
  --accent: #e0805e;
  --accent-2: #8fbfa3;
  --gold: #d6aa4f;
  --link: #f0a27f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f;
    --panel: #201b16;
    --panel-2: #2a231c;
    --ink: #eadfca;
    --ink-soft: #b3a38a;
    --line: #3e342a;
    --accent: #e0805e;
    --accent-2: #8fbfa3;
    --gold: #d6aa4f;
    --link: #f0a27f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 26px; color: var(--accent); }
.brand-text { font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1.1; display: flex; flex-direction: column; }
.brand-text small { font-family: var(--serif); font-weight: 400; font-size: 13px; color: var(--ink-soft); letter-spacing: .04em; }
.search-wrap { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
#search {
  width: 100%; padding: 8px 14px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink);
}
#search:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 70vh; overflow-y: auto; padding: 6px;
}
.search-results a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--ink); }
.search-results a:hover, .search-results a.active { background: var(--panel-2); text-decoration: none; }
.search-results .sr-type { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin-left: 8px; }
.search-results .sr-snip { display: block; font-size: 14px; color: var(--ink-soft); }
.search-results .empty { padding: 10px; color: var(--ink-soft); font-style: italic; }
.menu-btn, .theme-btn {
  background: none; border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; font-size: 18px; width: 38px; height: 38px; cursor: pointer; flex-shrink: 0;
}
.menu-btn { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.sidebar {
  position: sticky; top: 62px; align-self: start; height: calc(100vh - 62px); overflow-y: auto;
  padding: 20px 14px 40px; border-right: 1px solid var(--line); background: var(--panel);
}
.sidebar h4 {
  font-family: var(--display); font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin: 18px 8px 6px;
}
.sidebar h4:first-child { margin-top: 0; }
.sidebar a { display: flex; justify-content: space-between; padding: 5px 10px; border-radius: 6px; color: var(--ink); font-size: 17px; }
.sidebar a:hover { background: var(--panel-2); text-decoration: none; }
.sidebar a.active { background: var(--panel-2); color: var(--accent); font-weight: 600; }
.sidebar .count { color: var(--ink-soft); font-size: 14px; }

.content { padding: 32px clamp(16px, 4vw, 56px) 80px; max-width: 1080px; width: 100%; }
.content:focus { outline: none; }

/* ---------- typography ---------- */
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 6px; }
h2 { font-size: 22px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
h3 { font-size: 18px; margin: 24px 0 8px; }
p { margin: 0 0 14px; }
ul { margin: 0 0 14px; padding-left: 22px; }
li { margin-bottom: 5px; }
.crumbs { font-size: 15px; color: var(--ink-soft); margin-bottom: 10px; }
.crumbs a { color: var(--ink-soft); }
.lede { font-size: 20px; color: var(--ink-soft); font-style: italic; margin-bottom: 20px; }
.muted { color: var(--ink-soft); }

/* ---------- article ---------- */
.article { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.article.no-box { grid-template-columns: minmax(0, 1fr); }
.infobox {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow); font-size: 16px; position: sticky; top: 84px;
}
.infobox h3 { margin: 0 0 10px; font-size: 17px; text-align: center; color: var(--accent); }
.infobox dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.infobox dt { font-weight: 600; color: var(--ink-soft); }
.infobox dd { margin: 0; }
.tag {
  display: inline-block; font-size: 13px; font-family: var(--serif); letter-spacing: .04em;
  padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-soft);
  margin: 0 4px 4px 0; white-space: nowrap;
}
.tag.status-active, .tag.status-alive { color: var(--accent-2); border-color: var(--accent-2); }
.tag.status-completed { color: var(--gold); border-color: var(--gold); }
.tag.status-dead, .tag.status-failed, .tag.status-abandoned { color: var(--accent); border-color: var(--accent); }
.session-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.session-chips a { font-size: 13px; padding: 1px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); }
.session-chips a:hover { border-color: var(--gold); text-decoration: none; }
.backlinks { margin-top: 36px; font-size: 16px; }
.backlinks a { margin-right: 4px; }

/* ---------- cards / grids ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 20px; }
.toolbar input, .toolbar select {
  font: inherit; font-size: 16px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.toolbar input { flex: 1; min-width: 180px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--gold); text-decoration: none; transform: translateY(-1px); }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card p { margin: 6px 0 0; font-size: 16px; color: var(--ink-soft); line-height: 1.45; }
.card .meta { font-size: 14px; color: var(--ink-soft); }

.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pc-card { text-align: center; padding: 20px 16px; }
.pc-card .sigil {
  width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--display); font-size: 26px; font-weight: 700;
  background: var(--panel-2); border: 2px solid var(--gold); color: var(--accent);
}

/* ---------- sessions timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 22px 24px; margin: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -8px; top: 8px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--gold);
}
.timeline .num { font-family: var(--display); font-size: 14px; color: var(--accent); letter-spacing: .08em; }
.timeline h3 { margin: 0 0 4px; }
.timeline p { margin: 0; font-size: 17px; color: var(--ink-soft); }
.timeline .gap { color: var(--ink-soft); font-style: italic; font-size: 16px; }
.timeline .gap::before { border-style: dashed; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }
.pager a { font-family: var(--display); font-size: 15px; }

/* ---------- home ---------- */
.hero {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: clamp(20px, 4vw, 40px); box-shadow: var(--shadow); margin-bottom: 28px;
  background-image: radial-gradient(ellipse at top right, color-mix(in srgb, var(--gold) 14%, transparent), transparent 60%);
}
.hero h1 { font-size: clamp(30px, 5vw, 48px); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 22px 0 0; }
.stat { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); }
.stat:hover { border-color: var(--gold); text-decoration: none; }
.stat b { display: block; font-family: var(--display); font-size: 26px; color: var(--accent); }
.stat span { font-size: 15px; color: var(--ink-soft); }

table.cast { border-collapse: collapse; width: 100%; font-size: 17px; }
table.cast th, table.cast td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.cast th { font-family: var(--display); font-size: 14px; letter-spacing: .06em; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; }

.note {
  border-left: 3px solid var(--gold); background: var(--panel); padding: 10px 14px; border-radius: 0 8px 8px 0;
  font-size: 16px; color: var(--ink-soft); margin: 16px 0;
}
blockquote { margin: 0 0 14px; padding: 6px 16px; border-left: 3px solid var(--accent); color: var(--ink-soft); font-style: italic; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .article { grid-template-columns: minmax(0, 1fr); }
  .infobox { position: static; order: -1; }
}
@media (max-width: 780px) {
  body { font-size: 17px; }
  .menu-btn { display: block; }
  .brand-text small { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 58px; left: 0; bottom: 0; width: 280px; height: auto; z-index: 15;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .topbar { gap: 10px; padding: 10px 16px; }
  .brand-text { font-size: 16px; }
}
@media (max-width: 600px) {
  .brand-text { display: none; }
}
.search-wrap, #search, .content, .article > div { min-width: 0; }
.content { overflow-wrap: break-word; }
