/* DailyMine Wiki — публичный сайт. Раскладка в духе GitBook: шапка, дерево слева, текст по центру, оглавление справа. */

:root {
  --font: 'Geologica Variable', 'Geologica', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;

  --topbar-h: 64px;
  --sidebar-w: 304px;
  --toc-w: 260px;
  --content-w: 780px;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

:root[data-theme='dark'] {
  --bg: #161616;
  --bg-elev: #1f1f1f;
  --bg-soft: #262626;
  --bg-code: #101010;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ececec;
  --text-soft: #c4c4c4;
  --muted: #8f8f94;
  --primary: #7c8ce0;
  --primary-strong: #4c5fc7;
  --primary-soft: rgba(124, 140, 224, 0.15);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --topbar-bg: rgba(22, 22, 22, 0.82);
  --mark: rgba(124, 140, 224, 0.32);
  --danger: #ff7b72;
  --srv-bg: #303136; --srv-bg-hover: #414349; --srv-fg: #f1f1f3; --srv-ok: #6dd58c; --srv-bad: #f28b82;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elev: #f6f7f9;
  --bg-soft: #eef0f4;
  --bg-code: #f3f4f7;
  --border: rgba(20, 24, 40, 0.1);
  --border-strong: rgba(20, 24, 40, 0.2);
  --text: #1b1f27;
  --text-soft: #3b4250;
  --muted: #667085;
  --primary: #3d50bd;
  --primary-strong: #3d50bd;
  --primary-soft: rgba(61, 80, 189, 0.1);
  --shadow: 0 12px 40px rgba(20, 24, 40, 0.18);
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --mark: rgba(61, 80, 189, 0.22);
  --danger: #c7372f;
  --srv-bg: #e8eaed; --srv-bg-hover: #dcdfe4; --srv-fg: #131314; --srv-ok: #1e9e50; --srv-bad: #d93025;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: anywhere;
}

body.menu-open, body.search-open, body.lightbox-open { overflow: hidden; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
kbd { font-family: var(--mono); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.icon { flex: none; display: block; }
.muted { color: var(--muted); }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 1000; background: var(--primary-strong); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; text-decoration: none; }

/* ───────────── шапка ───────────── */

.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 100%;
  max-width: 1600px; margin: 0 auto;
  padding: 0 max(20px, var(--safe-r)) 0 max(20px, var(--safe-l));
  display: flex; align-items: center; gap: 14px;
}

.brand { display: flex; align-items: center; flex: none; }
.brand img { display: block; height: 34px; width: auto; }
/* Два файла одного логотипа одинакового размера: в светлой теме белая надпись становится тёмной, поэтому ничего не смещается */
.brand .logo-light { display: none; }
:root[data-theme='light'] .brand .logo-dark { display: none; }
:root[data-theme='light'] .brand .logo-light { display: block; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  color: var(--text-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.menu-toggle { display: none; margin-left: -8px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); cursor: pointer; list-style: none; user-select: none;
  font-size: 14px; font-weight: 550;
}
.pill:hover { border-color: var(--border-strong); }
.pill-text { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }

.search-trigger {
  min-width: 0;
  flex: 1 1 auto; max-width: 460px; margin: 0 auto 0 8px;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted); cursor: pointer; text-align: left; font-size: 14px;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-soft); }
.search-trigger-text { flex: 1; }
.kbd { font-size: 11px; padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--muted); }

.topnav { display: flex; align-items: center; gap: 4px; flex: none; }
.topnav-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--text-soft); font-size: 14px; font-weight: 550; cursor: pointer; list-style: none;
}
.topnav-link:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }

.theme-toggle .when-light { display: none; }
:root[data-theme='light'] .theme-toggle .when-light { display: block; }
:root[data-theme='light'] .theme-toggle .when-dark { display: none; }

