/* ==========================================================================
   WHITE WORLD LIBRARY
   Нейтральный фон под чтение, сайдбар у самого края, обложки, якоря.
   ========================================================================== */

@font-face {
  font-family: 'Benzin';
  src: local('Benzin Medium'), local('Benzin-Medium'),
       url('/fonts/Benzin/Benzin-Medium.woff2') format('woff2'),
       url('/fonts/Benzin/Benzin-Medium.woff') format('woff'),
       url('/fonts/Benzin/Benzin-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------- токены ---------------------------------- */

:root {
  /* нейтральные поверхности — без синего */
  --bg: #0f1115;
  --bg-2: #16191f;
  --bg-3: #1c2027;
  --surface: #16191f;
  --text: #e7e9ec;
  --text-muted: #99a1ab;
  --accent: #4aa6ff;
  --accent-hover: #7ec8ff;
  --accent-deep: #1b6fd4;
  --glow: rgba(74, 166, 255, 0.32);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --card-bg: #14171c;
  --code-bg: rgba(255, 255, 255, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  --side-w: 262px;
  --toc-w: 224px;
}

[data-theme='light'] {
  --bg: #f6f6f3;
  --bg-2: #ffffff;
  --bg-3: #edede7;
  --surface: #ffffff;
  --text: #17191c;
  --text-muted: #5d646d;
  --accent: #1f7fe0;
  --accent-hover: #1668bd;
  --accent-deep: #155fa8;
  --glow: rgba(31, 127, 224, 0.2);
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);
  --card-bg: #ffffff;
  --code-bg: rgba(0, 0, 0, 0.04);
  --shadow: 0 12px 30px rgba(20, 24, 30, 0.1);
}

/* ------------------------------- база ------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body.lib {
  margin: 0;
  min-height: 100vh;
  font-family: 'Benzin', system-ui, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
::selection { background: var(--accent); color: #04101f; }

kbd {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-3); color: var(--text-muted);
}

.lib-muted { color: var(--text-muted); font-size: 13px; }
.lib-lead { margin: 0 0 18px; max-width: 70ch; color: var(--text-muted); font-size: 15px; }

/* ------------------------------ каркас ----------------------------------- */

/* сайдбар у самого края, контент — отдельным полем */
.lib-shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  align-items: start;
}

.lib-main {
  min-width: 0;
  padding: 26px 40px 80px;
  max-width: 1180px;
  margin: 0 auto;
}

.lib-main-article { max-width: 1280px; }

@media (min-width: 1400px) {
  .lib-main-article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--toc-w);
    gap: 34px;
    align-items: start;
  }
  .lib-main-article .lib-crumbs,
  .lib-main-article .lib-article { grid-column: 1; }
  .lib-main-article .lib-toc { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 84px; }
}

/* ------------------------------ хедер ------------------------------------ */

.lib-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
[data-theme='light'] .lib-header { background: rgba(255, 255, 255, 0.85); }

.lib-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  min-height: 58px;
}

.lib-brand { display: flex; align-items: center; gap: 5px; font-size: 17px; font-weight: 900; letter-spacing: 1.4px; white-space: nowrap; }
.lib-brand .b-white { color: var(--text); }
.lib-brand .b-accent { color: var(--accent); }
.lib-brand .b-tag {
  margin-left: 8px; font-size: 9.5px; letter-spacing: 2.2px; padding: 3px 9px; border-radius: 999px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid var(--border-strong);
}

.lib-topnav { display: flex; gap: 2px; }
.lib-topnav a { padding: 7px 12px; border-radius: var(--radius-xs); font-size: 13px; color: var(--text-muted); }
.lib-topnav a:hover { color: var(--text); background: var(--bg-3); }
.lib-topnav a.is-active { color: var(--text); background: var(--bg-3); }

.lib-search-trigger {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 460px;
  padding: 9px 13px; border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text-muted); font-family: inherit; font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.lib-search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.lib-search-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-search-trigger kbd { margin-left: auto; flex-shrink: 0; }
.lib-search-trigger svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }

.lib-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.lib-user {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-3); font-size: 12px; color: var(--text);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-user-dot { width: 7px; height: 7px; border-radius: 50%; background: #5ee08a; box-shadow: 0 0 8px #5ee08a; flex-shrink: 0; }

.lib-burger { display: none; flex-direction: column; gap: 4px; width: 36px; height: 36px; padding: 9px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--bg-3); cursor: pointer; }
.lib-burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

/* ------------------------------ кнопки ----------------------------------- */

.lib-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border: 1px solid transparent; border-radius: var(--radius-xs);
  font-family: inherit; font-size: 12px; font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap; cursor: pointer; color: #04121f;
  background: linear-gradient(105deg, var(--accent-deep), var(--accent) 55%, var(--accent-hover));
  box-shadow: 0 8px 22px var(--glow);
  transition: transform 0.15s, filter 0.15s;
}
.lib-btn:hover { transform: translateY(-2px); filter: brightness(1.07); }
.lib-btn.ghost { background: transparent; color: var(--text-muted); border-color: var(--border); box-shadow: none; }
.lib-btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }
.lib-btn.icon { padding: 9px 11px; }
.lib-btn.sm { padding: 6px 10px; font-size: 11px; }
.lib-btn.ghost.danger:hover { color: #ff8d8d; border-color: rgba(255, 90, 90, 0.45); }
[data-theme='light'] .lib-btn { color: #fff; }
.ico-sun, .ico-moon { font-size: 14px; line-height: 1; }
[data-theme='dark'] .ico-sun { display: none; }
[data-theme='light'] .ico-moon { display: none; }

/* ----------------------------- сайдбар ----------------------------------- */

.lib-side {
  position: sticky;
  top: 58px;
  align-self: start;
  height: calc(100vh - 58px);
  overflow-y: auto;
  padding: 18px 12px 40px 16px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-2) 55%, transparent);
}
.lib-side::-webkit-scrollbar { width: 6px; }
.lib-side::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

.lib-tree { display: flex; flex-direction: column; gap: 1px; }

.tree-group { margin-top: 12px; }
.tree-link {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: var(--radius-xs);
  font-size: 13px; color: var(--text-muted); border-left: 2px solid transparent;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}
.tree-link:hover { color: var(--text); background: var(--bg-3); }
.tree-link.is-active { color: var(--text); background: var(--bg-3); border-left-color: var(--accent); }
.tree-link.is-static { pointer-events: none; opacity: 0.65; }
.tree-home, .tree-section { font-weight: 900; color: var(--text); font-size: 12.5px; letter-spacing: 0.2px; }
.tree-folder { color: var(--accent); }
.tree-subsection { padding-left: 16px; font-size: 12.5px; }
.tree-kids { display: flex; flex-direction: column; margin: 1px 0 4px; }
.tree-kids .tree-link { padding-left: 26px; font-size: 12.5px; }
.tree-ico { width: 16px; text-align: center; opacity: 0.85; flex-shrink: 0; }
.tree-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { font-size: 10px; padding: 1px 6px; border-radius: 99px; color: var(--text-muted); background: var(--bg-3); border: 1px solid var(--border); }

/* ------------------------------- герой ----------------------------------- */

.lib-hero { padding: 26px 0 26px; }
.lib-kicker { display: inline-block; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.lib-hero h1 { margin: 0 0 12px; font-size: clamp(30px, 4.6vw, 52px); line-height: 1.05; letter-spacing: -1px; }
.lib-hero h1 span { color: var(--accent); }
.lib-hero-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.lib-stat { min-width: 108px; padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); }
.lib-stat b { display: block; font-size: 24px; line-height: 1.1; color: var(--accent); }
.lib-stat span { font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase; color: var(--text-muted); }

/* ---------------------------- заголовки/сетки ---------------------------- */

.lib-h2 { display: flex; align-items: center; gap: 12px; margin: 38px 0 14px; font-size: 19px; }
.lib-h2::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); }
.lib-h2-more { font-size: 12px; color: var(--accent); }
.lib-h2-count { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--bg-3); border: 1px solid var(--border); color: var(--text-muted); }
.lib-sub-desc { margin: -6px 0 14px; font-size: 13px; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }

.lib-card {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); overflow: hidden;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.lib-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.lib-card.has-cover { padding-top: 0; }
.lib-card-cover {
  display: block; height: 132px; margin: 0 -18px 12px;
  background-size: cover; background-position: center;
  border-bottom: 1px solid var(--border);
}
.lib-card-ico { font-size: 20px; line-height: 1; }
.lib-card-title { font-size: 15px; font-weight: 900; }
.lib-card-desc {
  font-size: 12.5px; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-card-foot { margin-top: auto; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--accent); }
.lib-card.is-book { border-color: var(--border-strong); }

/* --------------------------- список обновлённых -------------------------- */

.lib-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.lib-recent li { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 10px 12px; border-radius: var(--radius-xs); }
.lib-recent li:hover { background: var(--card-bg); }
.lib-recent .lib-muted { font-size: 11.5px; white-space: nowrap; }

/* -------------------------------- чипы ----------------------------------- */

.lib-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lib-chips.lg { gap: 10px; }
.lib-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-3); font-size: 12px; color: var(--text-muted);
  transition: color 0.14s, border-color 0.14s;
}
.lib-chip:hover { color: var(--text); border-color: var(--border-strong); }
.lib-chip i { font-style: normal; font-size: 10px; opacity: 0.65; }
.lib-chip.sm { padding: 3px 9px; font-size: 11px; }

/* ------------------------------- крошки ---------------------------------- */

.lib-crumbs { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.lib-crumbs a:hover { color: var(--accent); }
.lib-crumbs b { color: var(--text); font-weight: 500; }
.lib-crumbs span { opacity: 0.5; }

/* ------------------------------ шапка стр. ------------------------------- */

.lib-page-head { margin-bottom: 20px; }
.lib-page-head h1 { margin: 0 0 10px; font-size: clamp(25px, 3.4vw, 38px); line-height: 1.12; letter-spacing: -0.5px; }
.lib-page-ico { font-size: 28px; display: block; margin-bottom: 6px; }
.lib-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.lib-edit { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--accent); font-size: 11px; }
.lib-edit:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lib-edit.ghost { border-color: var(--border); color: var(--text-muted); }

/* ------------------------------ обложка статьи --------------------------- */

.lib-cover-head { position: relative; margin: 0 0 24px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.lib-cover-head img { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.lib-cover-overlay {
  position: absolute; inset: auto 0 0 0; padding: 22px 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.15) 70%, transparent);
}
.lib-cover-overlay h1 { margin: 0 0 6px; font-size: clamp(24px, 3.4vw, 38px); color: #fff; }
.lib-cover-overlay p { margin: 0 0 6px; color: rgba(255, 255, 255, 0.82); }
.lib-cover-overlay .lib-muted { color: rgba(255, 255, 255, 0.6); }

/* ----------------------------- контент статьи ---------------------------- */

.lib-content { font-size: 15.5px; line-height: 1.78; overflow-wrap: break-word; max-width: 78ch; }
.lib-content > *:first-child { margin-top: 0; }
.lib-content h1, .lib-content h2, .lib-content h3, .lib-content h4 { line-height: 1.25; letter-spacing: -0.2px; }
.lib-content h1 { font-size: 29px; margin: 34px 0 14px; }
.lib-content h2 { font-size: 22px; margin: 36px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); scroll-margin-top: 80px; }
.lib-content h3 { font-size: 18px; margin: 26px 0 10px; scroll-margin-top: 80px; }
.lib-content h4 { font-size: 16px; margin: 20px 0 8px; scroll-margin-top: 80px; }
.lib-content p { margin: 0 0 15px; }
.lib-content ul, .lib-content ol { margin: 0 0 16px; padding-left: 24px; }
.lib-content li { margin-bottom: 6px; }
.lib-content a { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.lib-content a:hover { border-bottom-color: var(--accent); }
.lib-content blockquote { margin: 20px 0; padding: 14px 20px; border-left: 3px solid var(--accent); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; background: var(--code-bg); color: var(--text-muted); }
.lib-content code { font-family: ui-monospace, Menlo, monospace; font-size: 0.88em; padding: 2px 6px; border-radius: 6px; background: var(--code-bg); color: var(--accent-hover); }
.lib-content pre { margin: 18px 0; padding: 16px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-3); overflow-x: auto; }
.lib-content pre code { padding: 0; background: none; color: var(--text); }
.lib-content img { border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 8px 0; }
.lib-content hr { border: 0; border-top: 1px solid var(--border); margin: 30px 0; }
.lib-content table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px; display: block; overflow-x: auto; }
.lib-content th, .lib-content td { padding: 10px 13px; border: 1px solid var(--border); text-align: left; }
.lib-content th { background: var(--bg-3); font-weight: 900; }

