@font-face {
    font-family: "Manrope";
    src: url("../fonts/Manrope-Variable.ttf") format("truetype");
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #182536;
    --muted: #66758a;
    --line: #dbe7f4;
    --blue-50: #f3f9ff;
    --blue-100: #dcefff;
    --blue-600: #2d7dd2;
    --blue-700: #276fbb;
    --blue-900: #173f6e;
    --coral: #ed6f86;
    --coral-dark: #d9536d;
    --success: #1d9a71;
    --sidebar: 272px;
}

* { box-sizing: border-box; }
html { min-width: 0; background: #fff; }
body {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    background: #fff;
    font-family: "Manrope", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
}
body.menu-open { overflow: hidden; }
img { max-width: 100%; display: block; }
button, input { font: inherit; }
button { border: 0; }
a { color: var(--blue-700); }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.container { width: calc(100% - 32px); max-width: 1800px; margin-inline: auto; }

/* Шапка сайта: логотип, поиск и мобильные кнопки меню/поиска. */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, .98);
    border-bottom: 1px solid #e8edf4;
}
.header-row {
    min-height: 82px;
    display: grid;
    grid-template-columns: auto minmax(280px, 520px);
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}
.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    color: var(--blue-900);
    text-decoration: none;
}
.brand-logo {
    width: 260px;
    max-width: 100%;
    height: auto;
    max-height: 64px;
    object-fit: contain;
}
.search { display: flex; min-width: 0; }
.search-results-summary { margin: 0 0 20px; overflow-wrap: anywhere; }
.search input {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    height: 46px;
    padding: 0 17px;
    color: var(--ink);
    background: #f2f6fb;
    border: 1px solid transparent;
    border-right: 0;
    border-radius: 8px 0 0 8px;
    outline: 0;
}
.search input:focus {
    background: #fff;
    border-color: #9ebce2;
    box-shadow: 0 0 0 3px var(--blue-100);
}
.icon-button {
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: var(--blue-900);
    background: #fff;
    border: 1px solid #c8d5e5;
    border-radius: 8px;
    cursor: pointer;
}
.icon-button:hover { color: #fff; background: var(--blue-700); border-color: var(--blue-700); }
.search button {
    flex: 0 0 46px;
    color: #fff;
    background: var(--blue-700);
    border-color: var(--blue-700);
    border-radius: 0 8px 8px 0;
}
.search button:hover { background: var(--blue-900); }
.mobile-menu-button, .mobile-search-button { display: none; }

/* Основная раскладка публичных страниц: левое меню + контент. */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    gap: 46px;
    align-items: start;
    padding-block: 38px 72px;
    transition: grid-template-columns .2s ease;
}
.layout.sidebar-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 104px;
    max-height: calc(100vh - 128px);
    overflow: auto;
    background: transparent;
    border: 0;
    border-radius: 0;
    scrollbar-width: thin;
}
.sidebar-head {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 12px 3px;
}
.sidebar-title { margin: 0; color: var(--blue-900); font-size: 15px; font-weight: 800; }
.sidebar-close { display: none; }
.sidebar-collapse .icon { transition: transform .2s ease; }
.sidebar-nav { padding: 0; }
.sidebar-empty { padding: 12px 4px; color: var(--muted); font-size: 14px; }

