/* «Полотно истории» — каркас 0.1.0 (тестовые данные). Тёмная музейная тема. */
:root {
  --bg: #14161c; --bg2: #1a1d26; --panel: #20242f; --line: #323848;
  --text: #d8dce6; --muted: #8a92a4; --accent: #e8b64c;
  --ruler: #4f7fbf; --war: #e05252; --rev: #a564c8; --event: #e8b64c;
  --link-cause: #56c4a2; --link-bg: #7a86b8; --link-cons: #d98f4e; --link-spawn: #c85a8f;
  --inv: #58a8d8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Georgia", "Times New Roman", serif; }
a { color: #9fc2e8; text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: Consolas, monospace; font-size: 13px; }

header.top { display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top h1 { font-size: 19px; margin: 0; letter-spacing: .4px; color: var(--accent); white-space: nowrap; }
header.top nav { display: flex; gap: 14px; }
header.top nav a { padding: 4px 10px; border-radius: 6px; color: var(--text); }
header.top nav a.active { background: var(--panel); color: var(--accent); }
.badge-test { font-size: 11px; font-family: Consolas, monospace; color: #ffb4b4; border: 1px dashed #b46; padding: 2px 8px; border-radius: 8px; white-space: nowrap; }

main { display: flex; gap: 14px; padding: 14px 18px; align-items: flex-start; }
#stage-wrap { flex: 1 1 auto; min-width: 0; }
#canvas-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); }
canvas { display: block; cursor: default; }
canvas.hovering { cursor: pointer; }
#map-canvas { cursor: grab; }
#tapestry { cursor: grab; }
#map-canvas.grabbing, canvas.grabbing { cursor: grabbing; }

aside#side { width: 350px; flex: 0 0 350px; max-height: calc(100vh - 90px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
aside#side h2 { margin: 0 0 4px; font-size: 18px; color: var(--accent); }
aside#side .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
aside#side .desc { margin: 8px 0; }

.layers { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 4px; }
.layers label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 14px; color: var(--text); user-select: none; }
.layers label.sub-option { margin-left: 14px; font-size: 13px; color: var(--muted); }
.swatch-inline { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: baseline; }
.inspect-item { cursor: pointer; }
.inspect-item:hover { background: rgba(232, 182, 76, 0.08); }
.jump-year { color: var(--accent); margin: 0 3px; }

/* инспектор: режимы окна и группировка по годам */
.insp-modes { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.insp-mode { background: var(--bg2); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 9px; cursor: pointer; font-size: 13px; }
.insp-mode.active { color: var(--accent); border-color: var(--accent); }
.insp-year { color: var(--accent); font-size: 13px; margin: 8px 0 3px; }

/* персонажи: фильтры, карточки с фото, карточка-модалка (владелец 01.12) */
.person-filters { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 8px; }
.person-filters input[type="search"] { flex: 0 0 220px; }
.person-filters select, .person-filters input[type="text"] { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.persons-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.person-card { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.person-card:hover { border-color: var(--accent); }
.person-card .pc-thumb { width: 72px; height: 88px; object-fit: cover; border-radius: 6px; flex: 0 0 72px; }
.person-card .pc-thumb.pc-noimg { display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--accent); background: var(--bg2); }
.person-card .pc-col { min-width: 0; }
.person-card .name { color: var(--accent); font-size: 16px; }
.person-card .meta { color: var(--muted); font-size: 13px; }
.person-card .pc-snippet { color: var(--text); font-size: 13px; margin-top: 5px; line-height: 1.35; }
.person-card .pc-open { margin-top: 6px; background: var(--bg2); color: var(--accent); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.person-card .pc-open:hover { border-color: var(--accent); }

.person-link { color: var(--accent); cursor: pointer; border-bottom: 1px dotted var(--accent); }
.person-modal { position: fixed; inset: 0; background: rgba(5, 7, 12, 0.72); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; z-index: 60; padding: 40px 16px; }
.person-modal-body { position: relative; width: min(720px, 94vw); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; }
.person-modal-body .pc-close { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.person-modal-body .pc-close:hover { color: var(--text); }
.person-modal-body .pc-years { margin: 6px 0 10px; }
.pc-body::after { content: ''; display: block; clear: both; }
.pc-body .pc-photo { float: left; width: 180px; max-width: 45%; margin: 4px 16px 8px 0; border-radius: 8px; border: 1px solid var(--line); }
.pc-body .pc-photo.pc-noimg { display: flex; align-items: center; justify-content: center; font-size: 56px; color: var(--accent); background: var(--bg2); height: 200px; }
.pc-credit { font-size: 11px; color: var(--muted); margin: -4px 0 8px; }
.pc-desc { line-height: 1.45; }
.person-modal-body .credit-wiki { margin-top: 10px; }
.layers .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.link-item { border-top: 1px solid var(--line); padding: 10px 0; cursor: pointer; }
.link-item:hover { background: rgba(232,182,76,.06); }
.link-item:hover .dir { text-decoration: underline; }
.link-item .dir { font-weight: bold; color: var(--accent); font-size: 14px; }
.link-item .conf { display: inline-block; font-size: 11px; font-family: Consolas, monospace; padding: 1px 7px; border-radius: 8px; margin-left: 6px; vertical-align: 1px; }
.conf-Факт { background: #1d4034; color: #7fe0b8; border: 1px solid #2f6a52; }
.conf-Устойчивая { background: #3a3a1d; color: #e0d07f; border: 1px solid #6a6a2f; }
.conf-Интерпретация { background: #3d2033; color: #e0a0c8; border: 1px solid #6a2f52; }
.link-item .text { margin: 6px 0 4px; font-size: 14px; }
.link-item .srcs { font-size: 12px; color: var(--muted); }
details.src-details { margin: 6px 0 0; font-size: 13px; }
details.src-details summary { cursor: pointer; color: var(--muted); user-select: none; }
details.src-details summary:hover { color: var(--text); }
details.src-details[open] summary { color: var(--text); }
.ai-plate { background: #26202f; border: 1px solid #4a3a5c; border-left: 4px solid var(--rev); border-radius: 6px; padding: 8px 10px; font-size: 13px; margin: 8px 0; color: #cfc4dd; }
.ai-mark { display: inline-block; font-family: Consolas, monospace; font-size: 11px; border-radius: 8px; padding: 1px 7px; cursor: help; vertical-align: 1px; }
.ai-mark.ai-ai { background: #26202f; border: 1px solid #4a3a5c; color: #d0a8e8; }
.ai-mark.ai-note { background: #26202f; border: 1px solid #4a3a5c; color: #d0a8e8; }
.legend-btn { background: var(--panel); color: var(--accent); border: 1px solid var(--line); border-radius: 6px; padding: 5px 14px; font: inherit; cursor: pointer; white-space: nowrap; }
.legend-btn:hover { border-color: var(--accent); }
.legend-overlay { position: fixed; inset: 0; background: rgba(8,10,14,.72); z-index: 200; display: flex; align-items: center; justify-content: center; }
.legend-modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; max-width: 720px; width: 92%; max-height: 86vh; overflow-y: auto; padding: 18px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.6); }
.legend-head { display: flex; justify-content: space-between; align-items: center; }
.legend-head h2 { margin: 0; color: var(--accent); font-size: 20px; }
.legend-close { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.legend-body h3 { color: var(--text); font-size: 15px; margin: 14px 0 4px; }
.legend-body p { margin: 5px 0; font-size: 14px; }
.legend-body .sw { display: inline-block; width: 18px; height: 6px; border-radius: 3px; vertical-align: middle; margin-right: 3px; }
.credit-wiki { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 10px; }

.tooltip { position: absolute; pointer-events: none; background: #262a36; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 13px; max-width: 300px; z-index: 50; box-shadow: 0 4px 14px rgba(0,0,0,.5); display: none; }
.tooltip b { color: var(--accent); }

.map-controls { display: flex; align-items: center; gap: 10px; padding: 8px 4px; flex-wrap: wrap; }
.map-controls button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 14px; font: inherit; cursor: pointer; }
.map-controls button.active { background: var(--accent); color: #222; border-color: var(--accent); font-weight: bold; }
.map-note { color: var(--muted); font-size: 13px; }
.map-attrib { font-size: 12px; color: var(--muted); padding: 6px 4px; max-width: 900px; }

/* стили карточек персон — см. блок «персонажи» выше (заменены карточками с фото) */
#life-canvas { border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); margin-top: 10px; }
input#person-search { width: 320px; max-width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font: inherit; }

footer#about { border-top: 1px solid var(--line); background: var(--bg2); padding: 14px 18px 26px; font-size: 13px; color: var(--muted); }
footer#about h3 { color: var(--text); font-size: 15px; margin: 12px 0 6px; }
footer#about p { margin: 6px 0; }
footer#about .src-list code { color: #9fc2e8; }

.hint { color: var(--muted); font-size: 13px; padding: 4px; }
.chip { display:inline-block; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 1px 9px; font-size: 12px; color: var(--muted); margin: 2px 4px 2px 0; }
.legend-row { display:flex; flex-wrap:wrap; gap: 8px 16px; padding: 6px 4px 0; color: var(--muted); font-size: 13px; }

.play-controls { display: flex; align-items: center; gap: 10px; padding: 8px 18px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--bg2); }
.play-controls button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 16px; font: inherit; cursor: pointer; }
.play-controls button.active { background: var(--accent); color: #222; border-color: var(--accent); font-weight: bold; }
.play-controls select { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: inherit; }
.play-controls label { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.play-controls .play-steps { display: inline-flex; align-items: center; gap: 4px; }
.play-controls .play-steps button { padding: 4px 10px; font-size: 13px; }
.play-controls .play-steps b { color: var(--accent); font-size: 18px; min-width: 56px; text-align: center; font-family: Consolas, monospace; }
.play-controls input#play-year { background: var(--bg2); color: var(--accent); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; width: 62px; text-align: center; font: bold 18px Consolas, monospace; }
.play-controls input#play-year:focus { outline: none; border-color: var(--accent); }
.play-controls input#play-year.play-year-err { border-color: #e05252; background: #3a2028; color: #ffb4b4; }
#timeline { display: block; margin: 0 18px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); cursor: pointer; }
#timeline.hovering { cursor: pointer; }
.legend-row .sw { display:inline-block; width: 22px; height: 4px; border-radius: 2px; vertical-align: 3px; margin-right: 5px; }

/* страница «В планах» */
.plans { margin: 8px 0 16px; padding-left: 22px; line-height: 1.5; }
.plans li { margin-bottom: 6px; }
