/* ==============================
   ГЛОБАЛЬНЫЕ СТИЛИ САЙТА
   (объединение styles.css + улучшения)
   ============================== */

/* Системные шрифты и базовые переменные */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --elevated: rgba(255,255,255,0.72);
  --text: #0f1216;
  --text-muted: #5b6270;
  --primary: #e11d48;
  --primary-600: #b91c1c;
  --accent: #7f1d1d;
  --border: rgba(15,18,22,0.12);
  --shadow: 0 8px 22px rgba(15,18,22,0.08);
  --grad: linear-gradient(180deg, #ffffff, #faf7f7 50%, #f5f2f2 100%);
  --radius-xs: 4px;
  --radius-s: 6px;
  --radius-m: 8px;

  /* системный стек */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
             Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-head: var(--font-ui);

  --focus: 0 0 0 2px color-mix(in oklab, var(--primary) 45%, transparent);

  /* сетка сайта */
  --site-max: 1280px;
  --site-gutter: 22px;

  /* SVG карточки в контенте (сохраняем светлый фон в обеих темах) */
  --ls-fig-bg: #ffffff;
  --ls-fig-fg: #111111;

  /* Высота шапки и отступ для якорей */
  --header-height: 84px; /* базовая высота шапки = высоте .header-inner */
  --anchor-offset: calc(var(--header-height) + 12px); /* +зазор под шапкой */
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #121418;
  --elevated: rgba(18,20,24,0.68);
  --text: #e9edf3;
  --text-muted: #9aa1b0;
  --primary: #f43f5e;
  --primary-600: #e11d48;
  --accent: #b91c1c;
  --border: rgba(233,237,243,0.10);
  --shadow: 0 10px 28px rgba(0,0,0,0.45);
  --grad:
    radial-gradient(1200px 560px at 22% -10%, rgba(225,29,72,0.16), transparent 60%),
    radial-gradient(980px 420px at 78% -10%, rgba(127,29,29,0.12), transparent 60%),
    linear-gradient(180deg, #0e1116, #0e1116);

  /* Сохраняем читаемость схем */
  --ls-fig-bg: #ffffff;
  --ls-fig-fg: #111111;
}

/* Адаптивная высота шапки (при желании можно подстроить под мобильные) */
@media (max-width: 600px){
  :root { --header-height: 72px; }
}

/* Нормализация и базовая типографика */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; scroll-behavior: smooth; }
/* Отступ скролла для якорных переходов (вдобавок к scroll-margin-top на целях) */
html { scroll-padding-top: var(--anchor-offset); }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--grad);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  font-size: 17px;
  line-height: 1.55;
  /* Компенсация фиксированной шапки, чтобы контент не прятался под ней */
  padding-top: var(--header-height);
}

/* Компенсация фиксированной шапки для всех якорных целей */
[id] { scroll-margin-top: var(--anchor-offset); }
/* Для отладки можно подсветить цель якоря:
:target { outline: 2px solid color-mix(in oklab, var(--primary) 45%, transparent); outline-offset: 2px; }
*/

/* Моноширинный стек */
code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", "DejaVu Sans Mono", monospace;
}

/* Текст внутри SVG по умолчанию — заголовочный стек */
svg text { font-family: var(--font-head) !important; }

/* Лёгкая фоновая сетка */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, color-mix(in oklab, var(--text-muted) 14%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklab, var(--text-muted) 14%, transparent) 1px, transparent 1px);
  background-size: 44px 44px, 44px 44px;
  opacity: .055;
  z-index: 0;
}

/* Контейнеры и лейаут */
.container{
  width: 100%;
  max-width: var(--site-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--site-gutter);
  padding-right: var(--site-gutter);
  position: relative;
  z-index: 1;
}
.layout{
  display: grid;
  grid-template-columns: 300px 1fr; /* десктоп: сайдбар + контент */
  gap: 9px;
  align-items: start;
}
.layout > *{ min-width: 0; } /* защита от переполнения */
@media (max-width: 960px){
  .layout{ grid-template-columns: 1fr; }
}