/* кнопка «скопировать IP» + онлайн (по образцу кнопки на dailymine.net) */
.srv {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  height: 40px; padding: 0 14px; border: 0; border-radius: 12px;
  background: var(--srv-bg); color: var(--srv-fg); font-size: 14px; cursor: pointer;
  transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.srv:hover { background: var(--srv-bg-hover); }
.srv:active { transform: scale(0.98); }
.srv__ipwrap { display: grid; align-items: center; }
.srv__ipwrap > * { grid-area: 1 / 1; justify-self: start; white-space: nowrap; font-weight: 550; letter-spacing: 0.01em; transition: opacity 0.35s ease, transform 0.35s ease; }
.srv__version { opacity: 0; transform: translateY(8px); pointer-events: none; }
.srv__copied { opacity: 0; color: var(--srv-ok); font-weight: 600; pointer-events: none; transition: opacity 0.2s ease; }
.srv.show-version .srv__ip { opacity: 0; transform: translateY(-8px); }
.srv.show-version .srv__version { opacity: 1; transform: none; }
.srv.is-copied .srv__ip, .srv.is-copied .srv__version { opacity: 0; }
.srv.is-copied .srv__copied { opacity: 1; }
.srv.is-copied { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--srv-ok) 55%, transparent); }
.srv__icon { display: grid; opacity: 0.55; transition: opacity 0.2s; }
.srv:hover .srv__icon { opacity: 1; }
.srv__icon--check { display: none; color: var(--srv-ok); }
.srv.is-copied .srv__icon--copy { display: none; }
.srv.is-copied .srv__icon--check { display: grid; opacity: 1; }
.srv__sep { width: 1px; align-self: stretch; margin: 8px 0; background: currentColor; opacity: 0.2; flex: none; }
.srv__status { display: inline-flex; align-items: center; gap: 8px; }
.srv__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.35; flex: none; }
.srv[data-state='online'] .srv__dot { background: var(--srv-ok); opacity: 1; }
.srv[data-state='offline'] .srv__dot, .srv[data-state='error'] .srv__dot { background: var(--srv-bad); opacity: 1; }
.srv[data-state='loading'] .srv__dot { animation: srv-breathe 1.4s ease-in-out infinite alternate; }
@keyframes srv-breathe { from { opacity: 0.2; } to { opacity: 0.7; } }
.srv__count { font-weight: 600; font-variant-numeric: tabular-nums; }
.sidebar-mc { display: none; margin: 0 0 16px; }
.sidebar-mc .srv { width: 100%; height: 46px; border-radius: 14px; }
/* адрес занимает всё свободное место, поэтому значок копирования стоит справа, вплотную к разделителю и числу онлайна */
.sidebar-mc .srv__ipwrap { flex: 1; min-width: 0; }

/* выпадающие списки (на <details>, работают и без JS) */
.dropdown { position: relative; }
.dropdown[open] > summary.pill { border-color: var(--primary); }
.dd-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  min-width: 240px; max-width: min(340px, calc(100vw - 24px));
  padding: 6px;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.dd-right { left: auto; right: 0; }
.dd-label { padding: 8px 10px 4px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  flex-wrap: wrap;
}
.dd-item:hover { background: var(--bg-soft); text-decoration: none; }
.dd-item.is-current { background: var(--primary-soft); color: var(--primary); }
.dd-title { font-weight: 550; }
.dd-desc { flex-basis: 100%; font-size: 12.5px; color: var(--muted); font-weight: 400; }

/* ───────────── каркас ───────────── */

.shell {
  max-width: 1600px; margin: 0 auto;
  padding-top: var(--topbar-h);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}
.shell.has-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); }

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  padding-left: var(--safe-l);
}
.sidebar-head { display: none; }
.sidebar-head-actions { display: flex; align-items: center; gap: 2px; }
.sidebar-scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 14px 32px 20px;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.backdrop { display: none; }

