/* Knowledge site (rendered from the text bucket) in the style of the new SOZD UI (sozd_web/frontend theme.ts, MUI):
   Roboto 13-15px, primary #1565c0 / #90caf9, secondary #2e7d32 / #81c784, backgrounds #fafafa/#ffffff and #121212/#1e1e1e,
   radius 8, dense tables (6px 10px), an app bar in the MUI "default" colour with elevation 1. */
:root, [data-theme="dark"] {
  --bg: #121212; --s1: #1e1e1e; --s2: #272727; --line: #3a3a3a; --row: #242424;
  --tx: #ffffff; --mu: #b3b3b3; --dim: #8c8c8c; --ac: #90caf9; --ac-bg: #1a2733; --ac-line: #2f4f6f; --link: #90caf9; --ext: #81c784;
  --bar: #272727; --shadow: 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 1px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.12);
  --r: 8px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #fafafa; --s1: #ffffff; --s2: #f5f5f5; --line: #e0e0e0; --row: #f0f0f0;
  --tx: rgba(0,0,0,.87); --mu: rgba(0,0,0,.6); --dim: rgba(0,0,0,.45); --ac: #1565c0; --ac-bg: #e3f2fd; --ac-line: #90caf9; --link: #1565c0; --ext: #2e7d32;
  --bar: #f5f5f5;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.6 Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--tx); text-decoration: none; border-bottom: 1px solid var(--dim); }
a:hover { color: var(--ac); border-bottom-color: var(--ac); }
.top { display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 24px; background: var(--bar); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; border: 0; font-size: 18px; font-weight: 500; color: var(--ac); }
.brand .tld { color: var(--mu); }
.brand .kb { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--mu); margin-left: 4px; cursor: default; }
.search { margin-left: auto; }
.search input { width: 260px; background: var(--bg); color: var(--tx); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; font: inherit; }
.search input:focus { outline: none; border-color: var(--mu); }
.langs { display: flex; gap: 8px; align-items: center; }
.langs a, .theme-btn { border: 1px solid var(--line); border-radius: var(--r); padding: 3px 8px; font-size: 12px; color: var(--mu); background: transparent; cursor: pointer; line-height: 18px; font-family: inherit; }
.theme-btn:hover, .langs a:hover { color: var(--tx); border-color: var(--mu); }
.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--bar); border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 9; overflow-x: auto; }
.tabs a { border: 0; padding: 10px 12px; color: var(--mu); font-weight: 500; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.on, .tabs a:hover { color: var(--tx); border-bottom-color: var(--ac); }
.wrap { display: flex; gap: 32px; max-width: 1400px; margin: 0 auto; padding: 24px; }
.side { flex: 0 0 250px; font-size: 14px; position: sticky; top: 120px; align-self: flex-start; max-height: calc(100vh - 140px); overflow: auto; }
.side ul { list-style: none; margin: 0; padding-left: 12px; }
.side > ul { padding-left: 0; }
.side li { margin: 3px 0; }
.side a { border: 0; color: var(--mu); }
.side a.on { color: var(--ac); background: var(--ac-bg); border-radius: 4px; padding: 1px 6px; margin-left: -6px; }
.side a:hover { color: var(--tx); }
.side summary { cursor: pointer; color: var(--mu); }
.side li:not(:has(> details)) { position: relative; padding-left: 14px; }
.side li:not(:has(> details))::before { content: "•"; position: absolute; left: 2px; top: 0; color: var(--mu); }
.side li:has(> a.on)::before { color: var(--ac); }
.content { flex: 1 1 auto; min-width: 0; max-width: 860px; position: relative; }
/* "On this page": the title stays, only the list scrolls; the heading in view is lit like the current page on the left */
.toc-side { flex: 0 0 220px; font-size: 13px; position: sticky; top: 120px; align-self: flex-start; max-height: calc(100vh - 140px); display: flex; flex-direction: column; }
.toc-list { overflow: auto; min-height: 0; }
.toc-list ul { list-style: none; padding-left: 10px; margin: 0; }
.toc-list .toc > ul { padding-left: 0; }
.toc-list li { margin: 2px 0; }
.toc-side a { border: 0; color: var(--mu); }
.toc-side a.on { color: var(--ac); }
.toc-side a:hover { color: var(--tx); }
.toch { color: var(--dim); text-transform: uppercase; letter-spacing: .4px; font-size: 11px; margin-bottom: 6px; flex: none; }
/* A jump to a heading leaves it just below the sticky header and tabs, not under them */
.doc :is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: calc(112px + var(--head-h, 0px)); }
/* The page title and the editor buttons stay pinned under the tabs while the text scrolls */
.page-head { position: sticky; top: 103px; z-index: 6; background: var(--bg); display: flex; align-items: flex-start; gap: 10px; padding: 10px 0 8px; margin: -10px 0 8px; }
.page-head .page-title { flex: 1 1 auto; min-width: 0; }
.page-head .page-title h1 { margin: 0; }
.page-head .page-tools { position: static; flex: none; margin-top: 6px; }
.page-head .back-close { position: static; flex: none; margin-top: 4px; }
/* Thin scrollbars, as on Three Readings: semi-transparent grey that suits both themes */
* { scrollbar-width: thin; scrollbar-color: rgba(128, 128, 128, .55) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, .55); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
.doc h1, .content > h1 { font-weight: 400; font-size: 30px; line-height: 1.25; margin: 0 0 16px; }
.doc h2 { font-weight: 500; font-size: 22px; margin: 32px 0 10px; }
.doc h3 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
.doc .headerlink { border: 0; color: var(--dim); margin-left: 6px; opacity: 0; font-size: .8em; }
.doc h2:hover .headerlink, .doc h3:hover .headerlink { opacity: 1; }
.doc table { border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--s1); margin: 12px 0; font-size: 14px; display: block; overflow-x: auto; }
.doc th, .doc td { border: 0; border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--s2); font-weight: 500; }
.doc tr:last-child > td { border-bottom: 0; }
.doc tbody tr:hover > td { background: var(--row); }
.doc code { font-family: "JetBrains Mono", monospace; font-size: .88em; background: var(--s1); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.doc pre { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow-x: auto; }
.doc pre code { border: 0; padding: 0; background: none; }
.doc pre.mermaid { background: transparent; border: 0; }
.doc img { max-width: 100%; }
.doc blockquote { border-left: 3px solid var(--line); margin: 12px 0; padding: 2px 14px; color: var(--mu); }
.doc .admonition, .doc details { border: 1px solid var(--line); border-left: 3px solid var(--ac); border-radius: var(--r); background: var(--s1); padding: 8px 14px; margin: 14px 0; }
.doc .admonition-title, .doc details > summary { font-weight: 600; margin: 0 0 4px; cursor: pointer; }
.doc .tabbed-set { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; margin: 12px 0; display: flex; flex-wrap: wrap; }
.doc .tabbed-set > input { display: none; }
.doc .tabbed-labels { display: flex; gap: 12px; width: 100%; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.doc .tabbed-labels label { cursor: pointer; color: var(--mu); padding: 4px 0; }
.doc .tabbed-content { width: 100%; }
.doc .tabbed-block { display: none; }
.doc .tabbed-set > input:nth-child(1):checked ~ .tabbed-content > .tabbed-block:nth-child(1),
.doc .tabbed-set > input:nth-child(2):checked ~ .tabbed-content > .tabbed-block:nth-child(2),
.doc .tabbed-set > input:nth-child(3):checked ~ .tabbed-content > .tabbed-block:nth-child(3),
.doc .tabbed-set > input:nth-child(4):checked ~ .tabbed-content > .tabbed-block:nth-child(4) { display: block; }
.badge { display: inline-block; background: var(--ac-bg); color: var(--ac); border: 1px solid var(--ac-line); border-radius: var(--r); padding: 3px 10px; font-size: 13px; margin-bottom: 12px; }
.note { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px; color: var(--mu); font-size: 13px; margin-bottom: 12px; }
/* Editor buttons in the top-right corner of a page: «Picture» and «Edit» */
.page-tools { display: flex; gap: 6px; }
.edit { font-size: 13px; color: var(--mu); border: 1px solid var(--line); border-radius: var(--r); padding: 3px 10px; background: transparent; cursor: pointer; font-family: inherit; line-height: 1.6; }
/* "Updated" and the change history stay pinned to the bottom of the window while the text scrolls; an open history scrolls inside */
.pagefoot { margin-top: 40px; padding: 10px 0 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--mu); position: sticky; bottom: 0; background: var(--bg); z-index: 4; }
.pagefoot .hist { max-height: 30vh; overflow: auto; margin: 6px 0 0; }
.pagefoot summary { cursor: pointer; margin-top: 6px; }
.hist { list-style: none; padding: 0; }
.hist .d { color: var(--dim); font-variant-numeric: tabular-nums; }
.hist .v { color: var(--ac); }
.hit { margin: 14px 0; }
.muted { color: var(--mu); font-size: 13px; }
@media (max-width: 1100px) { .toc-side { display: none; } }
@media (max-width: 780px) { .side { display: none; } .search input { width: 140px; } .wrap { padding: 16px; } }

/* Mermaid diagrams follow the theme through their own colors; images with transparent dark art keep a backdrop */
[data-theme="light"] .doc img[src*="/assets/brand/"] { background: #121212; border-radius: var(--r); padding: 4px; }

/* Site version with its date, bottom-left corner */
.site-version { position: fixed; left: 12px; bottom: 8px; font-size: 11px; color: var(--dim); background: var(--bg); padding: 2px 6px; border-radius: 4px; z-index: 5; font-variant-numeric: tabular-nums; }

/* Links that open another page (in a page text and in search results): blue, not underlined */
.doc a, .hit a { color: var(--link); border-bottom: 0; }
.doc a:hover, .hit a:hover { color: var(--link); filter: brightness(1.25); }
/* Links to other sites (opened in a new tab): green, so they are told apart from pages of this site */
.doc a[target="_blank"], .doc a[target="_blank"]:hover { color: var(--ext); }
/* ✕ in the top-right corner of a page opened from another page: back to that place */
.back-close { position: absolute; right: 0; top: 0; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--mu); font-size: 15px; line-height: 1; cursor: pointer; z-index: 3; }
.back-close:hover { color: var(--tx); border-color: var(--mu); }
.content.has-back > h1 { padding-right: 50px; }

/* Pictures: numbered figures in the text, their list at the bottom of «On this page», viewing over the page */
figure.pic { margin: 20px 0; }
figure.pic img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); cursor: zoom-in; display: block; }
figure.pic figcaption { margin-top: 6px; font-size: 13px; color: var(--mu); }
.pics-h { margin-top: 14px; }
.toc-list ul.pics { padding-left: 0; }
.pic-view { position: fixed; inset: 0; background: rgba(0, 0, 0, .82); backdrop-filter: blur(4px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.pic-view[hidden] { display: none; }
.pic-box { position: relative; background: var(--s1); border: 1px solid var(--line); border-radius: 10px; padding: 44px 16px 14px; max-width: 94vw; max-height: 92vh; display: flex; flex-direction: column; gap: 8px; }
.pic-box > img { max-width: calc(94vw - 34px); max-height: calc(92vh - 110px); object-fit: contain; align-self: center; }
.pic-cap { color: var(--mu); font-size: 14px; }
.pic-x { top: 8px; right: 8px; }
.pic-form { width: 560px; padding-top: 16px; }
.pic-form > img { max-height: 40vh; max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); align-self: flex-start; }
.pic-title { font-size: 19px; font-weight: 500; }
.pic-paste { border: 1px dashed var(--line); border-radius: var(--r); padding: 28px; text-align: center; color: var(--mu); }
.pic-paste[hidden], .pic-form > img[hidden] { display: none; }
.pic-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mu); }
.pic-form input { background: var(--bg); color: var(--tx); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; font: inherit; }
.pic-form input:focus { outline: none; border-color: var(--mu); }
.pic-err { min-height: 18px; font-size: 13px; color: var(--ac); }
.pic-btns { display: flex; justify-content: flex-end; gap: 8px; }
.pic-save { color: var(--ac); border-color: var(--ac-line); }
.muted { color: var(--dim); }
/* The viewer is drawn in the opposite theme (data-theme set by the script), so the picture stands out from the page */
.pic-view .pic-box { color: var(--tx); }
.pic-foot { display: flex; align-items: center; gap: 12px; }
.pic-foot .pic-cap { flex: 1; }
.pic-ask { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 8px 10px; border: 1px solid var(--ac-line); background: var(--ac-bg); border-radius: var(--r); }
.pic-ask[hidden] { display: none; }
.pic-ask span { flex: 1; }
.pic-del:hover, .pic-del-yes { color: #D9534F; border-color: #D9534F; }
/* The page behind the viewer is dimmed and blurred (on the dark site a plain dim left the text readable and noisy);
   the light card on the dark site gets a soft glow, and no empty error line under the caption */
html:not([data-theme="light"]) .pic-view .pic-box { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 18px 60px rgba(0, 0, 0, .7); }
html[data-theme="light"] .pic-view .pic-box { box-shadow: 0 18px 60px rgba(0, 0, 0, .45); }
.pic-view .pic-err:empty { display: none; }
/* Header: «Sign in with Google» (only where there is no IAP, i.e. the local site) or the signed-in e-mail */
.login-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r); padding: 3px 10px; font-size: 12px; color: var(--mu); line-height: 18px; background: transparent; }
.login-btn:hover, .langs a.login-btn:hover { border-color: var(--mu); color: var(--tx); }
.who { font-size: 12px; color: var(--mu); cursor: default; }
/* Side list for the team: «Разрешить всем» (🔒 team only / 🌐 everyone) and «Удалить» next to every document */
.side li { position: relative; }
.doc-tools { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: 1px; }
.doc-tools button { border: 0; background: transparent; padding: 0 2px; font-size: 11px; line-height: 1; cursor: pointer; opacity: .35; filter: grayscale(1); }
.side li:hover > .doc-tools button, .side summary:hover .doc-tools button, .doc-tools button.on { opacity: 1; filter: none; }
.doc-tools button:hover { opacity: 1; filter: none; transform: scale(1.15); }
/* «＋ Add file» at the top of the left list (the team) and its form */
.add-doc { display: block; margin: 0; }
.pic-form select { background: var(--bg); color: var(--tx); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; font: inherit; }
.pic-form input[type="file"] { padding: 4px; }
/* On the light site the dim is softer and without blur: the page behind stays recognisable */
html[data-theme="light"] .pic-view { background: rgba(0, 0, 0, .45); backdrop-filter: none; }
/* The viewer's bottom row (caption, Copy, Delete) is a bar of its own, so it is not taken for part of the picture;
   the picture gets a thin frame */