/* --------------------------- якоря (TOC + меню) -------------------------- */

.lib-toc { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); font-size: 12.5px; max-height: calc(100vh - 120px); overflow-y: auto; }
.lib-toc-title { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.lib-toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.lib-toc a { display: block; padding: 5px 9px; border-radius: 7px; color: var(--text-muted); border-left: 2px solid transparent; }
.lib-toc a:hover { color: var(--text); }
.lib-toc a.is-active { color: var(--accent); border-left-color: var(--accent); }
.lib-toc .toc-h3 a { padding-left: 20px; font-size: 12px; }

/* кнопка-меню «перейти к разделу» над статьёй */
.lib-anchor-menu { position: relative; margin: 0 0 18px; }
.lib-anchor-toggle {
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 14px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--bg-3); color: var(--text-muted);
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.lib-anchor-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.lib-anchor-panel {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: min(420px, 90vw);
  max-height: 50vh; overflow-y: auto; padding: 8px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow);
}
.lib-anchor-panel[hidden] { display: none; }
.lib-anchor-panel a { display: block; padding: 8px 11px; border-radius: var(--radius-xs); font-size: 13px; color: var(--text-muted); }
.lib-anchor-panel a:hover { background: var(--bg-3); color: var(--text); }
.lib-anchor-panel .lvl3 { padding-left: 24px; font-size: 12.5px; }

/* ------------------------------- пагинация ------------------------------- */

.lib-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--border); }
.lib-pager-item { display: flex; flex-direction: column; gap: 4px; padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); transition: border-color 0.16s, transform 0.16s; }
.lib-pager-item:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.lib-pager-item.is-next { text-align: right; }
.lib-pager-dir { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.lib-pager-title { font-size: 14px; }

/* ---------------------------- прогресс чтения ---------------------------- */

.lib-progress { position: fixed; top: 0; left: 0; height: 2px; width: 100%; transform: scaleX(0); transform-origin: 0 50%; background: var(--accent); z-index: 1200; }

/* ------------------------- палитра поиска (Ctrl+K) ----------------------- */

.cmdk { position: fixed; inset: 0; z-index: 1500; display: flex; align-items: flex-start; justify-content: center; padding: 11vh 18px 18px; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.66); backdrop-filter: blur(6px); }
.cmdk-box { position: relative; width: min(660px, 100%); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg-2); box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6); overflow: hidden; }
.cmdk-input-row { display: flex; align-items: center; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.cmdk-input-row svg { width: 17px; height: 17px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.cmdk-input-row input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font-family: inherit; font-size: 15px; }
.cmdk-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmdk-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 13px; border-radius: var(--radius-xs); border-left: 2px solid transparent; }
.cmdk-item.is-active { background: var(--bg-3); border-left-color: var(--accent); }
.cmdk-item-title { font-size: 14px; }
.cmdk-item-sec { font-size: 11px; color: var(--accent); }
.cmdk-item-desc { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.cmdk-foot { padding: 9px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); }

/* ------------------------------- поиск ----------------------------------- */