.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-root { margin-bottom: 18px; }
.nav-caption {
  padding: 4px 12px 8px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.nav-empty { color: var(--muted); padding: 8px 12px; font-size: 14px; }

.nav-row { display: flex; align-items: center; cursor: pointer; border-radius: var(--radius-sm); }
.nav-row:hover { background: var(--bg-soft); }
.nav-row .nav-link { flex: 1; min-width: 0; }
.nav-row .nav-link:hover { background: transparent; }
.nav-chevron { display: grid; place-items: center; width: 30px; height: 30px; color: var(--muted); transition: transform 0.18s ease; }
details[open] > .nav-row .nav-chevron { transform: rotate(90deg); }

.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-size: 14.5px; line-height: 1.4;
}
a.nav-link:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-label { color: var(--text); }
.nav-emoji { flex: none; }
.nav-text { min-width: 0; }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-row:has(.is-active) { background: var(--primary-soft); }

[data-depth='0'] > .nav-link, [data-depth='0'] > details > .nav-row > .nav-link { font-weight: 600; color: var(--text); }
[data-depth='0'] > a.nav-link.is-active, [data-depth='0'] > details > .nav-row > .nav-link.is-active { color: var(--primary); }

.nav-item > details > .nav-list {
  margin: 2px 0 6px 18px; padding-left: 8px; border-left: 1px solid var(--border);
}
.nav-item { margin: 1px 0; }

.badge { font-size: 10.5px; padding: 1px 6px; border-radius: 99px; background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); font-weight: 500; }

.sidebar-links { display: none; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.sidebar-links .nav-caption { padding-top: 0; }

/* ───────────── содержимое ───────────── */

.main { min-width: 0; padding: 0 max(32px, var(--safe-r)) 0 32px; min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; }
.doc-grid { width: 100%; max-width: var(--content-w); margin: 0 auto; flex: 1; }
.doc { padding: 32px 0 48px; }

.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }
.crumb { color: var(--muted); }
a.crumb:hover { color: var(--text); text-decoration: none; }
.crumb-home { display: inline-flex; }
.crumb-sep { opacity: 0.5; }

.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.doc h1 { margin: 0 0 12px; font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.doc-emoji { margin-right: 10px; }
.lead { font-size: 1.1rem; color: var(--text-soft); }

.edit-link {
  display: inline-flex; align-items: center; gap: 6px; flex: none; margin-top: 8px;
  padding: 6px 12px; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 99px; color: var(--text-soft);
}
.edit-link:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }

.draft-banner {
  display: flex; align-items: center; gap: 10px; margin: 16px auto 0; max-width: var(--content-w);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-soft);
}

.prose { font-size: 16px; color: var(--text-soft); }
.prose > :first-child { margin-top: 0; }
.prose h2, .prose h3, .prose h4, .prose h5 { color: var(--text); line-height: 1.3; font-weight: 650; scroll-margin-top: calc(var(--topbar-h) + 20px); position: relative; }
.prose h2 { font-size: 1.55rem; margin: 2.2em 0 0.6em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.28rem; margin: 1.9em 0 0.5em; }
.prose h4 { font-size: 1.1rem; margin: 1.6em 0 0.4em; }
.prose h5 { font-size: 1rem; margin: 1.4em 0 0.4em; }
.prose p { margin: 0.9em 0; }
.prose strong { color: var(--text); font-weight: 650; }
.prose ul, .prose ol { margin: 0.9em 0; padding-left: 1.5em; }
.prose li { margin: 0.3em 0; }
.prose li > ul, .prose li > ol { margin: 0.3em 0; }
.prose li::marker { color: var(--muted); }
.prose ul.contains-task-list { list-style: none; padding-left: 0.2em; }
.prose blockquote { margin: 1.2em 0; padding: 0.4em 1.1em; border-left: 3px solid var(--primary-strong); background: var(--bg-elev); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-soft); }
.prose blockquote > :first-child { margin-top: 0.3em; } .prose blockquote > :last-child { margin-bottom: 0.3em; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose code { font-family: var(--mono); font-size: 0.88em; padding: 0.15em 0.4em; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.prose pre { position: relative; margin: 1.2em 0; padding: 16px 18px; overflow-x: auto; background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; line-height: 1.6; }
.prose pre code { padding: 0; background: none; border: 0; font-size: inherit; color: var(--text-soft); }
.prose img { display: block; margin: 1.2em 0; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; background: var(--bg-elev); }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--primary) 40%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--primary); }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { background: var(--bg-elev); color: var(--text); font-weight: 600; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose td { min-width: 110px; }

.anchor { position: absolute; left: -1.1em; padding-right: 0.3em; color: var(--muted); font-weight: 400; text-decoration: none !important; opacity: 0; transition: opacity 0.12s; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor, .anchor:focus { opacity: 1; }

.copy-btn {
  position: absolute; top: 8px; right: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text-soft); opacity: 0; transition: opacity 0.12s;
}
.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }

