:root {
  /* Кремовая тема: на ступень глубже их #faf9f5, чтобы меньше светила ночью */
  --bg: #f5f4ed;
  --card: #f0eee6;
  --chip: #e8e6dc;
  --line: #dedcd1;
  --ink: #1f1e1d;
  --muted: #5e5d59;
  --accent: #c6613f;
  --btn-bg: #141413;
  --btn-fg: #faf9f5;
  --field: rgba(31, 30, 29, .3);
  --error: #c8362a;
  --art-filter: none;
  /* Подвал тёмный в обеих темах */
  --foot-bg: #141413;
  --foot-fg: #e8e6dc;
  --foot-muted: #9c9a92;
  --foot-line: #3d3d3a;
  --focus: #2c84db;

  --sans: "Golos Text", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "PT Serif", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1e1d; --card: #262624; --chip: #30302e; --line: #3d3d3a;
    --ink: #e8e6dc; --muted: #b0aea5; --accent: #d97757;
    --btn-bg: #e8e6dc; --btn-fg: #1a1918; --field: rgba(232, 230, 220, .3); --error: #e87a6d;
    --art-filter: brightness(.82) saturate(.92);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1e1d; --card: #262624; --chip: #30302e; --line: #3d3d3a;
  --ink: #e8e6dc; --muted: #b0aea5; --accent: #d97757;
  --btn-bg: #e8e6dc; --btn-fg: #1a1918; --field: rgba(232, 230, 220, .3); --error: #e87a6d;
  --art-filter: brightness(.82) saturate(.92);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1.0625rem/1.6 var(--serif); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
body::before { content: ""; position: fixed; inset: 0 0 auto; z-index: 10; height: env(safe-area-inset-top, 0px); background: var(--bg); }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
section[id] { scroll-margin-top: 72px; }

:root { --g: clamp(16px, 8vw - 26px, 80px); }
.wrap { padding-left: max(var(--g), env(safe-area-inset-left, 0px)); padding-right: max(var(--g), env(safe-area-inset-right, 0px)); }
.in { max-width: max(1760px, 76vw); margin-inline: auto; }
.art { filter: var(--art-filter); }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
  font: 400 .8125rem/1.5 var(--sans); letter-spacing: .005em; text-decoration: none; cursor: pointer;
  padding: 5px 13px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink);
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 13px; height: 13px; flex: none; transition: transform .2s; }
a.btn:hover svg.go { transform: translateX(2px); }
a.btn:hover svg.up { transform: translate(1px, -1px); }
a.btn:hover svg.dn { transform: translateY(2px); }
.btn-main { background: var(--btn-bg); color: var(--btn-fg); font-weight: 500; }
.btn-main:hover { opacity: .86; }
.btn-soft { background: var(--chip); }
.btn-soft:hover { background: var(--line); }
.btn-line { border-color: var(--line); }
.btn-line:hover { background: var(--chip); }
.btn-wide { display: flex; width: 100%; }
.icon { width: 30px; height: 30px; padding: 0; color: var(--muted); }
.icon:hover { background: var(--chip); color: var(--ink); }
.icon svg { width: 16px; height: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.moon, .is-dark .sun { display: block; }
.sun, .is-dark .moon { display: none; }

/* Раскрывающийся блок */
.acc { border-block: 1px solid var(--line); }
.acc summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px; cursor: pointer; list-style: none; font: 500 .9375rem/1.4 var(--sans); }
.acc summary::-webkit-details-marker { display: none; }
.acc summary svg { width: 15px; height: 15px; flex: none; transition: rotate .2s; }
.acc[open] summary svg { rotate: 45deg; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn svg, .acc summary svg { transition: none; }
}

/* Шапка */
header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.bar { display: flex; align-items: center; gap: 8px; padding-block: 12px; }
.name { font: 600 1.0625rem/1 var(--sans); letter-spacing: -.01em; text-decoration: none; margin-right: auto; white-space: nowrap; }
.nav { display: flex; gap: 22px; margin-right: 14px; font: 400 .875rem/1.5 var(--sans); }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--ink); }
@media (max-width: 1080px) { .nav { display: none; } }

