/* =========================================================================
   ТОКЕНЫ ДИЗАЙН-СИСТЕМЫ
   Все цвета — через переменные. Тема/акцент/плотность переключаются
   атрибутами на <html>: data-theme, data-accent, data-density.
   Значения ниже — справочные (для автономного предпросмотра); в продукте
   переменные приходят из платформы и эти определения можно удалить.
   ========================================================================= */
:root, [data-theme="light"]{
  --bg:#faf9f6; --bg-subtle:#f4f2ec; --surface:#ffffff; --surface-2:#fbfaf7;
  --fg:#1d1b17; --fg-muted:#5c574e; --fg-subtle:#8b8479;
  --border:#e8e4da; --border-strong:#d6d0c2;
  --success:#1f8a5b; --success-soft:#e7f4ee; --success-ink:#13633f;
  --warning:#b7791f; --warning-soft:#fbf5e8; --warning-ink:#8a5a10;
  --danger:#c2402f; --danger-soft:#fbecea; --danger-ink:#8f2c20;
  --info:#2a6fdb; --info-soft:#eaf1fc; --info-ink:#23579e;
  --shadow-sm:0 1px 2px rgba(20,18,12,.06);
  --shadow-md:0 4px 12px -4px rgba(20,18,12,.12);
  --shadow-lg:0 24px 50px -28px rgba(20,18,12,.30);
  --radius-sm:6px; --radius:8px; --radius-lg:10px; --radius-xl:14px;
}
[data-theme="dark"]{
  --bg:#171511; --bg-subtle:#1f1d18; --surface:#22201a; --surface-2:#2a2822;
  --fg:#ece8df; --fg-muted:#a9a397; --fg-subtle:#817b6f;
  --border:#33302a; --border-strong:#45413a;
  --success:#4cc28a; --success-soft:#1b2c23; --success-ink:#8fe0b6;
  --warning:#e0b96b; --warning-soft:#2e2615; --warning-ink:#e8c97d;
  --danger:#e58270; --danger-soft:#2e1d19; --danger-ink:#f0a596;
  --info:#6fa3ec; --info-soft:#172234; --info-ink:#a9c8f4;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow-md:0 4px 14px -4px rgba(0,0,0,.5);
  --shadow-lg:0 24px 50px -24px rgba(0,0,0,.6);
}
/* ---- Акценты (4 темы) ---- */
[data-accent="indigo"]{ --accent:#5b5bd6; --accent-hover:#4a4ac4; --accent-soft:#ececf9; --accent-ink:#2c289a; --on-accent:#ffffff; }
[data-accent="emerald"]{ --accent:#1f8a5b; --accent-hover:#16744b; --accent-soft:#e6f4ed; --accent-ink:#135a3a; --on-accent:#ffffff; }
[data-accent="terracotta"]{ --accent:#c2603a; --accent-hover:#a84e2d; --accent-soft:#f8ebe3; --accent-ink:#8a4022; --on-accent:#ffffff; }
[data-accent="slate"]{ --accent:#566073; --accent-hover:#454e5e; --accent-soft:#eceef2; --accent-ink:#37404f; --on-accent:#ffffff; }
[data-theme="dark"][data-accent="indigo"]{ --accent:#8b8bf0; --accent-hover:#9d9df3; --accent-soft:#23223a; --accent-ink:#bcbcf6; }
[data-theme="dark"][data-accent="emerald"]{ --accent:#4cc28a; --accent-hover:#62cf9b; --accent-soft:#15291f; --accent-ink:#86dab1; }
[data-theme="dark"][data-accent="terracotta"]{ --accent:#e08a64; --accent-hover:#e89c79; --accent-soft:#2c1d16; --accent-ink:#eaa988; }
[data-theme="dark"][data-accent="slate"]{ --accent:#9aa4b6; --accent-hover:#aab3c3; --accent-soft:#23262d; --accent-ink:#b9c1cf; }

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg); color:var(--fg);
  font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{ font-family:Fraunces,Georgia,serif; font-weight:500; letter-spacing:-.01em; margin:0; color:var(--fg); }
a{ color:var(--accent); }
::selection{ background:var(--accent-soft); color:var(--accent-ink); }
img{ max-width:100%; height:auto; display:block; }

/* ---- Topbar ---- */
.topbar{
  position:sticky; top:0; z-index:40; background:var(--surface);
  border-bottom:1px solid var(--border);
}
.topbar-inner{ max-width:1240px; margin:0 auto; height:64px; padding:0 28px; display:flex; align-items:center; gap:22px; }
.brand{ display:flex; align-items:center; gap:11px; flex:none; text-decoration:none; color:inherit; }
.brand-logo{ width:28px; height:28px; border-radius:var(--radius-sm); background:var(--fg); color:var(--bg); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:15px; font-family:Inter,sans-serif; }
.brand-name{ font-size:14.5px; font-weight:600; color:var(--fg); }
.brand-name .muted{ color:var(--fg-subtle); font-weight:500; }
.brand-sep{ width:1px; height:20px; background:var(--border); margin:0 4px; }
.brand-section{ font-size:14.5px; font-weight:600; color:var(--accent); }
.topbar-spacer{ flex:1; }
.search{ position:relative; width:340px; max-width:42vw; }
.search svg{ position:absolute; left:13px; top:50%; transform:translateY(-50%); pointer-events:none; }
.search input{
  width:100%; height:40px; padding:0 14px 0 38px; border:1px solid var(--border);
  border-radius:var(--radius); background:var(--bg-subtle); color:var(--fg);
  font-family:inherit; font-size:14px; outline:none;
}
.search input:focus{ border-color:var(--accent); }
.search-results{
  position:absolute; top:46px; left:0; right:0; background:var(--surface);
  border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow-lg);
  overflow:hidden; max-height:60vh; overflow-y:auto; z-index:50;
}
.search-result{ display:block; text-decoration:none; padding:11px 14px; cursor:pointer; border-bottom:1px solid var(--border); }
.search-result:last-child{ border-bottom:0; }
.search-result:hover,.search-result:focus-visible{ background:var(--accent-soft); }
.search-result .sr-sec{ display:block; font-family:"JetBrains Mono",monospace; font-size:9.5px; letter-spacing:.1em; color:var(--fg-subtle); margin-bottom:3px; text-transform:uppercase; }
.search-result .sr-title{ font-size:14px; font-weight:600; color:var(--fg); }
.search-result .sr-snip{ font-size:12.5px; line-height:1.45; color:var(--fg-muted); margin-top:3px; }
.search-empty{ padding:16px; font-size:14px; color:var(--fg-subtle); }
mark{ background:var(--accent-soft); color:var(--accent-ink); padding:0 1px; border-radius:3px; }

.nav-toggle{ display:none; height:40px; padding:0 14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--fg); font-family:inherit; font-size:13.5px; font-weight:500; cursor:pointer; }

/* ---- Layout ---- */
.layout{ max-width:1240px; margin:0 auto; padding:0 28px; display:flex; align-items:flex-start; gap:40px; }

/* ---- Sidebar ---- */
.sidebar{ flex:none; width:268px; position:sticky; top:64px; max-height:calc(100dvh - 64px); overflow-y:auto; align-self:flex-start; padding:30px 0 40px; }
.nav-grouplabel{ font-family:"JetBrains Mono",monospace; font-size:10px; letter-spacing:.14em; color:var(--fg-subtle); margin:0 8px 12px; text-transform:uppercase; }
.nav-grouplabel + .nav-grouplabel,.nav-steplist + .nav-grouplabel{ margin-top:24px; }
.nav-sec{ display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:var(--radius); cursor:pointer; background:transparent; border:0; width:100%; text-align:left; font-family:inherit; }
.nav-sec:hover{ background:var(--surface-2); }
.nav-sec[aria-current="true"]{ background:var(--accent-soft); }
.nav-sec .nav-num{ font-family:"JetBrains Mono",monospace; font-size:11px; font-weight:600; color:var(--accent); width:18px; }
.nav-sec .nav-label{ font-size:14px; font-weight:600; color:var(--fg); }
.nav-steplist{ margin:2px 0 6px 28px; border-left:1px solid var(--border); }
.nav-step{ display:block; padding:6px 10px; font-size:13px; color:var(--fg-muted); text-decoration:none; border-radius:var(--radius-sm); }
.nav-step:hover{ background:var(--surface-2); color:var(--fg); }
.nav-note{ margin:20px 8px 0; padding-top:16px; border-top:1px solid var(--border); font-size:12px; line-height:1.5; color:var(--fg-subtle); }

/* ---- Main ---- */
.main{ flex:1; min-width:0; padding:36px 0 120px; max-width:840px; }
.section{ }
.sec-eyebrow{ font-family:"JetBrains Mono",monospace; font-size:11px; letter-spacing:.14em; color:var(--accent); margin-bottom:14px; text-transform:uppercase; }
.sec-title{ font-size:32px; line-height:1.15; margin-bottom:14px; }
.sec-intro{ font-size:16px; line-height:1.55; color:var(--fg-muted); margin:0; }

/* ---- Step (нумерованный блок) ---- */
.step{ margin-top:34px; border-top:1px solid var(--border); padding-top:28px; scroll-margin-top:80px; }
.step:first-of-type{ margin-top:38px; }
.step-head{ display:flex; gap:14px; align-items:center; }
.step-num{ flex:none; width:30px; height:30px; border-radius:7px; background:var(--accent); color:var(--on-accent); display:flex; align-items:center; justify-content:center; font-family:"JetBrains Mono",monospace; font-size:13px; font-weight:600; }
.step-num.is-muted{ background:var(--fg-subtle); }
.step-eyebrow{ font-family:"JetBrains Mono",monospace; font-size:10px; letter-spacing:.1em; color:var(--fg-subtle); text-transform:uppercase; }
.step-title{ font-size:21px; line-height:1.2; }
.step-body{ padding-left:44px; margin-top:12px; }

/* ---- Item (пункт внутри группы) ---- */
.item{ padding:14px 0; border-top:1px solid var(--border); scroll-margin-top:80px; }
.item:first-child{ padding-top:0; border-top:0; }
.item-title{ font-size:16px; font-weight:600; font-family:Fraunces,Georgia,serif; margin-bottom:4px; }
.item-titlerow{ display:flex; align-items:center; gap:10px; margin-bottom:4px; }
.item-titlerow .item-title{ margin-bottom:0; }
.item-desc,.prose{ font-size:14.5px; line-height:1.6; color:var(--fg); margin:0; max-width:660px; }
.prose + .prose{ margin-top:10px; }
.prose strong{ font-weight:600; color:var(--fg); }

/* ---- Inline UI key ---- */
.kbd{ display:inline-block; padding:1px 6px; border-radius:var(--radius-sm); background:var(--bg-subtle); color:var(--fg); font-weight:600; border:1px solid var(--border); font-size:13.5px; white-space:nowrap; }

/* ---- Callout ---- */
.callout{ border:1px solid var(--border); background:var(--surface-2); border-radius:var(--radius); padding:13px 16px; max-width:660px; margin-top:14px; }
.callout-label{ font-family:"JetBrains Mono",monospace; font-size:10.5px; font-weight:600; letter-spacing:.11em; margin-bottom:6px; text-transform:uppercase; color:var(--fg-muted); }
.callout-body{ font-size:14px; line-height:1.55; color:var(--fg); }
.callout.tip{ border-color:var(--accent-soft); background:var(--accent-soft); }
.callout.tip .callout-label{ color:var(--accent-ink); }
.callout.tip .callout-body{ color:var(--accent-ink); }
.callout.warn{ border-color:var(--warning-soft); background:var(--warning-soft); }
.callout.warn .callout-label{ color:var(--warning-ink); }
.callout.warn .callout-body{ color:var(--warning-ink); }

/* ---- Action list ---- */
.action-list{ border:1px solid var(--border); border-radius:var(--radius-lg); overflow:hidden; max-width:680px; }
.action-row{ padding:13px 16px; border-bottom:1px solid var(--border); font-size:15px; line-height:1.55; color:var(--fg); }
.action-row:last-child{ border-bottom:0; }
.action-row strong{ font-weight:600; color:var(--fg); }

/* ---- Card grid ---- */
.card-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.card-grid.one-col{ grid-template-columns:1fr; max-width:680px; }
.card{ border:1px solid var(--border); border-radius:var(--radius-lg); padding:14px 16px; background:var(--surface-2); }
.card.span{ grid-column:1 / -1; }
.card-title{ font-size:15px; font-weight:600; font-family:Fraunces,Georgia,serif; color:var(--fg); margin-bottom:4px; }
.card-desc{ font-size:13.5px; line-height:1.55; color:var(--fg-muted); }

/* ---- Tag / dev badge ---- */
.tag{ font-family:"JetBrains Mono",monospace; font-size:9.5px; font-weight:600; letter-spacing:.08em; color:var(--fg-subtle); border:1px solid var(--border); border-radius:4px; padding:2px 6px; text-transform:uppercase; }

/* ---- Figure (скриншот) ---- */
.figure{ border:1px solid var(--border-strong); border-radius:var(--radius); overflow:hidden; background:var(--surface); margin:18px 0 0; cursor:zoom-in; }
.figure.narrow{ max-width:380px; margin-left:auto; margin-right:auto; }
.figure.mid{ max-width:480px; margin-left:auto; margin-right:auto; }
.figure-grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:14px; }
.figure-grid .figure{ margin-top:0; }
figcaption{ font-size:11.5px; color:var(--fg-subtle); margin-top:8px; }
figcaption .fig-num{ font-family:"JetBrains Mono",monospace; color:var(--fg-muted); font-weight:500; }

/* ---- Lightbox ---- */
.lightbox{ display:none; position:fixed; inset:0; z-index:90; background:rgba(10,9,6,.82); align-items:center; justify-content:center; padding:40px; cursor:zoom-out; }
.lightbox.is-open{ display:flex; }
.lightbox img{ max-width:94vw; max-height:90vh; border-radius:var(--radius); box-shadow:var(--shadow-lg); background:var(--surface); }
.lightbox-close{ position:absolute; top:22px; right:26px; width:38px; height:38px; border-radius:50%; background:rgba(255,255,255,.16); border:0; display:flex; align-items:center; justify-content:center; color:#fff; font-size:22px; line-height:1; cursor:pointer; }

/* ---- Density: compact ---- */
[data-density="compact"] .step{ margin-top:26px; padding-top:22px; }
[data-density="compact"] .step:first-of-type{ margin-top:30px; }
[data-density="compact"] .item{ padding:11px 0; }
[data-density="compact"] .action-row{ padding:11px 14px; }
[data-density="compact"] .card{ padding:12px 14px; }

/* ---- Progressive enhancement: показывать одну роль при включённом JS ---- */
.js .section{ display:none; }
.js .section.is-active{ display:block; }

[data-step]{ scroll-margin-top:78px; }
[hidden]{ display:none !important; }
.zoom-image{ display:block; width:100%; background:none; border:0; padding:0; cursor:zoom-in; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.search input:focus-visible{ outline-offset:0; }
.step-body ul,.step-body ol{ padding-left:1.5em; color:var(--fg-muted); }
.step-body li + li{ margin-top:6px; }

/* ---- Адаптив ---- */
@media (max-width:900px){
  .layout{ flex-direction:column; gap:0; }
  .sidebar{ position:static; width:100%; max-height:none; padding:16px 0 8px; }
  .js .sidebar{ display:none; }
  .js .sidebar.is-open{ display:block; }
  .nav-toggle{ display:inline-flex; align-items:center; }
  .topbar-inner{ flex-wrap:wrap; gap:6px 12px; height:auto; padding-top:7px; padding-bottom:8px; }
  .search{ flex-basis:100%; max-width:none; }
  [data-step]{ scroll-margin-top:112px; }
  .brand-sep{ display:none; }
  /* «Написать нам» на телефоне — только конверт: текст с nowrap уезжал за край */
  .topbar-write{ padding:0 10px; }
  .topbar-write .write-label{ display:none; }

  .main{ padding-top:20px; }
  .sec-title{ font-size:27px; }
}
@media (max-width:560px){
  .topbar-inner,.layout{ padding-left:16px; padding-right:16px; }
  .brand-section{ display:none; }
  .figure-grid,.card-grid{ grid-template-columns:1fr; }
  .step-body{ padding-left:0; }
  .step-num{ width:28px; height:28px; }
}
