/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px;
  padding: 0 var(--s5); border-radius: var(--r-sm); border: 1px solid transparent; font-weight: 800; font-size: 15px;
  text-decoration: none; background: var(--accent); color: var(--on-accent); transition: background .15s; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--secondary:hover { background: #f2f1e8; }
.btn--text { background: none; color: var(--link); padding-inline: 0; min-height: 44px; }
.btn--text:hover { background: none; text-decoration: underline; }
.btn--small { min-height: 36px; padding-inline: var(--s4); font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink); position: relative; text-decoration: none; }
.icon-btn:hover { background: #efeee4; }
.icon-btn .count { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
  background: var(--warm); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }

/* ---------- шапка ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.site-header__bar { display: flex; align-items: center; gap: var(--s4); min-height: 64px; }
.logo { display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; color: var(--ink); font-weight: 900; font-size: 24px; letter-spacing: -.03em; }
.logo img { width: 36px; height: 36px; }
.logo b { color: var(--warm); font-weight: 900; }
.nav { display: none; gap: var(--s1); margin-inline: var(--s4) auto; }
.nav-group { position: relative; }
.nav-group > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s3); font-weight: 800; color: var(--ink-soft); border-radius: var(--r-sm); }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover, .nav-group[open] > summary { color: var(--ink); background: #f3f2ea; }
.nav-group > summary .icon { width: 20px; height: 20px; }
.nav-group__arrow { width: 16px !important; height: 16px !important; transition: transform .15s; }
.nav-group[open] .nav-group__arrow { transform: rotate(180deg); }
.nav-group.is-current > summary { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }
.nav-group__panel { position: absolute; left: 0; top: calc(100% + 6px); z-index: 70; min-width: 270px; display: grid; gap: 2px; padding: var(--s2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
.nav-group__panel a { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s3); border-radius: var(--r-sm); text-decoration: none; color: var(--ink); }
.nav-group__panel a:hover { background: #f3f2ea; }
.nav-group__panel a[aria-current="page"] { background: var(--mint); }
.nav-group__panel .icon { width: 24px; height: 24px; color: var(--accent); flex: none; }
.nav-group__panel b { display: block; font-weight: 800; }
.nav-group__panel small { display: block; color: var(--ink-soft); font-size: 13px; }
.header-search { display: none; position: relative; flex: 0 1 280px; }
.header-search .input { width: 100%; }
.header-actions { display: flex; align-items: center; gap: var(--s1); margin-left: auto; }
.header-login { display: none; }
.menu-toggle { display: inline-flex; }
.mobile-menu { display: none; border-top: 1px solid var(--line); background: var(--surface); padding: var(--s2) var(--gutter) var(--s5); max-height: calc(100vh - 64px); overflow-y: auto; }
.mobile-menu.is-open { display: block; }
.mobile-menu__title { display: flex; align-items: center; gap: var(--s2); margin: var(--s4) 0 var(--s2); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.mobile-menu__title .icon { width: 18px; height: 18px; }
.mobile-menu__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.mobile-menu__grid form { display: contents; }
.mobile-menu a, .mobile-menu__out { display: flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s3); font: 800 16px var(--font-ui); color: var(--ink); text-decoration: none; background: #f6f5ee; border: 1px solid var(--line); border-radius: var(--r-sm); min-width: 0; }
.mobile-menu a[aria-current="page"] { background: var(--mint); border-color: var(--accent); }
.mobile-menu .icon { width: 22px; height: 22px; color: var(--accent); flex: none; }
.sidebar { display: none; }
.mobile-search { display: flex; gap: var(--s2); margin-top: var(--s3); }
.mobile-search .input { flex: 1; min-width: 0; }
@media (min-width: 960px) {
  :root { --side: 232px; --page: 1240px; --page-left: max(0px, calc(50% - var(--page) / 2)); }
  html { background: #e8e7dc; }
  body { max-width: var(--page); margin-inline: auto; padding-left: var(--side); background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
  .menu-toggle, .search-toggle, .mobile-search { display: none; }
  .site-header { margin-left: calc(-1 * var(--side)); }
  .header-search, .header-login { display: flex; }
  .header-search { flex: 1 1 auto; max-width: 520px; align-items: center; }
  .header-search .icon { position: absolute; left: 12px; width: 20px; height: 20px; color: var(--ink-soft); pointer-events: none; }
  .header-search .input { min-height: 36px; height: 36px; padding-left: 38px; border-radius: 8px; background: #f6f5ee; }
  .site-header .wrap { padding-left: 0; }
  .site-header__bar { display: grid; grid-template-columns: var(--side) minmax(0, 520px) 1fr; gap: 0; }
  .site-header .logo { padding-left: var(--gutter); }
  .site-header .header-actions { justify-self: end; }
  .header-actions { margin-left: auto; }
  .mobile-menu.is-open { display: none; }
  .sidebar { display: block; position: fixed; z-index: 45; left: var(--page-left); top: 65px; bottom: 0; width: var(--side); overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line); padding: var(--s3) var(--s3) var(--s5); }
  .side-nav { display: grid; gap: 2px; }
  .side-sep { border: 0; border-top: 1px solid var(--line); margin: var(--s2) var(--s3); }
  .side-link { display: flex; align-items: center; gap: var(--s3); min-height: 42px; padding: 0 var(--s3); border-radius: var(--r-sm); text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14.5px; }
  .side-link .icon { width: 22px; height: 22px; color: var(--accent); flex: none; }
  .side-link:hover { background: #f3f2ea; }
  .side-link.is-current, .side-link[aria-current="page"] { background: var(--mint); color: var(--accent); }
}
@media print { body { padding-left: 0; } .sidebar { display: none !important; } }

/* ---------- подвал ---------- */
.site-footer { background: #f1f0e6; border-top: 1px solid var(--line); margin-top: var(--s7); padding-block: var(--s6); }
.site-footer__grid { display: grid; gap: var(--s5) var(--s4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.site-footer__grid > div:first-child { grid-column: 1 / -1; }
.site-footer h2 { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin-bottom: var(--s3); }
.site-footer ul { list-style: none; padding: 0; }
.site-footer li a { display: inline-block; padding: 6px 0; color: var(--ink); text-decoration: none; }
.site-footer li a:hover { text-decoration: underline; }
.site-footer__note { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); }
@media (min-width: 640px) { .site-footer__grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } .site-footer__grid > div:first-child { grid-column: 1 / -1; } }
@media (min-width: 960px) { .site-footer__grid > div:first-child { grid-column: auto; } }
.site-footer__about { margin-top: 12px; max-width: 34ch; }

/* ---------- формы ---------- */
.field { display: grid; gap: var(--s1); }
.field label { font-weight: 700; font-size: var(--fs-small); }
.input, .select { min-height: 44px; width: 100%; padding: 0 var(--s3); background: var(--surface); border: 1px solid #cfcdbd; border-radius: var(--r-sm); }
.input:hover, .select:hover { border-color: #aeb3a4; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: var(--fs-small); font-weight: 700; }
.search { display: flex; align-items: center; gap: var(--s2); background: var(--surface); border: 1px solid #cfcdbd; border-radius: var(--r-sm); padding-left: var(--s3); }
.search .input { border: 0; padding-left: 0; background: none; }
.check { display: flex; align-items: center; gap: var(--s2); min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check .n { margin-left: auto; color: var(--ink-soft); font-size: var(--fs-small); }

/* ---------- чипы, бейджи ---------- */
.chip { display: inline-flex; align-items: center; gap: var(--s1); min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: var(--fs-small); font-weight: 700; text-decoration: none; }
a.chip:hover { border-color: var(--accent); }
.chip--on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip button { border: 0; background: none; padding: 0 0 0 2px; display: inline-flex; min-width: 24px; min-height: 24px; align-items: center; justify-content: center; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.badge { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 800; background: var(--yellow); color: #6b4e12; }

/* ---------- карточка произведения ---------- */
.cards { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 480px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .cards { grid-template-columns: repeat(3, 1fr); } .cards--4 { grid-template-columns: repeat(4, 1fr); } }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card__cover { aspect-ratio: 16 / 9; background: var(--tone, var(--mint)); display: grid; place-items: center; overflow: hidden; }
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__letter { font: 600 72px/1 var(--font-text); color: rgb(41 60 52 / .55); }
.card__fav { position: absolute; top: var(--s2); right: var(--s2); z-index: 2; background: rgb(255 255 255 / .9); }
.card__body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s1); flex: 1; }
.card__meta { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.card__title { font-size: var(--fs-card); font-weight: 800; line-height: 1.25; }
.card__title a { color: var(--ink); text-decoration: none; }
.card__title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card__author { position: relative; z-index: 2; font-size: var(--fs-small); font-weight: 700; width: fit-content; }
.card__lead { font-size: var(--fs-small); color: var(--ink-soft); }
.card__foot { margin-top: auto; padding-top: var(--s2); display: flex; flex-wrap: wrap; gap: var(--s3); font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.card__foot span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- строка-список ---------- */
.rows { list-style: none; padding: 0; border-top: 1px solid var(--line); }
.row { position: relative; display: grid; grid-template-columns: 1fr auto; gap: var(--s1) var(--s4); align-items: baseline; padding: var(--s3) var(--s2); border-bottom: 1px solid var(--line); }
.row:hover { background: #f3f2ea; }
.row__title { font-weight: 800; font-size: 17px; }
.row__title a { color: var(--ink); text-decoration: none; }
.row__title a::after { content: ""; position: absolute; inset: 0; }
.row__first { grid-column: 1; font-family: var(--font-text); font-weight: 400; font-size: 15px; color: var(--ink-soft); font-style: italic; }
.row__meta { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-size: 13px; font-weight: 700; color: var(--ink-soft); }

/* ---------- фильтры ---------- */
.catalog { display: grid; gap: var(--s5); }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); }
.filters fieldset { border: 0; padding: 0; margin: 0 0 var(--s4); }
.filters legend { font-weight: 800; padding: 0; margin-bottom: var(--s1); }
.filters-toggle { display: inline-flex; }
.filters-panel { display: none; }
.filters-panel.is-open { display: block; position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto; padding: var(--s4); }
.filters-panel__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s4); }
@media (min-width: 960px) {
  .catalog { grid-template-columns: 260px 1fr; align-items: start; }
  .filters-toggle, .filters-panel__head { display: none; }
  .filters-panel { display: block; position: sticky; top: 80px; }
  .filters-panel.is-open { position: sticky; inset: auto; padding: 0; background: none; overflow: visible; z-index: auto; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; margin-bottom: var(--s4); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.segmented a, .segmented button { min-height: 40px; padding: 0 var(--s4); border: 0; background: none; font-weight: 700; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.segmented [aria-current="true"] { background: var(--accent); color: #fff; }

/* ---------- крошки, пагинация ---------- */
.crumbs { padding-block: var(--s3); font-size: var(--fs-small); font-weight: 600; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs li + li::before { content: "›"; margin-right: 6px; color: var(--ink-soft); }
.crumbs a { color: var(--ink-soft); }
.crumbs [aria-current] { color: var(--ink); }
.pagination { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: center; margin-top: var(--s5); }
.pagination a, .pagination span { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-weight: 700; color: var(--ink); padding: 0 var(--s3); }
.pagination [aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- плеер, сообщения, пустые состояния ---------- */
.player { display: flex; align-items: center; gap: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); flex-wrap: wrap; }
.player__bar { flex: 1 1 140px; accent-color: var(--accent); height: 28px; }
.player__time { font-variant-numeric: tabular-nums; font-size: var(--fs-small); font-weight: 700; color: var(--ink-soft); min-width: 5.5em; }
.toasts { position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); z-index: 90; display: grid; gap: var(--s2); width: min(92vw, 440px); }
.toast { background: var(--ink); color: #fff; border-radius: var(--r-md); padding: var(--s3) var(--s4); box-shadow: var(--shadow); font-weight: 700; display: flex; justify-content: space-between; gap: var(--s3); align-items: center; }
.toast button { background: none; border: 0; color: #fff; min-width: 36px; min-height: 36px; }
.notice { border-radius: var(--r-md); padding: var(--s3) var(--s4); font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.notice--ok { background: var(--ok-bg); border-color: #b9d6c3; }
.notice--error { background: var(--danger-bg); border-color: #e8b9b2; color: var(--danger); }
.empty { text-align: center; padding: var(--s7) var(--s4); background: var(--surface); border: 1px dashed #cfcdbd; border-radius: var(--r-md); }
.empty img { width: 120px; margin: 0 auto var(--s4); }
.empty h2 { margin-bottom: var(--s2); }
.empty p { color: var(--ink-soft); margin: 0 auto var(--s4); max-width: 44ch; }

/* ---------- страница, панели ---------- */
.page-head { padding-block: var(--s5) var(--s4); }
.page-head p { color: var(--ink-soft); margin-top: var(--s2); max-width: 60ch; }
.work-actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5); }
.tile { display: block; border-radius: var(--r-md); padding: var(--s5) var(--s4); background: var(--tone, var(--mint)); text-decoration: none; color: var(--ink); }
.tile:hover { box-shadow: var(--shadow); }
.tile b { display: block; font-size: var(--fs-card); font-weight: 800; }
.tile span { font-size: var(--fs-small); color: var(--ink-soft); font-weight: 600; }
.swatch { height: 56px; border-radius: var(--r-sm); border: 1px solid var(--line); }

/* ---------- панель действий произведения ---------- */
.work-bar { display: flex; flex-direction: column; gap: var(--s3); margin: var(--s4) 0; }
.work-bar__main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.work-bar__main:not(:has(> :not([hidden]))) { display: none; }
.work-bar__main > .btn { flex: 1 1 150px; }
.work-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 60px; padding: 8px 2px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font: 700 12px/1.2 var(--font-ui); text-align: center; cursor: pointer; }
.tool:hover { background: #f2f1e8; }
.tool .icon { width: 22px; height: 22px; }
.tool span { overflow-wrap: anywhere; }
@media (min-width: 720px) {
  .work-bar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .work-bar__main > .btn { flex: 0 0 auto; }
  .work-tools { display: flex; flex-wrap: wrap; gap: var(--s3); }
  .tool { flex-direction: row; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); font-size: 15px; font-weight: 800; }
  .tool .icon { width: 1.25em; height: 1.25em; }
}

/* ---------- печать произведения ---------- */
@media print {
  .site-header, .site-footer, .crumbs, .work-bar, .work-audio, .marks, .memo, .toasts, .skip-link, .read-progress,
  .work-after, .talk, .about-author, article ~ *, .work .section, .work-pic, .tale-hero__cover, .notice, .work-actions { display: none !important; }
  body { background: #fff !important; color: #000; font-size: 14pt; min-height: 0; display: block; }
  .work-body, .work-body--pic { display: block; border: 0; padding: 0; }
  .work-head, .tale-hero { background: none !important; padding: 0; display: block; }
  .poem .line { display: block; }
  .text-version > summary { display: none; }
  .work::after { content: "Вбуквы.рф — vbukvy.ru"; display: block; margin-top: 2em; font-size: 10pt; color: #555; }
}

/* кнопки действий на телефоне: подписи в одну строку */
@media (max-width: 719px) {
  .tool { font-size: clamp(9.5px, 2.8vw, 11.5px); font-weight: 700; padding: 8px 1px; white-space: nowrap; letter-spacing: -.1px; }
  .tool span { overflow-wrap: normal; }
}
/* Узкий компьютерный экран: восемь пунктов меню и имя не помещаются — имя прячем, остаётся картинка */
@media (max-width: 400px) { .mobile-menu a, .mobile-menu__out { font-size: 14.5px; padding: 0 var(--s2); gap: 6px; } .mobile-menu .icon { width: 20px; height: 20px; } }

/* Карточка без обложки: значок вида произведения вместо большой буквы */
.card__stub { width: 64px; height: 64px; border-radius: 50%; background: rgba(255, 255, 255, .7); display: grid; place-items: center; color: var(--accent); }
.card__stub .icon { width: 32px; height: 32px; }
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.site-footer li a { overflow-wrap: anywhere; }
@media (max-width: 400px) { .site-footer li a { font-size: 15px; } }

.nav-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s3); font-weight: 800; color: var(--ink-soft); text-decoration: none; border-radius: var(--r-sm); }
.nav-link:hover { color: var(--ink); background: #f3f2ea; }
.nav-link .icon { width: 20px; height: 20px; }
.nav-link.is-current { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }
