/* Design system v2 — calm, functional, no web fonts. */
:root {
  --bg: #f7f8fa; --surface: #fff; --text: #14161a; --muted: #5d6675; --line: #e3e6eb;
  --accent: #2b62d9; --accent-weak: #e8effc; --good: #117a55; --bad: #c2360c; --warn: #a66300; --on-accent: #fff;
  --r: 12px; --maxw: 1200px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1014; --surface: #161a21; --text: #e7e9ee; --muted: #9aa3b2; --line: #272c36;
    --accent: #6f9bff; --accent-weak: #1b2640; --good: #3ccf91; --bad: #ff7a59; --warn: #f0b35a; --on-accent: #0b0f19; }
}
/* The visitor's own choice (the button in the header, stored as localStorage «theme») wins over the system setting. */
:root[data-theme="light"] { color-scheme: light; --bg: #f7f8fa; --surface: #fff; --text: #14161a; --muted: #5d6675; --line: #e3e6eb;
  --accent: #2b62d9; --accent-weak: #e8effc; --good: #117a55; --bad: #c2360c; --warn: #a66300; --on-accent: #fff; }
:root[data-theme="dark"] { color-scheme: dark; --bg: #0e1014; --surface: #161a21; --text: #e7e9ee; --muted: #9aa3b2; --line: #272c36;
  --accent: #6f9bff; --accent-weak: #1b2640; --good: #3ccf91; --bad: #ff7a59; --warn: #f0b35a; --on-accent: #0b0f19; }
* { box-sizing: border-box; }
/* `hidden` always hides: a class with its own display (.field { display: grid }, .btn) used to override it — the
   simulator showed the isolated margin field in cross, «Перевірка угоди» its hidden button (audit B-006, 27.11.2026) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.62 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* «Перейти до змісту»: hidden above the page until a keyboard user tabs to it (tools/apply_footer.py skip_link) */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 8px;
  background: var(--surface, #fff); color: var(--text, #14161a); border: 2px solid var(--accent, #2b62d9); font-weight: 600;
  text-decoration: none; }
.skip-link:focus { top: 12px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s4); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 20px; }

/* Header */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-head .wrap { display: flex; align-items: center; gap: var(--s5); height: 60px; }
.logo { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.logo-mark { width: 26px; height: 26px; background: url(/favicon.svg) center / contain no-repeat; flex: none; }
.nav { display: flex; gap: var(--s4); margin-left: auto; }
.nav a { color: var(--text); text-decoration: none; font-size: 15px; padding: 6px 2px; }
.nav a:hover, .nav a[aria-current] { color: var(--accent); }
.search { width: 280px; font: inherit; font-size: 14px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); }
/* The same page in the other language (the build adds it only where both versions exist): a link, never a redirect. */
.site-head .lang { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-decoration: none; padding: 5px 10px; min-height: 24px; border: 1px solid var(--line); border-radius: 999px; }
.site-head .lang:hover { color: var(--accent); border-color: var(--accent); }
/* Two versions of the site (decision 27.11.2026): computer — window from 1024 px, phone and tablet — narrower.
   Phone and tablet: the menu becomes a second, sideways-scrolling row; the header scrolls away with the page
   (two sticky rows would take too much of a small screen). search.js shows the search field next to the logo.
   The full header needs 877 px (Ukrainian) and 907 px (Russian): with the old 760 px switch it was wider than the
   window from 761 to ~910 px. */
@media (max-width: 1023px) {
  .site-head { position: static; }
  .site-head .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 4px; gap: 6px var(--s4); }
  .nav { order: 3; width: 100%; margin-left: 0; gap: var(--s3); justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  /* more items past the right edge: fade it, so the row reads as scrollable (search.js sets .more; audits 27.11.2026) */
  .nav.more { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .nav a { white-space: nowrap; padding: 8px 0; }
  .search { display: none; }
  /* the language switch shares the menu row (the first row — logo, search, theme — is full), at its right end */
  .site-head .lang { order: 4; margin-left: auto; }
  .site-head .wrap:has(> .lang) .nav { width: calc(100% - 64px); }
}

/* Type */
h1 { font-size: 32px; line-height: 40px; margin: 0 0 var(--s3); letter-spacing: -0.01em; }
h2 { font-size: 22px; line-height: 30px; margin: 0 0 var(--s3); }
h3 { font-size: 18px; line-height: 26px; margin: 0 0 var(--s2); }
@media (max-width: 760px) { h1 { font-size: 26px; line-height: 32px; } }
.lead { font-size: 18px; line-height: 28px; color: var(--muted); margin: 0 0 var(--s5); max-width: 720px; }
section { padding: var(--s7) 0; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }

/* Breadcrumbs */
.crumbs { font-size: 13px; color: var(--muted); padding: var(--s4) 0 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); }
.grid { display: grid; gap: var(--s4); }
/* min(N, 100%): on a 320 px phone the content is 288 px — one full-width column instead of a sideways scroll */
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.g3w { grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); } /* five groups lay out 3 + 2, not 4 + 1 */
.tile { display: block; text-decoration: none; color: var(--text); transition: border-color .15s; }
.tile:hover { border-color: var(--accent); }
.tile .tag { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.tile p { margin: var(--s2) 0 0; color: var(--muted); font-size: 15px; }
.tile[aria-disabled="true"] { opacity: .6; cursor: default; }
.tile[aria-disabled="true"]:hover { border-color: var(--line); }
.tile .new { font-size: 11px; background: var(--accent-weak); color: var(--accent); padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; }

/* Entry cards (hero) */
.entry { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s5); border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--text); min-height: 150px; }
.entry:hover { border-color: var(--accent); }
.entry .q { font-size: 20px; font-weight: 700; }
.entry .a { color: var(--muted); }
.entry .go { margin-top: auto; color: var(--accent); font-weight: 600; }