.lib-search-form { display: flex; gap: 10px; margin-top: 14px; }
.lib-search-form input { flex: 1; padding: 12px 15px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--bg-3); color: var(--text); font-family: inherit; font-size: 15px; outline: none; }
.lib-search-form input:focus { border-color: var(--accent); }
.lib-search-count { margin: 6px 0 14px; }
.lib-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lib-results li { padding: 15px 17px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); }
.lib-results li > a { font-size: 15.5px; color: var(--accent); }
.lib-results p { margin: 6px 0 0; }
.lib-snip { font-size: 13px; color: var(--text-muted); }
.lib-results-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }

/* ------------------------------- формы ----------------------------------- */

.lib-form { display: flex; flex-direction: column; gap: 20px; }
.lib-form-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; position: sticky; top: 66px; z-index: 50; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--bg-2) 90%, transparent); backdrop-filter: blur(12px); }
.lib-form-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.lib-form-status { font-size: 12px; color: var(--text-muted); }
.lib-form-status.is-ok { color: #5ee08a; }
.lib-form-status.is-error { color: #ff8d8d; }

.lib-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lib-field { display: flex; flex-direction: column; gap: 7px; }
.lib-field.span2 { grid-column: 1 / -1; }
.lib-field > span { font-size: 11px; letter-spacing: 1.3px; text-transform: uppercase; color: var(--text-muted); }
.lib-field > span small { text-transform: none; letter-spacing: 0; opacity: 0.7; }
.lib-field input[type='text'], .lib-field input[type='number'], .lib-field select, .lib-field textarea {
  padding: 10px 12px; border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text); font-family: inherit; font-size: 14px; outline: none; width: 100%;
}
.lib-field input:focus, .lib-field select:focus { border-color: var(--accent); }
.lib-field input[readonly] { opacity: 0.65; }
.lib-field > small { font-size: 11.5px; color: var(--text-muted); }
.lib-field > small b { color: var(--accent); }

.lib-cover-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.lib-cover-row input[type='text'] { flex: 1; min-width: 220px; }
.lib-cover-preview { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; max-width: 360px; }
.lib-cover-preview img { display: block; width: 100%; max-height: 170px; object-fit: cover; }

/* ------------------------------- Quill ----------------------------------- */

.q-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--bg-3); }
.q-toolbar .ql-formats { display: flex; align-items: center; gap: 3px; margin: 0 6px 0 0; }
.q-toolbar button, .q-toolbar select, .q-custom, .q-color {
  border: 1px solid var(--border) !important; border-radius: 7px !important; background: var(--bg-2) !important;
  color: var(--text) !important; cursor: pointer; height: 29px; min-width: 29px;
  display: inline-flex; align-items: center; justify-content: center; font-family: inherit; font-size: 12px;
}
.q-toolbar button svg { fill: currentColor; }
.q-toolbar button:hover, .q-custom:hover, .q-color:hover { border-color: var(--accent) !important; }
.q-toolbar .ql-active, .q-toolbar button.ql-active { border-color: var(--accent) !important; color: var(--accent) !important; }
.q-toolbar select { padding: 0 8px; }
.q-color { position: relative; overflow: hidden; width: 33px; }
.q-color input[type='color'] { position: absolute; inset: -6px; width: 200%; height: 200%; border: 0; padding: 0; cursor: pointer; opacity: 0; }
.q-color-ico { font-size: 13px; font-weight: 900; pointer-events: none; }
.q-color-bg .q-color-ico { display: block; width: 14px; height: 14px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); }
.q-editor { min-height: 420px; border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--bg-3); }
.ql-toolbar.ql-snow { border: 0; }
.ql-container.ql-snow { border: 0; font-family: inherit; font-size: 15px; }
.ql-editor { min-height: 420px; line-height: 1.7; color: var(--text); }
.ql-editor.ql-blank::before { color: var(--text-muted) !important; font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text); }
.ql-snow .ql-fill { fill: var(--text); }
.ql-snow .ql-picker { color: var(--text); }
.ql-snow .ql-picker-options { background: var(--bg-2); border-color: var(--border) !important; }
.ql-snow a { color: var(--accent); }
.ql-editor blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--text-muted); }
.ql-editor pre.ql-syntax, .ql-editor pre { background: var(--bg-2); color: var(--text); border-radius: 10px; padding: 12px; }

/* ------------------------------ превью ----------------------------------- */