/* Медиа внутри не должны растягивать контейнер */
img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Шапка (фиксированная, всегда на виду) */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: color-mix(in oklab, var(--surface) 96%, transparent);
  backdrop-filter: saturate(1.12) blur(6px);
  -webkit-backdrop-filter: saturate(1.12) blur(6px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: var(--header-height); }
.brand {
  display: inline-flex; align-items: center; gap: 14px; text-decoration: none;
  color: var(--text); font-weight: 800; letter-spacing: .2px;
  font-family: var(--font-head);
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: var(--radius-s);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; box-shadow: var(--shadow); font-size: 20px;
  border: 1px solid color-mix(in oklab, var(--primary) 50%, transparent);
}
.brand-text {
  font-size: clamp(1.1rem, 0.9rem + 1.2vw, 1.6rem); line-height: 1.1; white-space: nowrap;
  font-family: var(--font-head);
  letter-spacing: .02em;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border-radius: var(--radius-s); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-family: var(--font-head);
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.icon-btn:hover { border-color: color-mix(in oklab, var(--primary) 30%, var(--border)); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* Иконки темы */
.theme-icon { font-size: 18px; }
.theme-icon--sun { display: none; }
:root[data-theme="dark"] .theme-icon--sun { display: inline; }
:root[data-theme="dark"] .theme-icon--moon { display: none; }

/* Сайдбар */
.sidebar {
  position: sticky; top: var(--anchor-offset); align-self: start;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-m); box-shadow: var(--shadow); padding: 14px;
}
.side-title {
  margin: 6px 8px 10px; font-size: 1.6rem; color: var(--text-muted);
  font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  font-family: var(--font-head);
}
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.side-list a {
  display: block; padding: 10px 12px; border-radius: var(--radius-s); text-decoration: none;
  color: var(--text); border: 1px solid transparent;
  font-family: var(--font-head);
  font-size: 1.1rem;
  letter-spacing: .01em;
}
.side-list a:hover {
  border-color: var(--border); background: color-mix(in oklab, var(--surface) 94%, transparent);
}

/* Херо */
.hero { padding: 34px 0 26px; }
.hero-inner { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }
@media (max-width: 1100px) { .hero-inner { grid-template-columns: 1fr; } }
.hero-copy h1 {
  font-size: clamp(2rem, 1.6rem + 2.6vw, 3.25rem); margin: 0 0 12px;
  font-family: var(--font-head);
  letter-spacing: .01em;
}
.lead { font-size: clamp(1.05rem, 0.98rem + .55vw, 1.22rem); color: var(--text-muted); line-height: 1.65; }
.hero-cta { margin-top: 20px; display: flex; gap: 12px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: var(--radius-s); font-weight: 700; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  font-family: var(--font-head);
  letter-spacing: .02em;
  transition: filter .15s ease, transform .05s ease, border-color .15s ease, background .15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; box-shadow: var(--shadow);
  border-color: color-mix(in oklab, var(--primary) 45%, transparent);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: color-mix(in oklab, var(--surface) 94%, transparent); border-color: color-mix(in oklab, var(--primary) 26%, var(--border)); }
.btn-ghost:focus-visible { outline: none; box-shadow: var(--focus); }

/* Карточки */
.glass-card {
  border: 1px solid var(--border); background: var(--elevated);
  backdrop-filter: blur(8px) saturate(1.15); -webkit-backdrop-filter: blur(8px) saturate(1.15);
  padding: 18px; border-radius: var(--radius-m); box-shadow: var(--shadow);
}
.glass-card h2 { margin: 0 0 10px; font-size: 1.15rem; font-family: var(--font-head); letter-spacing: .02em; }
.guide-list { margin: 0; padding-left: 18px; color: var(--text-muted); line-height: 1.65; font-size: 1.02rem; }

/* Подвал */
.site-footer { border-top: 1px solid var(--border); background: color-mix(in oklab, var(--surface) 96%, transparent); }
.footer-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; }
.link-quiet { color: var(--text-muted); text-decoration: none; font-family: var(--font-head); }
.link-quiet:hover { color: var(--text); }
.link-quiet:focus-visible { outline: none; box-shadow: var(--focus); }

