:root {
  --bg: #0d0e10;
  --panel: rgba(18, 20, 24, 0.78);
  --panel-strong: rgba(22, 24, 28, 0.95);
  --border: rgba(212, 175, 95, 0.22);
  --border-strong: rgba(212, 175, 95, 0.55);
  --gold: #d4af5f;
  --gold-bright: #f0c97a;
  --text: #e6e3da;
  --muted: #9b9588;
  --link: #f0c97a;
  --link-hover: #ffd98a;
  --tag-player: #4a8; --tag-enchant: #b86; --tag-npc: #87a;
  --sidebar-w: 320px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Cormorant Garamond', 'Avenir Next Cyr', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg) var(--chronicle-bg) center top / cover no-repeat fixed;
  color: var(--text);
  line-height: 1.55;
  font-size: 17px;
}
h1, h2, h3, h4, .brand, .sidebar-title, .sidebar-link, .chronicle-tile-name, .card-label, .topnav a, .pager a, .level-switch a {
  font-family: 'Cinzel', 'Trajan Pro', Georgia, serif;
  letter-spacing: .04em;
}
.entity-table th { font-family: 'Cinzel', Georgia, serif; }

.bg-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(180deg, rgba(13,14,16,0.4) 0%, rgba(13,14,16,0.85) 50%, rgba(13,14,16,0.95) 100%);
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: .8rem 1.5rem;
  background: rgba(10, 11, 13, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 36px; width: auto; }
.search-form { width: 100%; max-width: 480px; justify-self: center; }
.search-form input {
  width: 100%;
  padding: .5rem 1rem;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: .35rem;
  font-size: .92rem;
}
.search-form input:focus { outline: none; border-color: var(--border-strong); background: rgba(0,0,0,0.7); }

.meta { display: flex; flex-direction: column; gap: .35rem; align-items: flex-end; font-size: .85rem; }
.chronicle-switch, .lang-switch { display: flex; gap: .35rem; }
.chronicle-switch a, .lang-switch a {
  padding: .15rem .5rem; border-radius: .25rem;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.chronicle-switch a:hover, .lang-switch a:hover {
  background: rgba(212, 175, 95, 0.15);
  color: var(--gold-bright);
  text-decoration: none;
}
.chronicle-switch a.active, .lang-switch a.active {
  background: var(--gold);
  color: #1a1a1a;
}

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  width: 100%;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 70px;
  align-self: start;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
  background: rgba(8, 9, 11, 0.85);
  backdrop-filter: blur(10px);
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}
.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .25em;
  color: var(--gold);
  padding: .4rem .85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
  font-weight: 600;
}
.sidebar-link {
  display: block;
  padding: .55rem .85rem;
  color: var(--text);
  border-left: 2px solid transparent;
  font-size: .95rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: .1rem;
  transition: all .12s;
}
.sidebar-link:hover {
  border-left-color: var(--gold);
  color: var(--gold-bright);
  text-decoration: none;
  background: rgba(212, 175, 95, 0.06);
}
.sidebar-link.active {
  border-left-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(212, 175, 95, 0.10);
}
.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .85; }

/* Chronicle tiles — large logos */
.chronicle-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
}
.chronicle-tile {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: .35rem;
  background: rgba(0,0,0,0.4);
  color: var(--text);
  transition: all .15s;
}
.chronicle-tile:hover {
  border-color: var(--border-strong);
  background: rgba(20, 18, 12, 0.85);
  text-decoration: none;
}
.chronicle-tile.active {
  border-color: var(--gold);
  background: rgba(212, 175, 95, 0.13);
}
.chronicle-tile-logo {
  width: 110px;
  height: 50px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(1.1);
}
.chronicle-tile-name {
  font-size: .82rem;
  line-height: 1.3;
  color: var(--text);
}
.chronicle-tile.active .chronicle-tile-name { color: var(--gold-bright); }

/* ---------- main content ---------- */
.content {
  padding: 2rem;
  min-height: calc(100vh - 70px - 60px);
}
h1 { font-size: 2rem; margin: 0 0 1rem; color: var(--gold-bright); font-weight: 600; }
h2 { font-size: 1.4rem; color: var(--gold); margin-top: 2rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .8rem; }
code { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; font-size: .85em; background: rgba(0,0,0,0.3); padding: .1em .4em; border-radius: .2em; }
.params { color: var(--muted); }

