/* Общие стили сайта. Цвета, шрифты и размеры берутся только из css/tokens.css.
   Порядок: основа, шапка и подвал, кнопки и чипы, поля, карточка, библиотека,
   страница истории, окна и уведомления, профиль и настройки, служебное. */

/* ---------- Основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body) / var(--lh-body) var(--font);
  font-synthesis: none;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}
main { flex: 1; display: block; }
h1, h2, h3, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
::selection { background: var(--brand); color: var(--on-brand); }

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
/* Сетка в 12 колонок: внутри .container. Колонки равные, зазор --gap. Блок занимает колонки через grid-column.
   Уже 768 колонка одна */
.cols { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); column-gap: var(--gap); }
@media (max-width: 767px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 16px; top: -80px; z-index: 600;
  padding: 12px 20px; border-radius: var(--r-pill);
  background: var(--ink); color: var(--bg);
}
.skip:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); line-height: 1.5; }
.caps { text-transform: uppercase; }
.num { font-variant-numeric: tabular-nums; }
.link { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { text-decoration-thickness: 2px; }
.stack > * + * { margin-top: var(--stack, 16px); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--row, 12px); }
.icon { width: 1.3em; height: 1.3em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Шапка ---------- */
.header {
  position: sticky; top: 0; z-index: var(--z-header);
  background: var(--panel);
}
.header__in {
  height: var(--header-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--gap);
}
.nav { justify-self: center; }
/* Уже 1100 меню «Библиотека» и «Поддержка» в шапке не помещается рядом с кнопками и прячется */
@media (max-width: 1099px) {
  .header__in { grid-template-columns: minmax(0, 1fr) auto; }
  .header .nav { display: none; }
}
.header__left { display: flex; align-items: center; gap: var(--header-gap); min-width: 0; }
.logo {
  font-weight: 700; font-size: var(--header-logo); line-height: 1.1;
  letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.nav { display: flex; gap: var(--nav-gap); }
/* Ссылка всегда 44 в высоту: строка текста и поровну сверху и снизу. Линия стоит под строкой текста */
.nav a {
  position: relative; display: block; padding: calc((44px - var(--lh-header)) / 2) 0;
  text-transform: uppercase; font-size: var(--fs-header); line-height: var(--lh-header);
  font-weight: var(--fw-header); letter-spacing: 0;
}
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; height: var(--header-line-w);
  bottom: calc((44px - var(--lh-header)) / 2 - var(--header-line-gap) - var(--header-line-w));
  background: var(--header-line);
}
/* Кнопки в шапке на компьютере и ноутбуке: на 1920 по 15 от текста сверху и снизу и по 48 по бокам, 60 в высоту.
   «Войти» с рамкой цвета главной кнопки */
@media (min-width: 768px) {
  .header .btn {
    min-height: 0; height: calc(var(--lh-header) + var(--header-pad) * 2); padding: 0 var(--header-btn-x);
    font-size: var(--fs-header); line-height: var(--lh-header);
    font-weight: var(--fw-header); letter-spacing: 0;
  }
  .header .btn--line { border-color: var(--brand); }
}
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .header .btn--line:not([disabled]):hover { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
}
.header__right { display: flex; align-items: center; justify-content: flex-end; gap: clamp(4px, 1.4vw, 24px); }
.counter {
  position: relative; display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
}
.counter .icon { width: 30px; height: 30px; stroke-width: 1.5; }
.counter__n {
  position: absolute; top: 2px; right: -2px;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--ink); color: var(--bg);
  font-size: 13px; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}
.counter__n:empty { display: none; }
.ava {
  --s: 48px;
  width: var(--s); height: var(--s); flex: none; border-radius: 50%;
  display: inline-grid; place-items: center; overflow: hidden;
  background: var(--brand); color: var(--on-brand);
  font-weight: 700; font-size: calc(var(--s) * 0.42); line-height: 1; text-transform: uppercase;
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava--s { --s: 36px; }
.ava--l { --s: 120px; }
.usermenu { position: relative; }
.usermenu__btn { padding: 0; border: 0; background: none; border-radius: 50%; display: block; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: var(--z-sticky);
  min-width: 230px; padding: 8px; border-radius: var(--r-box);
  background: var(--surface); box-shadow: 0 12px 32px rgba(23, 20, 18, 0.16);
  transform-origin: top right;
  transition: opacity var(--t-pop) var(--ease-out), transform var(--t-pop) var(--ease-out);
}
.menu[hidden] { display: block !important; opacity: 0; transform: scale(0.96); visibility: hidden; pointer-events: none; transition-duration: 130ms; }
.menu a, .menu button {
  display: flex; align-items: center; width: 100%; min-height: 48px; padding: 8px 16px;
  border: 0; background: none; border-radius: 10px; text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--panel); }