/* Поисковая панель (попап) */
.search-panel {
  position: fixed; inset: 0; display: grid; place-items: center; visibility: hidden;
  z-index: 1500;
}
.search-panel[aria-hidden="false"] { visibility: visible; }
.search-panel__backdrop {
  position: absolute; inset: 0;
  background: rgba(10,12,16,0.35);
  opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(10px) saturate(1.05);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  will-change: opacity;
}
.search-panel[aria-hidden="false"] .search-panel__backdrop { opacity: 1; }
.search-panel__dialog {
  position: relative; width: min(920px, calc(100% - 24px)); max-height: calc(100% - 24px);
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  border-radius: var(--radius-m); box-shadow: var(--shadow);
  padding: 16px; transform: translateY(10px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
  display: grid; grid-template-rows: auto auto auto 1fr; gap: 10px;
  backdrop-filter: blur(12px) saturate(1.12);
  -webkit-backdrop-filter: blur(12px) saturate(1.12);
}
.search-panel[aria-hidden="false"] .search-panel__dialog { transform: translateY(0); opacity: 1; }
.search-panel__header { display: flex; align-items: center; justify-content: space-between; }
.search-panel__bar { display: flex; gap: 10px; }
.search-panel__bar input[type="search"] {
  flex: 1; background: color-mix(in oklab, var(--surface) 94%, transparent); border: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; border-radius: var(--radius-s); outline: none;
  font-family: var(--font-ui);
  font-size: 1.02rem;
}
.search-panel__bar input[type="search"]:focus-visible { box-shadow: var(--focus); }
.search-panel__meta { display: flex; align-items: center; gap: 10px; }
.search-results { overflow: auto; border-top: 1px dashed var(--border); padding-top: 8px; }
.result-item {
  display: block; padding: 10px 8px; border-radius: var(--radius-s); text-decoration: none; color: var(--text);
  border: 1px solid transparent; font-family: var(--font-head); font-size: 1.02rem;
}
.result-item:hover { border-color: var(--border); background: color-mix(in oklab, var(--surface) 94%, transparent); }
.result-title { margin: 0 0 4px; font-weight: 700; font-family: var(--font-head); letter-spacing: .01em; }
.result-desc { margin: 0; color: var(--text-muted); font-size: .97rem; font-family: var(--font-ui); }

.muted { color: var(--text-muted); }
.divider { color: var(--text-muted); }

/* Мобильное меню (попап) */
.menu-panel {
  position: fixed; inset: 0; display: grid; place-items: center; visibility: hidden;
  z-index: 1500;
}
.menu-panel[aria-hidden="false"] { visibility: visible; }
.menu-panel__backdrop {
  position: absolute; inset: 0; background: rgba(10,12,16,0.35);
  opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(10px) saturate(1.05);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  will-change: opacity;
}
.menu-panel[aria-hidden="false"] .menu-panel__backdrop { opacity: 1; }
.menu-panel__dialog {
  position: relative; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px);
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  border-radius: var(--radius-m); box-shadow: var(--shadow);
  padding: 16px; transform: translateY(10px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
  display: grid; grid-template-rows: auto 1fr; gap: 10px;
  backdrop-filter: blur(12px) saturate(1.12);
  -webkit-backdrop-filter: blur(12px) saturate(1.12);
}
.menu-panel[aria-hidden="false"] .menu-panel__dialog { transform: translateY(0); opacity: 1; }
.menu-panel__header { display: flex; align-items: center; justify-content: space-between; }
.menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.menu-list a {
  display: block; padding: 12px 12px; border-radius: var(--radius-s); color: var(--text); text-decoration: none; border: 1px solid transparent;
  font-family: var(--font-head); font-size: 1.05rem;
}
.menu-list a:hover { border-color: var(--border); background: color-mix(in oklab, var(--surface) 94%, transparent); }

/* Респонсив и утилиты */
@media (max-width: 980px) { .sidebar { display: none; } }
@media (max-width: 480px) { .brand-text { font-size: 1.05rem; } }
body.modal-open { overflow: hidden; }

/* SVG в контенте: фон и currentColor для текста */
#ls-article .ls-figure svg,
#ls-article svg[role="img"] {
  display: block;
  width: 100%;
  height: auto;
  background-color: var(--ls-fig-bg);
  color: var(--ls-fig-fg);
  border-radius: 0;
  padding: 8px;
  box-sizing: border-box;
}
#ls-article svg text,
#ls-article svg tspan { fill: currentColor; }