/* ---------- hero ---------- */
.hero { padding: 2.5rem 0 3rem; text-align: center; }
.hero h1 { font-size: 2.8rem; }
.subtitle { font-size: 1.05rem; color: var(--muted); }

/* ---------- card grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1.5rem;
  text-align: center;
  transition: all .15s;
  color: var(--text);
}
.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  text-decoration: none;
  background: var(--panel-strong);
}
.card-num { font-size: 2.4rem; font-weight: 700; color: var(--gold-bright); }
.card-label { font-size: 1.1rem; color: var(--text); margin: .3rem 0; letter-spacing: .03em; }
.card-hint { color: var(--muted); font-size: .85rem; }

/* ---------- filters ---------- */
.filters {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .8rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .4rem;
  margin-bottom: 1rem;
}
.filters input, .filters select {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .35rem .7rem;
  border-radius: .25rem;
  font-size: .9rem;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--border-strong); }
.filters button, .btn {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  padding: .35rem 1.2rem;
  border-radius: .25rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.filters button:hover, .btn:hover { background: var(--gold-bright); text-decoration: none; }

/* ---------- icons ---------- */
.icon-img {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.5);
  border-radius: .2rem;
  display: block;
  image-rendering: pixelated;
}
.icon-large {
  width: 64px; height: 64px;
  border: 2px solid var(--border);
  background: rgba(0,0,0,0.6);
  border-radius: .25rem;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.head-with-icon { display: flex; gap: 1rem; align-items: center; }
.head-with-icon h1 { margin: 0 0 .3rem; }

/* ---------- entity table ---------- */
.entity-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .4rem;
  overflow: hidden;
}
.entity-table th, .entity-table td {
  padding: .55rem .85rem;
  text-align: left;
  border-bottom: 1px solid rgba(212, 175, 95, 0.1);
  vertical-align: top;
}
.entity-table th {
  background: rgba(0,0,0,0.4);
  color: var(--gold);
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.entity-table td .muted.small { display: block; }
.entity-table tr:hover { background: rgba(212, 175, 95, 0.05); }
.entity-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tags { display: flex; gap: .3rem; }
.tag {
  font-size: .7rem;
  padding: .1rem .5rem;
  border-radius: .2rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.tag-player  { background: rgba(74,168,136,0.2); color: var(--tag-player); border: 1px solid var(--tag-player); }
.tag-enchant { background: rgba(184,136,102,0.2); color: var(--tag-enchant); border: 1px solid var(--tag-enchant); }
.tag-npc     { background: rgba(136,119,170,0.2); color: var(--tag-npc); border: 1px solid var(--tag-npc); }

/* ---------- entity detail ---------- */
.entity-head {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.entity-head h1 { margin: 0 0 .3rem; }
.entity-head .key { color: var(--muted); font-family: monospace; font-size: .9rem; }
.entity-head .title { color: var(--gold); font-style: italic; margin-top: .3rem; }
.breadcrumbs { color: var(--muted); margin-bottom: 1rem; font-size: .9rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--gold-bright); }

.level-switch { display: flex; gap: .25rem; margin-top: .5rem; flex-wrap: wrap; }
.level-switch a {
  padding: .2rem .6rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: .25rem;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.level-switch a.active, .level-switch a:hover {
  background: var(--gold);
  color: #1a1a1a;
  border-color: var(--gold);
  text-decoration: none;
}

.desc {
  padding: 1rem 1.2rem;
  background: var(--panel);
  border-left: 3px solid var(--gold);
  border-radius: .25rem;
  color: var(--text);
  font-size: 1.02rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem;
  margin: 1.5rem 0;
}
.stat-grid > div {
  display: flex; justify-content: space-between;
  padding: .5rem .8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .25rem;
}
.stat-grid .k { color: var(--muted); font-size: .85rem; }
.stat-grid .v { color: var(--text); font-weight: 600; }

.chip-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  padding: .25rem .7rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  font-family: monospace;
}

.link-list { list-style: none; padding: 0; }
.link-list li { padding: .35rem 0; border-bottom: 1px solid rgba(212, 175, 95, 0.08); }

/* ---------- pager ---------- */
.pager {
  display: flex; gap: .25rem; justify-content: center; align-items: center;
  margin: 1.5rem 0;
}
.pager a {
  padding: .35rem .8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .25rem;
  color: var(--text);
  font-size: .9rem;
}
.pager a:hover { background: rgba(212,175,95,0.15); text-decoration: none; }
.pager a.active { background: var(--gold); color: #1a1a1a; border-color: var(--gold); }

/* ---------- footer ---------- */
.footer {
  padding: 1.2rem 2rem;
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--border);
  background: rgba(10, 11, 13, 0.92);
  font-size: .85rem;
  color: var(--muted);
  margin-top: auto;
}

/* ---------- error ---------- */
.error-404 { text-align: center; padding: 4rem 2rem; }
.error-404 h1 { font-size: 6rem; margin: 0; }

/* ---------- chronicle landing ---------- */
.chronicle-landing { padding: 1rem 0; }
.chronicle-landing h1 { font-size: 2.2rem; }
.chronicle-landing .notice {
  margin: 1rem 0 2rem;
  padding: 1rem 1.5rem;
  background: rgba(212,175,95,0.08);
  border-left: 3px solid var(--gold);
  color: var(--text);
  border-radius: 0 .3rem .3rem 0;
}
.patchnotes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem;
  margin: 1.5rem 0;
}
.patchnotes-list a {
  display: block;
  padding: .9rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .35rem;
  color: var(--text);
  transition: all .12s;
}
.patchnotes-list a:hover {
  border-color: var(--border-strong);
  background: var(--panel-strong);
  text-decoration: none;
  transform: translateY(-1px);
}
.patchnotes-list .title-line { color: var(--gold-bright); font-weight: 600; }
.patchnotes-list .key-line { color: var(--muted); font-size: .8rem; margin-top: .2rem; font-family: monospace; }

/* ---------- patchnote (rendered HTML) ---------- */
.patchnote-body {
  padding: 1.5rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .5rem;
  font-size: .95rem;
  line-height: 1.7;
  overflow-x: auto;
}
.patchnote-body h1, .patchnote-body h2, .patchnote-body h3, .patchnote-body h4 {
  color: var(--gold-bright);
  margin-top: 1.5em;
  margin-bottom: .5em;
}
.patchnote-body p { margin: 0 0 1em; }
.patchnote-body img {
  max-width: 100%;
  height: auto;
  border-radius: .25rem;
  margin: .5rem 0;
  display: block;
}
.patchnote-body table {
  border-collapse: collapse;
  margin: 1em 0;
  width: auto;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
}
.patchnote-body td, .patchnote-body th {
  padding: .4rem .8rem;
  border: 1px solid rgba(212, 175, 95, 0.15);
  vertical-align: top;
}
.patchnote-body th { background: rgba(0,0,0,0.4); color: var(--gold); }
.patchnote-body ul, .patchnote-body ol { padding-left: 1.5em; }
.patchnote-body li { margin: .3em 0; }
.patchnote-body a { color: var(--link); }
.patchnote-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }

/* ---------- classes tree ---------- */
.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.race-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1.2rem;
}
.race-card h2 {
  margin: 0 0 .8rem;
  font-size: 1.1rem;
  color: var(--gold-bright);
  border: none;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.class-tree { list-style: none; padding: 0; margin: 0; }
.class-tree li { padding: .15rem 0; }
.class-tree .lvl-1 { padding-left: 0; }
.class-tree .lvl-2 { padding-left: 1rem; color: var(--text); }
.class-tree .lvl-3 { padding-left: 2rem; color: var(--muted); font-size: .9rem; }
.class-tree a { color: inherit; }
.class-tree a:hover { color: var(--gold-bright); }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .topbar { grid-template-columns: 1fr; gap: .8rem; padding: 1rem; }
  .meta { align-items: flex-start; }
  .content { padding: 1rem; }
}
