:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --border: #dde1e7; --text: #1b2230; --muted: #5f6b7c;
  --accent: #2563eb; --accent-soft: #e8efff; --link: #1d4ed8; --code-bg: #f3f4f7;
  --ok: #15803d; --ok-bg: #e7f6ec; --acc: #1d4ed8; --acc-bg: #e8efff; --draft: #a16207; --draft-bg: #fdf4dc;
  --closed: #64748b; --closed-bg: #eef1f5; --planned: #7c3aed; --planned-bg: #f1eafe; --down: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --surface: #161b23; --surface-2: #1c222c; --border: #2b3340; --text: #e3e8ef; --muted: #9aa5b4;
    --accent: #5b8def; --accent-soft: #1b2740; --link: #8db1ff; --code-bg: #1c222c;
    --ok: #4ade80; --ok-bg: #12301f; --acc: #8db1ff; --acc-bg: #1b2740; --draft: #f2c14e; --draft-bg: #33290f;
    --closed: #9aa5b4; --closed-bg: #222a35; --planned: #c4a5ff; --planned-bg: #2a2140; --down: #f97066;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --surface: #161b23; --surface-2: #1c222c; --border: #2b3340; --text: #e3e8ef; --muted: #9aa5b4;
  --accent: #5b8def; --accent-soft: #1b2740; --link: #8db1ff; --code-bg: #1c222c;
  --ok: #4ade80; --ok-bg: #12301f; --acc: #8db1ff; --acc-bg: #1b2740; --draft: #f2c14e; --draft-bg: #33290f;
  --closed: #9aa5b4; --closed-bg: #222a35; --planned: #c4a5ff; --planned-bg: #2a2140; --down: #f97066;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 0.88em/1.4 ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
.muted { color: var(--muted); }

/* Шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.top-nav { display: flex; gap: 18px; margin-left: auto; }
.top-nav a { color: var(--muted); font-weight: 500; }
.menu { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 18px; padding: 2px 10px; cursor: pointer; }

/* Лендінг */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.hero { padding: 48px 0 16px; }
.hero h1 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; letter-spacing: -0.01em; }
.lead { font-size: 17px; color: var(--muted); max-width: 720px; margin: 0; }
section { margin: 36px 0; }
section h2 { font-size: 20px; margin: 0 0 14px; }
section h2 a { color: inherit; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.card.feature { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.card h3 { margin: 10px 0 6px; font-size: 18px; }
.card p { margin: 0 0 14px; color: var(--muted); }
.card .actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.btn { display: inline-block; padding: 6px 14px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 550; font-size: 14px; border: 1px solid var(--accent); }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--link); border-color: var(--border); }
.btn.ghost:hover { background: var(--accent-soft); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.doc { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.doc:hover { border-color: var(--accent); text-decoration: none; }
.doc span { color: var(--muted); font-size: 14px; }
.cmd { background: var(--code-bg); border-radius: 8px; padding: 10px 14px; margin: 0 0 10px; overflow-x: auto; }
.cmd code { background: none; padding: 0; }
.foot { padding-top: 24px; padding-bottom: 40px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.down { background: var(--down); opacity: 0.8; }

.registry { width: 100%; }
.registry td.rid { white-space: nowrap; }
.registry tr.closed td { color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.accepted { color: var(--acc); background: var(--acc-bg); }
.badge.draft { color: var(--draft); background: var(--draft-bg); }
.badge.closed { color: var(--closed); background: var(--closed-bg); }
.badge.planned { color: var(--planned); background: var(--planned-bg); }

/* Таблиці */
.table-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* Сторінки документів */
.shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); max-width: 1500px; margin: 0 auto; }
.shell.has-toc { grid-template-columns: 270px minmax(0, 1fr) 240px; }
.side { position: sticky; top: 52px; align-self: start; height: calc(100vh - 52px); overflow-y: auto; padding: 16px 12px 40px 20px; border-right: 1px solid var(--border); font-size: 14px; }
.side summary { cursor: pointer; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 0 4px; }
.side ul { list-style: none; margin: 0 0 8px; padding: 0; }
.side li a { display: flex; align-items: baseline; gap: 6px; padding: 4px 8px; border-radius: 6px; color: var(--text); line-height: 1.35; }
.side li a .dot { align-self: center; }
.side li a:hover { background: var(--surface-2); text-decoration: none; }
.side li a[aria-current] { background: var(--accent-soft); color: var(--link); font-weight: 550; }
.rid { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); white-space: nowrap; }
.content { min-width: 0; padding: 20px 40px 60px; }
.content > * { max-width: 860px; }
.content.wide > * { max-width: none; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.toc { position: sticky; top: 52px; align-self: start; max-height: calc(100vh - 52px); overflow-y: auto; padding: 20px 16px; font-size: 13px; }
.toc-h { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 10px; color: var(--muted); line-height: 1.35; }
.toc li.d3 a { padding-left: 22px; font-size: 12.5px; }
.toc li a:hover { color: var(--link); text-decoration: none; }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin: 4px 0 20px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; }
.banner > div { flex: 1; min-width: 0; }

.md { overflow-wrap: break-word; }
.md h1 { font-size: 28px; line-height: 1.25; margin: 8px 0 16px; }
.md h2 { font-size: 21px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 17px; margin: 26px 0 8px; }
.md h4 { font-size: 15px; margin: 20px 0 6px; }
.md h1, .md h2, .md h3, .md h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; color: var(--muted); opacity: 0; font-weight: 400; }
.md :is(h1, h2, h3, h4):hover .anchor { opacity: 1; text-decoration: none; }
.md p, .md ul, .md ol { margin: 0 0 14px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 0 0 14px; padding: 4px 16px; border-left: 3px solid var(--border); color: var(--muted); }
.md pre { background: var(--code-bg); padding: 12px 16px; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md img { max-width: 100%; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
a.xref { text-decoration: underline dotted; text-underline-offset: 3px; }
:target { scroll-margin-top: 64px; }
h2:target, h3:target, h4:target { background: var(--accent-soft); border-radius: 4px; }

.code-title { font-size: 22px; margin: 4px 0; }
pre.code { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 0; overflow-x: auto; font: 13px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; }
pre.code code { background: none; padding: 0; white-space: pre; }
.ln { display: inline-block; width: 3.5em; padding-right: 1em; margin-right: 0.75em; text-align: right; color: var(--muted); border-right: 1px solid var(--border); user-select: none; }
.files { margin: 24px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; }
.files summary { cursor: pointer; font-weight: 600; }
.files ul { columns: 2 220px; list-style: none; padding: 0; margin: 10px 0 0; font-size: 14px; }
.src { margin-top: 48px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* Сторінка стенда */
.stand input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.stand input:disabled { background: var(--surface-2); color: var(--muted); }
.stand input.num { width: 6.5em; }
.stand input.db { width: 9em; }
.stand .registry td { vertical-align: middle; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin: 4px 16px 4px 0; }
.fld { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; font-size: 13px; color: var(--muted); max-width: 420px; }
.fld input { font-size: 15px; }
.pg { margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pg legend { padding: 0 6px; font-weight: 600; }
.pg .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; }
.pg p { margin: 8px 0 0; }
.save { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 20px 0; padding: 14px 16px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); }
.save .fld { margin: 0; }
.save p { flex-basis: 100%; margin: 0; }
button.btn { font-family: inherit; cursor: pointer; }
.note { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--border); }
.note.ok { background: var(--ok-bg); border-left-color: var(--ok); }
.note.err { background: var(--closed-bg); border-left-color: var(--down); color: var(--down); }
pre.cmd { background: var(--code-bg); padding: 12px 16px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
pre.cmd code { background: none; padding: 0; }

@media (max-width: 1200px) {
  .shell.has-toc { grid-template-columns: 250px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .top .brand { font-size: 0; gap: 0; }
  .top .tabs { margin-left: 8px; }
  .tabs a { padding: 0 8px; font-size: 14px; }
  .top .settings { display: none; }
  .menu { display: block; }
  .shell, .shell.has-toc { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 16px; }
  .nav-open .side { display: block; }
  .content { padding: 16px 16px 48px; }
  .wrap { padding: 0 16px; }
  .hero { padding-top: 28px; }
  .hero h1 { font-size: 27px; }
  .top { padding: 0 16px; }
  .top-nav { gap: 12px; font-size: 14px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .banner { flex-wrap: wrap; }
}

/* Вкладки головної — у шапці */
.top .tabs { display: flex; align-self: stretch; gap: 2px; margin-left: 24px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 550; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current] { color: var(--link); border-bottom-color: var(--accent); }
.top .settings { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.js .tab:not(.active) { display: none; }
.tab { margin: 20px 0 32px; }
.count.warn { background: var(--draft-bg); color: var(--draft); }
.spec h3 { margin-top: 0; }
.spec h3 a { color: var(--text); }
.meta { margin: 8px 0 0; font-size: 14px; }
.meta summary { cursor: pointer; color: var(--muted); font-weight: 550; }
.meta .chips, .qids { margin: 8px 0 0; }
.qids { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.registry-link { margin-left: auto; align-self: center; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 8px; border: 1px solid var(--border); border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--text); }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.filters button { font: inherit; font-size: 14px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.filters button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--link); }
.research-table td.date { white-space: nowrap; color: var(--muted); }
.research-table tr.hidden { display: none; }
.mats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; }
.mat.code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.small { font-size: 12.5px; margin-top: 4px; }

/* Плашки > [!…] і колонка «Стан» у таблицях; якір рядка таблиці */
blockquote.alert { border-left: 4px solid var(--acc); background: var(--acc-bg); border-radius: 6px; padding: 8px 14px; margin: 12px 0; color: var(--text); }
blockquote.alert p { margin: 4px 0; }
blockquote.alert .alert-t { display: inline-block; margin-right: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
blockquote.alert-ask { border-left-color: var(--draft); background: var(--draft-bg); }
blockquote.alert-unconfirmed { border-left-color: var(--planned); background: var(--planned-bg); }
blockquote.alert-warn { border-left-color: var(--down); background: var(--closed-bg); }
td.st { font-weight: 600; white-space: nowrap; }
td.st-open { color: var(--draft); }
td.st-done { color: var(--ok); }
td.st-unconfirmed { color: var(--planned); }
td.st-off { color: var(--closed); }
tr:target td { background: var(--accent-soft); }
tr:target td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