/* ==============================
   КОНТЕНТНЫЙ БЛОК СТАТЬИ (#ls-article)
   (объединение всех style-блоков из st.html)
   ============================== */

/* Переменные и базовая коробка */
#ls-article{
  --lg-bg:rgba(18, 18, 18, 0.95);
  --lg-fg:#f5f5f5;
  --lg-accent:#dc2626;
  --lg-accent-2:#f97316;
  --lg-muted:#b5b5b5;
  --lg-border:rgba(220, 38, 38, 0.22);
  --lg-note:rgba(220, 38, 38, 0.06);
  --lg-tip:rgba(249, 115, 22, 0.08);
  --lg-warn:rgba(220, 38, 38, 0.12);
  --lg-ok:#22c55e;
  --lg-bad:#ef4444;
  --lg-link:#f97316;
  --lg-code-bg:#0a0a0a;
  --lg-code:#b5b5b5;
  --lg-font: 'Barlow Condensed', system-ui, sans-serif;
  --lg-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --lg-radius: 0;
  --lg-shadow: none;
  --lg-focus: 0 0 0 2px rgba(220, 38, 38, 0.4);

  color:var(--lg-fg);
  background:var(--lg-bg);
  font-family:var(--lg-font);
  line-height:1.6;
  font-size:16px;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  padding:0.5rem;
  border:1px solid var(--lg-border);
  border-radius:var(--lg-radius);
  box-shadow:var(--lg-shadow);
  overflow:hidden;
}
html[data-theme="dark"] #ls-article{
  --lg-bg:rgba(18, 18, 18, 0.95);
  --lg-fg:#f5f5f5;
  --lg-accent:#dc2626;
  --lg-accent-2:#f97316;
  --lg-muted:#b5b5b5;
  --lg-border:rgba(220, 38, 38, 0.22);
  --lg-note:rgba(220, 38, 38, 0.06);
  --lg-tip:rgba(249, 115, 22, 0.08);
  --lg-warn:rgba(220, 38, 38, 0.12);
  --lg-link:#f97316;
  --lg-code-bg:#0a0a0a;
  --lg-code:#b5b5b5;
  --lg-shadow: none;
  --lg-focus: 0 0 0 2px rgba(220, 38, 38, 0.4);
}

/* Мелкие утилиты */
#ls-article .muted{ color:var(--lg-muted); }

/* Заголовки */
#ls-article h1{ margin:.15rem 0 .35rem; font-size:1.6rem; }
#ls-article h2, #ls-article h3{ display:flex; align-items:center; gap:.5rem; margin-top:0; }

/* Оглавления (общие и локальные) */
#ls-article #ls-toc,
#ls-article .local-toc{
  border:1px solid var(--lg-border);
  border-radius:var(--lg-radius);
  padding:1rem;
  background: rgba(10, 10, 10, 0.5);
  margin:.5rem 0 1rem;
}
#ls-article #ls-toc h2,
#ls-article .local-toc h2{ margin:.2rem 0 .4rem; font-size:1.15rem; }
#ls-article #ls-toc a,
#ls-article .local-toc a{ color:var(--lg-link); text-decoration:none; }
#ls-article #ls-toc a:hover,
#ls-article .local-toc a:hover{ text-decoration:underline; }
#ls-article .local-toc ol ol{ margin-top:.4rem; }