/* Нижняя панель на телефоне */
.tabbar { display: none; }
@media (max-width: 767px) {
  .header__in { grid-template-columns: minmax(0, 1fr) auto; }
  .header .nav, .header .header__write, .header .counter { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-header);
    display: grid; grid-template-columns: repeat(3, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--panel); border-top: 1px solid var(--line-soft);
  }
  .tabbar a, .tabbar button {
    display: grid; place-items: center; align-content: center; gap: 2px;
    border: 0; background: none; font-size: 12px; line-height: 1.2; color: var(--muted);
  }
  .tabbar .icon { width: 26px; height: 26px; }
  .tabbar [aria-current="page"] { color: var(--ink); font-weight: 700; }
}

/* ---------- Подвал ---------- */
.footer { margin-top: 96px; padding-block: 56px 40px; background: var(--panel); font-size: var(--fs-small); line-height: 1.5; }
.footer__in { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.3fr; gap: 32px var(--gap); }
.footer h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); font-weight: 400; margin-bottom: 16px; }
.footer li + li { margin-top: 10px; }
.footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.footer__about { font-size: var(--fs-body); margin-top: 12px; }
.footer__legal { grid-column: 1 / -1; display: grid; grid-template-columns: 1.5fr 2fr 1.3fr; gap: 12px var(--gap); margin-top: 24px; color: var(--muted); }
@media (max-width: 1023px) {
  .footer { margin-top: 64px; padding-block: 40px 32px; }
  .footer__in { grid-template-columns: 1fr 1fr; }
  .footer__brand { grid-column: 1 / -1; }
  .footer__legal { grid-template-columns: 1fr; }
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--ctl); padding: 0 clamp(20px, 2.6vw, 48px);
  border: 1.5px solid transparent; border-radius: var(--r-pill);
  background: none; color: var(--ink); white-space: nowrap; text-align: center;
  transition: transform var(--t-press) var(--ease-out), background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn--brand { background: var(--brand); color: var(--on-brand); }
.btn--line { border-color: var(--ink); }
.btn--quiet { padding-inline: 12px; min-height: var(--ctl-small); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.btn--small { min-height: var(--ctl-small); padding-inline: 20px; font-size: var(--fs-small); }
.btn--block { width: 100%; white-space: normal; }
.btn--two { flex-direction: column; gap: 0; padding-block: 8px; line-height: 1.25; }
.btn--two small { font-size: var(--fs-small); opacity: 0.85; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy::after {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-on { background: var(--panel); border-color: var(--panel); color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .btn--brand:not([disabled]):hover { background: var(--brand-strong); }
  .btn--line:not([disabled]):hover { background: var(--ink); color: var(--bg); }
  .btn.is-on:hover { background: var(--panel-strong); border-color: var(--panel-strong); color: var(--ink); }
  .counter:hover, .iconbtn:hover { background: rgba(23, 20, 18, 0.07); }
}
.iconbtn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; flex: none;
  padding: 0; border: 0; border-radius: 50%; background: none;
  transition: transform var(--t-press) var(--ease-out), background-color 160ms ease;
}
.iconbtn:active { transform: scale(0.94); }
.iconbtn .icon { width: 28px; height: 28px; }

/* ---------- Чипы ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--ctl-small); padding: 4px 16px; border: 0; border-radius: var(--r-pill);
  background: var(--panel); font-size: var(--fs-small); line-height: 1.3;
}
.chip b { font-weight: 400; color: var(--muted); }
.chip__x { display: grid; place-items: center; width: 28px; height: 28px; margin-right: -8px; padding: 0; border: 0; border-radius: 50%; background: none; }
.chip__x .icon { width: 16px; height: 16px; stroke-width: 2; }
.chip__x:hover { background: var(--panel-strong); }
.chip--glass { background: var(--glass-light); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.chip--dark { background: rgba(30, 22, 17, 0.6); color: #fff; }
.tag-good { color: var(--good); font-weight: 700; }

/* ---------- Поля ---------- */
.field { display: block; }
.field__label { display: block; margin-bottom: 8px; font-weight: 700; }
.field__opt { font-weight: 400; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; min-height: var(--ctl); padding: 12px 20px;
  border: 1px solid var(--line); border-radius: var(--r-box);
  background: var(--surface); font-size: max(16px, var(--fs-body)); line-height: 1.4;
  transition: border-color 160ms ease;
}
.textarea { min-height: 132px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { outline-offset: 1px; }
.field__note { display: block; min-height: 1.5em; margin-top: 6px; font-size: var(--fs-small); line-height: 1.5; color: var(--muted); }
.field.is-bad .input, .field.is-bad .textarea, .field.is-bad .select { border-color: var(--bad); }
.field.is-bad .field__note { color: var(--bad); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: var(--fs-small); line-height: 1.5; }
.check input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--brand); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding-block: 8px; border-bottom: 1px solid var(--line-soft); }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 52px; height: 30px; margin: 0; border-radius: 15px; background: var(--line); cursor: pointer;
  transition: background-color 160ms ease;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform 180ms var(--ease-out);
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(22px); }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; min-height: var(--ctl-small); padding: 4px 20px; border-radius: var(--r-pill); background: var(--panel); transition: background-color 160ms ease, color 160ms ease; }
.segmented input:checked + span { background: var(--brand); color: var(--on-brand); }
.segmented input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.code { display: flex; gap: clamp(6px, 1.4vw, 12px); }
.code input {
  width: 100%; max-width: 64px; height: 72px; padding: 0; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-box); background: var(--surface);
  font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.code.is-bad input { border-color: var(--bad); }

/* ---------- Строка поиска и фильтры ---------- */
.search { position: relative; flex: 1 1 320px; min-width: 0; }
.search input {
  width: 100%; height: var(--ctl); padding: 0 56px 0 24px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: transparent;
  font-size: max(16px, var(--fs-body));
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search .icon { position: absolute; right: 20px; top: 50%; width: 26px; height: 26px; margin-top: -13px; pointer-events: none; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px clamp(12px, 2vw, 40px); }
/* Фильтр со списком и поиском внутри: кнопка выглядит как .pick, название на ней не меняется (js/app.js, функция combo) */
.combo { position: relative; }
.combo__btn { color: var(--ink); text-align: left; white-space: nowrap; }
.combo__panel {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: var(--z-sticky);
  width: max-content; min-width: 260px; max-width: min(340px, calc(100vw - 32px)); padding: 8px;
  border-radius: var(--r-box); background: var(--surface); box-shadow: 0 12px 32px rgba(23, 20, 18, 0.16);
}
.combo__panel[hidden] { display: none; }
.combo__search {
  width: 100%; height: var(--ctl-small); padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: transparent; font-size: max(16px, var(--fs-body));
}
.combo__search::placeholder { color: var(--muted); opacity: 1; }
.combo__search::-webkit-search-cancel-button { display: none; }
.combo__list { max-height: 264px; overflow-y: auto; margin: 8px 0 0; padding: 0; list-style: none; }
.combo__list [role="option"] { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.combo__list [role="option"].is-active, .combo__list [role="option"]:hover { background: var(--panel); }
.combo__list [role="option"][aria-selected="true"] { font-weight: 700; }
.combo__empty { padding: 12px; color: var(--muted); }
.pick {
  appearance: none; -webkit-appearance: none;
  field-sizing: content;
  height: var(--ctl-small); max-width: 240px; padding: 0 28px 0 4px; border: 0; border-radius: 8px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 8' fill='none' stroke='%23171412' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 4px center / 14px 8px;
  font-size: max(16px, var(--fs-body)); text-overflow: ellipsis; cursor: pointer;
}
/* От 1024: текст поиска и фильтров в стиле «Основной шрифт_ноутбук» (на ноутбуке 16/150%), поле поиска с отступами кнопки: сверху, снизу и слева как у кнопок шапки (12 на ноутбуке) */
@media (min-width: 1024px) {
  .finder .search input, .finder .pick, .finder .combo__panel, .finder .combo__search, .chips .chip, .chips .btn--quiet {
    font-family: var(--font); font-size: var(--fs-header); line-height: var(--lh-header);
    font-weight: var(--fw-header); letter-spacing: var(--main-laptop-ls); color: var(--main-laptop-color);
  }
  .finder .search input {
    height: calc(var(--lh-header) + var(--header-pad) * 2);
    padding: var(--header-pad) 56px var(--header-pad) var(--header-pad);
  }
  .finder .combo__search { height: calc(var(--lh-header) + var(--header-pad) * 2); padding: var(--header-pad); }
  /* Плашки выбранных фильтров и «Сбросить»: отступы внутри со всех сторон как у кнопок шапки (12 на ноутбуке) */
  .chips .chip { min-height: 0; padding: var(--header-pad); gap: var(--header-pad); }
  .chips .chip b { font-weight: inherit; }
  .chips .chip__x { position: relative; width: 16px; height: 16px; margin: 0; border-radius: 4px; }
  .chips .chip__x::after { content: ""; position: absolute; inset: -16px; } /* зона нажатия 48 на 48 */
  .chips .btn--quiet { min-height: 0; padding: var(--header-pad); border: 0; }
}
/* Рамка 1,5: браузеры округляют border до целых пикселей, поэтому рисуем её внутренней тенью */
@media (min-width: 1024px) and (max-width: 1599px) {
  .finder .search input, .finder .combo__search { border-color: transparent; box-shadow: inset 0 0 0 var(--field-border-laptop) var(--line); }
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.sort { display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: var(--panel); }
.sort button { min-height: 40px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: none; font-size: var(--fs-small); transition: background-color 160ms ease, color 160ms ease; }
.sort button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }

/* ---------- Карточка истории ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px var(--gap); }
@media (max-width: 1199px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .grid { grid-template-columns: minmax(0, 1fr); gap: 32px; } }
.card { position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card__author { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; min-height: 44px; padding-right: 8px; border-radius: var(--r-pill); }
.card__link {
  --bite: 34px; --bite-c: 28px;
  position: relative; display: block; aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: var(--r-card); background: var(--panel-strong); color: #fff;
  -webkit-mask: radial-gradient(circle var(--bite) at calc(100% - var(--bite-c)) var(--bite-c), transparent calc(var(--bite) - 0.6px), #000 var(--bite));
  mask: radial-gradient(circle var(--bite) at calc(100% - var(--bite-c)) var(--bite-c), transparent calc(var(--bite) - 0.6px), #000 var(--bite));
}
.card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 600ms var(--ease-out); }
.card__link::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(23, 20, 18, 0.62) 0%, rgba(23, 20, 18, 0) 34%, rgba(23, 20, 18, 0) 52%, rgba(23, 20, 18, 0.5) 100%);
}
.card__top, .card__bottom { position: absolute; left: 0; right: 0; z-index: 2; padding: clamp(14px, 1.3vw, 24px); }
.card__top { top: 0; padding-right: 76px; }
.card__title { display: block; font-size: var(--fs-card); line-height: 1.15; text-transform: uppercase; text-wrap: balance; overflow-wrap: anywhere; }
.card__work { display: block; margin-top: 6px; }
.card__bottom { bottom: 0; display: flex; flex-direction: column; gap: 12px; }
.card__heroes, .card__tags { display: flex; flex-wrap: wrap; gap: 8px; }
.card__panel { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 16px; border-radius: calc(var(--r-card) - 8px); background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.card__text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; line-height: 1.45; }
.card__frame { position: relative; }
.card__badge {
  position: absolute; top: 0; right: 0; z-index: 3;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: var(--brand); color: var(--on-brand); line-height: 1; pointer-events: none;
}
.card__badge b { font-size: 20px; font-variant-numeric: tabular-nums; }
.card__badge i { font-style: normal; font-size: 12px; margin-top: 2px; }
.card__meta { display: flex; align-items: center; gap: 20px; min-height: 32px; }
.count { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.count .icon { width: 28px; height: 28px; stroke-width: 1.5; }
.card.is-off .card__link { filter: grayscale(1); opacity: 0.6; }
@media (hover: hover) and (pointer: fine) {
  .card__link:hover .card__img { transform: scale(1.03); }
  .card__author:hover { text-decoration: underline; text-underline-offset: 3px; }
}
@media (max-width: 767px) { .card__text { -webkit-line-clamp: 3; } }

/* Строка «Продолжить чтение» */
.resume { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.resume__item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; align-items: center; padding: 12px; border-radius: var(--r-card); background: var(--panel); }
.resume__item img { width: 96px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; }
.resume__title { font-weight: 700; text-transform: uppercase; line-height: 1.2; overflow-wrap: anywhere; }
.bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar i { display: block; height: 100%; width: calc(var(--v, 0) * 1%); border-radius: 3px; background: var(--brand); }
@media (max-width: 1199px) { .resume { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Библиотека: первый экран ---------- */
/* Баннер с видео под шапкой: видео на всю ширину. Плашка с размытием фона (Background blur) стоит на сетке:
   текст в колонках 9-12 на компьютере и ноутбуке, 7-12 на планшете, во всю ширину на телефоне.
   Размытая подложка выходит влево на зазор и вправо до края экрана */
.banner { position: relative; height: var(--banner-h); overflow: hidden; background: var(--panel-strong); }
.banner__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.banner__in { position: relative; height: 100%; grid-template-rows: auto 1fr; }
.banner__panel { position: relative; isolation: isolate; grid-column: 9 / -1; grid-row: 1; padding: 16px 0 24px; color: var(--on-brand); }
.banner__panel::before {
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: calc(var(--gap) * -1); right: -100vw;
  background: var(--banner-glass); border-radius: 0 0 0 var(--r-card);
  -webkit-backdrop-filter: blur(var(--banner-blur)); backdrop-filter: blur(var(--banner-blur));
}
.banner__title { font-family: var(--title-laptop-font); font-weight: var(--title-laptop-weight); font-size: var(--fs-banner); line-height: var(--title-laptop-lh); letter-spacing: var(--title-laptop-ls); color: var(--title-laptop-color); }
.banner__text { margin-top: 12px; font-family: var(--font); font-size: var(--main-laptop-size); line-height: var(--main-laptop-lh); font-weight: var(--main-laptop-weight); letter-spacing: var(--main-laptop-ls); color: var(--on-brand); }
.banner__toggle {
  grid-column: -2 / -1; grid-row: 2; justify-self: end; align-self: end; margin-bottom: 16px;
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r-pill); cursor: pointer;
  color: var(--on-brand); background: var(--banner-btn-glass);
  -webkit-backdrop-filter: blur(var(--banner-blur)); backdrop-filter: blur(var(--banner-blur));
}
@media (max-width: 1023px) { .banner__panel { grid-column: 7 / -1; } }
@media (max-width: 767px) {
  .banner__panel { grid-column: 1 / -1; }
  .banner__panel::before { left: calc(var(--gutter) * -1); border-radius: 0; }
  .banner__title { font-size: 26px; }
  .banner__text { font-size: var(--fs-small); line-height: 1.5; }
}

.hero { padding-block: clamp(32px, 4.6vw, 88px) clamp(24px, 3.4vw, 64px); text-align: center; }
.hero__eyebrow { text-transform: uppercase; }
.hero h1 { margin-top: 8px; font-size: var(--fs-hero); line-height: 1.15; font-weight: 400; text-transform: uppercase; text-wrap: balance; }
.hero__lead { margin-top: 12px; color: var(--muted); text-wrap: balance; }
.finder { display: flex; flex-wrap: wrap; align-items: center; gap: 12px clamp(16px, 2.4vw, 46px); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: var(--ctl-small); }
.section { margin-top: clamp(32px, 3.4vw, 56px); }
#resume:not([hidden]), #resume[hidden] + .section { margin-top: var(--banner-gap); } /* первый видимый блок под баннером */
.section__title { font-size: var(--fs-h2); line-height: var(--lh-tight); font-weight: 700; margin-bottom: 20px; }
.more { display: flex; justify-content: center; margin-top: 48px; }
.empty { max-width: 560px; margin: 48px auto; text-align: center; }
.empty h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); }
.empty p { margin-top: 8px; color: var(--muted); }
.empty .btn { margin-top: 24px; }

/* ---------- Страница истории: верх ---------- */
.story-top { display: grid; grid-template-columns: minmax(0, 553fr) minmax(0, 956fr); gap: clamp(24px, 8.9vw, 171px); padding-top: clamp(20px, 2.4vw, 46px); align-items: start; }
.cover { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border-radius: var(--r-card); background: var(--panel-strong); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover__likes { position: absolute; right: 16px; bottom: 16px; display: inline-flex; align-items: center; gap: 14px; min-height: 48px; padding: 4px 18px; border-radius: var(--r-pill); background: var(--bg); }
.back { margin-left: -12px; }
.title { font-size: var(--fs-title); line-height: 1.15; font-weight: 700; text-transform: uppercase; text-wrap: balance; overflow-wrap: anywhere; }
.story-info > * + * { margin-top: 28px; }
.story-info .title { margin-top: 12px; }
.story-info .title + p { margin-top: 2px; }
.byline { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; border-radius: var(--r-pill); padding-right: 8px; }
.byline:hover { text-decoration: underline; text-underline-offset: 3px; }
.label { font-weight: 700; margin-bottom: 10px; }
.prose > * + * { margin-top: 0.6em; }
.heroes { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-card { width: clamp(132px, 11.8vw, 225px); padding: 0; border: 0; background: none; text-align: left; border-radius: var(--r-card); }
.hero-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-card); background: var(--panel-strong); transition: transform 500ms var(--ease-out); }
.hero-card b { display: block; margin-top: 10px; line-height: 1.25; }
.hero-card span { display: block; font-size: var(--fs-small); line-height: 1.4; }
.hero-card__pic { display: block; overflow: hidden; border-radius: var(--r-card); }
@media (hover: hover) and (pointer: fine) { .hero-card:hover img { transform: scale(1.04); } }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
@media (max-width: 1023px) {
  .story-top { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .story-info { display: contents; }
  .story-top .back { order: -2; margin-bottom: 8px; }
  .story-top .cover { order: -1; max-width: 420px; margin-bottom: 20px; }
}

/* ---------- Чтение ---------- */
.progress { position: fixed; left: 0; right: 0; top: var(--header-h); z-index: var(--z-header); height: 4px; pointer-events: none; opacity: 0; transition: opacity 200ms ease; }
.progress.is-on { opacity: 1; }
.progress i { display: block; height: 100%; background: var(--brand); transform-origin: left; transform: scaleX(var(--p, 0)); }
.reader { margin-top: clamp(48px, 5vw, 96px); }
.reader__title { font-size: var(--fs-title); line-height: 1.15; font-weight: 700; text-transform: uppercase; margin-bottom: 24px; }
.reader__cols { display: grid; grid-template-columns: minmax(0, 956fr) minmax(0, 694fr); gap: clamp(20px, 1.6vw, 30px); align-items: start; }
.reader__text { max-width: var(--measure); }
.chapter { font-size: var(--fs-h2); line-height: var(--lh-tight); font-weight: 700; margin: 2.2em 0 0.9em; scroll-margin-top: calc(var(--header-h) + 24px); }
.chapter:first-child { margin-top: 0; }
.part { scroll-margin-top: calc(var(--header-h) + 24px); }
.part + .part { margin-top: 1.4em; }
.part p + p { margin-top: 0.7em; }
.part p { overflow-wrap: break-word; text-wrap: pretty; }
@media (max-width: 480px) { .part p { hyphens: auto; } }
.part__img { display: none; margin-bottom: 20px; }
.part__img img, .art img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-card); background: var(--panel-strong); }
.art { position: sticky; top: var(--header-h); height: calc(100dvh - var(--header-h)); display: grid; align-items: center; }
.art__frame { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: calc(100dvh - var(--header-h) - 48px); margin-inline: auto; }
.art__frame img { position: absolute; inset: 0; height: 100%; opacity: 0; transition: opacity var(--t-art) ease, filter var(--t-art) ease; filter: blur(6px); outline: 1px solid rgba(0, 0, 0, 0.08); outline-offset: -1px; }
.art__frame img.is-on { opacity: 1; filter: blur(0); }
.endmark { display: flex; align-items: center; gap: 16px; margin-top: 3em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--fs-small); }
.endmark::before, .endmark::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
@media (max-width: 1023px) {
  .reader__cols { grid-template-columns: minmax(0, 1fr); }
  .art { display: none; }
  .part__img { display: block; }
  .reader__text { max-width: none; }
}

