@font-face {
  font-family: "Press Start 2P";
  src: url("../vendor/PressStart2P-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #120e0b;
  --bg: #1a140f;
  --panel: #261c15;
  --panel-2: #31241b;
  --line: #a07848;
  --line-dim: #4d3826;
  --gold: #f0d7a2;
  --gold-2: #c9964a;
  --ember: #e07a3d;
  --moss: #b7d39a;
  --sea: #9ec4d4;
  --rose: #e3a0c4;
  --text: #f7ecdc;
  --muted: #cbb79f;
  --danger: #e08a78;
  --ok: #9dce8a;
  --shadow: #070504;
  --display: "Press Start 2P", ui-monospace, monospace;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --ui: "Segoe UI", "Avenir Next", "Helvetica Neue", sans-serif;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font-family: var(--ui);
  background:
    linear-gradient(180deg, rgba(224, 122, 61, 0.05), transparent 220px),
    linear-gradient(rgba(240, 215, 162, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 215, 162, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 8px 8px, 8px 8px, auto;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
textarea, .field input, .field select, .field textarea { width: 100%; }
textarea { min-height: 80px; background: #140f0c; border: 1px solid var(--line-dim); padding: 8px; }
a { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
img.pixel, .pixel, canvas.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(18, 14, 11, 0.92);
  border-bottom: 1px solid var(--line-dim);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 180px; text-decoration: none; }
.brand svg { width: 28px; height: 28px; image-rendering: pixelated; }
.brand-name { font-family: var(--display); font-size: 11px; letter-spacing: 0; color: var(--gold); }
.brand-sub { display: block; margin-top: 4px; font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--muted); }
.menu-btn, .btn, .btn-quiet {
  border: 1px solid var(--line-dim);
  background: var(--panel);
  color: var(--text);
  border-radius: 2px;
  padding: 8px 10px;
}
.menu-btn { display: none; }
.btn-ember { background: #6a341c; border-color: var(--ember); color: var(--gold); }
.btn-quiet { background: transparent; color: var(--muted); padding: 4px 8px; }
.search { flex: 1; display: flex; }
.search input, .field input, .field select, .field textarea, .inline-input {
  width: 100%;
  background: #140f0c;
  border: 1px solid var(--line-dim);
  border-radius: 2px;
  padding: 8px 10px;
}
.top-tools { display: flex; gap: 8px; align-items: center; }
.lang-toggle { display: flex; }
.lang-toggle button { border-radius: 0; }
.lang-toggle button:first-child { border-radius: 2px 0 0 2px; }
.lang-toggle button:last-child { border-radius: 0 2px 2px 0; }
.lang-toggle button[aria-pressed="true"] { background: #4a3018; color: var(--gold); border-color: var(--gold-2); }
.author-input { width: 140px; }

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: calc(100vh - 58px); }
.sidebar {
  padding: 14px 10px 28px;
  border-right: 1px solid var(--line-dim);
  background: rgba(18, 14, 11, 0.55);
}
.nav-link {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin: 2px 0;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}
.nav-link small { color: var(--gold-2); }
.nav-link.active, .nav-link:hover { color: var(--text); background: var(--panel); border-color: var(--line-dim); }
.nav-label { font-size: 14px; }
.main { padding: 22px 22px 64px; max-width: 1180px; }
.kicker { font-family: var(--display); font-size: 9px; color: var(--gold-2); letter-spacing: 0.08em; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0; }
h1 { font-size: 40px; margin: 6px 0 8px; }
h2 { font-size: 26px; margin: 0 0 8px; }
.lede { font-family: var(--serif); font-size: 20px; color: var(--muted); max-width: 62ch; }

.panel {
  background: linear-gradient(180deg, rgba(240, 215, 162, 0.04), transparent 40px), var(--panel);
  border: 1px solid var(--line-dim);
  box-shadow: 0 0 0 1px #120e0b, 0 0 0 3px #3c2b1d;
  padding: 14px;
  margin: 12px 0;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat b { display: block; font-family: var(--display); font-size: 16px; color: var(--gold); margin-top: 8px; }
.stat span, .muted { color: var(--muted); }
.banner {
  border: 1px dashed var(--ember);
  color: var(--gold);
  padding: 10px 12px;
  background: rgba(224, 122, 61, 0.08);
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  padding: 10px;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line-dim);
}
.card:hover { border-color: var(--gold-2); }
.avatar, .avatar-lg {
  width: 56px; height: 56px; background: #140f0c; border: 1px solid var(--line-dim);
  display: grid; place-items: center; overflow: hidden;
}
.avatar img, .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; }
.card h3 { margin: 0 0 4px; font-size: 18px; }
.badge, .chip {
  display: inline-block;
  border: 1px solid var(--line-dim);
  padding: 2px 6px;
  margin: 2px 4px 2px 0;
  font-size: 12px;
  color: var(--gold);
  background: #1a130e;
}
.badge.warn { color: var(--danger); border-color: #7a4036; }
.badge.ok { color: var(--ok); border-color: #3e5a36; }
.badge.draft { color: var(--ember); }
.glossary-list { max-height: 70vh; overflow: auto; }

.entity-head { display: flex; gap: 14px; align-items: flex-start; }
.entity-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.prose { font-family: var(--serif); font-size: 18px; line-height: 1.55; }
.prose h1, .prose h2, .prose h3 { margin: 0.2em 0; }
.prose p { margin: 0.4em 0; }
.prose a.xref { border-bottom: 1px dashed var(--gold-2); text-decoration: none; }
.block {
  position: relative;
  padding: 8px 8px 8px 12px;
  margin: 8px 0;
  border-left: 3px solid var(--line-dim);
}
.block.edited { border-left-color: var(--ember); }
.block.awaiting { background: rgba(224, 122, 61, 0.06); }
.block.orphan { border-left-color: var(--danger); }
.block-tools { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; align-items: center; }
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 2px;
}
.icon-btn:hover, .icon-btn:focus-visible {
  color: var(--gold);
  border-color: var(--line-dim);
  background: var(--panel);
}
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  border-radius: 7px;
  background: #6a341c;
  color: var(--gold);
  border: 1px solid var(--ember);
}
.block textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: 14px; }
.other {
  margin-top: 8px;
  padding: 8px;
  background: #140f0c;
  color: var(--muted);
  font-size: 15px;
}
.gallery { display: flex; gap: 8px; flex-wrap: wrap; }
.shot {
  width: 96px; background: #140f0c; border: 1px solid var(--line-dim); padding: 4px; color: inherit; text-align: left;
}
.shot img { width: 88px; height: 88px; object-fit: contain; background: #0c0907; }
.shot small { display: block; color: var(--muted); }
.drop {
  border: 1px dashed var(--line);
  padding: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.drop.hot { background: rgba(240, 215, 162, 0.08); }
.side-block + .side-block { margin-top: 14px; }
.comment { border-top: 1px solid var(--line-dim); padding: 8px 0; }
.comment .who { color: var(--gold); }
.comment .meta { color: var(--muted); font-size: 12px; }
.children { margin-left: 12px; }

#cy {
  height: min(72vh, 760px);
  background: #100c09;
  border: 1px solid var(--line-dim);
}
.filters { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.filters label { color: var(--muted); font-size: 14px; }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: middle; }
.faction-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.member { display: flex; gap: 8px; align-items: center; margin: 6px 0; text-decoration: none; color: inherit; }
.member img { width: 28px; height: 28px; }

.change { padding: 10px 0; border-bottom: 1px solid var(--line-dim); }
.change h3 { font-size: 16px; margin: 0 0 4px; }
.diff del { background: #5c2e2a; text-decoration: none; }
.diff ins { background: #2d4a32; text-decoration: none; }
.modal {
  position: fixed; inset: 0; background: rgba(7, 5, 4, 0.72);
  display: grid; place-items: center; padding: 18px; z-index: 40;
}
.modal[hidden] { display: none; }
.dialog { width: min(760px, 100%); max-height: min(86vh, 900px); overflow: auto; background: var(--panel-2); border: 1px solid var(--line); padding: 16px; }
.toast {
  position: fixed; bottom: 16px; right: 16px; z-index: 50;
  background: #3a2718; border: 1px solid var(--gold-2); padding: 10px 12px; max-width: 360px;
}
.toast[hidden] { display: none; }
.timeline-item { display: grid; grid-template-columns: 72px 1fr; gap: 10px; text-decoration: none; color: inherit; padding: 8px 0; border-bottom: 1px solid var(--line-dim); }
.timeline-item b { font-family: var(--display); font-size: 10px; color: var(--gold-2); }
.field { display: grid; gap: 4px; margin: 8px 0; }
.field span { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-family: var(--serif); font-size: 18px; }

@media (max-width: 860px) {
  .menu-btn { display: inline-block; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 30; inset: 58px auto 0 0; width: min(84vw, 320px);
    transform: translateX(-105%); transition: transform 0.18s ease;
    background: #16110d;
  }
  .sidebar.open { transform: none; }
  .entity-layout { grid-template-columns: 1fr; }
  .author-input { width: 96px; }
  h1 { font-size: 32px; }
  .brand-sub { display: none; }
  .main { padding: 16px 12px 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
