:root{
  --bg:#f6f4ef; --surface:#ffffff; --surface-2:#faf8f3; --text:#1f2328; --muted:#5f6670;
  --line:#ddd7ca; --accent:#7a4b1e; --accent-2:#a8692b; --accent-soft:#f3e8da;
  --new:#c0392b; --link:#1d4f91;
  --shadow:0 1px 2px rgba(60,40,20,.05),0 8px 24px rgba(60,40,20,.06);
  --on-accent:#fff; --badge-bg:#b0302a; --badge-fg:#fff; --hero-1:#7a4b1e; --hero-2:#3f250e;
  --fs:18px;
}
[data-theme="dark"]{
  --bg:#17150f; --surface:#1f1c17; --surface-2:#26221c; --text:#e8e6e1; --muted:#a9adb3;
  --line:#3a342b; --accent:#e0a868; --accent-2:#f0bd82; --accent-soft:#2c2620;
  --new:#ff8a7e; --link:#9cc0fa; --shadow:none;
  --on-accent:#1b1208; --badge-bg:#f2b8a0; --badge-fg:#3a0f08; --hero-1:#5a3716; --hero-2:#2a1a0b;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#17150f; --surface:#1f1c17; --surface-2:#26221c; --text:#e8e6e1; --muted:#a9adb3;
    --line:#3a342b; --accent:#e0a868; --accent-2:#f0bd82; --accent-soft:#2c2620;
    --new:#ff8a7e; --link:#9cc0fa; --shadow:none;
    --on-accent:#1b1208; --badge-bg:#f2b8a0; --badge-fg:#3a0f08; --hero-1:#5a3716; --hero-2:#2a1a0b;
  }
}
*{box-sizing:border-box}
html{font-size:var(--fs);scroll-behavior:smooth;scroll-padding-top:96px}
body{margin:0;background:var(--bg);color:var(--text);font:400 1rem/1.7 Inter,system-ui,sans-serif;transition:background .2s,color .2s}
a{color:var(--link);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3{font-family:"PT Serif",Georgia,serif;line-height:1.2;letter-spacing:-.005em;text-wrap:balance;margin:0 0 .5em}
p{margin:0 0 1em}
.wrap{max-width:1180px;margin:0 auto;padding:0 20px}
:focus-visible{outline:3px solid var(--link);outline-offset:2px;border-radius:6px}

/* Header */
header.top{background:var(--surface);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20}
.top-inner{display:flex;align-items:center;gap:16px;min-height:72px}
.brand{display:flex;align-items:center;gap:12px;color:var(--text);font-family:"PT Serif",serif;font-weight:700;font-size:1.4rem;letter-spacing:0;line-height:1.15}
.brand:hover{text-decoration:none}
.brand-mark{width:44px;height:44px;flex-shrink:0;border-radius:12px;background:linear-gradient(135deg,var(--hero-1),var(--hero-2));color:#fff;display:grid;place-items:center;box-shadow:inset 0 0 0 1px rgba(255,255,255,.12)}
[data-theme="dark"] .brand-mark{background:linear-gradient(135deg,#a8692b,#5a3716)}
.brand small{display:block;font:500 .85rem/1 Inter,sans-serif;color:var(--muted);letter-spacing:.02em;margin-top:4px}
.search{flex:1;max-width:360px;margin-left:auto;position:relative}
.search input{width:100%;padding:11px 14px 11px 40px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--text);font:inherit;font-size:1rem}
.search input::placeholder{color:var(--muted);opacity:1}
.search svg{position:absolute;left:13px;top:50%;transform:translateY(-50%);opacity:.7}
.search-results{position:absolute;top:calc(100% + 6px);left:0;right:0;background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow);display:none;max-height:320px;overflow:auto;z-index:5}
.search-results a{display:block;padding:10px 14px;font-size:1rem;color:var(--text);border-bottom:1px solid var(--line)}
.search-results a:last-child{border:0}
.search-results a:hover{background:var(--accent-soft);text-decoration:none}
.tools{display:flex;gap:6px}
.icon-btn{border:1px solid var(--line);background:var(--surface-2);color:var(--text);border-radius:10px;height:44px;min-width:44px;padding:0 10px;cursor:pointer;font:600 1rem Inter,sans-serif;display:inline-grid;place-items:center}
.icon-btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.icon-btn:hover{border-color:var(--accent);background:var(--accent-soft)}
.theme-moon{display:none}
[data-theme="dark"] .theme-sun{display:none}
[data-theme="dark"] .theme-moon{display:block}
.menu-btn,.drawer-close{display:none}

/* Layout */
.layout{display:grid;grid-template-columns:280px minmax(0,1fr);gap:32px;padding-block:28px 60px}
aside.side{position:sticky;top:96px;align-self:start;max-height:calc(100vh - 112px);overflow:auto;padding-right:4px;scrollbar-width:thin}
.nav-group{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:12px;margin-bottom:14px;box-shadow:none}
.nav-group h4{margin:2px 10px 8px;font:700 .8rem/1.2 Inter,sans-serif;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
.nav-group a{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;column-gap:8px;row-gap:2px;min-height:44px;padding:9px 12px;border-radius:9px;color:var(--text);font-size:1rem;line-height:1.35}
.nav-group a:hover{background:var(--accent-soft);text-decoration:none}
.nav-group a[aria-current="page"]{background:var(--accent-soft);color:var(--accent);font-weight:600;box-shadow:inset 3px 0 0 var(--accent)}
.nav-group a .meta{margin-left:auto;display:inline-flex;align-items:center;gap:6px;font-size:.8rem;color:var(--muted);white-space:nowrap}
.badge{display:inline-block;background:var(--badge-bg);color:var(--badge-fg);font:700 .7rem/1 Inter,sans-serif;padding:4px 7px;border-radius:6px;letter-spacing:.02em;vertical-align:middle}

/* Main */
main{min-width:0;scroll-margin-top:96px}
main p a,footer a{text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:.18em;text-decoration-color:color-mix(in srgb,var(--link) 45%,transparent)}
main p a:hover{text-decoration-color:currentColor}
.hero{background:linear-gradient(135deg,var(--hero-1),var(--hero-2));color:#fff;border-radius:20px;padding:clamp(28px,4vw,48px);margin-bottom:24px;position:relative;overflow:hidden;isolation:isolate}
.hero::after{content:"";position:absolute;right:-30px;bottom:-40px;width:300px;height:300px;z-index:-1;opacity:.09;
  background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%23fff' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 9C13.4 7.2 10.2 6.6 7 6.9V25M16 9c2.6-1.8 5.8-2.4 9-2.1V25M16 9v16'/%3E%3C/svg%3E") center/contain no-repeat}
.hero h1{font-size:clamp(1.75rem,1.2rem + 2.2vw,2.5rem);margin-bottom:.35em}
.hero p{font-size:1.15rem;color:#f3e8da;max-width:68ch;margin:0 0 1.2em}
.hero :focus-visible{outline-color:#fff}
.hero .cta{display:flex;flex-wrap:wrap;gap:10px}
.btn{display:inline-flex;align-items:center;gap:8px;min-height:48px;padding:12px 22px;border-radius:12px;font-weight:600;font-size:1rem;border:1px solid transparent}
.btn:hover{text-decoration:none;filter:brightness(1.05)}
.btn-light{background:#fff;color:#3f250e}
.btn-ghost{border-color:rgba(255,255,255,.6);color:#fff}
.btn-ghost:hover{background:rgba(255,255,255,.1)}
.btn-accent{background:var(--accent);color:var(--on-accent)}

.card{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:clamp(20px,3vw,32px);margin-bottom:24px;box-shadow:var(--shadow)}
.card h2{font-size:1.6rem;margin-bottom:.75em;display:flex;align-items:center;gap:12px}
.card h2 .ico{width:40px;height:40px;border-radius:10px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;flex-shrink:0}
.card h2 .ico svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.card p{max-width:68ch}
.card h3,.sub-h{font-size:1.2rem;margin:0 0 .4em}
.sub-h .muted{font:400 .85rem Inter,sans-serif}
.muted{color:var(--muted)}

.quick .d{font-size:.85rem;color:var(--muted)}

.pillars{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px;margin-top:10px}
.pillar{background:var(--surface-2);border:1px solid var(--line);border-radius:12px;padding:16px 18px;font-size:1rem;line-height:1.5;display:flex;gap:12px;align-items:flex-start}
.pillar b{flex:0 0 32px;height:32px;border-radius:50%;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font-family:"PT Serif",serif;font-size:1.05rem}

.quick{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.quick a{display:block;position:relative;background:var(--surface-2);border:1px solid var(--line);border-radius:14px;padding:20px;color:var(--text);transition:transform .15s,border-color .15s}
.quick a::after{content:"→";position:absolute;right:18px;top:18px;color:var(--accent);transition:transform .15s}
.quick a:hover{text-decoration:none;transform:translateY(-2px);border-color:var(--accent)}
.quick a:hover::after{transform:translateX(3px)}
.quick .t{font-weight:700;font-family:"PT Serif",serif;font-size:1.1rem;display:block;margin-bottom:4px;padding-right:24px}

blockquote{margin:22px 0;padding:18px 24px;border-left:4px solid var(--accent);background:var(--accent-soft);border-radius:0 10px 10px 0;font-family:"PT Serif",serif;font-size:1.2rem}

.contact{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:16px}
.contact h2{margin-bottom:.2em}

footer{border-top:1px solid var(--line);background:var(--surface);padding:26px 0;font-size:.95rem;color:var(--muted)}
footer .wrap{display:flex;flex-wrap:wrap;justify-content:space-between;gap:12px}

.to-top{position:fixed;right:16px;bottom:16px;width:52px;height:52px;border-radius:50%;border:0;background:var(--accent);color:var(--on-accent);font-size:22px;cursor:pointer;box-shadow:0 4px 14px rgba(0,0,0,.2);opacity:0;pointer-events:none;transition:opacity .2s;z-index:10}
.to-top.show{opacity:1;pointer-events:auto}

@media (max-width:960px){
  .top-inner{flex-wrap:wrap;padding-top:10px;padding-bottom:10px;row-gap:10px}
  .tools{margin-left:auto}
  .search{display:block;order:5;flex:1 0 100%;max-width:none;margin:0}
  .layout{grid-template-columns:1fr}
  /* Меню всегда на странице (без выдвижной шторки): на узком экране — блоком над содержимым */
  aside.side{position:static;max-height:none;overflow:visible;padding:0}
  .quick{grid-template-columns:1fr}
}
@media (max-width:960px) and (min-width:561px){.quick{grid-template-columns:1fr 1fr}}
@media (max-width:560px){
  .wrap{padding:0 16px}
  .top-inner{gap:8px}
  .brand{font-size:1.05rem;gap:8px;flex:1;min-width:0}
  .brand-mark{width:38px;height:38px}
  .brand small{display:none}
  .tools{gap:4px}
  #fontMinus{display:none}
}
@media (prefers-reduced-motion:reduce){*{transition:none!important;scroll-behavior:auto!important}.quick a:hover{transform:none}}
.hero-sm{padding:clamp(22px,3vw,34px)}.hero-sm h1{margin-bottom:.2em}.hero-sm p{margin:0}

.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

.icon-btn.signin{padding:0 16px;font-weight:700;background:var(--accent);color:var(--on-accent);border-color:var(--accent);text-decoration:none}.icon-btn.signin:hover{filter:brightness(1.08);background:var(--accent)}

/* Внутренние страницы на узком экране: меню свёрнуто, а статьи видны сразу */
.menu-toggle{display:none}
@media (max-width:960px){
  body.inner .menu-toggle{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:48px;padding:10px 16px;margin-bottom:12px;border:1px solid var(--line);border-radius:12px;background:var(--surface);color:var(--text);font:600 1rem Inter,sans-serif;cursor:pointer;text-align:left}
  body.inner .menu-toggle::after{content:"▾";font-size:1.1rem;color:var(--accent)}
  body.inner aside.side.open .menu-toggle::after{content:"▴"}
  body.inner aside.side .nav-group{display:none}
  body.inner aside.side.open .nav-group{display:block}
}
/* длинные слова без пробелов переносятся, а не растягивают страницу */
.card h1,.card h2,.card h3,.card p,.theme{overflow-wrap:anywhere}

/* Телефон: название в две строки, кнопка A− снова видна */
@media (max-width:560px){
  #fontMinus{display:inline-grid}
  .brand > span:last-child{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.15}
}
/* Когда внизу панель редактора — оставляем место и поднимаем кнопку «наверх» */
body.has-ed-bar{padding-bottom:84px}
body.has-ed-bar .to-top{bottom:84px}

/* Телефон: название — в первой строке целиком, кнопки — во второй; шапка не липнет и не занимает экран */
@media (max-width:560px){
  .brand{flex:1 1 100%}
  .brand > span:last-child{-webkit-line-clamp:3}
  .tools{width:100%;justify-content:flex-end;margin-left:0}
  header.top{position:static}
}

.lang-sel{height:44px;padding:0 10px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--text);font:700 .9rem Inter,sans-serif;cursor:pointer}
.lang-sel:hover{border-color:var(--accent)}
