:root {
  --bg: #15130f; --panel: #1f1c16; --panel2: #29251d; --line: #3a3529;
  --text: #ebe4d3; --muted: #9d9582; --accent: #d9a441; --accent-ink: #1a1405;
  --danger: #d0583f; --ok: #6fae6a; --radius: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.5;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3efe4; --panel: #fffdf7; --panel2: #ebe5d3; --line: #d3cab1;
    --text: #231f15; --muted: #6a634f; --accent: #9a6a0a; --accent-ink: #fff; --danger: #b43a22; --ok: #2f7a2c;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px; z-index: 9; }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .04em; text-decoration: none; text-transform: uppercase; color: var(--accent); }
nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
nav a { padding: 6px 10px; border-radius: var(--radius); text-decoration: none; color: var(--text); }
nav a:hover, nav a[aria-current="page"] { background: var(--panel2); }
.burger { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--text); border-radius: var(--radius); font-size: 20px; padding: 2px 10px; }
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
.foot { padding: 16px; text-align: center; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
h1 { font-size: 28px; margin: 0 0 12px; } h2 { font-size: 20px; margin: 24px 0 8px; }
.lead { color: var(--muted); font-size: 18px; max-width: 60ch; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 16px 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius); padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
form.stack { display: grid; gap: 12px; max-width: 420px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
input, select, textarea { font: inherit; padding: 8px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); width: 100%; }
input[type="checkbox"] { width: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.msg { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel2); }
.msg.err { border-color: var(--danger); } .msg.ok { border-color: var(--ok); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.tag.banned { color: var(--danger); } .tag.muted { color: var(--accent); } .tag.active { color: var(--ok); }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 16px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stat { font-size: 28px; font-weight: 700; } .stat small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
svg.chart { width: 100%; height: auto; max-height: 220px; } svg.chart .bar { fill: var(--accent); } svg.chart text { fill: var(--muted); font-size: 10px; }
.kbd { font-family: ui-monospace, monospace; background: var(--panel2); padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); }
.banner { background: var(--panel2); border-left: 4px solid var(--accent); padding: 10px 14px; margin: 12px 0; }
@media (max-width: 720px) {
  .burger { display: block; } nav { display: none; width: 100%; flex-direction: column; margin-left: 0; }
  nav.open { display: flex; } h1 { font-size: 24px; }
}
.footlinks { display: flex; flex-direction: row; width: auto; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 8px 0 0; font-size: 14px; }
.footlinks a { color: var(--muted); }
.cookiebar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 16px; background: var(--panel2); border-top: 1px solid var(--line); font-size: 14px; z-index: 20; }