.doc-meta { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--muted); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 28px; }
.pager-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); transition: border-color 0.15s, background 0.15s; min-width: 0; }
.pager-card:hover { border-color: var(--primary); background: var(--bg-elev); text-decoration: none; }
.pager-next { text-align: right; align-items: flex-end; }
.pager-dir { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.pager-title { font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 22px; }
.card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--bg); transition: border-color 0.15s, background 0.15s, transform 0.15s; }
.card:hover { border-color: var(--primary); background: var(--bg-elev); text-decoration: none; transform: translateY(-1px); }
.card-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 20px; }
.card-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card-title { font-weight: 600; }
.card-sub { font-size: 13px; color: var(--muted); }
.card > .icon { color: var(--muted); }

.not-found { text-align: center; padding-top: 12vh; }
.nf-code { font-size: 5rem; font-weight: 800; line-height: 1; color: var(--primary); opacity: 0.9; }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font-weight: 550; cursor: pointer; }
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn-primary { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); background: var(--primary-strong); }

.site-footer { padding: 24px 0 calc(32px + var(--safe-b)); font-size: 13.5px; color: var(--muted); text-align: center; }
.site-footer p { margin: 0; }
.site-footer-meta { margin-top: 6px !important; font-size: 12.5px; opacity: 0.8; }
.site-footer-meta a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ───────────── оглавление справа ───────────── */

