/* Фирменные цвета «Доброго Легиона»: синий #1E3F74, бордовый #9B2F2F, светлый #F9F9F7.
   Сцена демонстрации тёмная, пояснения под ней — на светлом поле, как в «Досье». */
@font-face { font-family: "Source Sans 3"; src: url("fonts/SourceSans3-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/SourceSans3-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/SourceSans3-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --navy-950: #070F1F;
  --navy-900: #0B162B;
  --navy-800: #101F3B;
  --navy-700: #16294C;
  --line: #24406F;
  --ink: #EDF2F9;
  --muted: #9AADCA;
  --faint: #6F84A6;
  --blue: #1E3F74;
  --red: #9B2F2F;
  --red-bright: #C9463F;
  --paper: #F9F9F7;
  --text: #1A1A1C;
  --rule: #D8DFE8;
  --g-tech: #4A8BD6;
  --g-info: #C5D3E0;
  --g-people: #D2524B;
  --g-pref: #E0A64A;
  --g-cond: #5FA08F;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
/* атрибут hidden должен побеждать display: flex и grid у панелей и форм */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--sans); font-size: 17px; line-height: 1.5; color: var(--text); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sheet :focus-visible, .foot :focus-visible { outline-color: var(--blue); }

/* ---------- сцена ---------- */
.stage { background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%); color: var(--ink); padding: 0 28px 22px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 62px; border-bottom: 1px solid var(--navy-700); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand b { display: block; font-size: 19px; font-weight: 700; line-height: 1.1; }
.brand small { display: block; font-size: 13px; color: var(--muted); }
.nav { display: flex; gap: 26px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); border-bottom-color: var(--red-bright); }

.intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 40px; padding: 20px 0 18px; }
.intro h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.08; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.lead { margin-top: 12px; max-width: 760px; color: var(--muted); font-size: 18px; }
.facts { display: grid; grid-template-columns: repeat(4, auto); gap: 0; }
.facts div { padding: 0 22px; border-left: 1px solid var(--line); }
.facts dt { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.facts dd { margin-top: 6px; font-size: 13px; color: var(--muted); max-width: 110px; line-height: 1.25; }

.console { display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.25fr) minmax(360px, 1.05fr); gap: 14px; height: clamp(600px, calc(100vh - 262px), 900px); }
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--navy-800); border: 1px solid var(--navy-700); border-radius: 10px; overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--navy-700); flex: none; }
.panel-head h2 { font-size: 16px; font-weight: 700; white-space: nowrap; }
.panel-note { font-size: 13px; color: var(--faint); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* журнал */
.log-body { flex: 1; overflow-y: auto; padding: 12px 14px 18px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.log-empty { font-family: var(--sans); font-size: 15px; color: var(--faint); padding: 6px 2px; }
.entry { padding: 9px 0 10px; border-bottom: 1px dashed var(--navy-700); animation: rise .35s ease both; }
.entry:last-child { border-bottom: 0; }
.entry .tag { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--faint); margin-bottom: 3px; }
.entry.ask .tag { color: var(--g-pref); }
.entry.terms .tag { color: var(--g-cond); }
.entry.extract .tag { color: var(--g-tech); }
.entry.update .tag { color: var(--g-info); }
.entry.decide .tag { color: var(--red-bright); }
.entry p { color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.4; }
.entry .row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 6px; align-items: baseline; margin-top: 4px; }
.entry .row .sign { font-weight: 700; }
.entry .row.plus .sign { color: #7CC08F; }
.entry .row.minus .sign { color: var(--red-bright); }
.entry .row .what { color: var(--ink); }
.entry .row .num { color: var(--muted); white-space: nowrap; }
.entry .quote { grid-column: 2 / -1; color: var(--faint); font-family: var(--sans); font-size: 13px; line-height: 1.35; }
.entry .move { display: grid; grid-template-columns: minmax(0, 1fr) auto 14px; gap: 8px; margin-top: 3px; }
.entry .move .num { color: var(--muted); white-space: nowrap; }
.entry .move.up .arrow { color: #7CC08F; }
.entry .move.down .arrow { color: var(--red-bright); }
.entry .term { margin-top: 3px; color: var(--ink); }
.entry .term span { color: var(--muted); }

/* разговор */
.chat-body { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; font-size: 16px; line-height: 1.42; animation: rise .3s ease both; }
.msg.bot { align-self: flex-start; background: var(--navy-700); border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--blue); border: 1px solid #2E5596; border-top-right-radius: 4px; }
.msg .who { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.typing { color: var(--muted); }
.msg.typing i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
.msg mark { background: none; color: inherit; border-bottom: 2px solid var(--g-cond); padding-bottom: 1px; }
.final { align-self: stretch; max-width: none; background: #F9F9F7; color: var(--text); border-radius: 10px; padding: 16px 18px; animation: rise .4s ease both; }
.final h3 { font-size: 18px; color: var(--blue); }
.final .sub { margin-top: 2px; font-size: 14px; color: #55606E; }
.final ol { margin-top: 10px; display: grid; gap: 10px; counter-reset: dir; }
.final li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; counter-increment: dir; }
.final li::before { content: counter(dir); width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.final li b { display: block; font-size: 16px; }
.final li span { display: block; font-size: 14px; color: #47525F; line-height: 1.35; }
.final .foot-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 14px; color: #47525F; }

.controls { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--navy-700); }
.btn { cursor: pointer; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 15px; }
.btn:hover { background: var(--navy-700); }
.btn.primary { background: var(--red-bright); border-color: var(--red-bright); color: #fff; min-width: 168px; }
.btn.primary:hover { background: #D4554E; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--navy-900); border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.modes { display: flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mode { cursor: pointer; padding: 5px 12px; border: 0; background: transparent; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.mode + .mode { border-left: 1px solid var(--line); }
.mode:hover { color: var(--ink); }
.mode[aria-pressed="true"] { background: var(--ink); color: var(--navy-900); }
.live { flex: none; padding: 12px 16px; border-top: 1px solid var(--navy-700); display: grid; gap: 8px; }
.live-row { display: flex; align-items: center; gap: 8px; }
.live textarea { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--navy-950); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.35; resize: none; }
.live textarea:focus { outline: none; border-color: var(--g-info); }
.live textarea::placeholder { color: var(--faint); }
.live .btn.primary { min-width: 0; align-self: stretch; }
.live-note { flex: 1; font-size: 12.5px; line-height: 1.3; color: var(--faint); }
.live .counter { margin-left: 0; white-space: nowrap; }
.msg.note { align-self: stretch; max-width: none; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 15px; }
.counter { margin-left: auto; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* профиль */
.map { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sphere-wrap { position: relative; flex: 1 1 0; min-height: 250px; }
#sphere { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#sphere:active { cursor: grabbing; }
.tip { position: absolute; z-index: 2; max-width: 240px; padding: 9px 11px; border-radius: 8px; background: #F9F9F7; color: var(--text); font-size: 13px; line-height: 1.35; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.tip b { display: block; font-size: 14px; }
.tip .st { display: block; margin-top: 3px; color: var(--blue); font-weight: 600; }
.tip q { display: block; margin-top: 4px; color: #55606E; quotes: "«" "»"; }
.legend { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; padding: 0 16px 10px; }
.legend li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: default; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }
.progress { flex: none; padding: 10px 16px 12px; border-top: 1px solid var(--navy-700); }
.progress-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); }
.progress-row b { font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-track { position: relative; height: 8px; margin-top: 6px; border-radius: 4px; background: var(--navy-950); }
.progress-track i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--g-info); transition: width .7s ease, background-color .4s; }
.progress-track.ready i { background: #7CC08F; }
.progress-track em { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.hyp { flex: none; padding: 10px 16px 14px; border-top: 1px solid var(--navy-700); }
.hyp-head { display: flex; justify-content: space-between; align-items: baseline; }
.hyp-head h3 { font-size: 15px; font-weight: 700; }
.hyp-head span { font-size: 12px; color: var(--faint); }
.hyp-list { position: relative; margin-top: 8px; height: 140px; }
.hyp-list li { position: absolute; left: 0; right: 0; top: 0; height: 28px; display: grid; grid-template-columns: minmax(0, 1fr) 44px 40px; align-items: center; gap: 8px; padding: 0 6px; border-radius: 5px; cursor: pointer; transition: transform .7s cubic-bezier(.2, .8, .2, 1), opacity .4s; }
.hyp-list li:hover, .hyp-list li.on { background: var(--navy-700); }
.hyp-list li.off { opacity: 0; pointer-events: none; }
.hyp-list .nm { position: relative; z-index: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hyp-list .bar { position: absolute; left: 0; top: 4px; bottom: 4px; border-radius: 4px; background: rgba(74, 139, 214, .32); transition: width .7s ease; }
.hyp-list li.lead .bar { background: rgba(201, 70, 63, .55); }
.hyp-list .pc { text-align: right; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.hyp-list .dl { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--faint); white-space: nowrap; }
.hyp-list .dl.up { color: #7CC08F; }
.hyp-list .dl.down { color: var(--red-bright); }
.map.instant .hyp-list li, .map.instant .hyp-list .bar, .map.instant .progress-track i { transition: none; }
.hyp-caption { margin-top: 6px; min-height: 34px; font-size: 13px; line-height: 1.35; color: var(--muted); }

.disclaimer { margin-top: 12px; font-size: 13px; color: var(--faint); max-width: 980px; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- светлые разделы ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.sheet { padding: 72px 0; background: var(--paper); }
.sheet.alt { background: #EEF2F6; }
.sheet h2 { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.12; color: var(--blue); text-wrap: balance; }
.sheet-lead { margin-top: 12px; max-width: 760px; font-size: 19px; color: #3B4552; }
.sub { margin-top: 52px; font-size: 20px; color: var(--blue); }

.sides { margin-top: 34px; display: grid; grid-template-columns: 1fr 44px 1.15fr 44px 1fr; align-items: stretch; }
.side { padding: 22px 22px 20px; background: #fff; border: 1px solid var(--rule); border-radius: 10px; }
.side.core { border-color: var(--blue); border-width: 2px; }
.side h3 { font-size: 20px; color: var(--blue); }
.side p { margin-top: 8px; font-size: 16px; color: #3B4552; }
.side-num { margin-top: 14px !important; font-size: 15px !important; color: #55606E !important; }
.side-num b { font-size: 22px; color: var(--red); font-variant-numeric: tabular-nums; }
.side-link { align-self: center; height: 2px; background: var(--blue); position: relative; }
.side-link::before, .side-link::after { content: ""; position: absolute; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.side-link::before { left: -5px; }
.side-link::after { right: -5px; }
.chips { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--rule); border-radius: 999px; font-size: 14px; }
.chips i { width: 10px; height: 10px; border-radius: 2px; }

.loop { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; counter-reset: step; }
.loop li { counter-increment: step; padding-top: 14px; border-top: 3px solid var(--blue); font-size: 16px; color: #3B4552; }
.loop li::before { content: counter(step); display: block; font-size: 30px; font-weight: 700; line-height: 1; color: var(--red); margin-bottom: 8px; }
.loop b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.gains { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.gains h4 { font-size: 17px; color: var(--text); }
.gains p { margin-top: 6px; font-size: 16px; color: #3B4552; }
.boundary { margin-top: 44px; padding: 18px 22px; border-left: 4px solid var(--red); background: #fff; font-size: 16px; color: #3B4552; max-width: 900px; }
.boundary b { color: var(--text); }

.packs { margin-top: 32px; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.pack { display: flex; flex-direction: column; padding: 20px; background: #fff; border: 1px solid var(--rule); border-radius: 10px; text-decoration: none; color: inherit; transition: border-color .2s, transform .2s; }
.pack:hover { border-color: var(--blue); transform: translateY(-2px); }
.pack b { font-size: 18px; color: var(--blue); line-height: 1.2; }
.pack p { margin-top: 8px; font-size: 15px; color: #3B4552; flex: 1; }
.pack .n { margin-top: 14px; font-size: 14px; color: #55606E; }
.pack .n strong { font-size: 24px; color: var(--red); font-variant-numeric: tabular-nums; }
.pack .go { margin-top: 10px; font-size: 15px; font-weight: 600; color: var(--blue); }

.foot { padding: 28px 0 36px; background: var(--navy-950); color: var(--muted); font-size: 14px; }
.foot b { color: var(--ink); }
.foot p + p { margin-top: 6px; max-width: 760px; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1180px) {
  .intro { grid-template-columns: 1fr; align-items: start; gap: 20px; }
  .facts div:first-child { padding-left: 0; border-left: 0; }
  .console { grid-template-columns: 1fr 1fr; height: auto; }
  .panel.chat { grid-column: 1 / -1; grid-row: 1; height: 520px; }
  .panel.log, .panel.map { height: 600px; }
  .loop, .gains { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .stage { padding: 0 16px 18px; }
  .wrap { padding: 0 16px; }
  .nav { display: none; }
  .facts { grid-template-columns: repeat(2, 1fr); gap: 14px 0; }
  .facts div { padding: 0 14px 0 0; border-left: 0; }
  .console { grid-template-columns: 1fr; }
  .panel.chat { height: 500px; }
  .panel.map { height: auto; }
  .panel.log { height: 420px; }
  .sphere-wrap { flex-basis: 300px; min-height: 300px; }
  .controls { flex-wrap: wrap; }
  .btn.primary { flex: 1 1 100%; }
  .sides { grid-template-columns: 1fr; gap: 12px; }
  .side-link { display: none; }
  .loop, .gains { grid-template-columns: 1fr; }
  .sheet { padding: 48px 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