/* Секции/карточки */
#ls-article section{
  border:1px solid var(--lg-border);
  border-radius:var(--lg-radius);
  padding:0.5rem;
  background: rgba(10, 10, 10, 0.35);
  margin:0.5rem 0;
}

/* Таблицы и код */
#ls-article table{ border-collapse:collapse; width:100%; display:block; overflow:auto; }
#ls-article th, #ls-article td{ border:1px solid var(--lg-border); padding:.55rem .6rem; text-align:left; vertical-align:top; }
#ls-article caption{ caption-side:top; text-align:left; font-weight:600; padding:.35rem 0; }
#ls-article code{ font-family:var(--lg-mono); background:rgba(220,38,38,.08); padding:.1rem .35rem; border-radius:0; color:var(--lg-accent-2); }
#ls-article pre{
  background:var(--lg-code-bg); color:var(--lg-code);
  padding:.8rem 1rem; border-radius:var(--lg-radius); overflow:auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}

/* Вспом. навигация */
#ls-article .back-links{
  display:flex; flex-wrap:wrap; gap:.6rem 1rem; align-items:center;
  margin:.35rem 0 -.25rem;
  font-size:.96rem;
}
#ls-article .back-links a{ color:var(--lg-link); text-decoration:none; }
#ls-article .back-links a:hover{ text-decoration:underline; }
#ls-article .divider{ color:var(--lg-muted); }

/* Ссылки "Назад к содержанию" и "Наверх" (+ якорные ссылки) */
#ls-article a[href="#ls-toc"],
#ls-article a[href="#ls-top"],
#ls-article a[href^="#"]:not([href="#"]){
  color: var(--lg-link);
  text-decoration: none;
}
#ls-article a[href="#ls-toc"]:hover,
#ls-article a[href="#ls-toc"]:focus,
#ls-article a[href="#ls-top"]:hover,
#ls-article a[href="#ls-top"]:focus,
#ls-article a[href^="#"]:not([href="#"]):hover,
#ls-article a[href^="#"]:not([href="#"]):focus{
  text-decoration: underline;
  outline: none;
}
#ls-article a[href="#ls-toc"]:visited,
#ls-article a[href="#ls-top"]:visited,
#ls-article a[href^="#"]:not([href="#"]):visited{
  color: var(--lg-link);
}

/* Фигуры/изображения */
#ls-article .ls-figure{
  border:1px solid var(--lg-border);
  border-radius:var(--lg-radius);
  background:var(--lg-bg);
  padding:.5rem;
  margin:.6rem 0 1rem;
  overflow:auto;
}
#ls-article .ls-figure figcaption{ font-size:.95rem; color:var(--lg-muted); margin:.25rem 0 .15rem .15rem; }
#ls-article svg{ max-width:100%; height:auto; display:block; }

/* Формы/калькуляторы */
#ls-article fieldset{
  border:1px solid var(--lg-border);
  border-radius:var(--lg-radius);
  padding:.75rem;
}
#ls-article input,
#ls-article select,
#ls-article textarea{
  padding:.5rem .55rem;
  border:1px solid var(--lg-border);
  border-radius:0;
  background:rgba(10, 10, 10, 0.9);
  color:var(--lg-fg);
  font-family:var(--lg-mono);
}
#ls-article .ls-actions{ display:flex; flex-wrap:wrap; gap:.5rem; margin:.75rem 0 1rem; }
#ls-article .ls-actions button{
  background:transparent; color:#f5f5f5; border:1px solid var(--lg-accent); border-radius:0; padding:.6rem .9rem; cursor:pointer; font-weight:600;
  box-shadow: none;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
#ls-article .ls-actions button + button{
  background:transparent; color:#b5b5b5; border:1px solid var(--lg-border);
}
#ls-article .ls-results{
  padding:.65rem .8rem;
  border:1px dashed var(--lg-border);
  border-radius:0;
  background:rgba(10, 10, 10, 0.4);
  font-family:var(--lg-mono);
}
#ls-article .ls-error{ color:var(--lg-bad); font-weight:600; }