.pic-view .pic-box > img { border: 1px solid var(--line); border-radius: var(--r); }
.pic-view .pic-foot { background: var(--s2); border-top: 1px solid var(--line); margin: 6px -16px -14px; padding: 10px 16px; border-radius: 0 0 10px 10px; }
.pic-view[data-theme="dark"] .pic-foot { background: #1E1E1E; }
.pic-view[data-theme="light"] .pic-foot { background: #f5f5f5; }
/* On the dark site the dim is moderate with a light blur (82 % made the page behind black) */
html:not([data-theme="light"]) .pic-view { background: rgba(0, 0, 0, .62); backdrop-filter: blur(2px); }
/* The viewer card: no empty band above the picture - the ✕ sits on the card's corner; no blur behind it (the
   blurred page looked smeared), only the dim */
.pic-view > .pic-box:not(.pic-form) { padding-top: 16px; }
.pic-view .pic-x { position: absolute; top: -14px; right: -14px; width: 30px; height: 30px; border-radius: 50%; background: var(--s1); box-shadow: 0 2px 8px rgba(0, 0, 0, .4); z-index: 2; }
html:not([data-theme="light"]) .pic-view { backdrop-filter: none; }
/* Dark site: the same dim as on the light site - 45 %, no blur */
html:not([data-theme="light"]) .pic-view { background: rgba(0, 0, 0, .45); backdrop-filter: none; }
/* Dark site: the backdrop lightens the page instead of darkening it, so the dark card stands out */
html:not([data-theme="light"]) .pic-view { background: rgba(255, 255, 255, .16); backdrop-filter: none; }
/* A link to a page closed to this reader is shown as plain text (no address, nothing to follow) */
.doc .link-closed { color: inherit; }
/* «Home»: back to the portal landing, left of the logo */
.home-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: var(--r); color: var(--mu); margin-right: -6px; }
.home-btn:hover { color: var(--ac); border-color: var(--ac); }


/* splitters between the cards (the gap of 32px is kept: the 14px grip sits in its middle) */
.splitter { flex: 0 0 14px; margin: 0 -23px; cursor: col-resize; position: relative; z-index: 2; align-self: stretch; }
.splitter::after { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; border-radius: 1px; background: var(--line); }
.splitter:hover::after, .splitter.drag::after { background: var(--ac); }
body.dragging { user-select: none; cursor: col-resize; }
.custom-w .content { max-width: none; }
@media (max-width: 1100px) { .splitter-toc { display: none; } }
@media (max-width: 780px) { .splitter-side { display: none; } }

/* the side card: the tool row stays put, only the list under it scrolls */
.side { display: flex; flex-direction: column; overflow: hidden; }
.side-tools { flex: none; display: flex; gap: 6px; align-items: center; padding-bottom: 8px; }
.side-tools .edit { padding: 3px 10px; line-height: 1.4; }
.side-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.side-scroll > ul { padding-left: 0; }
#foldOpen { margin-left: auto; }

/* The page itself does not scroll: header and tabs on top, the cards fill the rest above the version line and
   scroll inside (the list on the left, the text, «On this page»). */
html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }
.top, .tabs { position: static; flex: none; }
.wrap { flex: 1 1 auto; min-height: 0; width: 100%; padding: 16px 24px 34px; }
.side, .toc-side { position: static; top: auto; max-height: none; align-self: stretch; min-height: 0; }
.content { align-self: stretch; overflow: auto; padding-right: 12px; }
.page-head { top: 0; margin: 0 0 8px; padding: 0 0 8px; }
.doc :is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: calc(var(--head-h, 0px) + 8px); }

/* «On this page»: the items carry a bullet like the side list */
.toc-list li { position: relative; padding-left: 12px; }
.toc-list li::before { content: "•"; position: absolute; left: 0; top: 0; color: var(--mu); }
.toc-list li:has(> a.on)::before { color: var(--ac); }
