/* База знаний Pineo — оформление по токенам продукта (frontend/src/theme):
   Inter, радиусы 6/10/14, палитра slate, брендовые лайм green/500 #A8D94A и
   жёлтый yellow/500 #FFD12A, тёмный сайдбар slate/900. Две темы, как в приложении. */

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --bg-page: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-muted: #F1F5F9;
  --bg-sidebar: #0F172A;
  --bg-sidebar-hover: #1E293B;
  --text: #0F172A;
  --text-2: #64748B;
  --text-3: #94A3B8;
  --text-on-dark: #F8FAFC;
  --text-on-dark-muted: #94A3B8;
  --link: #1D4ED8;
  --border: #E2E8F0;
  --divider: #F1F5F9;
  --lime: #A8D94A;
  --lime-600: #8FC22F;
  --lime-50: #F5FAEC;
  --yellow: #FFD12A;
  --yellow-600: #E6B800;
  --yellow-50: #FFFBEA;
  --yellow-100: #FFF6D9;
  --amber: #F59E0B;
  --blue: #3B82F6;
  --red: #EF4444;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .10);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .16);
  --top-h: 64px;
  --side-w: 288px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page: #020617; --bg-surface: #0F172A; --bg-muted: #1E293B; --bg-sidebar: #0F172A; --bg-sidebar-hover: #1E293B;
    --text: #F8FAFC; --text-2: #94A3B8; --text-3: #64748B; --link: #93C5FD; --border: #334155; --divider: #1E293B;
    --lime-50: #14261A; --yellow-50: #2A2410; --yellow-100: #3A3112;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4); --shadow-md: 0 4px 12px rgba(0,0,0,.45); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg-page: #020617; --bg-surface: #0F172A; --bg-muted: #1E293B; --bg-sidebar: #0F172A; --bg-sidebar-hover: #1E293B;
  --text: #F8FAFC; --text-2: #94A3B8; --text-3: #64748B; --link: #93C5FD; --border: #334155; --divider: #1E293B;
  --lime-50: #14261A; --yellow-50: #2A2410; --yellow-100: #3A3112;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4); --shadow-md: 0 4px 12px rgba(0,0,0,.45); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + 16px); }
body { margin: 0; overflow-x: hidden; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg-page); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
code, kbd, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
code { font-size: .92em; background: var(--bg-muted); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px; }
pre { background: #0F172A; color: #DCE5EC; border-radius: var(--r-md); padding: 14px 16px; overflow: auto; font-size: 13px; line-height: 1.55; }
pre code { background: none; border: 0; padding: 0; color: inherit; }
kbd { font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; color: var(--text-2); background: var(--bg-surface); }
.ico { width: 18px; height: 18px; flex: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--yellow); color: #0F172A; padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- шапка */
.top { position: sticky; top: 0; z-index: 40; background: var(--bg-surface); border-bottom: 1px solid var(--border); height: var(--top-h); }
.top-inner { max-width: 1440px; margin: 0 auto; padding: 0 24px; height: 100%; display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-sidebar); padding: 5px; }
.brand-word { display: flex; flex-direction: column; line-height: 1.05; }
.brand-word strong { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand-word small { font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--yellow-600); }
.brand-kb { font-weight: 600; font-size: 14px; color: var(--text-2); padding-left: 12px; border-left: 1px solid var(--border); }
.search { position: relative; flex: 1 1 0; min-width: 0; max-width: 560px; margin-left: 8px; }
.search-box { display: flex; align-items: center; gap: 10px; background: var(--bg-muted); border: 1px solid transparent; border-radius: var(--r-md); padding: 0 12px; height: 40px; }
.search-box:focus-within { border-color: var(--lime); background: var(--bg-surface); box-shadow: 0 0 0 3px rgba(168, 217, 74, .25); }
.search-box input { flex: 1; border: 0; background: none; font: inherit; color: var(--text); outline: none; min-width: 0; }
.search-box input::placeholder { color: var(--text-3); }
.search-ico { color: var(--text-3); }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; max-height: 70vh; overflow: auto; z-index: 50; }
.search-results a { display: block; padding: 10px 12px; border-radius: var(--r-sm); color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--bg-muted); text-decoration: none; }
.search-results a strong { display: block; font-size: 14px; }
.search-results a small { display: block; color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.search-results a mark { background: var(--yellow-100); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-results .empty { padding: 14px 12px; color: var(--text-2); font-size: 14px; }
.top-links { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r-md); font-weight: 600; font-size: 14px; border: 1px solid transparent; cursor: pointer; font-family: inherit; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--yellow); color: #0F172A; }
.btn.primary:hover { background: var(--yellow-600); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--bg-muted); }
.btn-ico { width: 16px; height: 16px; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }
.menu-btn { display: none; }
[data-theme="dark"] .sun, :root:not([data-theme="light"]) .sun { display: none; }
[data-theme="dark"] .moon, :root:not([data-theme="light"]) .moon { display: block; }
.moon { display: none; }
:root[data-theme="light"] .sun { display: block; } :root[data-theme="light"] .moon { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .sun { display: block; } :root:not([data-theme="dark"]) .moon { display: none; } }