/* Печать */
@media print{
  body { padding-top: 0 !important; }
  .site-header { position: static !important; }
  #ls-article{ box-shadow:none; border:none; }
  #ls-article .ls-actions button{ display:none !important; }
  #ls-article a{ text-decoration:underline; }
}

/* ==============================
   КОМПОЗИТОР ДЛЯ СПРАВОЧНИКОВ/КАЛЬКУЛЯТОРОВ (.lg-root)
   (объединение "physics"-блоков)
   ============================== */

/* Переменные темы */
.lg-root{
  --lg-bg:rgba(18, 18, 18, 0.95);
  --lg-fg:#f5f5f5;
  --lg-accent:#dc2626;
  --lg-accent-2:#f97316;
  --lg-muted:#b5b5b5;
  --lg-border:rgba(220, 38, 38, 0.22);
  --lg-note:rgba(220, 38, 38, 0.06);
  --lg-tip:rgba(249, 115, 22, 0.08);
  --lg-warn:rgba(220, 38, 38, 0.12);
  --lg-ok:#22c55e;
  --lg-bad:#ef4444;
  --lg-link:#f97316;
  --lg-code-bg:#0a0a0a;
  --lg-code:#b5b5b5;
  --lg-font: 'Barlow Condensed', system-ui, sans-serif;
  --lg-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --lg-radius: 0;
  --lg-shadow: none;
  --lg-focus: 0 0 0 2px rgba(220, 38, 38, 0.4);

  color:var(--lg-fg);
  background:var(--lg-bg);
  font-family:var(--lg-font);
  line-height:1.6;
  font-size:16px;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  padding: 1rem;
  border:1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  box-shadow: var(--lg-shadow);
  overflow: hidden;
}
/* Темная тема: глобальный синк через html[data-theme] и локальный переключатель через data-lg-theme */
html[data-theme="dark"] .lg-root,
.lg-root[data-lg-theme="dark"]{
  --lg-bg:rgba(18, 18, 18, 0.95);
  --lg-fg:#f5f5f5;
  --lg-accent:#dc2626;
  --lg-accent-2:#f97316;
  --lg-muted:#b5b5b5;
  --lg-border:rgba(220, 38, 38, 0.22);
  --lg-note:rgba(220, 38, 38, 0.06);
  --lg-tip:rgba(249, 115, 22, 0.08);
  --lg-warn:rgba(220, 38, 38, 0.12);
  --lg-link:#f97316;
  --lg-code-bg:#0a0a0a;
  --lg-code:#b5b5b5;
  --lg-shadow: none;
  --lg-focus: 0 0 0 2px rgba(220, 38, 38, 0.4);
}

/* Заголовок и подзаголовки */
.lg-root .lg-header{ display:grid; gap:.75rem; margin-bottom:1rem; }
.lg-root h1{ font-size: clamp(1.6rem, 2.5vw, 2.25rem); line-height:1.25; margin: 0; }
.lg-root .lg-subtitle{ color:var(--lg-muted); margin:0; }

/* Асайды */
.lg-root .lg-forwho{
  background:var(--lg-note);
  border:1px dashed var(--lg-border);
  padding:.75rem 1rem;
  border-radius: var(--lg-radius);
}

/* Кнопки управления */
.lg-root .lg-controls{ display:flex; gap:.5rem; flex-wrap:wrap; }
.lg-root .lg-btn{
  background:transparent;
  color:#f5f5f5;
  border:1px solid var(--lg-accent);
  border-radius:0;
  padding:.6rem .9rem;
  cursor:pointer;
  font-weight:600;
  box-shadow: none;
}
.lg-root .lg-btn:focus{ outline:none; box-shadow: var(--lg-focus); }
.lg-root .lg-btn.secondary{
  background: transparent;
  color: var(--lg-accent);
  border:1px solid var(--lg-accent);
}