/* Дерево категорий: ссылка открывает категорию, отдельная кнопка раскрывает подкатегории. */
.menu-tree, .menu-tree ul { margin: 0; padding: 0; list-style: none; }
.menu-tree > .menu-item { margin-bottom: 5px; }
.menu-item { border-radius: 8px; }
.menu-item.is-open { background: transparent; }
.menu-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0;
    overflow: hidden;
    border-radius: 8px;
}
.menu-item.is-open > .menu-row { background: rgba(225, 241, 255, .7); }
.menu-item.is-active > .menu-row { background: var(--blue-700); }
.menu-link {
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 9px 12px;
    color: #2c3c53;
    text-decoration: none;
    border-radius: 8px 0 0 8px;
    font-size: 16px;
    font-weight: 500;
    transition: color .18s ease;
}
.menu-item:not(.has-children) > .menu-row .menu-link { border-radius: 8px; }
.menu-link:hover { color: var(--blue-600); background: transparent; }
.menu-item.is-active > .menu-row .menu-link,
.menu-link.is-current { color: #fff; background: transparent; }
.menu-item.is-active > .menu-row .menu-link:hover,
.menu-link.is-current:hover { color: #fff; }
.menu-toggle {
    align-self: stretch;
    width: 40px;
    min-height: 44px;
    height: auto;
    display: grid;
    place-items: center;
    color: #637b99;
    background: transparent;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
}
.menu-toggle:hover { color: var(--blue-900); background: rgba(210, 234, 253, .9); }
.menu-item.is-active > .menu-row .menu-toggle { color: #fff; }
.menu-item.is-active > .menu-row .menu-toggle:hover { color: #fff; background: rgba(255, 255, 255, .18); }
.menu-toggle .icon {
    width: 16px;
    height: 16px;
    transform: rotate(90deg);
    transition: transform .15s ease;
}
.menu-item.is-open > .menu-row .menu-toggle .icon { transform: rotate(270deg); }
.menu-children { display: none; padding: 0 8px 9px 18px; }
.menu-item.is-open > .menu-children { display: block; }
.menu-children .menu-children { padding-left: 18px; border-left: 1px solid #cbd9ea; }
.menu-level-2 > .menu-row .menu-link,
.menu-level-3 > .menu-row .menu-link {
    min-height: 44px;
    padding: 9px 12px;
    font-size: inherit;
    font-weight: inherit;
}
.menu-level-2 > .menu-row .menu-toggle,
.menu-level-3 > .menu-row .menu-toggle {
    width: 40px;
    min-height: 44px;
}
.layout.sidebar-collapsed .sidebar-head { justify-content: center; padding-inline: 8px; }
.layout.sidebar-collapsed .sidebar-title,
.layout.sidebar-collapsed .sidebar-nav { display: none; }
.layout.sidebar-collapsed .sidebar-collapse .icon { transform: rotate(180deg); }

.main { min-width: 0; }
.ad-slot {
    margin-bottom: 26px;
    padding: 14px;
    color: var(--muted);
    background: #f5faff;
    border: 1px dashed #bdd4ee;
    border-radius: 12px;
}
.ad-slot-bottom { margin: 0 0 30px; }

/* Заголовок страницы и хлебные крошки. На внутренних страницах крошки стоят под h1. */
.page-intro { padding: 2px 0 30px; }
.breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 15px 0 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}
.breadcrumb a {
    color: var(--blue-700);
    text-decoration: none;
    transition: color .18s ease;
}
.breadcrumb a:hover { color: var(--coral-dark); }
.page-intro h1 {
    margin: 0;
    color: var(--ink);
    font-size: 38px;
    line-height: 1.16;
    font-weight: 800;
}
.page-intro p {
    max-width: 960px;
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 17px;
}

/* Страница одной открытки: верхний блок по центру, метаданные и похожие ниже. */
.content-page { min-width: 0; }
.content-hero {
    max-width: 860px;
    margin-inline: auto;
    text-align: center;
}
.content-hero h1 {
    margin: 0;
    color: var(--ink);
    font-size: 36px;
    line-height: 1.18;
    font-weight: 850;
}
.content-hero .breadcrumb { justify-content: center; }
.content-preview {
    max-width: min(560px, 100%);
    margin: 26px auto 0;
}
.content-preview img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 560px;
    margin-inline: auto;
    object-fit: contain;
    border-radius: 22px;
    box-shadow: 0 18px 42px rgba(38, 94, 145, .14);
}
/* Полупрозрачная подложка заполняет зарезервированное место до появления изображения. */
.content-preview img,
.postcard-image-link { background-color: rgba(38, 94, 145, .08); }
/* Держим дату и счётчики в одной строке и используем для них размер основного текста. */
.content-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 3vw, 18px);
    margin-top: 16px;
    color: var(--muted);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.content-stat,
.content-like {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.content-stat .icon { width: 16px; height: 16px; }
/* Лайк занимает ширину содержимого, сохраняя удобную зону нажатия на телефоне. */
.content-like {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0 4px;
    color: #ac3158;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
}
.content-like:hover,
.content-like[aria-pressed="true"] { color: #9d244b; }
.content-like[aria-pressed="true"] .icon { fill: currentColor; }
.content-like:focus-visible { outline: 3px solid var(--blue-700); outline-offset: 3px; }
.content-like:disabled { cursor: wait; opacity: .65; }
.content-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}
.content-button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 10px 20px;
    color: var(--blue-900);
    background: #fff;
    border: 1px solid #bdd0e4;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 850;
    box-shadow: 0 10px 22px rgba(38, 94, 145, .1);
}
.content-button:hover {
    color: #fff;
    background: var(--blue-700);
    border-color: var(--blue-700);
}
.content-button-primary {
    color: #fff;
    background: var(--coral);
    border-color: var(--coral);
}
.content-button-primary:hover {
    background: var(--coral-dark);
    border-color: var(--coral-dark);
}

/* Редактор использует цвета и кнопки открытки, а на телефоне складывается в одну колонку. */
.content-actions [data-postcard-editor-open][hidden] { display: none; }
body:has(.postcard-editor[open]) { overflow: hidden; }
.postcard-editor {
    width: min(840px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: clamp(14px, 3vw, 24px);
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 18px 44px rgba(26, 65, 112, .24);
    overscroll-behavior: contain;
}
.postcard-editor::backdrop { background: rgba(10, 28, 52, .62); }
.postcard-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 12px;
    margin-bottom: 16px;
}
.postcard-editor-head h2 {
    margin: 0;
    color: var(--blue-900);
    font-size: clamp(21px, 4vw, 26px);
    line-height: 1.2;
    font-weight: 850;
}
.postcard-editor-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.postcard-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
}
/* Центрируем само изображение и сообщение загрузки в свободной области редактора. */
.postcard-editor-preview {
    display: grid;
    place-items: center;
    min-height: 108px;
    text-align: center;
}
.postcard-editor-canvas {
    display: block;
    max-width: 100%;
    max-height: min(60vh, 520px);
    width: auto;
    height: auto;
    background: #fff;
    border-radius: 8px;
}
.postcard-editor-canvas[hidden] { display: none; }
/* Перехватываем жесты только над рабочей областью с текстом, чтобы остальной диалог прокручивался. */
.postcard-editor-canvas.has-text { cursor: grab; touch-action: none; }
.postcard-editor-canvas.has-text:active { cursor: grabbing; }
.postcard-editor-controls,
.postcard-editor-field { display: grid; min-width: 0; }
.postcard-editor-controls { gap: 12px; }
.postcard-editor-field { gap: 5px; color: var(--blue-900); font-size: 14px; font-weight: 750; }
.postcard-editor-style {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 12px;
}
.postcard-editor-field :is(textarea, select, input[type="color"]) {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #bdd0e4;
    border-radius: 8px;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
}
.postcard-editor-field textarea { resize: vertical; }
.postcard-editor-field input[type="color"] { height: 44px; padding: 4px; cursor: pointer; }
.postcard-editor-field input[type="range"] { width: 100%; margin: 0; accent-color: var(--blue-600); }
.postcard-editor :focus-visible { outline: 2px solid var(--blue-700); outline-offset: 2px; }
.postcard-editor-note { margin: 0; color: var(--muted); font-size: 13px; }
.postcard-editor-note:empty { display: none; }
.postcard-editor .content-button { width: 100%; max-width: none; }
.postcard-editor .content-button:disabled {
    background: var(--coral);
    border-color: var(--coral);
    opacity: .65;
    cursor: not-allowed;
}
@media (max-width: 680px) {
    /* Оставляем больше места для полей и кнопки скачивания на портретном экране. */
    .postcard-editor-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .postcard-editor-controls { gap: 10px; }
    .postcard-editor-canvas { max-height: min(38vh, 320px); max-height: min(38dvh, 320px); }
}

.content-meta {
    max-width: none;
    margin: 34px 0 0;
    color: var(--ink);
    font-size: 16px;
}
.content-meta span {
    color: var(--muted);
    font-weight: 700;
}
.content-meta a {
    transition: color .18s ease;
}
.content-meta a:hover { color: var(--coral-dark); }
.content-about {
    max-width: none;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 17px;
}
.share-panel {
    max-width: 620px;
    margin: 16px auto 0;
    padding: 7px;
    background: rgba(255, 255, 255, .98);
    border: 1px solid #d7e5f4;
    border-radius: 18px;
    box-shadow: 0 16px 36px rgba(26, 65, 112, .14);
}
.share-services {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
}
.share-service {
    min-width: 0;
    min-height: 48px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    padding: 3px;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .18s ease;
}
.share-service:hover {
    color: var(--ink);
    background: transparent;
    box-shadow: none;
    transform: translateY(-2px);
}
.share-service-icon {
    width: 42px;
    height: 42px;
    display: block;
    border-radius: 12px;
}
.related-section { max-width: none; }
.section { padding-top: 38px; }
.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}
.section-title { margin: 0; color: var(--ink); font-size: 25px; line-height: 1.25; font-weight: 800; }
.section-note { margin: 5px 0 0; color: var(--muted); font-size: 15px; }
.section-more { display: flex; justify-content: center; margin-top: 18px; }
.section-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 22px;
    color: #fff;
    background: var(--blue-700);
    border: 1px solid var(--blue-700);
    border-radius: 999px;
    box-shadow: 0 12px 24px rgba(45, 111, 187, .18);
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.section-link:hover {
    color: #fff;
    background: var(--blue-900);
    border-color: var(--blue-900);
    box-shadow: 0 14px 28px rgba(45, 111, 187, .22);
    transform: translateY(-1px);
}
.section-link:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 3px; }