/* Граница бесплатной части */
.paywall { margin-top: 2.2em; }
.paywall__peek { position: relative; max-height: 7.2em; overflow: hidden; -webkit-mask: linear-gradient(#000 10%, transparent 96%); mask: linear-gradient(#000 10%, transparent 96%); }
.paywall__box { margin-top: 8px; padding: clamp(20px, 2.2vw, 40px); border-radius: var(--r-card); background: var(--panel); }
.paywall__box h3 { font-size: var(--fs-h2); line-height: var(--lh-tight); }
.paywall__box p { margin-top: 8px; }
.paywall__box .btn { margin-top: 20px; }

/* После текста */
.after { max-width: 1116px; margin: clamp(48px, 5vw, 96px) auto 0; }
.after__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 16px; }
.likebtn .icon { transition: transform 240ms var(--ease-out); }
.likebtn.is-on .icon { fill: var(--like); stroke: var(--like); }
.likebtn.is-pop .icon { transform: scale(1.22); }
.authorbox { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 32px; padding: 20px 24px; border-radius: var(--r-card); background: var(--panel); }
.authorbox__name { flex: 1; min-width: 160px; }
.comments { margin-top: 48px; }
.comment-form { display: flex; align-items: flex-end; gap: 12px; padding: 8px 8px 8px 24px; border: 1px solid var(--line); border-radius: 30px; }
.comment-form textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 240px; padding: 8px 0; border: 0; background: none; resize: none; font-size: max(16px, var(--fs-body)); line-height: 1.5; outline: none; }
.comment-form:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.comment { margin-top: 28px; }
.comment__head { display: flex; align-items: center; gap: 12px; }
.comment__body { margin-top: 8px; white-space: pre-line; overflow-wrap: anywhere; }
.comment__acts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; margin-left: -12px; }
.comment--reply { margin-left: clamp(24px, 5vw, 66px); }
.locked { padding: clamp(20px, 2.2vw, 40px); border-radius: var(--r-card); background: var(--panel); text-align: center; }
.locked .btn { margin-top: 16px; }