/* ---------- оболочка */
.shell { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); gap: 24px; padding: 24px; align-items: start; }
.side { position: sticky; top: calc(var(--top-h) + 24px); max-height: calc(100vh - var(--top-h) - 48px); overflow: auto; background: var(--bg-sidebar); color: var(--text-on-dark); border-radius: var(--r-lg); padding: 12px; box-shadow: var(--shadow-sm); scrollbar-width: thin; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 12px; }
.side-head a { display: flex; align-items: center; gap: 8px; color: var(--text-on-dark-muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.side-head a:hover { text-decoration: none; color: var(--text-on-dark); }
.side-close { display: none; background: transparent; border-color: #334155; color: var(--text-on-dark); }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-toggle { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--text-on-dark); font: inherit; font-weight: 600; font-size: 14px; padding: 9px 10px; border-radius: var(--r-md); cursor: pointer; text-align: left; }
.nav-toggle:hover { background: var(--bg-sidebar-hover); }
.nav-ico { color: var(--text-on-dark-muted); }
.nav-toggle span:first-of-type { flex: 1; }
.nav-count { color: var(--text-on-dark-muted); font-weight: 500; font-size: 12px; }
.chev { width: 16px; height: 16px; color: var(--text-on-dark-muted); transition: transform .15s; }
.nav-sec.active > .nav-toggle { background: var(--lime); color: #0F172A; }
.nav-sec.active > .nav-toggle .nav-ico, .nav-sec.active > .nav-toggle .nav-count, .nav-sec.active > .nav-toggle .chev { color: #0F172A; }
.nav-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.nav-list { list-style: none; margin: 4px 0 8px; padding: 0 0 0 14px; border-left: 1px solid #334155; margin-left: 19px; }
.nav-list a { display: block; padding: 6px 10px; border-radius: var(--r-sm); color: var(--text-on-dark-muted); font-size: 13.5px; }
.nav-list a:hover { color: var(--text-on-dark); background: var(--bg-sidebar-hover); text-decoration: none; }
.nav-list a.current { color: var(--text-on-dark); background: var(--bg-sidebar-hover); font-weight: 600; }
.side-foot { margin-top: 12px; padding: 12px 8px 4px; border-top: 1px solid #334155; }
.side-foot a { display: flex; align-items: center; gap: 8px; color: var(--text-on-dark-muted); font-size: 13.5px; }
.side-foot a:hover { color: var(--text-on-dark); text-decoration: none; }
.side-backdrop { display: none; }

/* ---------- контент */
.main { min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin: 2px 0 14px; }
.crumbs .ico { width: 14px; height: 14px; color: var(--text-3); }
.crumbs a { color: var(--text-2); }
.crumbs span:last-child { color: var(--text); font-weight: 500; }
.article-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
.article { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 40px 48px 32px; box-shadow: var(--shadow-sm); min-width: 0; }
.article-head { margin-bottom: 28px; }
.article h1 { font-size: 34px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; }
.article .lead { font-size: 17px; color: var(--text-2); margin: 0 0 12px; }
.meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-3); font-size: 13px; }
.meta-roles { display: inline-flex; align-items: center; gap: 6px; }
.meta-roles .ico { width: 14px; height: 14px; }
.article h2 { font-size: 22px; font-weight: 700; margin: 36px 0 12px; padding-top: 8px; letter-spacing: -.01em; }
.article h3 { font-size: 17px; font-weight: 700; margin: 26px 0 8px; }
.article h4 { font-size: 15px; font-weight: 700; margin: 18px 0 6px; }
.anchor { margin-left: 8px; color: var(--text-3); font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
.article p { margin: 0 0 14px; }
.article ul, .article ol { margin: 0 0 16px; padding-left: 24px; }
.article li { margin: 6px 0; }
.article li > ul, .article li > ol { margin: 6px 0 0; }
.article ol > li::marker { font-weight: 700; color: var(--text-2); }
.article hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
blockquote { margin: 0 0 16px; padding: 10px 16px; border-left: 3px solid var(--lime); background: var(--bg-muted); border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--text-2); }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); margin: 0 0 16px; border: 1px solid var(--border); background: var(--bg-muted); }
.callout-ico { margin-top: 2px; }
.callout.tip { background: var(--lime-50); border-color: rgba(168, 217, 74, .5); }
.callout.tip .callout-ico { color: var(--lime-600); }
.callout.warn { background: var(--yellow-50); border-color: rgba(230, 184, 0, .45); }
.callout.warn .callout-ico { color: var(--amber); }
.callout.note .callout-ico { color: var(--blue); }
.callout p { margin: 0; }
figure.shot { margin: 16px 0 22px; }
figure.shot img { border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-md); background: var(--bg-muted); }
figure.shot a.zoom { display: block; cursor: zoom-in; }
figcaption { font-size: 13px; color: var(--text-2); margin-top: 8px; text-align: center; }
.table-wrap { overflow: auto; margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--r-md); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
tr:last-child td { border-bottom: 0; }

.toc { position: sticky; top: calc(var(--top-h) + 24px); font-size: 13px; }
.toc-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; margin: 0 0 8px 12px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 5px 12px; color: var(--text-2); margin-left: -1px; border-left: 2px solid transparent; }
.toc li.lvl3 a { padding-left: 24px; font-size: 12.5px; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--text); border-left-color: var(--lime-600); font-weight: 600; }