/* Оглавление */
.lg-root .lg-toc{
  border:1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  padding:1rem;
  background: rgba(10, 10, 10, 0.5);
  margin: .5rem 0 1rem;
}
.lg-root .lg-toc h2{ margin:.2rem 0 .4rem; font-size:1.15rem; }
.lg-root .lg-toc ul{
  list-style:none; padding:0; margin:0;
  columns: 2; column-gap: 2rem;
}
@media (max-width: 900px){ .lg-root .lg-toc ul{ columns:1; } }
.lg-root .lg-toc a{ color:var(--lg-link); text-decoration:none; }
.lg-root .lg-toc a:hover{ text-decoration:underline; }
.lg-root .lg-toc li{ break-inside: avoid; padding:.15rem 0; }

/* Основная сетка и секции */
.lg-root .lg-main{ display:grid; gap: 1.25rem; }
.lg-root .lg-section{
  border:1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  padding:1rem;
  background: rgba(10, 10, 10, 0.35);
  position: relative;
}
.lg-root .lg-section h2, .lg-root .lg-section h3{
  display:flex; align-items:center; gap:.5rem; margin-top:0;
}
.lg-root .lg-section .lg-copylink{
  margin-left:auto; font: inherit; border:none; background: transparent; color: var(--lg-accent);
  cursor:pointer; padding:.2rem .45rem; border-radius:6px;
}
.lg-root .lg-top{
  margin-top: .5rem; display:inline-flex; gap:.4rem; align-items:center;
  color:var(--lg-link); text-decoration:none; font-size:.95rem;
}
.lg-root .lg-top:focus{ outline:none; box-shadow:var(--lg-focus); }

/* Боковые блоки */
.lg-root .lg-note, .lg-root .lg-tip, .lg-root .lg-warn{
  padding:.75rem 1rem; border-radius: var(--lg-radius); border:1px solid var(--lg-border);
  margin:.75rem 0;
}
.lg-root .lg-note{ background:var(--lg-note); }
.lg-root .lg-tip{ background:var(--lg-tip); }
.lg-root .lg-warn{ background:var(--lg-warn); }
.lg-root .lg-aside-title{ font-weight:700; margin-bottom:.35rem; }

