/* Скопировано из vibe-canvas/assets/canvas.html (дизайн slopalytics.com). Не править: общий вид. */
:root {
  color-scheme: dark;
  --bg: light-dark(#fff, #000);
  --hover: light-dark(#f1eeea, #141210);
  --on-accent: light-dark(#fff, #000);
  --fg: light-dark(#20201e, #fff);
  --fg-2: light-dark(#625d57, #aaa39d);
  --fg-3: light-dark(#736d68, #7e7873); /* на сайте #77716c, сдвинут до контраста AA */
  --line: light-dark(#e8e4df, #1c1a18);
  --line-2: light-dark(#ccc5be, #36312d);
  --surface: light-dark(#f8f6f3, #0d0b0a);
  --accent: light-dark(#806047, #c5ac98);
  --clay: light-dark(#ae5235, #df9477);
  --ink: light-dark(#303840, #f1f3f5);
  --green: light-dark(#218347, #56ca80);
  --gold: light-dark(#8e7318, #ecd36e);
  --violet: light-dark(#6d55bd, #9b94ee);
  --blue: light-dark(#236bbd, #5ea4ff);
  --teal: light-dark(#157d83, #52cdd2);
  --sidebar-width: 248px;
  /* Содержимое не шире --content-width и стоит по центру основной колонки: боковые поля
     растут вместе с экраном, а разделители разделов остаются на всю ширину. */
  --content-width: 960px;
  --gutter: max(28px, calc((100% - var(--content-width)) / 2));
  --header-height: 60px;
  --font: "DM Sans", "Onest", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: var(--font);
  font-synthesis: none;
  color: var(--fg);
  background: var(--bg);
}
:root[data-theme=light] { color-scheme: light; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
* { box-sizing: border-box; }
body { margin: 0; -webkit-text-size-adjust: 100%; overflow-wrap: anywhere; }
button, input, textarea, a { -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button:hover, a:hover { color: var(--fg); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
::selection { background: var(--accent); color: var(--on-accent); }

/* ---------- шапка ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10; height: var(--header-height);
  display: flex; align-items: center; gap: 36px; padding: 0 28px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { flex-shrink: 0; white-space: nowrap; font-size: 24px; font-weight: 450; letter-spacing: -1.2px; }
.brand span { color: var(--accent); }
.view-tabs {
  align-self: stretch; display: flex; align-items: stretch; gap: 22px; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.view-tabs a { position: relative; display: flex; align-items: center; white-space: nowrap; color: var(--fg-2); font-size: 12.5px; }
.view-tabs a[aria-current=true] { color: var(--fg); }
.view-tabs a[aria-current=true]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--accent);
}
.header-actions { flex-shrink: 0; display: flex; align-items: center; gap: 2px; margin-left: auto; }
.icon-button { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--fg-2); }
.icon-button svg { width: 16px; height: 16px; }

/* ---------- раскладка ---------- */
.body-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar-width); grid-template-rows: 1fr auto;
  min-height: calc(100dvh - var(--header-height));
}
main { grid-column: 1; min-width: 0; }
.sidebar {
  grid-column: 2; grid-row: 1 / span 2; align-self: start;
  position: sticky; top: var(--header-height); height: calc(100dvh - var(--header-height));
  display: flex; flex-direction: column; gap: 18px; padding: 16px 18px;
  border-left: 1px solid var(--line); overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) var(--bg);
}
.sidebar > * { flex-shrink: 0; }
.doc-footer {
  grid-column: 1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px var(--gutter); border-top: 1px solid var(--line); color: var(--fg-3); font-size: 11px;
}
.doc-footer a { color: var(--fg-2); }
.doc-footer .accent { color: var(--accent); }

/* ---------- текст ---------- */
.doc-head { padding: 22px var(--gutter) 20px; }
.doc-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.doc-title > * { min-width: 0; }
h1 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.25; }
.doc-source { color: var(--fg-3); font-size: 11px; }
.doc-source a { text-decoration: underline; text-underline-offset: 4px; }
.doc-source a:hover { color: var(--accent); }
.doc-updated { margin-left: auto; color: var(--fg-3); font-size: 11px; }
.lede { max-width: 72ch; margin: 10px 0 0; color: var(--fg-2); font-size: 14px; line-height: 1.65; }
.doc-section { padding: 20px var(--gutter) 26px; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-height) + 8px); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 12px; }
h2 { margin: 0; font-size: 16px; font-weight: 500; }
.section-heading .aside { color: var(--fg-3); font-size: 11px; }
h3 { margin: 20px 0 6px; font-size: 13px; font-weight: 550; }
h3:first-child { margin-top: 0; }
p, li { max-width: 72ch; font-size: 14px; line-height: 1.65; }
p { margin: 0 0 10px; }
ul, ol { margin: 0 0 10px; padding-left: 18px; }
li + li { margin-top: 4px; }
li::marker { color: var(--fg-3); }
b, strong { font-weight: 550; }
.prose a, p a, li a, td a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); }
.small { font-size: 12px; }
.ok { color: var(--green); }
.warn { color: var(--gold); }
.bad { color: var(--clay); }
code { font-family: var(--mono); font-size: .86em; color: var(--fg); background: var(--hover); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
pre { max-width: 100%; margin: 10px 0 14px; padding: 12px 14px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; line-height: 1.6; }
pre code { background: none; padding: 0; font-size: inherit; }
kbd { font: inherit; font-size: 11px; color: var(--fg-3); }
input[type=range] { max-width: 100%; accent-color: var(--accent); }

/* ---------- блоки ---------- */
.note { max-width: 80ch; margin: 4px 0 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; }
.note-head { margin-bottom: 6px; font-size: 13px; font-weight: 550; }
.note p, .note li { font-size: 13.5px; }
.note p:last-child, .note ul:last-child, .note ol:last-child { margin-bottom: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 32px; }
details { max-width: 72ch; margin-top: 12px; padding: 12px 0 0; border-top: 1px solid var(--line); color: var(--fg-2); font-size: 13px; }
details p, details li { font-size: 13px; line-height: 1.8; }
summary { cursor: pointer; }
details[open] summary { margin-bottom: 10px; }

/* цифры: ряд значений и крупное значение */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px 14px; margin: 4px 0 18px; }
.stats > div { display: flex; flex-direction: column; gap: 7px; }
.stats span { color: var(--fg-3); font-size: 11px; }
.stats strong { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stats .big strong { font-size: 38px; letter-spacing: -1px; line-height: 1; }

/* рейтинг с полоской доли */
.rank-list { max-width: 560px; margin: 4px 0 18px; }
.rank-heading, .rank { display: grid; grid-template-columns: 14px minmax(0, 1fr) 64px 52px; gap: 8px; }
.rank-heading { padding-bottom: 8px; color: var(--fg-3); font-size: 10px; }
.rank-heading > :nth-child(n+3) { text-align: right; }
.rank { align-items: center; min-height: 43px; border-top: 1px solid var(--line); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank-n { color: var(--fg-3); font-size: 10px; }
.rank-name { position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; padding: 8px 0 11px; }
.rank-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { position: absolute; left: 0; bottom: 2px; height: 2px; opacity: .65; }
.rank-value, .rank-share { text-align: right; }
.rank-share { color: var(--fg-2); }
.dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: currentColor; }

/* таблица */
.table-scroll { max-width: 100%; margin: 4px 0 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; overflow-wrap: break-word; font-size: 13px; line-height: 1.5; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 16px 8px 0; text-align: left; vertical-align: top; font-weight: 400; border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { padding-right: 0; }
thead th { padding-top: 0; color: var(--fg-3); font-size: 11px; border-bottom-color: var(--line-2); white-space: nowrap; }
tbody th { color: var(--fg-2); }
.num { text-align: right; }

/* схемы и графики (inline SVG) */
.diagram { margin: 6px 0 18px; overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 520px; max-width: 760px; height: auto; }
.diagram text { font-family: var(--font); }
.diagram .box { fill: var(--surface); stroke: var(--line-2); }
.diagram .box.hi { stroke: var(--accent); }
.diagram .edge { stroke: var(--fg-3); stroke-width: 1.2; fill: none; }
.diagram .head { fill: var(--fg-3); }
.diagram .lbl { fill: var(--fg); font-size: 13px; font-weight: 500; }
.diagram .sub { fill: var(--fg-3); font-size: 11px; }
.diagram .grid { stroke: var(--line); stroke-dasharray: 3 5; }
.diagram .axis { fill: var(--fg-3); font-size: 11px; }
.diagram .series-clay { stroke: var(--clay); fill: none; stroke-width: 1.6; }
.diagram .series-ink { stroke: var(--ink); fill: none; stroke-width: 1.6; }
.diagram .dot-clay { fill: var(--clay); stroke: var(--bg); stroke-width: 1.5; }
.diagram .dot-ink { fill: var(--ink); stroke: var(--bg); stroke-width: 1.5; }
.diagram .tag-clay { fill: var(--clay); font-size: 13px; font-weight: 550; }
.diagram .tag-ink { fill: var(--ink); font-size: 13px; font-weight: 550; }
figcaption { margin-top: 8px; color: var(--fg-3); font-size: 11px; }

/* ---------- варианты на выбор ---------- */
.variant { padding: 18px 0 20px; border-top: 1px solid var(--line); }
.variants > legend + .variant { padding-top: 6px; border-top: 0; }
.variant-head { margin-bottom: 12px; }
.variant-head .opt { max-width: none; color: var(--fg); font-size: 16px; font-weight: 500; }
.variant-head .opt-name { flex: 0 1 auto; }
.variant-code { color: var(--accent); font-weight: 550; }
.variant-head p { max-width: 72ch; margin: 2px 0 0 21px; color: var(--fg-2); font-size: 13px; }
.mock { margin: 0 0 14px; padding: 18px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; }
.variant:has(.variant-head input:checked) .mock { border-color: var(--accent); }
.variant .cols h3 { margin-top: 0; }

/* ---------- вопросы к Developer ---------- */
.q { min-width: 0; margin: 0 0 22px; padding: 0; border: 0; }
.q:last-of-type { margin-bottom: 8px; }
.q legend { padding: 0; margin-bottom: 2px; font-size: 13px; font-weight: 550; }
.q .hint { max-width: 72ch; margin: 2px 0 6px; color: var(--fg-2); font-size: 12px; line-height: 1.6; }
.opt { display: flex; align-items: center; gap: 9px; max-width: 560px; min-height: 30px; color: var(--fg-3); font-size: 13px; cursor: pointer; }
@media (hover: hover) { .opt:hover { color: var(--fg-2); } }
.opt:has(input:checked) { color: var(--fg); }
.opt input {
  appearance: none; flex-shrink: 0; display: grid; place-content: center; width: 12px; height: 12px; margin: 0;
  border: 1px solid var(--line-2); border-radius: 3px; cursor: pointer;
}
.opt input[type=radio] { border-radius: 50%; }
.opt input:checked { background: var(--accent); border-color: var(--accent); }
.opt input[type=checkbox]:checked::after {
  content: ""; width: 6px; height: 3px; margin-top: -1px;
  border: solid var(--on-accent); border-width: 0 0 1.5px 1.5px; transform: rotate(-45deg);
}
.opt input[type=radio]:checked::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--on-accent); }
.opt-name { flex: 1; min-width: 0; }
.rec { flex-shrink: 0; color: var(--accent); font-size: 11px; }
.field {
  display: flex; align-items: center; gap: 8px; max-width: 560px; min-height: 32px; margin-top: 4px;
  border-bottom: 1px solid var(--line-2); color: var(--fg-3);
}
.field:focus-within { border-color: var(--accent); }
.field input, .field textarea, .field select {
  flex: 1; min-width: 0; padding: 6px 0; background: none; border: 0; outline: none; color: var(--fg); font-size: 12.5px; resize: vertical;
}
.field input::placeholder, .field textarea::placeholder { color: var(--fg-3); }
.field select { appearance: none; cursor: pointer; }
.field select option { background: var(--surface); color: var(--fg); }
.field:has(select)::after { content: "▾"; color: var(--fg-3); font-size: 11px; pointer-events: none; }
.copy-fallback { width: 100%; min-height: 120px; padding: 8px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; color: var(--fg); font-size: 12px; resize: vertical; }

/* ---------- боковая панель ---------- */
.side-heading { display: flex; align-items: center; gap: 8px; margin-bottom: -6px; }
.side-heading h2 { flex: 1; font-size: 15px; font-weight: 500; }
.side-heading h2 span { margin-left: 6px; color: var(--fg-3); font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; }
.side-heading button { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--fg-3); }
.side-heading button svg { width: 14px; height: 14px; }
.side-section h3 { margin: 0 0 4px; font-size: 12px; font-weight: 550; }
.side-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 12px; }
.side-row span { color: var(--fg-2); }
.side-row:not(.stacked) span { flex-shrink: 0; max-width: 50%; }
.side-row b { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.side-row b.empty { color: var(--fg-3); font-weight: 400; }
.side-row.stacked { flex-direction: column; gap: 2px; }
.side-row.stacked span { font-size: 11px; }
.side-row.stacked b { text-align: left; }
.text-button { color: var(--accent); font-size: 12px; }
.side-actions { display: flex; align-items: center; gap: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-note { margin: 0; color: var(--fg-2); font-size: 12px; line-height: 1.6; }

/* ---------- узкие экраны (как на сайте) ---------- */
@media (width <= 1150px) {
  .app-header { gap: 24px; padding: 0 18px; }
  .brand { font-size: 21px; }
  .view-tabs { gap: 16px; }
  .view-tabs a { font-size: 12px; }
  .doc-head, .doc-section, .doc-footer { padding-left: 18px; padding-right: 18px; }
}
@media (width <= 900px) {
  .app-header { flex-wrap: wrap; gap: 0; height: auto; padding: 0; }
  .brand { display: flex; align-items: center; height: 52px; padding-left: 16px; }
  .header-actions { height: 52px; padding-right: 10px; }
  .view-tabs { order: 3; width: 100%; height: 42px; gap: 20px; padding: 0 16px; border-top: 1px solid var(--line); }
  .view-tabs a { font-size: 13.5px; }
  .body-layout { display: block; min-height: 0; }
  .sidebar { position: static; height: auto; padding: 20px 16px 24px; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .doc-head { padding: 20px 16px 18px; }
  .doc-section { padding: 20px 16px 24px; scroll-margin-top: 104px; }
  .doc-footer { padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }
  .doc-updated { margin-left: 0; width: 100%; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .stats .big strong { font-size: 30px; }
  .opt { min-height: 44px; font-size: 15px; }
  .q legend { font-size: 14px; }
  .variant-head .opt { font-size: 17px; }
  .mock { padding: 14px; }
  .field input, .field textarea, .field select, .copy-fallback { font-size: 16px; }
  .side-heading h2 { font-size: 17px; }
  .side-row, .text-button { font-size: 14px; }
  .text-button { min-height: 32px; }
}
@media print {
  .app-header, .sidebar { display: none; }
  .body-layout { display: block; }
}
