:root {
  --bg: #0f1114; --surface: #171a1f; --surface-2: #1e222a; --line: #2a2f38;
  --text: #e8e4da; --muted: #9a9688; --brass: #c9a463; --gold: #e3b95a;
  --ok: #7fbf8a; --alt: #8fa8c8; --cand: #b8a27a;
  --radius: 10px; --gutter: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f2ea; --surface: #ffffff; --surface-2: #f0ece2; --line: #ddd6c6;
    --text: #1d1f23; --muted: #6a665c; --brass: #8a6a2f; --gold: #9a7420;
    --ok: #2f7d43; --alt: #3b5f8a; --cand: #7d6a3f;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--gold); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }

.top { border-bottom: 1px solid var(--line); padding: 28px 0 0; background: var(--surface); }
.top.slim { padding: 14px 0; }
.top.slim .wrap { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.eyebrow { margin: 0; color: var(--brass); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }
h1 { margin: 4px 0 2px; font: 600 30px/1.2 Georgia, "Times New Roman", serif; letter-spacing: .01em; }
.sub { margin: 0 0 18px; color: var(--muted); }
.tabs { display: flex; gap: 4px; }
.tab { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tab.on { color: var(--text); border-bottom-color: var(--gold); }
.back { text-decoration: none; }
.path { color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 0 4px; flex-wrap: wrap; }
.toggle { color: var(--muted); display: flex; gap: 8px; align-items: center; cursor: pointer; }
.count { color: var(--muted); font-size: 13px; }

.group { padding: 18px 0 8px; }
.group h2 { font: 600 18px/1.3 Georgia, serif; margin: 0 0 14px; }
.gid { font: 600 12px ui-monospace, Menlo, monospace; color: var(--bg); background: var(--brass);
  padding: 2px 7px; border-radius: 5px; vertical-align: 2px; margin-right: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { all: unset; cursor: pointer; display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.card:hover, .card:focus-visible { border-color: var(--brass); transform: translateY(-1px); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.play { position: absolute; left: 8px; bottom: 8px; font-size: 11px; background: rgba(0,0,0,.65);
  color: #fff; padding: 2px 7px; border-radius: 4px; }
.cap { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 11px; }
.name { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.alt { color: var(--alt); } .badge.cand { color: var(--cand); }
.empty { color: var(--muted); }

.lightbox { position: fixed; inset: 0; background: rgba(5,6,8,.92); z-index: 10; display: flex; padding: 24px; }
.lightbox[hidden] { display: none; }
.lb-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: #fff; font-size: 32px; cursor: pointer; }
.lb-body { margin: auto; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; width: 100%; max-width: 1600px; max-height: 100%; }
.lb-media { display: flex; align-items: center; justify-content: center; min-height: 0; }
.lb-media img, .lb-media video { max-width: 100%; max-height: calc(100vh - 60px); border-radius: 6px; }
.lb-meta { background: #15181d; color: #e8e4da; border-radius: var(--radius); padding: 16px; overflow: auto; max-height: calc(100vh - 60px); }
.lb-meta h3 { margin: 0 0 12px; font: 600 15px Georgia, serif; }
.lb-meta dl { margin: 0; display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 13px; }
.lb-meta dt { color: #9a9688; } .lb-meta dd { margin: 0; word-break: break-word; }
.dl { display: inline-block; margin-top: 14px; }

.doclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.doclist li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.doclist a { text-decoration: none; }

.md { max-width: 920px; padding: 24px 0 64px; }
.md h1 { font-size: 28px; } .md h2 { font: 600 21px Georgia, serif; margin-top: 2em; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.md h3 { font-size: 16px; margin-top: 1.6em; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; margin: 1em 0; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md code { font: 12.5px ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--surface); border: 1px solid var(--line); padding: 12px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 1em 0; padding: 4px 14px; border-left: 3px solid var(--brass); color: var(--muted); background: var(--surface); }
.md img { max-width: 100%; background: #0d0f12; border-radius: 8px; }
.md .mermaid { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }

@media (max-width: 760px) {
  h1 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .lb-body { grid-template-columns: 1fr; overflow: auto; }
  .lightbox { padding: 44px 12px 12px; }
}