/* Общие компактные кнопки для подкатегорий и праздников на главной. */
.subcategory-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: -8px 0 8px;
}
.subcategory-pill {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    color: var(--blue-900);
    background: #eef7ff;
    border: 1px solid #d5e8fa;
    border-radius: 999px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(42, 92, 136, .08);
    transition: background-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.subcategory-pill:hover {
    color: #fff;
    background: var(--blue-700);
    border-color: var(--blue-700);
    box-shadow: 0 12px 24px rgba(45, 111, 187, .2);
    transform: translateY(-1px);
}
/* Подписи дней выводятся обычным шрифтом рядом с кнопками; длинные списки переносятся. */
.holiday-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 14px; }
.holiday-row + .holiday-row { margin-top: 14px; }
.holiday-label { margin: 0; color: var(--ink); font-size: 16px; font-weight: 400; }
.holiday-links { display: flex; flex: 1 1 240px; flex-wrap: wrap; gap: 10px; min-width: 0; }
.holiday-links .subcategory-pill { max-width: 100%; overflow-wrap: anywhere; }
.subcategory-pill:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 3px; }

/* Каталог разделов: ссылки сгруппированы по родителям, без галереи открыток. */
.catalog-description { margin: -4px 0 24px; color: var(--muted); overflow-wrap: anywhere; }
.catalog-search { max-width: 440px; margin: 0 0 24px; }
.catalog-search label { display: block; margin-bottom: 8px; color: var(--blue-900); font-weight: 700; }
.catalog-search input {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    background: #fff;
}
.catalog-search input:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 2px; }
.catalog-grid {
    align-items: start;
    margin: 0;
    padding: 0;
    list-style: none;
}
.catalog-node { min-width: 0; }
.catalog-children {
    display: grid;
    gap: 8px;
    margin: 8px 0 0 12px;
    padding: 0 0 0 10px;
    border-left: 1px solid var(--line);
    list-style: none;
}
.catalog-empty { margin: 24px 0; padding: 20px; border-radius: 12px; background: var(--blue-50); color: var(--muted); }
.catalog-node[hidden], .catalog-search[hidden], .catalog-empty[hidden] { display: none; }