/* ---------- Окно поверх страницы ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: min(92dvh, 860px); padding: 0; border: 0;
  border-radius: var(--r-card); background: var(--surface); color: var(--ink);
  overflow: auto; overscroll-behavior: contain;
  opacity: 0; transform: scale(0.96) translateY(8px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), overlay 180ms allow-discrete, display 180ms allow-discrete;
}
.dialog[open] { opacity: 1; transform: none; transition-duration: var(--t-dialog); }
@starting-style { .dialog[open] { opacity: 0; transform: scale(0.96) translateY(8px); } }
.dialog::backdrop { background: var(--veil); opacity: 0; transition: opacity 180ms ease, overlay 180ms allow-discrete, display 180ms allow-discrete; }
.dialog[open]::backdrop { opacity: 1; transition-duration: var(--t-dialog); }
@starting-style { .dialog[open]::backdrop { opacity: 0; } }
.dialog--wide { width: min(760px, calc(100vw - 24px)); }
.dialog__in { position: relative; padding: clamp(24px, 3vw, 44px); }
.dialog__close { position: absolute; top: 12px; right: 12px; }
.dialog h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); padding-right: 44px; text-wrap: balance; }
.dialog__lead { margin-top: 8px; color: var(--muted); }
.dialog__body { margin-top: 24px; }
.dialog__body > * + * { margin-top: 16px; }
.or { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: var(--fs-small); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.notice { padding: 14px 18px; border-radius: var(--r-box); background: var(--panel); font-size: var(--fs-small); line-height: 1.5; }
.notice b { font-variant-numeric: tabular-nums; letter-spacing: 0.12em; }
.plan { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 20px 24px; border-radius: var(--r-box); border: 1.5px solid var(--ink); }
.plan b { font-size: var(--fs-h2); }
.ticks li { position: relative; padding-left: 34px; }
.ticks li + li { margin-top: 8px; }
.ticks li::before { content: ""; position: absolute; left: 4px; top: 0.36em; width: 14px; height: 8px; border-left: 2px solid var(--good); border-bottom: 2px solid var(--good); transform: rotate(-45deg); }
.hero-view { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: start; }
.hero-view img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-box); }
@media (max-width: 560px) { .hero-view { grid-template-columns: 1fr; } .hero-view img { max-width: 200px; } }
/* Место под полосу прокрутки не резервируем: шапка и подвал идут от края до края экрана */
html:has(dialog[open]) { overflow: hidden; }