.lib-preview { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); padding: 18px 20px; }
.lib-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }

/* ------------------------------- книги ----------------------------------- */

.lib-book-head { display: flex; gap: 22px; align-items: flex-start; margin-bottom: 24px; }
.lib-book-cover { flex-shrink: 0; width: 100px; height: 134px; display: grid; place-items: center; font-size: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-3); }
.lib-book-head h1 { margin: 0 0 8px; font-size: clamp(23px, 3.2vw, 34px); }
.lib-chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.lib-chapters a { display: flex; align-items: baseline; gap: 12px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--card-bg); transition: border-color 0.15s, transform 0.15s; }
.lib-chapters a:hover { border-color: var(--border-strong); transform: translateX(3px); }
.lib-ch-num { flex-shrink: 0; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; font-size: 11px; background: var(--bg-3); color: var(--accent); border: 1px solid var(--border); }
.lib-ch-title { font-size: 14px; }
.lib-ch-desc { flex: 1; font-size: 12px; color: var(--text-muted); }

/* ------------------------------ ревизии ---------------------------------- */

.lib-revs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.lib-rev { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); }
.lib-rev-main b { display: block; font-size: 14px; margin-bottom: 3px; }

/* --------------------------- управление -------------------------------- */

.lib-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
.lib-manage-list { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lib-manage-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg);
}
.lib-manage-list b { display: block; font-size: 14px; }
.lib-manage-list .lib-muted { font-size: 11.5px; }
.lib-manage-actions { display: flex; gap: 7px; flex-shrink: 0; }

@media (max-width: 1000px) {
  .lib-grid-2 { grid-template-columns: 1fr; }
}

/* --------------------------- пустые состояния ---------------------------- */

.lib-empty { text-align: center; padding: 64px 20px; max-width: 560px; margin: 0 auto; }
.lib-empty-ico { font-size: 44px; margin-bottom: 12px; opacity: 0.85; }
.lib-empty h1 { margin: 0 0 12px; font-size: 28px; }
.lib-empty-actions { display: flex; gap: 11px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* ------------------------------- футер ----------------------------------- */

.lib-footer { border-top: 1px solid var(--border); margin-top: 40px; }
.lib-footer-inner { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 26px; padding: 32px 40px; font-size: 13px; }
.lib-footer-brand { font-weight: 900; letter-spacing: 1.4px; margin-bottom: 8px; }
.lib-footer-brand span { color: var(--accent); }
.lib-footer-links { display: flex; flex-direction: column; gap: 7px; }
.lib-footer-links a { color: var(--text-muted); }
.lib-footer-links a:hover { color: var(--accent); }
.lib-footer-copy { color: var(--text-muted); font-size: 12px; }
.lib-who { display: block; margin-top: 8px; color: var(--accent); font-size: 11px; }

/* ----------------------------- адаптивность ------------------------------ */

@media (max-width: 1080px) {
  :root { --side-w: 228px; }
  .lib-main { padding: 22px 24px 70px; }
  .lib-footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .lib-burger { display: flex; }
  .lib-topnav { display: none; }
  .lib-shell { grid-template-columns: minmax(0, 1fr); }
  .lib-side {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(310px, 86vw); height: auto; z-index: 1000;
    padding: 16px; background: var(--bg-2); border-right: 1px solid var(--border);
    transform: translateX(-104%); transition: transform 0.22s; overflow-y: auto;
  }
  .lib-side.is-open { transform: translateX(0); box-shadow: 0 0 80px rgba(0, 0, 0, 0.6); }
  .lib-search-trigger span { display: none; }
  .lib-form-grid { grid-template-columns: 1fr; }
  .lib-pager { grid-template-columns: 1fr; }
  .lib-footer-inner { grid-template-columns: 1fr; padding: 26px 20px; }
  .lib-main { padding: 20px 16px 70px; }
}

@media (max-width: 560px) {
  .lib-hero h1 { font-size: 28px; }
  .lib-book-head { flex-direction: column; gap: 16px; }
  .lib-user { display: none; }
  .lib-card-cover { height: 108px; }
}

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