/* Код/формулы */
.lg-root code{ font-family: var(--lg-mono); background: rgba(2,6,23,.06); padding:.1rem .35rem; border-radius:6px; }
.lg-root pre{
  background: var(--lg-code-bg);
  color: var(--lg-code);
  padding: .8rem 1rem;
  border-radius: var(--lg-radius);
  overflow:auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.lg-root .lg-formula{ font-family: var(--lg-mono); display:inline-block; padding:.15rem .35rem; background:rgba(2,6,23,.06); border-radius:6px; }

/* SVG схемы */
.lg-root .lg-figure{
  border:1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  background: var(--lg-bg);
  padding:.5rem;
  margin:.6rem 0 1rem;
  overflow:auto;
}
.lg-root .lg-figure .lg-figcap{ font-size:.95rem; color:var(--lg-muted); margin:.25rem 0 .15rem .15rem; }
.lg-root svg{ max-width:100%; height:auto; display:block; }
.lg-root .lg-svg-axis, .lg-root .lg-svg-line, .lg-root .lg-svg-shape{
  stroke: var(--lg-fg); fill: none; stroke-width: 2; vector-effect: non-scaling-stroke;
}
.lg-root .lg-svg-label{ fill: var(--lg-fg); font-size: 12px; font-family: var(--lg-mono); }
.lg-root .lg-svg-dim{ stroke: var(--lg-accent); fill:none; stroke-dasharray:4 3; vector-effect: non-scaling-stroke; }
.lg-root .lg-svg-accent{ stroke: var(--lg-accent); }
.lg-root .lg-svg-accent2{ stroke: var(--lg-accent-2); }
.lg-root .lg-legend{ font-size:12px; fill:var(--lg-fg); font-family:var(--lg-mono); }
.lg-root .lg-key{ display:flex; gap:1rem; flex-wrap:wrap; padding:.35rem 0 .1rem; }
.lg-root .lg-key span{ display:inline-flex; align-items:center; gap:.35rem; font-size:.9rem; }
.lg-root .lg-dot{ width:10px; height:10px; border-radius:50%; display:inline-block; }
.lg-root .lg-dot.a{ background: var(--lg-accent); }
.lg-root .lg-dot.b{ background: var(--lg-accent-2); }
.lg-root .lg-dot.c{ background: #22c55e; }
.lg-root .lg-dot.d{ background: #ef4444; }

/* Калькуляторы */
.lg-root .lg-calc{
  border:1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  padding:.75rem;
  background: rgba(10, 10, 10, 0.4);
  margin:.75rem 0;
}
.lg-root .lg-form{ display:grid; gap:.6rem; grid-template-columns: repeat(12, 1fr); align-items:end; }
.lg-root .lg-field{ grid-column: span 4; display:grid; gap:.25rem; }
.lg-root .lg-field label{ font-weight:600; }
.lg-root .lg-field input, .lg-root .lg-field select{
  padding:.5rem .55rem; border:1px solid var(--lg-border); border-radius:0; background: rgba(10, 10, 10, 0.9); color:var(--lg-fg);
  font-family: var(--lg-mono);
}
.lg-root .lg-actions{ grid-column: 1 / -1; display:flex; gap:.5rem; flex-wrap:wrap; }
.lg-root .lg-actions button{
  background: transparent; color:#f5f5f5; border:1px solid var(--lg-accent); border-radius:0; padding:.6rem .9rem; cursor:pointer; font-weight:600;
  box-shadow: none;
}
.lg-root .lg-actions button.secondary{
  background: transparent; color: var(--lg-accent); border:1px solid var(--lg-accent);
}
.lg-root .lg-out{
  grid-column: 1 / -1; background: rgba(2,6,23,.05); border:1px dashed var(--lg-border);
  padding:.65rem .8rem; border-radius: 0; font-family: var(--lg-mono);
}
.lg-root .lg-help{ grid-column: 1 / -1; font-size:.95rem; color:var(--lg-muted); }
.lg-root .lg-mini-figure{ grid-column: 1 / -1; }
.lg-root .lg-err{ color:var(--lg-bad); font-weight:600; }
.lg-root .lg-ok{ color:var(--lg-ok); font-weight:600; }
@media (max-width: 980px){ .lg-root .lg-field{ grid-column: span 6; } }
@media (max-width: 640px){ .lg-root .lg-field{ grid-column: span 12; } }

/* Подвал блока */
.lg-root .lg-footer{
  border-top:1px solid var(--lg-border);
  margin-top:1rem; padding-top:1rem;
  display:grid; gap:.75rem;
}
.lg-root .lg-version{ font-size:.95rem; color:var(--lg-muted); }

/* Печать */
@media print{
  .lg-root{ box-shadow:none; border: none; }
  .lg-root .lg-controls, .lg-root .lg-copylink, .lg-root .lg-actions, .lg-root .lg-btn{ display:none !important; }
  .lg-root a{ text-decoration: underline; }
}

/* ==============================
   ДОП. УТИЛИТЫ И ИНДЕКСЫ
   ============================== */

.tools-index{ display:grid; gap:.5rem; }
.tools-index ul{ margin:.25rem 0 .5rem; }
.tools-index li{ margin:.15rem 0; }

/* Приведение кнопок в единый вид между разделами */
#ls-article .ls-actions button,
.lg-root .lg-actions button,
.lg-root .lg-btn{
  background: transparent;
  color: #f5f5f5;
  border: 1px solid var(--lg-accent);
  border-radius: 0;
  padding: .6rem .9rem;
  cursor: pointer;
  font-weight: 600;
  box-shadow: none;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
#ls-article .ls-actions button + button,
.lg-root .lg-actions button.secondary,
.lg-root .lg-btn.secondary{
  background: transparent;
  color: #b5b5b5;
  border: 1px solid rgba(220, 38, 38, 0.22);
}