/* ---------- Короткие уведомления ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px)); z-index: var(--z-toast); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-radius: var(--r-pill);
  background: var(--ink); color: var(--bg); font-size: var(--fs-small); line-height: 1.4; pointer-events: auto;
  transition: opacity 320ms ease, transform 320ms ease;
}
@starting-style { .toast { opacity: 0; transform: translateY(100%); } }
.toast.is-out { opacity: 0; transform: translateY(40%); transition-duration: 200ms; }
.toast button { padding: 4px 0; border: 0; background: none; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Профиль ---------- */
.page-head { padding-top: clamp(24px, 3vw, 56px); }
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 24px 32px; }
.profile-head__text { flex: 1; min-width: 240px; }
.profile-head__text p { max-width: 60ch; }
.plaque { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-top: 32px; padding: 20px 24px; border-radius: var(--r-card); background: var(--panel); }
.tabs { display: flex; gap: 4px; margin-top: 40px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line-soft); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 52px; padding: 0 20px; border: 0; border-bottom: 3px solid transparent; background: none; white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--brand); font-weight: 700; }
.tabnote { margin: 16px 0 24px; }

/* ---------- Настройки ---------- */
.settings { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px clamp(24px, 5vw, 96px); margin-top: 32px; align-items: start; }
.sidemenu { position: sticky; top: calc(var(--header-h) + 24px); display: grid; gap: 4px; }
.sidemenu button { min-height: 52px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: none; text-align: left; }
.sidemenu button[aria-selected="true"] { background: var(--panel); font-weight: 700; }
.pane { max-width: 680px; }
.pane > h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); margin-bottom: 24px; }
.pane .stack { --stack: 20px; }
.line-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; min-height: 64px; padding-block: 10px; border-bottom: 1px solid var(--line-soft); }
@media (max-width: 899px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .sidemenu { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; scrollbar-width: none; }
}