.related { margin-top: 32px; }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.rel-card { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); background: var(--bg-surface); }
.rel-card:hover { border-color: var(--lime); text-decoration: none; box-shadow: var(--shadow-sm); }
.rel-card .ico { color: var(--text-2); margin-top: 2px; }
.rel-card strong { display: block; font-size: 14px; }
.rel-card small { display: block; color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.helpful { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 32px; padding: 16px; border: 1px dashed var(--border); border-radius: var(--r-md); color: var(--text-2); font-size: 14px; }
.helpful .btn { height: 32px; }
.helpful-thanks { color: var(--text); }
.prevnext { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.pn { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); max-width: 48%; }
.pn:hover { background: var(--bg-muted); text-decoration: none; }
.pn small { display: block; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.pn span { font-weight: 600; font-size: 14px; }
.pn .ico { color: var(--text-2); }

/* ---------- главная и разделы */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 32px; align-items: center; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 40px 48px; box-shadow: var(--shadow-sm); overflow: hidden; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; background: var(--lime-50); color: #365314; border: 1px solid rgba(168, 217, 74, .6); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; }
.eyebrow .ico { width: 14px; height: 14px; }
.hero h1 { font-size: 40px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 14px 0 12px; }
.hero .lead { font-size: 17px; color: var(--text-2); margin: 0; }
.hero-art img { border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-lg); transform: rotate(-1.5deg) translateX(12px); }
.steps, .sections { margin-top: 32px; }
.steps h2, .sections h2 { font-size: 22px; font-weight: 700; margin: 0 0 14px; }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.step { display: flex; gap: 14px; align-items: flex-start; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; color: var(--text); box-shadow: var(--shadow-sm); }
.step:hover { text-decoration: none; border-color: var(--lime); box-shadow: var(--shadow-md); }
.step-n { flex: none; width: 34px; height: 34px; border-radius: 999px; background: var(--yellow); color: #0F172A; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.step-body { flex: 1; min-width: 0; }
.step-body strong { display: block; font-size: 15px; }
.step-body small { display: block; color: var(--text-2); font-size: 13px; margin-top: 4px; }
.step .chev { color: var(--text-3); margin-top: 8px; }
.sec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sec-card { display: flex; flex-direction: column; gap: 6px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; color: var(--text); box-shadow: var(--shadow-sm); }
.sec-card:hover { text-decoration: none; border-color: var(--lime); box-shadow: var(--shadow-md); }
.sec-card-ico { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--bg-sidebar); color: var(--lime); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.sec-card-ico .ico { width: 20px; height: 20px; }
.sec-card strong { font-size: 16px; }
.sec-card small { color: var(--text-2); font-size: 13.5px; }
.sec-card-count { margin-top: auto; padding-top: 10px; font-size: 12px; color: var(--text-3); font-weight: 600; }
.section-page .sec-icon { width: 48px; height: 48px; border-radius: var(--r-md); background: var(--bg-sidebar); color: var(--lime); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.section-page .sec-icon .ico { width: 24px; height: 24px; }
.art-list { display: flex; flex-direction: column; gap: 8px; }
.art-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); }
.art-card:hover { text-decoration: none; background: var(--bg-muted); }
.art-num { font-weight: 800; color: var(--text-3); font-size: 13px; width: 28px; }
.art-card span:nth-child(2) { flex: 1; }
.art-card strong { display: block; font-size: 15px; }
.art-card small { display: block; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.art-card .chev { color: var(--text-3); }

/* ---------- подвал, лайтбокс */
.foot { border-top: 1px solid var(--border); margin-top: 24px; background: var(--bg-surface); }
.foot-inner { max-width: 1440px; margin: 0 auto; padding: 20px 24px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.foot-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }
.foot-links a { color: var(--text-2); }
.foot-copy { margin-left: auto; color: var(--text-3); }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(2, 6, 23, .82); display: flex; align-items: center; justify-content: center; padding: 32px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.lb-close { position: absolute; top: 16px; right: 16px; }

/* ---------- адаптив */
@media (max-width: 1100px) {
  .article-wrap { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .steps-grid, .sec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .menu-btn { display: inline-flex; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(320px, 88vw); max-height: none; border-radius: 0; z-index: 80; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .side-close { display: inline-flex; }
  .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 70; }
  .brand-kb, .brand-word, .top-links .ghost, .top-links .primary { display: none; }
  .top-inner { padding: 0 12px; gap: 10px; }
  .search { margin-left: 0; }
  .search-box kbd { display: none; }
  .search-results { position: fixed; left: 8px; right: 8px; top: calc(var(--top-h) - 6px); }
  .search { max-width: none; }
  .article { padding: 24px 18px; }
  .article h1 { font-size: 26px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 28px; }
  .steps-grid, .sec-grid { grid-template-columns: 1fr; }
  .prevnext { flex-direction: column; }
  .pn { max-width: none; }
  .foot-copy { margin-left: 0; }
}
