/* Общие стили демо GdeKirpich. Палитра - как во Viewer. */
:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --border: rgba(31, 30, 29, 0.15);
  --border-strong: rgba(31, 30, 29, 0.3);
  --text: #1f1e1d;
  --text-secondary: #5f5e5a;
  --text-muted: #888780;
  --blue-fill: #e6f1fb; --blue-line: #185fa5; --blue-text: #0c447c; --blue-solid: #378add;
  --teal-fill: #e1f5ee; --teal-line: #0f6e56; --teal-text: #085041; --teal-solid: #1d9e75;
  --gray-fill: #f1efe8; --gray-line: #5f5e5a; --gray-text: #444441;
  --purple-fill: #eeedfe; --purple-line: #534ab7; --purple-text: #3c3489; --purple-solid: #7f77dd;
  --coral-fill: #faece7; --coral-line: #993c1d; --coral-text: #712b13;
  --green-fill: #eaf3de; --green-line: #3b6d11; --green-text: #27500a;
  --amber-fill: #faeeda; --amber-line: #854f0b; --amber-text: #633806; --amber-solid: #e8a33a;
  --red-fill: #fcebeb; --red-line: #a32d2d; --red-text: #791f1f; --red-solid: #e24b4a;
  --brick-req: #378add;
  --brick-ok: #1d9e75;
  --brick-err: #e24b4a;
  --brick-db: #7f77dd;
  --brick-ext: #e8a33a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1c;
    --surface: #2a2a28;
    --border: rgba(236, 236, 234, 0.14);
    --border-strong: rgba(236, 236, 234, 0.3);
    --text: #ececea;
    --text-secondary: #c2c0b6;
    --text-muted: #9c9a92;
    --blue-fill: #0c3a68; --blue-line: #85b7eb; --blue-text: #b5d4f4;
    --teal-fill: #08443a; --teal-line: #5dcaa5; --teal-text: #9fe1cb;
    --gray-fill: #3a3a37; --gray-line: #b4b2a9; --gray-text: #d3d1c7;
    --purple-fill: #352f7a; --purple-line: #afa9ec; --purple-text: #cecbf6;
    --coral-fill: #5e2410; --coral-line: #f0997b; --coral-text: #f5c4b3;
    --green-fill: #22460a; --green-line: #97c459; --green-text: #c0dd97;
    --amber-fill: #553005; --amber-line: #ef9f27; --amber-text: #fac775;
    --red-fill: #661a1a; --red-line: #f09595; --red-text: #f7c1c1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
a { color: var(--blue-solid); }
button { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }

/* Верхняя панель с версиями */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-in { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; white-space: nowrap; }
.logo-mark { display: grid; grid-template-columns: repeat(2, 8px); gap: 2px; }
.logo-mark i { width: 8px; height: 8px; border-radius: 2px; background: var(--brick-req); }
.logo-mark i:nth-child(2) { background: var(--brick-ok); }
.logo-mark i:nth-child(3) { background: var(--brick-db); }
.logo-mark i:nth-child(4) { background: var(--brick-ext); }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  text-decoration: none; color: var(--text-secondary); padding: 6px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.tab b { font-size: 11px; width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--gray-fill); color: var(--gray-text); }
.tab:hover { background: var(--gray-fill); color: var(--text); }
.tab.on { background: var(--text); color: var(--bg); }
.tab.on b { background: var(--bg); color: var(--text); }
@media (max-width: 760px) {
  .top-in { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 16px; }
  .tabs { margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .tab { flex-direction: column; gap: 2px; padding: 5px 2px; font-size: 11px; text-align: center; }
}

/* Шапка страницы версии */
.page { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; margin-bottom: 16px; }
.head h1 { margin: 0; font-size: clamp(22px, 4vw, 30px); line-height: 1.15; letter-spacing: -0.01em; }
.head p { margin: 4px 0 0; color: var(--text-secondary); max-width: 640px; }
.branch { font-size: 12px; color: var(--text-muted); }
.head-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 760px) { .head-tools { margin-left: 0; width: 100%; } }