/* Подвал */
footer { background: var(--foot-bg); color: var(--foot-fg); margin-top: clamp(56px, 6vw, 96px); padding-block: clamp(48px, 5vw, 80px) 28px; }
.foot { display: grid; gap: 40px; }
@media (min-width: 900px) { .foot { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.ask { font: 600 clamp(1.875rem, 1.35rem + 1.8vw, 3.25rem)/1.08 var(--sans); letter-spacing: -.028em; max-width: 18em; text-wrap: balance; }
footer .row { margin-top: 24px; }
.btn-foot { background: var(--foot-fg); color: var(--foot-bg); font-weight: 500; }
.btn-foot:hover { opacity: .86; }
.btn-ghost { color: var(--foot-fg); border-color: var(--foot-line); }
.btn-ghost:hover { background: #30302e; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; font: 400 .875rem/1.5 var(--sans); }
.cols h3 { font: 400 .875rem/1.5 var(--sans); color: var(--foot-muted); margin-bottom: 10px; }
.cols ul { display: grid; gap: 8px; }
.cols a { text-decoration: none; }
.cols a:hover { text-decoration: underline; }
.legal { margin-top: clamp(40px, 5vw, 72px); padding-top: 18px; border-top: 1px solid var(--foot-line); font: 400 .8125rem/1.5 var(--sans); color: var(--foot-muted); }

/* Меню на весь экран */
#menu { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; padding-block: max(14px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-bottom, 0px)); }
.m-close { position: absolute; top: max(14px, env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); z-index: 1; }
.m-grid { min-height: 100%; display: grid; gap: 40px; max-width: 1760px; margin-inline: auto; }
.m-grid > * { min-width: 0; }
.m-art { display: none; }
.m-right { display: grid; gap: 32px; align-content: space-between; padding-top: 40px; }
.biglinks a { display: block; text-decoration: none; padding-block: 5px; font: 600 clamp(1.75rem, 1.5rem + 1vw, 2.25rem)/1.2 var(--sans); letter-spacing: -.02em; color: var(--muted); }
.biglinks a:hover { color: var(--ink); }
.m-acc .acc + .acc { border-top: 0; }
.m-acc .acc summary { font-weight: 400; font-size: .875rem; }
.m-acc ul { padding-bottom: 12px; display: grid; gap: 6px; font: 400 .9375rem/1.5 var(--sans); }
.m-acc a { text-decoration: none; color: var(--muted); }
.m-acc a:hover { color: var(--ink); }
.m-bottom { display: grid; gap: 24px; }
@media (min-width: 900px) {
  .m-grid { grid-template-columns: 1fr 1fr; gap: 64px; }
  .m-art { display: block; }
  .m-art img { width: 100%; max-height: calc(100vh - 40px); object-fit: cover; border-radius: 6px; }
}

@media (max-width: 560px) { .bar > .btn-main, .bar > .langs { display: none; } }

/* Переключатель языка */
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.langs a { font: 400 .75rem/1.5 var(--sans); padding: 4px 8px; text-decoration: none; color: var(--muted); }
.langs a:hover { color: var(--ink); }
.langs a[aria-current="true"] { background: var(--chip); color: var(--ink); }
.m-bottom .langs { justify-self: start; }

/* Значок в двух вариантах нити */
.only-dark, .is-dark .only-light { display: none; }
.is-dark .only-dark { display: block; }
.badge.art { filter: none; }

/* Пока текст переписывается, строки не перебалансируются на каждом кадре */
.rewriting * { text-wrap: wrap !important; }

/* Логотип: широкий гротеск заглавными, при прокрутке остаётся только число */
.name.mark { display: inline-flex; font: 600 clamp(1.0625rem, .92rem + .32vw, 1.3125rem)/1 "Sora", var(--sans); letter-spacing: .055em; }
.mk, .mk .mid { display: inline-flex; align-items: center; white-space: pre; }
.mk .fold { display: inline-block; overflow: hidden; }
.mark.ready .fold { max-width: var(--w, 16em); transition: max-width .55s cubic-bezier(.3, .7, .2, 1), opacity .3s ease .12s; }
.mark.small .fold { max-width: 0; opacity: 0; transition: max-width .55s cubic-bezier(.3, .7, .2, 1), opacity .16s ease; }
.mk .ox { color: var(--muted); display: inline-block; overflow: hidden; max-width: 2em; transition: max-width .25s ease, opacity .2s ease; }
.mk .ox.off { max-width: 0; opacity: 0; }
.mk .val { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .mark.ready .fold, .mark.small .fold, .mk .ox { transition: none; }
}

/* Выделение текста в цвете нашей бежевой нити */
::selection { background: #e3d3ae; color: #1b1918; }