/* ===== Страница «Сюжет» ===== */
:root { --st-game: #6fae6a; --st-part: #d9a441; --st-script: #6a9bd8; --st-none: #6d6757; --branch-n: #d9a441; --branch-m: #6a9bd8; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --st-game: #2f7a2c; --st-part: #9a6a0a; --st-script: #2f64a8; --st-none: #8a846f; --branch-n: #9a6a0a; --branch-m: #2f64a8; } }
.muted { color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi strong { display: block; font-size: 24px; line-height: 1.1; } .kpi small { color: var(--muted); }
.ready-grid { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: center; }
.donut { position: relative; width: 160px; height: 160px; } .donut svg { width: 100%; height: 100%; }
.donut .d-bg { stroke: var(--panel2); } .donut .d-fg { stroke: var(--accent); }
.donut-c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-c strong { font-size: 30px; } .donut-c small { color: var(--muted); font-size: 12px; max-width: 90px; }
.layer { margin: 10px 0; } .bar-track { height: 12px; background: var(--panel2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 99px; } .bar-fill.game { background: var(--st-game); } .bar-fill.part { background: var(--st-part); } .bar-fill.script { background: var(--st-script); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0; font-size: 13px; } .legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--st-none); }
.dot.game { background: var(--st-game); } .dot.part { background: var(--st-part); } .dot.script { background: var(--st-script); } .dot.none { background: transparent; border: 1px dashed var(--st-none); }
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; }
.chip.game, .chip.code { color: var(--st-game); border-color: var(--st-game); } .chip.part { color: var(--st-part); border-color: var(--st-part); }
.chip.script { color: var(--st-script); border-color: var(--st-script); } .chip.none, .chip.srv { color: var(--muted); border-style: dashed; }
.chip.mech { color: var(--text); } .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.smap-wrap { overflow-x: auto; padding: 10px 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin: 8px 0 16px; }
.lanes { display: flex; gap: 18px; padding: 0 12px 8px; font-size: 12px; } .lanes span::before { content: ""; display: inline-block; width: 18px; height: 3px; margin-right: 6px; vertical-align: middle; background: var(--muted); }
.lanes .N::before { background: var(--branch-n); } .lanes .M::before { background: var(--branch-m); }
.smap-in { position: relative; width: 100%; min-width: 1040px; padding: 6px 12px; box-sizing: border-box; }
.smap { display: grid; grid-template-columns: repeat(14, minmax(66px, 1fr)); grid-template-rows: auto auto auto; gap: 26px 8px; position: relative; z-index: 1; align-items: center; }
.smap-lines { position: absolute; left: 12px; top: 6px; pointer-events: none; z-index: 0; overflow: visible; }
.edge { stroke: var(--muted); stroke-width: 2; opacity: .7; } .edge.N { stroke: var(--branch-n); } .edge.M { stroke: var(--branch-m); }
.node { display: grid; gap: 2px; align-content: center; text-align: center; min-height: 74px; padding: 8px 6px; border-radius: 10px; border: 2px solid var(--st-none); background: var(--panel2); color: var(--text); font: inherit; cursor: pointer; line-height: 1.15; }
.node strong { font-size: 15px; } .node span { font-size: 11px; overflow-wrap: anywhere; } .node small { font-size: 10px; color: var(--muted); }
.node.router { border-style: dashed; }
.node.game { border-color: var(--st-game); } .node.part { border-color: var(--st-part); } .node.script { border-color: var(--st-script); } .node.none { border-style: dashed; opacity: .75; }
.node:hover, .node.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.node.static { cursor: default; } .node.fork { border-radius: 50%; width: 88px; height: 88px; justify-self: center; border-color: var(--accent); min-height: 0; padding: 4px; }
.fstack { display: grid; gap: 8px; } .node.final { min-height: 0; padding: 6px; }
.node.final.good { border-width: 3px; }
.card.N { border-left: 4px solid var(--branch-n); } .card.M { border-left: 4px solid var(--branch-m); }
.detail .meta { gap: 16px; font-size: 14px; margin: 6px 0; } .detail h3 { margin: 18px 0 8px; font-size: 17px; }
.timebar { margin: 8px 0; } .tb-track { position: relative; height: 10px; background: var(--panel2); border-radius: 99px; border: 1px solid var(--line); }
.tb-range { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 35%, transparent); } .tb-typ { position: absolute; top: -3px; width: 4px; height: 14px; background: var(--accent); border-radius: 2px; }
.tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.tl-i { position: relative; margin: 6px 0; } .tl-i::before { content: ""; position: absolute; left: -21px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--st-script); }
.tl-i.game::before { background: var(--st-game); } .tl-i.part::before { background: var(--st-part); } .tl-i.none::before { background: transparent; border: 1px dashed var(--st-none); }
.tl-i details { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
.tl-i summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .tl-meta { font-size: 12px; margin-left: auto; }
.tl-body { padding: 6px 0 4px; font-size: 14px; } .tl-body p { margin: 6px 0; } .tag.kt { color: var(--accent); }
.forks { margin: 8px 0; display: grid; gap: 6px; } .fork-card { border-left: 3px solid var(--accent); background: var(--panel2); padding: 6px 10px; border-radius: 0 var(--radius) var(--radius) 0; }
.side { margin: 14px 0; } .side summary { cursor: pointer; font-weight: 600; } .side ul { margin: 8px 0; padding-left: 18px; font-size: 14px; }
.searchbox { margin: 14px 0; } .results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hit { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.final-card.good { border-top: 3px solid var(--st-game); } .final-card.bad { border-top: 3px solid var(--danger); }
.stacked { display: flex; height: 34px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin: 6px 0; }
.stacked span { background: var(--accent); display: grid; place-content: center; min-width: 0; overflow: hidden; border-right: 1px solid var(--bg); }
.stacked small { color: var(--accent-ink); font-size: 11px; padding: 0 3px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.mirror { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; } .mirror li { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 10px 12px; }
.m-date { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; } .m-date span { color: var(--muted); }
.m-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .m-cols p { margin: 2px 0 0; font-size: 14px; }
.m-cols .N { border-left: 3px solid var(--branch-n); padding-left: 8px; } .m-cols .M { border-left: 3px solid var(--branch-m); padding-left: 8px; } .m-cols small { color: var(--muted); }
.matrix table { font-size: 12px; border-collapse: separate; border-spacing: 0; } .matrix th, .matrix td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.matrix th.sticky { position: sticky; left: 0; background: var(--panel); width: 300px; min-width: 300px; max-width: 300px; white-space: normal; text-align: left; font-weight: 400; z-index: 1; border-right: 1px solid var(--line); }
.matrix th.sticky .chip { display: block; width: max-content; margin-bottom: 2px; font-size: 10px; padding: 0 7px; }
.matrix th.mk { text-align: center; } .matrix th.mk.N { color: var(--branch-n); } .matrix th.mk.M { color: var(--branch-m); }
.mc { text-align: center; font-weight: 700; min-width: 30px; } .mc.v { background: color-mix(in srgb, var(--accent) 55%, transparent); } .mc.z { background: color-mix(in srgb, var(--accent) 22%, transparent); } .mc.p { background: color-mix(in srgb, var(--st-game) 45%, transparent); }
.linkbtn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
@media (max-width: 720px) { .ready-grid { grid-template-columns: 1fr; justify-items: center; } .ready-grid > div:last-child { width: 100%; } .m-cols { grid-template-columns: 1fr; } .matrix th.sticky { width: 170px; min-width: 170px; max-width: 170px; } }
dialog.reauth { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px; max-width: min(440px, calc(100vw - 32px)); }
dialog.reauth::backdrop { background: rgba(0, 0, 0, .6); }
dialog.reauth label { display: block; margin: 8px 0; }
dialog.reauth input { width: 100%; }
/* Карта города (админка) */
.map-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; margin: 12px 0 20px; align-items: start; }
.citymap { position: relative; height: 640px; min-height: 360px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.citymap-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline-offset: -3px; }
.citymap-canvas:active { cursor: grabbing; }
.map-side { max-height: 640px; overflow: auto; margin: 0; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 8px 0; font-size: 14px; }
.map-tools .chk { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 900px) { .map-grid { grid-template-columns: 1fr; } .citymap { height: 70vh; } .map-side { max-height: none; } }