/* Переключатель сценария */
.scenario { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.scenario button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.scenario button.on { background: var(--green-fill); color: var(--green-text); }
.scenario button.on.bad { background: var(--red-fill); color: var(--red-text); }

.btn {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px;
  padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.btn:hover { border-color: var(--text-secondary); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.note { font-size: 13px; color: var(--text-muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.pill.async { background: var(--amber-fill); color: var(--amber-text); }
.pill.err { background: var(--red-fill); color: var(--red-text); }
.pill.comp { background: var(--coral-fill); color: var(--coral-text); }
.pill.db { background: var(--purple-fill); color: var(--purple-text); }
.pill.ext { background: var(--amber-fill); color: var(--amber-text); }

/* Значения: вход и выход */
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv td { padding: 5px 0; border-top: 1px solid var(--border); vertical-align: top; }
.kv td:first-child { color: var(--text-muted); width: 40%; padding-right: 10px; }
.kv td:last-child { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; word-break: break-word; }
.kv tr:first-child td { border-top: 0; }

/* Картинки логики: дорога решений, деньги, было и стало */
.ramp-gray { background: var(--gray-fill); border-color: var(--gray-line); color: var(--gray-text); }
.ramp-teal { background: var(--teal-fill); border-color: var(--teal-line); color: var(--teal-text); }
.ramp-coral { background: var(--coral-fill); border-color: var(--coral-line); color: var(--coral-text); }
.ramp-green { background: var(--green-fill); border-color: var(--green-line); color: var(--green-text); }
.ramp-red { background: var(--red-fill); border-color: var(--red-line); color: var(--red-text); }

.pic { margin: 12px 0; }
.pic-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 8px; }

.road { display: flex; align-items: stretch; gap: 0; position: relative; }
.road-check { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; padding: 0 4px; min-width: 0; }
.road-check::before { content: ""; position: absolute; top: 50px; left: 0; right: 0; height: 3px; background: var(--border-strong); }
.road-check:first-child::before { left: 50%; }
.road .question { font-size: 13px; font-weight: 600; min-height: 40px; display: flex; align-items: flex-end; justify-content: center; }
.road .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--text-secondary); margin: 2px 0 6px; position: relative; z-index: 1; }
.road .answer { font-size: 12px; font-weight: 700; padding: 1px 10px; border-radius: 999px; border: 1px solid; }
.road .answer.yes { background: var(--green-fill); border-color: var(--green-line); color: var(--green-text); }
.road .answer.no { background: var(--red-fill); border-color: var(--red-line); color: var(--red-text); }
.road .otherwise { font-size: 12px; color: var(--text-muted); margin-top: 6px; border-top: 1px dashed var(--border-strong); padding-top: 4px; }
.road-end { display: flex; align-items: center; padding-left: 8px; position: relative; }
.road-end::before { content: ""; position: absolute; top: 50px; left: 0; width: 8px; height: 3px; background: var(--border-strong); }
.road-end .box { margin-top: 34px; align-self: flex-start; }
.box { border: 1px solid; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 14px; }
@media (max-width: 760px) {
  .road { flex-direction: column; padding-left: 4px; }
  .road-check { flex-direction: row; flex-wrap: wrap; align-items: center; text-align: left; gap: 4px 10px; padding: 0 0 14px 28px; }
  .road-check::before { top: 0; bottom: 0; left: 11px; right: auto; width: 3px; height: auto; }
  .road-check:first-child::before { left: 11px; top: 8px; }
  .road .question { min-height: 0; order: 1; display: block; flex: 1 1 60%; }
  .road .dot { position: absolute; left: 4px; top: 2px; margin: 0; }
  .road .answer { order: 2; }
  .road .otherwise { order: 3; flex-basis: 100%; margin-top: 0; }
  .road-end { padding: 0 0 0 28px; }
  .road-end::before { display: none; }
  .road-end .box { margin-top: 0; }
}

.money { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 8px; }
.bar-slot { flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; text-align: center; }
.bar { border: 1px solid; border-radius: 8px 8px 3px 3px; display: grid; place-items: center; font-weight: 700; font-size: 14px; min-height: 6px; transition: height 0.5s ease; }
.bar-value { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.bar-label { font-size: 12px; color: var(--text-secondary); margin-top: 6px; min-height: 18px; }
.formula { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.formula .op { color: var(--text-muted); font-weight: 700; }
.formula .term { background: var(--gray-fill); padding: 2px 8px; border-radius: 6px; }

.change { display: flex; gap: 10px; align-items: center; }
.change-card { flex: 1; font-weight: 400; padding: 10px 12px; min-width: 0; }
.change-title { font-weight: 700; margin-bottom: 6px; }
.change-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 6px; border-radius: 6px; font-size: 13px; border: 1px solid transparent; }
.change-row span:last-child { font-weight: 700; text-align: right; }
.change-arrow { font-size: 22px; color: var(--text-muted); }
@media (max-width: 520px) {
  .change { flex-direction: column; align-items: stretch; }
  .change-arrow { text-align: center; transform: rotate(90deg); }
}

.demo-note { margin-top: 24px; font-size: 13px; color: var(--text-muted); text-align: center; }