/* ---------- Написать историю ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px clamp(32px, 6vw, 120px); align-items: start; margin-top: 40px; }
.benefit { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 20px; align-items: center; }
.benefit + .benefit { margin-top: 20px; }
.benefit img, .benefit__pic { width: 120px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; background: var(--panel); }
.benefit__pic { display: grid; place-items: center; font-weight: 700; }
.steps { counter-reset: s; display: grid; gap: 14px; margin-top: 32px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: start; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--panel); font-weight: 700; }
.formbox { padding: clamp(20px, 2.6vw, 48px); border-radius: var(--r-card); background: var(--panel); }
.formbox .stack { --stack: 14px; }
.formbox .segmented span, .plaque .segmented span { background: var(--surface); }
.formbox .segmented input:checked + span, .plaque .segmented input:checked + span { background: var(--brand); }
@media (max-width: 1023px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Текстовая страница и служебные экраны ---------- */
.doc { max-width: 76ch; padding-top: clamp(24px, 3vw, 56px); }
.doc h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); margin-top: 1.8em; }
.doc p, .doc ul { margin-top: 0.8em; }
.doc ul { padding-left: 1.2em; list-style: disc; }
.doc li + li { margin-top: 0.4em; }
.center { min-height: 56dvh; display: grid; place-content: center; justify-items: center; text-align: center; padding-block: 48px; gap: 12px; }
.center p { max-width: 46ch; color: var(--muted); }
.center .btn { margin-top: 16px; }

/* ---------- Таблица (страница модератора) ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-box); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); line-height: 1.45; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.table th { font-weight: 700; white-space: nowrap; background: var(--panel); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr[tabindex]:hover { background: var(--bg); cursor: pointer; }
.funnel { display: grid; gap: 10px; }
.funnel__row { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr) 150px; gap: 16px; align-items: center; }
.funnel__bar { height: 28px; border-radius: 8px; background: var(--line-soft); overflow: hidden; }
.funnel__bar i { display: block; height: 100%; width: calc(var(--v, 0) * 1%); min-width: 2px; background: var(--brand); border-radius: 8px; }
@media (max-width: 767px) { .funnel__row { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- Загрузка ---------- */
.skeleton { border-radius: var(--r-card); background: linear-gradient(100deg, var(--panel) 40%, var(--bg) 50%, var(--panel) 60%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* ---------- Меньше движения ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .btn:active, .iconbtn:active { transform: none; }
  .dialog, .dialog[open], .menu, .menu[hidden], .toast, .card__img, .hero-card img { transform: none !important; }
  .art__frame img { filter: none; }
  .skeleton { animation: none; }
}
