:root {
  --bg: #050505;
  --panel: #0c0c0c;
  --panel-2: #141414;
  --line: #2a2a2a;
  --text: #f4f0e6;
  --muted: #9a9488;
  --dim: #5c574e;
  --neon: #f0d23c;
  --neon-2: #ff2d8a;
  --neon-dim: color-mix(in srgb, var(--neon) 28%, #000);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --font-ui: "Oswald", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-display: "Anton", Impact, sans-serif;
}

html[data-theme="1"] { --neon: #f0d23c; --neon-2: #ff2d8a; }
html[data-theme="2"] { --neon: #ff2bd6; --neon-2: #f5e642; }
html[data-theme="3"] { --neon: #e31b23; --neon-2: #f5d800; }
html[data-theme="4"] { --neon: #e8ff3c; --neon-2: #ff3db4; }
html[data-theme="5"] { --neon: #3dff4a; --neon-2: #f5e642; }
html[data-theme="6"] { --neon: #ff6b00; --neon-2: #00e5ff; }
html[data-theme="7"] { --neon: #2dffc8; --neon-2: #ff3dbf; }
html[data-theme="8"] { --neon: #f5e642; --neon-2: #ff3b30; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 500px at 80% -10%, color-mix(in srgb, var(--neon-2) 18%, transparent), transparent 55%),
    radial-gradient(700px 420px at 0% 0%, color-mix(in srgb, var(--neon) 14%, transparent), transparent 50%),
    #050505;
  color: var(--text);
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.app { max-width: 1440px; margin: 0 auto; padding: 18px 20px 56px; }

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #222;
}
.site-links { display: flex; gap: 8px; }
.site-nav .btn.on {
  border-color: var(--neon);
  color: var(--neon);
}

.sys {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--neon);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

/* —— Shelf —— */
.shelf { display: none; }
.shelf.on { display: block; }
.shelf-head { text-align: center; padding: 28px 12px 18px; }
.shelf-head .sys { color: var(--neon-2); }
.shelf-head h1 {
  font-family: var(--font-display);
  font-size: clamp(48px, 10vw, 92px);
  line-height: 0.86;
  letter-spacing: 0.02em;
  margin: 8px 0 10px;
  color: var(--neon);
  text-transform: uppercase;
}
.shelf-head p { color: var(--muted); margin: 0 auto; max-width: 52ch; }
.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
  padding: 12px 0 32px;
}
@media (min-width: 1200px) {
  .cover-grid { grid-template-columns: repeat(8, 1fr); }
}
.cover-card {
  position: relative;
  background: #000;
  border: 2px solid #222;
  padding: 0;
  text-align: left;
  color: inherit;
  overflow: hidden;
}
.cover-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; filter: contrast(1.05); }
.cover-card:hover { border-color: var(--neon); }
.cover-card .meta {
  padding: 10px 10px 12px;
  background: #000;
}
.cover-card .meta b {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.03em;
  display: block;
  line-height: 1;
  color: var(--neon);
}
.cover-card .meta span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.cover-card .lock-badge {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: #000;
  color: var(--neon-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 4px 7px;
  border: 1px solid var(--neon-2);
}
.cover-card.opened .lock-badge { display: none; }

/* —— Gate —— */
.gate {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 40;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gate.on { display: flex; }
.gate-card {
  width: min(520px, 100%);
  background: #000;
  border: 3px solid var(--neon);
  padding: 28px 24px;
  text-align: center;
}
.gate-card img { width: 140px; margin: 0 auto 16px; border: 2px solid var(--neon-2); }
.gate-card h2 {
  font-family: var(--font-display);
  font-size: 42px;
  line-height: 0.9;
  margin: 0 0 10px;
  color: var(--neon);
  text-transform: uppercase;
}
.gate-card p { color: var(--text); margin: 0 0 18px; }
.gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.complaint-card { text-align: left; }
.complaint-card h2 { text-align: center; }
.complaint-card p { text-align: center; }
.complaint-card .sys { display: block; margin: 12px 0 6px; }
.complaint-card .sys:first-child { text-align: center; margin-top: 0; }
.complaint-card select,
.complaint-card input[type="text"],
.complaint-card textarea {
  width: 100%;
  background: #0a0a0a;
  color: var(--text);
  border: 1px solid #333;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 10px;
}
.complaint-card select:focus,
.complaint-card input:focus,
.complaint-card textarea:focus {
  outline: none;
  border-color: var(--neon);
}
.complaint-card textarea { resize: vertical; min-height: 110px; }
.complaint-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.complaint-card .gate-actions { margin-top: 16px; }
.complaint-card .hp {
  position: absolute;
  left: -9999px;
  height: 0;
  opacity: 0;
}
@media (max-width: 520px) {
  .complaint-row { grid-template-columns: 1fr; }
}

/* —— Reader —— */
.reader { display: none; }
.reader.on { display: block; }

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  background: #000;
  border: 2px solid var(--neon);
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand-mark {
  width: 48px; height: 72px; overflow: hidden;
  border: 2px solid var(--neon-2);
  flex: 0 0 auto;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 0.86;
  margin: 0;
  letter-spacing: 0.03em;
  color: var(--neon);
  text-transform: uppercase;
}
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn, .tab, .book-chip {
  background: #111;
  color: var(--text);
  border: 1px solid #333;
  padding: 8px 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
}
.btn:hover, .tab:hover, .book-chip:hover { border-color: var(--neon); color: var(--neon); }
.btn.primary { background: var(--neon); color: #000; border-color: var(--neon); }
.btn.primary:hover { background: var(--neon-2); border-color: var(--neon-2); color: #000; }
.btn.ghost { background: transparent; }

.series {
  display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 8px;
}
.book-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  max-width: 100%;
  white-space: nowrap;
}
.book-chip img { width: 22px; height: 32px; object-fit: cover; flex: 0 0 auto; }
.book-chip .label { overflow: hidden; text-overflow: ellipsis; }
.book-chip.active { border-color: var(--neon); color: var(--neon); background: color-mix(in srgb, var(--neon) 12%, #000); }
.book-chip.gated { opacity: 0.55; }
.book-chip .lock { font-size: 10px; color: var(--neon-2); letter-spacing: 0.1em; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  margin-top: 8px;
}
.rail, .panel {
  background: #000;
  border: 1px solid #2a2a2a;
}
.rail { padding: 12px; max-height: calc(100vh - 180px); overflow: auto; position: sticky; top: 10px; }
.rail h2, .section-title {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  font-size: 26px;
  margin: 4px 8px 10px;
  color: var(--neon-2);
  text-transform: uppercase;
}
.chap-list { display: flex; flex-direction: column; gap: 3px; }
.chap {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid transparent;
  color: var(--text);
  background: transparent;
  text-align: left;
  width: 100%;
}
.chap .n { font-family: var(--font-mono); color: var(--dim); font-size: 11px; }
.chap .t, .chap .f { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chap .t { font-size: 14px; font-weight: 600; }
.chap .f { font-size: 11px; color: var(--muted); }
.chap:hover { border-color: #333; }
.chap.current { border-color: var(--neon); background: color-mix(in srgb, var(--neon) 10%, #000); }
.chap.current .n, .chap.current .f { color: var(--neon); }
.chap.boss .n { color: var(--neon-2); }

.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.recap {
  padding: 16px 18px;
  border: 1px solid #2a2a2a;
  background: #000;
  border-left: 4px solid var(--neon);
}
.recap .kicker { color: var(--neon-2); }
.recap h3 {
  margin: 6px 0 8px;
  font-size: clamp(28px, 4vw, 44px);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 0.9;
  color: var(--neon);
}
.recap p { margin: 0; color: #ddd6c8; font-size: 16px; line-height: 1.45; max-width: 70ch; }
.chapter-log {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 18px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #222;
}
.chapter-log ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chapter-log li {
  font-size: 14px;
  line-height: 1.35;
  color: #ddd6c8;
}
.chapter-log .when {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.chapter-log .empty-line {
  margin: 6px 0 0;
  padding: 0;
  color: var(--dim);
  font-style: italic;
  font-size: 14px;
}
button.log-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--neon);
  font: inherit;
  text-align: left;
}
button.log-link:hover { color: var(--neon-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag, button.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  background: #111;
  color: var(--neon-2);
  border: 1px solid color-mix(in srgb, var(--neon-2) 45%, #000);
}
button.tag { text-transform: none; letter-spacing: 0.04em; font-weight: 600; }
button.tag:hover { border-color: var(--neon); color: var(--neon); }

.party {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid #2a2a2a;
  background: #0a0a0a;
  cursor: pointer;
}
.card:hover { border-color: var(--neon-2); }
.card.selected { border-color: var(--neon); box-shadow: 0 0 0 1px var(--neon); }
.card img, .avatar-fallback { width: 92px; height: 118px; object-fit: cover; object-position: top center; }
.card img { border: 1px solid #222; background: #111; }
.avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 42px; color: #111;
  background: var(--neon);
}
.card .who {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.03em;
  margin: 0;
  text-transform: uppercase;
  line-height: 0.9;
}
.card .title { color: var(--neon-2); font-size: 12px; margin: 4px 0 8px; text-transform: uppercase; }
.lvl {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  background: #000;
  border: 1px solid var(--neon);
  color: var(--neon);
}
.stars { margin-top: 8px; font-size: 14px; letter-spacing: 1px; }
.star-b { color: #cd7f32; }
.star-s { color: #c0c0c0; }
.mini-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 8px; }
.mini-stats span { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-align: center; }
.mini-stats b { display: block; color: var(--text); font-size: 13px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 12px 0; }
.tab.active { border-color: var(--neon); color: #000; background: var(--neon); }
.detail { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 16px; }
.stat-row { display: grid; grid-template-columns: 110px 1fr 58px; gap: 10px; align-items: center; margin: 8px 0; }
.stat-row label { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.bar {
  height: 10px; background: #111; overflow: hidden; border: 1px solid #333;
}
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--neon), var(--neon-2)); }
.stat-row .val { font-family: var(--font-mono); text-align: right; }
.stat-row .val small { color: var(--muted); }

.gear, .inv, .boss-list { display: flex; flex-direction: column; gap: 8px; }
.slot, .item, .boss {
  padding: 10px 12px;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
}
.slot b, .item b, .boss b { display: block; }
.slot .slot-name, .item .when { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.bonus { color: var(--neon); font-size: 13px; }
.empty { color: var(--dim); font-style: italic; padding: 12px; }

.level-row { margin: 12px 0 18px; }
.level-meta { font-size: 14px; margin-bottom: 6px; }
.spark {
  width: 100%;
  height: 72px;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
}

.boss { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.boss .tier { font-family: var(--font-mono); font-size: 11px; color: var(--neon); text-transform: uppercase; }

.foe-board { display: flex; flex-direction: column; gap: 8px; }
.foe-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.foe-head .section-title { margin: 0; }
.foe-filters { padding: 0; }
.foe-grid { margin-top: 4px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.foe-card .title { text-transform: uppercase; }
.foe-card.defeated { opacity: 0.88; }
.foe-hero-wrap { margin-bottom: 12px; }
.foe-hero {
  width: min(220px, 100%);
  height: 280px;
  object-fit: cover;
  object-position: top center;
  border: 1px solid #222;
  background: #111;
}
.form-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.form-chip {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid #2a2a2a;
  background: #0a0a0a;
}
.form-chip img { width: 56px; height: 72px; object-fit: cover; object-position: top center; }
.form-chip .when { display: block; color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.form-chip.current { border-color: var(--neon); }

.footer {
  margin-top: 22px;
  color: var(--dim);
  font-size: 12px;
  font-family: var(--font-mono);
}
.shelf-foot {
  text-align: center;
  max-width: 52ch;
  margin: 0 auto 36px;
  line-height: 1.5;
}

.codex { display: none; }
.codex.on { display: block; }
.codex-head { margin: 8px 0 18px; }
.codex-head h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 72px);
  line-height: 0.86;
  margin: 6px 0 8px;
  color: var(--neon);
  text-transform: uppercase;
}
.codex-head p { color: var(--muted); max-width: 58ch; margin: 0; }
.codex-layout {
  display: grid;
  grid-template-columns: minmax(280px, 36%) 1fr;
  gap: 18px;
  align-items: start;
}
.codex-index {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 12px;
  background: #000;
  border: 1px solid #2a2a2a;
}
.codex-index .tabs { padding: 0 0 8px; }
.codex-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.codex-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
}
.codex-row img, .codex-row .avatar-fallback {
  width: 44px; height: 56px; object-fit: cover; object-position: top center;
}
.codex-row .avatar-fallback { font-size: 22px; }
.codex-row b {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
}
.codex-row span { color: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.codex-row:hover { border-color: #333; }
.codex-row.selected { border-color: var(--neon); color: var(--neon); }
.codex-file { padding: 18px 20px; min-height: 420px; }
.codex-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.codex-hero img, .codex-hero .avatar-fallback {
  width: 180px; height: 230px; object-fit: cover; object-position: top center;
}
.codex-file h2 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  line-height: 0.88;
  margin: 4px 0 10px;
  text-transform: uppercase;
  color: var(--neon);
}
.codex-file .blurb { color: #ddd6c8; line-height: 1.5; max-width: 62ch; }
.codex-file .blurb + .blurb { margin-top: 10px; }
.stat-list {
  margin: 6px 0 0;
  padding: 0 0 0 18px;
  color: #ddd6c8;
  line-height: 1.45;
  max-width: 62ch;
}
.stat-list li { margin: 0 0 4px; }

@media (max-width: 960px) {
  .topbar, .layout, .grid-2, .card, .codex-layout, .codex-hero { grid-template-columns: 1fr; }
  .brand-mark { width: 40px; height: 60px; }
  .rail { position: static; max-height: 280px; }
  .card img, .card .avatar-fallback { width: 100%; height: 180px; }
  .codex-index { position: static; max-height: none; }
  .codex-hero img, .codex-hero .avatar-fallback { width: 100%; height: 240px; }
  .foe-hero { width: 100%; height: 220px; }
  .shelf-head h1 { font-size: 52px; }
}