/* Forms */
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select { font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-height: 44px; width: 100%; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fields { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.seg { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--muted); padding: 9px 16px; cursor: pointer; min-height: 44px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent, #fff); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 15px; font-weight: 600; border-radius: 8px; padding: 10px 18px; min-height: 44px; cursor: pointer; text-decoration: none; border: 1px solid transparent; }
/* --on-accent: white on the light theme's dark fills, near-black on the dark theme's light ones (contrast ≥ 4.5:1) */
.btn-primary { background: var(--accent); color: var(--on-accent, #fff); }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--line); }
.btn:hover { filter: brightness(1.05); }

/* Results */
.kpis { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi.big .v { font-size: 34px; }
.pos { color: var(--good); } .neg { color: var(--bad); } .warn { color: var(--warn); }
.say { background: var(--accent-weak); border-radius: 10px; padding: var(--s3) var(--s4); margin-top: var(--s4); font-size: 15px; min-height: 3.4em; }
.say b { font-variant-numeric: tabular-nums; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
/* Tables of words (comparisons, rules): cells wrap, so the table fits the column instead of scrolling sideways */
table.txt { width: 100%; }
table.txt th, table.txt td { white-space: normal; text-align: left; vertical-align: top; }
table.txt td:first-child { font-weight: 600; width: 26%; }
@media (max-width: 480px) { table.txt th, table.txt td { padding: 6px 5px; overflow-wrap: anywhere; } }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
.row-best td { background: var(--accent-weak); font-weight: 600; }
.scroll { overflow-x: auto; }

/* Article */
.article { max-width: 760px; }
/* Article pages (tools/toc_blocks.py puts them in .art-row with the contents beside them). Phone and tablet: one
   column of 16 px text, ≤ 560 px (≈ 70 characters a line); computer: 610 px of 18 px text (≈ 68) and the contents
   on the right, held below the sticky header (60 px). Characters measured 27.11.2026 (tools/width_demo.py). */
.toc { display: none; }
/* !important: eight articles widen their own column in a style attribute (860–900 px, for wide tables) — in the
   two versions the reading width wins, wide tables scroll inside their frames */
.art-row > .article { max-width: 560px !important; }
@media (min-width: 1024px) {
  .art-row { display: flex; gap: var(--s7); align-items: flex-start; }
  .art-row > .article { flex: 0 0 610px; max-width: 610px !important; min-width: 0; }
  :where(.art-row > .article) :is(p, li) { font-size: 18px; line-height: 1.6; }
  .toc { display: block; flex: 0 1 300px; min-width: 0; position: sticky; top: 80px; max-height: calc(100vh - 96px);
    overflow-y: auto; margin-top: 20px; border-left: 1px solid var(--line); padding-left: 20px; font-size: 14px;
    line-height: 1.5; }
  .toc-h { margin: 0 0 var(--s2); font-weight: 600; }
  .toc ol { margin: 0; padding-left: 18px; }
  .toc li { margin: 4px 0; }
  /* bar charts are ≥ 720 px wide (they scroll on a phone); in the 610 px column they fit it instead */
  .art-row .bars { min-width: 0; }
}
.article h2 { margin-top: var(--s6); }
.article p, .article li { color: var(--text); }
.formula { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: var(--s3) var(--s4); overflow-x: auto; font-size: 14px; }
.limits { border-left: 3px solid var(--warn); padding: var(--s2) var(--s4); background: var(--surface); border-radius: 0 8px 8px 0; }
details { border-bottom: 1px solid var(--line); padding: var(--s3) 0; }
summary { cursor: pointer; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: var(--s4); margin-top: var(--s6); }

/* Trust strip */
.trust { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.trust .t { font-weight: 700; margin-bottom: 4px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Sticky result (tool pages) */
.sticky-sum { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px; z-index: 5; }
.sticky-sum .wrap { display: flex; gap: var(--s5); flex-wrap: wrap; }

/* Footer */
.site-foot { border-top: 1px solid var(--line); background: var(--surface); padding: var(--s6) 0; margin-top: var(--s7); font-size: 14px; }
.site-foot .cols { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.site-foot a { color: var(--muted); text-decoration: none; display: block; padding: 3px 0; }
.site-foot a:hover { color: var(--accent); }
.disclaimer { margin-top: var(--s5); color: var(--muted); font-size: 13px; }

/* Charts (shared SVG chart module) */
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; user-select: none; }
.chart .grid { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .line.good { stroke: var(--good); } .chart .line.bad { stroke: var(--bad); }
.chart .line.muted { stroke: var(--muted); stroke-width: 1.5; opacity: .7; }
.chart .ref { stroke: var(--muted); stroke-dasharray: 3 4; }
.chart .handle .hit { fill: transparent; cursor: grab; }
.chart .handle .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.chart .handle .hline { stroke: var(--accent); opacity: .35; }
/* Chart text — one system for every SVG chart on the site (chart.js, linechart.js, ladders, bars, funding):
   the site font with equal-width digits, 12 px ticks and labels, 13 px point labels. Text never takes a line
   stroke: classes such as «ref» style the dashed line AND are set on its label — without «stroke: none» the
   letters got a dashed outline. */
:is(.chart, .bars, .fchart, .ladder) { font-family: inherit; font-variant-numeric: tabular-nums; }
:is(.chart, .bars, .fchart, .ladder) text { font-family: inherit; letter-spacing: 0; }
/* !important: a vertical line and its label share the colour class (e.g. «lbl ref now»), and page rules like
   «.chart .ref.now { stroke: … }» are more specific — they outlined the letters. Halo labels (hlabel, note) keep a stroke. */
.chart text:is(.lbl, .tick, .slabel), .bars text, .fchart text { stroke: none !important; }
:is(.chart, .fchart) text:is(.tick, .lbl), .fchart text { fill: var(--muted); font-size: 12px; font-weight: 400; }
.chart text.lbl { font-weight: 500; }
.chart text.lbl.now { fill: var(--accent); }
.chart text.lbl:is(.liq, .bad, .zero) { fill: var(--bad); }
.chart text.lbl:is(.good, .kelly) { fill: var(--good); }
.chart text.lbl.peak { fill: var(--warn); }
.chart text.slabel { fill: var(--accent); font-size: 12px; font-weight: 600; }
.chart text.slabel.good { fill: var(--good); } .chart text.slabel.bad { fill: var(--bad); } .chart text.slabel.muted { fill: var(--muted); font-weight: 500; }
.chart text:is(.hlabel, .note) { font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart text.hlabel { fill: var(--text); font-size: 13px; }
.chart text.note { fill: var(--muted); font-size: 12px; } .chart text.note.bad { fill: var(--bad); }
/* bars: the SVG is drawn in a 720-unit box; it never gets narrower than that (on a phone it scrolls inside its
   container), so 12 units are 12 px on a phone and 12–14 px in a wider desktop column */
.bars { width: 100%; min-width: 720px; height: auto; display: block; }
.bars text:is(.tick, .lbl) { fill: var(--muted); font-size: 12px; }
.bars text.val { fill: var(--text); font-size: 12px; font-weight: 600; }
.bars .grid { stroke: var(--line); }
/* Several lines on one time axis (src/ui/linechart.js); the colour of a line comes from its series */
.lchart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lchart .zero { stroke: var(--muted); }
.lchart .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.lchart .dot { stroke: var(--surface); stroke-width: 2; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Anchored headings clear the sticky header */
[id] { scroll-margin-top: 80px; }

.chip.soon { opacity: .55; cursor: default; }
.chip.soon:hover { border-color: var(--line); color: var(--text); }
.soon-link { display: block; color: var(--muted); padding: 3px 0; opacity: .7; }

/* Home: the beginner's route and compact lists of tools by task */
.route { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.route li a { font-weight: 600; }
.route li span { color: var(--muted); }
.route li span::before { content: " — "; }
.glist { list-style: none; margin: 8px 0 0; padding: 0; }
.glist li { padding: 8px 0; border-top: 1px solid var(--line); }
.glist li a { font-weight: 600; text-decoration: none; }
.glist li a:hover { text-decoration: underline; }
.glist li span { display: block; color: var(--muted); font-size: 14px; line-height: 20px; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }

/* Glossary hub: terms explained inside guide chapters */
.terms { margin: 0; display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 0 20px; }
.terms dt { font-weight: 600; padding: 10px 0; border-top: 1px solid var(--line); }
.terms dd { margin: 0; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); }
@media (max-width: 640px) { .terms { grid-template-columns: 1fr; } .terms dd { border-top: 0; padding-top: 0; } }

/* «In this series» line under the intro of pages that belong to one cluster */
.series { font-size: 14px; line-height: 22px; color: var(--muted); margin: -4px 0 18px; }
.series b { color: var(--text); font-weight: 600; }

/* «Карта сайту»: plain lists of links in columns */
.sitemap { columns: 2 300px; column-gap: 32px; margin: 0 0 8px; padding-left: 18px; }
.sitemap li { break-inside: avoid; padding: 3px 0; }

/* Phones (mobile check 20.10.2026). Every field at 16 px: iOS Safari zooms the page into a field with a smaller font
   on focus and leaves it zoomed. Text-like buttons get a 24 px tall target. Result tiles go two to a row — one per
   row made the results longer than a screen. */
@media (max-width: 760px) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=button]):not([type=submit]), select, textarea { font-size: 16px !important; }
  .linklike, .live { min-height: 24px; }
}
@media (max-width: 480px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