.toc { position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto; padding: 32px max(20px, var(--safe-r)) 24px 8px; scrollbar-width: thin; }
.toc-title { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc-item a { display: block; padding: 4px 12px; margin-left: -1px; border-left: 2px solid transparent; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.toc-item a:hover { color: var(--text); text-decoration: none; }
.toc-item a.is-active { color: var(--primary); border-left-color: var(--primary); font-weight: 550; }
.toc-item[data-indent='1'] a { padding-left: 26px; }
.toc-item[data-indent='2'] a { padding-left: 40px; }

.toc-inline { display: none; margin: 8px 0 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.toc-inline summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-size: 14px; font-weight: 550; color: var(--text-soft); }
.toc-inline summary .icon:last-child { margin-left: auto; transition: transform 0.15s; }
.toc-inline[open] summary .icon:last-child { transform: rotate(180deg); }
.toc-inline .toc-list { margin: 0 14px 12px; }

/* ───────────── поиск ───────────── */

.search-modal[hidden] { display: none; }
.search-modal { position: fixed; inset: 0; z-index: 100; display: grid; justify-items: center; align-content: start; padding: 10vh 12px 0; }
.search-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.search-panel { position: relative; width: min(680px, 100%); max-height: 76vh; display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-input { flex: 1; min-width: 0; height: 46px; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 17px; -webkit-appearance: none; appearance: none; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-scope { padding: 8px 18px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-scope:empty { display: none; }
.search-scope label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.search-results { overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.result { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.result:hover, .result.is-selected { background: var(--bg-soft); text-decoration: none; }
.result.is-selected { outline: 1px solid var(--primary); }
.result-crumbs { font-size: 12px; color: var(--muted); }
.result-title { font-weight: 600; }
.result-snippet { font-size: 13.5px; color: var(--text-soft); line-height: 1.5; }
.result-snippet mark, .result mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.search-hint { padding: 18px; color: var(--muted); text-align: center; font-size: 14px; }
.search-form { display: flex; gap: 10px; margin: 16px 0; }
.search-input-lg { flex: 1; min-width: 0; height: 44px; padding: 0 14px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text); font: inherit; }
.results { display: flex; flex-direction: column; gap: 4px; }

/* ───────────── просмотр картинок ───────────── */

.lightbox { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.88); cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; color: #fff; }

/* ───────────── редактирование прямо на странице ───────────── */

.inline-editor { height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); }
.inline-editor-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
body.is-editing .doc-grid, body.is-editing .site-footer, body.is-editing .draft-banner { display: none; }
.shell.is-editing, .shell.is-editing.has-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.shell.is-editing .toc { display: none; }
.shell.is-editing .main { padding: 0; min-height: 0; }
@media (max-width: 1023px) {
  /* на телефонах и планшетах меню выезжающее — колонка одна */
  .shell.is-editing, .shell.is-editing.has-toc { grid-template-columns: minmax(0, 1fr); }
}

/* ───────────── планшеты ───────────── */

@media (max-width: 1180px) {
  .search-trigger .kbd { display: none; }
}

@media (max-width: 1279px) {
  .shell.has-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .toc-inline { display: block; }
}

/* ───────────── телефоны и узкие планшеты: меню выезжает слева ───────────── */

@media (max-width: 1023px) {
  :root { --topbar-h: 58px; --sidebar-w: 0px; }
  .srv--header { display: none; }
  .sidebar-mc { display: block; }
  .menu-toggle { display: inline-grid; }
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .shell, .shell.has-toc { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 0 20px; }
  .doc { padding-top: 20px; }

  .sidebar {
    position: fixed; z-index: 90; top: 0; bottom: 0; left: 0; height: auto;
    width: min(88vw, 360px);
    background: var(--bg); border-right: 1px solid var(--border-strong); box-shadow: var(--shadow);
    transform: translateX(-102%); visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    padding-left: 0; padding-bottom: var(--safe-b);
  }
  body.menu-open .sidebar { transform: none; visibility: visible; transition: transform 0.22s ease; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 8px 0 20px; border-bottom: 1px solid var(--border); }
  .sidebar-title { font-weight: 600; }
  .sidebar-scroll { padding: 14px 12px 28px; }
  .nav-link { padding: 10px 12px; font-size: 15.5px; }
  .nav-chevron { width: 40px; height: 40px; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.55); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.menu-open .backdrop { opacity: 1; pointer-events: auto; }
  .search-trigger { flex: 0 0 auto; width: 40px; padding: 0; justify-content: center; margin: 0 0 0 auto; }
  .search-trigger-text, .search-trigger .kbd { display: none; }
}

@media (max-width: 760px) {
  .topnav { display: none; }
  .topbar-theme { display: none; }
  .sidebar-links { display: block; }
  .brand img { height: 28px; }
  .pill { padding: 0 10px; }
  .pill-text { max-width: 120px; }
  .topbar-inner { gap: 6px; }
  .dd-menu { position: fixed; top: calc(var(--topbar-h) + 6px); left: 12px; right: 12px; max-width: none; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; align-items: flex-start; }
  .prose pre { font-size: 13px; padding: 14px; margin-left: -4px; margin-right: -4px; }
  .prose th, .prose td { padding: 8px 10px; font-size: 14px; }
  .anchor { display: none; }
  .search-modal { padding-top: 0; }
  .search-panel { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; }
  .search-input { font-size: 16px; } /* 16px — чтобы iOS не приближал страницу при фокусе */
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .main { padding: 0 16px; }
  .doc-head { flex-direction: column; gap: 4px; }
  .pill-text { max-width: 84px; }
}

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

@media print {
  .topbar, .sidebar, .toc, .toc-inline, .pager, .edit-link, .backdrop, .site-footer { display: none !important; }
  .shell { display: block; padding: 0; }
  body { background: #fff; color: #000; }
  .prose, .prose strong, .doc h1, .prose h2, .prose h3 { color: #000; }
}