.category-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: -8px 0 14px;
}
.sort-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 0;
    background: #eef7ff;
    border: 1px solid #d8e9fa;
    border-radius: 999px;
    overflow: hidden;
}
.sort-tab {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 13px;
    color: var(--blue-900);
    border-radius: 999px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 850;
    white-space: nowrap;
}
.sort-tab:hover {
    color: var(--blue-700);
    background: transparent;
}
.sort-tab.is-active {
    color: #fff;
    background: var(--blue-700);
    cursor: default;
}

/* Сетка открыток и сами карточки. */
.gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 36px;
    justify-items: center;
}
.postcard {
    /* Общие RGB-компоненты связывают цвет подписи и градиента, чтобы у картинки не появлялся шов. */
    --postcard-caption-rgb: 255, 255, 255;
    width: 100%;
    min-width: 0;
    position: relative;
    isolation: isolate;
    overflow: visible;
    padding: 0;
    /* Общая тусклая рамка объединяет изображение и подпись; внутренних отступов у тумбы нет. */
    background: rgb(var(--postcard-caption-rgb));
    border: 1px solid #e1e6ec;
    border-radius: 20px;
    box-shadow: none;
    transition: transform .2s ease;
}
.postcard::before {
    content: "";
    position: absolute;
    inset: -7px -6px -7px;
    z-index: -1;
    border-radius: 23px;
    background: rgba(210, 239, 255, .96);
    box-shadow: 0 18px 42px rgba(38, 94, 145, .16);
    opacity: 0;
    transform: scale(.985);
    transition: opacity .2s ease, transform .2s ease;
}
/* Внешнюю подсветку и тень сохраняем; подпись и переход используют общий голубой цвет при наведении. */
.postcard:hover {
    --postcard-caption-rgb: 210, 239, 255;
    border-color: transparent;
    transform: translateY(-3px);
}
.postcard:hover::before { opacity: 1; transform: scale(1); }
.postcard[hidden] { display: none; }
.postcard-image-link {
    display: block;
    position: relative;
    overflow: hidden;
    width: 100%;
    /* Картинка прилегает к рамке сверху и по бокам, нижний край стыкуется с областью подписи. */
    border-radius: 19px 19px 0 0;
    aspect-ratio: 4 / 5;
}
.postcard-image-link img {
    /* Тумба заполняет заданный формат 4:5, поэтому загрузка не меняет размеры ссылки. */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.postcard-image-link:focus-visible { outline: 3px solid var(--blue-600); outline-offset: -3px; }
.new-label {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 9px;
    color: #b9425a;
    background: rgba(255, 240, 244, .96);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 800;
}
/* Компактные отступы сохранены; скругление удерживает цветной фон внутри нижних углов рамки. */
.postcard-body {
    position: relative;
    z-index: 1;
    padding: 8px 10px 10px;
    background: rgb(var(--postcard-caption-rgb));
    border-radius: 0 0 19px 19px;
}
/* Переход рисуем от подписи поверх нижних 24 px картинки; ещё 2 px заходят на фон подписи и закрывают шов при дробных размерах и наведении. */
.postcard-body::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -24px;
    height: 26px;
    /* Нижние 2 px полностью непрозрачны: цвет на стыке совпадает с подписью, даже если браузер округляет края изображения. */
    background: linear-gradient(to top, rgba(var(--postcard-caption-rgb), 1) 2px, rgba(var(--postcard-caption-rgb), .75) 8px, rgba(var(--postcard-caption-rgb), .2) 18px, rgba(var(--postcard-caption-rgb), 0) 26px);
    /* Переход остаётся декоративным: клики по нижнему краю картинки проходят к ссылке. */
    pointer-events: none;
}
.postcard-category { color: var(--blue-700); font-size: 11px; font-weight: 800; text-transform: uppercase; }
/* Фиксированная высота 38 px сохраняет одинаковые тумбы; лишний текст скрывается без многоточия на всех экранах. */
.postcard-title {
    height: 38px;
    overflow: hidden;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    overflow-wrap: anywhere;
}
.postcard-title a { color: inherit; text-decoration: none; }
.button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 11px;
    color: var(--blue-900);
    background: #fff;
    border: 1px solid #b9cbe0;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
}
.button:hover { color: #fff; background: var(--blue-700); border-color: var(--blue-700); }
.button-primary { color: #fff; background: var(--coral); border-color: var(--coral); }
.button-primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.empty-state {
    display: none;
    padding: 36px;
    text-align: center;
    color: var(--muted);
    background: #fff;
    border: 1px dashed #afc2da;
    border-radius: 8px;
}
.empty-state.visible { display: block; }

/* Пагинация категорий. */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 26px;
}
.pagination-link {
    min-width: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    color: var(--blue-900);
    background: #fff;
    border: 1px solid #c8d8e9;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 800;
}
.pagination-link:hover {
    color: #fff;
    background: var(--blue-700);
    border-color: var(--blue-700);
}
.pagination-link.is-current {
    color: #fff;
    background: var(--blue-900);
    border-color: var(--blue-900);
}
.pagination-side { padding-inline: 16px; }

/* Карточки популярных категорий на главной и разделов каталога. */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.category-item {
    min-width: 0;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 11px;
    color: var(--ink);
    background: #eef7ff;
    border: 1px solid transparent;
    border-radius: 8px;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.category-item:nth-child(2n), .catalog-node:nth-child(2n) > .category-item { background: #f7f9ff; }
.category-item:nth-child(3n), .catalog-node:nth-child(3n) > .category-item { background: #fff4f7; }
.category-item:hover, .catalog-node > .category-item:hover {
    background: #fff;
    box-shadow: 0 14px 28px rgba(54, 101, 145, .17);
    transform: translateY(-2px);
}
.category-item:focus-visible { outline: 3px solid var(--blue-700); outline-offset: 2px; }
.category-text { min-width: 0; }
.category-thumb {
    width: 58px;
    height: 58px;
    object-fit: cover;
    background: #dbeafa;
    border-radius: 8px;
}
.category-thumb-empty {
    display: grid;
    place-items: center;
    color: var(--blue-700);
}
.category-name {
    display: block;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 15px;
    font-weight: 800;
}
.category-count { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.category-arrow { color: var(--blue-700); }
.category-arrow .icon { width: 17px; height: 17px; }
.main-about {
    max-width: 960px;
    color: var(--muted);
    font-size: 17px;
}

/* Компактные ссылки на сообщества: под категориями, а при скрытом мобильном меню — перед подвалом. */
.community-links { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.community-link {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 8px 10px;
    color: var(--blue-900);
    background: #fff;
    border: 1px solid #cce2f5;
    border-radius: 10px;
    text-decoration: none;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.community-link--max { border-color: #dcd4fb; }
.community-link--vk { border-color: #c7dcff; }
.community-icon { width: 24px; height: 24px; flex: 0 0 auto; }
.community-link-name { font-size: 12px; font-weight: 800; line-height: 1.3; }
.community-link:hover {
    border-color: #91bde6;
    box-shadow: 0 6px 18px rgba(39, 111, 187, .1);
    transform: translateY(-2px);
}
.community-link--max:hover { border-color: #b0a0eb; }
.community-link:focus-visible { outline: 3px solid var(--blue-700); outline-offset: 4px; }
.sidebar-communities {
    margin: 24px 3px 8px;
    padding: 20px 0 4px;
    border-top: 1px solid var(--line);
}
.sidebar-communities h2,
.prefooter-communities h2 { margin: 0 0 12px; color: var(--blue-900); font-size: 15px; font-weight: 800; }
/* На широком экране достаточно ссылок под категориями; перед подвалом копию не показываем. */
.prefooter-communities { display: none; }
/* При сворачивании дерева скрываем и подписи сообществ, чтобы они не выходили за узкую колонку. */
.layout.sidebar-collapsed .sidebar-communities { display: none; }

.site-footer {
    color: #64758a;
    background: #edf7ff;
    border-top: 1px solid #d8eaf8;
}
.footer-row {
    min-height: 92px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    font-size: 14px;
}
.site-footer a { color: var(--blue-700); text-decoration: none; font-weight: 700; }
.site-footer a:hover { text-decoration: underline; }
.menu-overlay { display: none; }

/* Компактная кнопка «Наверх» с полупрозрачным фоном; отступы учитывают безопасную область телефона. */
.scroll-to-top {
    position: fixed;
    right: calc(20px + env(safe-area-inset-right, 0px));
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: #fff;
    background: rgba(39, 111, 187, .6);
    border: 1px solid rgba(39, 111, 187, .1);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(23, 63, 110, .12);
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
/* Явное правило сохраняет hidden даже при display: inline-grid; скрытая кнопка не попадает в Tab-порядок. */
.scroll-to-top[hidden] { display: none; }
/* Наведение и фокус делают кнопку ярче, чтобы её было удобно найти мышью и клавиатурой. */
.scroll-to-top:hover {
    background: rgba(39, 111, 187, .8);
    box-shadow: 0 6px 18px rgba(23, 63, 110, .22);
}
/*.scroll-to-top:focus-visible { outline: 3px solid var(--blue-900); outline-offset: 4px; }*/
.scroll-to-top .icon { width: 20px; height: 20px; transform: rotate(-90deg); }
body.menu-open .scroll-to-top { visibility: hidden; }

.toast {
    position: fixed;
    right: 18px;
    /* Уведомление располагается над кнопкой «Наверх», не закрывая её. */
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    z-index: 80;
    max-width: min(360px, calc(100% - 36px));
    padding: 12px 14px;
    color: #fff;
    background: var(--success);
    border-radius: 6px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

/* Адаптив: планшеты. */
@media (max-width: 1050px) {
    .container { width: calc(100% - 24px); max-width: 960px; }
    .layout { grid-template-columns: 228px minmax(0, 1fr); gap: 28px; }
    .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .postcard { max-width: 360px; }
    .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Адаптив: мобильное меню и скрытый поиск. */
@media (max-width: 760px) {
    .container { width: calc(100% - 24px); max-width: 680px; }
    .site-header { position: relative; }
    .header-row {
        min-height: 70px;
        grid-template-columns: minmax(0, 1fr) 46px 46px;
        grid-template-areas: "brand search-toggle menu";
        gap: 10px;
        padding-block: 10px 12px;
    }
    .mobile-menu-button { display: inline-grid; grid-area: menu; justify-self: end; }
    .mobile-search-button { display: inline-grid; grid-area: search-toggle; justify-self: end; }
    body.search-open .mobile-search-button { color: #fff; background: var(--blue-700); border-color: var(--blue-700); }
    .brand { grid-area: brand; justify-self: start; }
    .brand-logo { width: 210px; max-height: 48px; }
    .search {
        position: absolute;
        top: calc(100% - 1px);
        left: 12px;
        right: 12px;
        z-index: 45;
        width: auto;
        padding: 8px;
        background: rgba(255, 255, 255, .98);
        border: 1px solid #dce8f5;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 16px 34px rgba(42, 92, 136, .14);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-8px);
        transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
    }
    body.search-open .search {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }
    .layout,
    .layout.sidebar-collapsed { display: block; padding-block: 28px 48px; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 55;
        width: min(330px, calc(100% - 48px));
        max-height: none;
        background: #fff;
        border: 0;
        border-right: 1px solid var(--line);
        border-radius: 0;
        transform: translateX(-102%);
        transition: transform .2s ease;
    }
    body.menu-open .sidebar { transform: translateX(0); }
    .sidebar-head {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 10px 12px;
        background: #fff;
        border-bottom: 1px solid var(--line);
    }
    .sidebar-nav { padding: 10px; }
    /* В выдвижном меню возвращаем блок даже после сворачивания дерева на компьютере. */
    .sidebar-communities,
    .layout.sidebar-collapsed .sidebar-communities { display: block; margin: 12px 16px 24px; }
    .sidebar-close { display: inline-grid; }
    .sidebar-collapse { display: none; }
    .layout.sidebar-collapsed .sidebar-head { justify-content: space-between; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--line); }
    .layout.sidebar-collapsed .sidebar-title,
    .layout.sidebar-collapsed .sidebar-nav { display: block; }
    .menu-overlay {
        position: fixed;
        inset: 0;
        z-index: 50;
        display: block;
        visibility: hidden;
        background: rgba(10, 28, 52, .45);
        opacity: 0;
        transition: opacity .2s ease, visibility .2s ease;
    }
    body.menu-open .menu-overlay { visibility: visible; opacity: 1; }
    .page-intro h1 { font-size: 30px; }
    .content-hero h1 { font-size: 30px; }
    .section-title { font-size: 22px; }
    /* Закрытое мобильное меню оставляет ссылки доступными перед подвалом без большого баннера. */
    .prefooter-communities { display: block; padding-bottom: 24px; }
    /* В открытом меню доступна его копия; сохраняем место перед подвалом, чтобы страница не прыгала. */
    body.menu-open .prefooter-communities { visibility: hidden; }
    .footer-row {
        min-height: 104px;
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        text-align: center;
    }
}

/* Адаптив: узкие экраны. */
@media (max-width: 520px) {
    .search input { min-width: 0; }
    .search button { width: 42px; }
    .page-intro { padding-top: 0; }
    .page-intro h1 { font-size: 27px; }
    .content-hero h1 { font-size: 27px; }
    .content-preview img { border-radius: 18px; }
    .content-button { width: 100%; max-width: 220px; }
    .share-panel { padding: 6px; border-radius: 16px; }
    .share-services { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
    .share-service { min-height: 52px; border-radius: 12px; }
    .section { padding-top: 28px; }
    .section-head { align-items: start; }
    .section-link { font-size: 14px; }
    .gallery,
    .category-grid { grid-template-columns: 1fr; }
    .postcard { max-width: 340px; }
    .category-item { grid-template-columns: 54px minmax(0, 1fr) auto; }
    .category-thumb { width: 54px; height: 54px; }
}

@media (max-width: 340px) {
    .container { width: calc(100% - 16px); }
    .header-row { grid-template-columns: minmax(0, 1fr) 42px 42px; gap: 8px; }
    .brand-logo { width: 150px; max-height: 40px; }
    .mobile-menu-button,
    .mobile-search-button { width: 42px; height: 42px; }
    .search { left: 8px; right: 8px; padding: 6px; }
    .search input { height: 42px; padding-inline: 12px; }
    .search button { height: 42px; flex-basis: 42px; }
    .page-intro h1 { font-size: 24px; }
    .content-hero h1 { font-size: 24px; }
    .share-services { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-head { gap: 10px; }
    .section-link { width: 100%; max-width: 220px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
