/* ============================================================
   Paushu Reel Theme — main.css
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --accent:       #e63030;
    --bg:           #0a0a0a;
    --surface:      #161616;
    --text:         #f0ece4;
    --muted:        rgba(240,236,228,.55);
    --header-h:     0px;            /* шапка убрана, оставлено для совместимости */
    --rail-w:       58px;           /* ширина сквозной правой панели */
    --radius:       10px;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body:    'Manrope', 'Helvetica Neue', sans-serif;
    --safe-bottom:  env(safe-area-inset-bottom, 0px);
    --safe-top:     env(safe-area-inset-top, 0px);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }

/* ── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;0,700;1,500&family=Manrope:wght@400;500;600&display=swap');

/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════════
   (Old .site-header / .nav-toggle / .site-nav removed — UI переехал в #paushu-rail)
══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   REEL FEED (TikTok-style)
══════════════════════════════════════════════════════════════ */
.reel-feed {
    height: 100dvh;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar */
    scrollbar-width: none;
}
.reel-feed::-webkit-scrollbar { display: none; }

/* ── Slide / Card ───────────────────────────────────────────── */
.reel-slide {
    position: relative;
    width: 100%;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

/* ── Media area ─────────────────────────────────────────────── */
.reel-media {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.reel-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.reel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* iframe wrapper for YouTube/Vimeo */
.reel-iframe-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.reel-iframe-wrap .reel-thumb-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reel-iframe-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none; /* prevent iframe eating touch events */
}

.reel-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: rgba(255,255,255,.85);
    text-shadow: 0 2px 20px rgba(0,0,0,.5);
    pointer-events: none;
    transition: opacity .3s;
}

.reel-iframe-wrap.is-playing .reel-play-icon,
.reel-iframe-wrap.is-playing .reel-thumb-placeholder {
    opacity: 0;
    pointer-events: none;
}

/* ── Gradient overlay ───────────────────────────────────────── */
.reel-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,.35) 0%,        /* top — header area */
        transparent 30%,
        transparent 50%,
        rgba(0,0,0,.5) 72%,
        rgba(0,0,0,.85) 100%       /* bottom — info area */
    );
    pointer-events: none;
}

/* ── Info panel (bottom 20%) ────────────────────────────────── */
.reel-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 2;
    padding: 20px 20px calc(20px + var(--safe-bottom));
    min-height: 20dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
}

.reel-cat {
    display: inline-block;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(230,48,48,.12);
    border: 1px solid rgba(230,48,48,.35);
    border-radius: 4px;
    padding: 2px 8px;
    align-self: flex-start;
    text-decoration: none;
    transition: background .18s, border-color .18s, transform .15s;
}
a.reel-cat:hover {
    background: rgba(230,48,48,.22);
    border-color: rgba(230,48,48,.55);
}
a.reel-cat:active { transform: scale(.96); }

.reel-title {
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 5vw, 1.5rem);
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    text-shadow: 0 1px 12px rgba(0,0,0,.6);
}

.reel-title a { color: inherit; }

.reel-excerpt {
    font-size: .82rem;
    line-height: 1.5;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reel-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.reel-date {
    font-size: .75rem;
    color: var(--muted);
}

/* .reel-read-btn удалён — кнопка «открыть пост» теперь в rail (.rail-btn--open) */

/* ── No media fallback ──────────────────────────────────────── */
.reel-no-media {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--surface) 0%, #1e1e1e 100%);
}

/* ══════════════════════════════════════════════════════════════
   (Old .reel-sidebar / .sb-* removed — контролы переехали в #paushu-rail)
══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   TOAST уведомление
══════════════════════════════════════════════════════════════ */
.paushu-toast {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 80px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 9999;
    background: rgba(20,20,20,.92);
    border: 1px solid rgba(255,255,255,.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    font-size: .82rem;
    font-family: var(--font-body);
    padding: 9px 18px;
    border-radius: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    white-space: nowrap;
}

.paushu-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ── Loader ─────────────────────────────────────────────────── */
.reel-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    /* height и scroll-snap-align наследуются от .reel-slide */
}

.reel-loader__spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,.12);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ────────────────────────────────────────────── */
.reel-empty {
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 1rem;
}

/* ══════════════════════════════════════════════════════════════
   FOOTER (only visible on single posts / other pages)
══════════════════════════════════════════════════════════════ */
.site-footer {
    padding: 24px 20px calc(20px + var(--safe-bottom));
    text-align: center;
    font-size: .75rem;
    color: var(--muted);
    border-top: 1px solid rgba(255,255,255,.06);
    background: var(--bg);
}

/* On feed, footer is hidden (feed is full-screen) */
.home .site-footer,
.blog .site-footer {
    display: none;
}

/* .archive-context удалён — контекст архива теперь в .rail-menu-context (см. rail-стили) */

.ctx-label {
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.4);
}

.ctx-value {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ── Scroll-snap hint arrow (auto-hides) ───────────────────── */
.reel-scroll-hint {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    color: rgba(255,255,255,.5);
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    animation: hintFloat 1.8s ease-in-out infinite, hintFadeOut 3s 3s forwards;
}

.reel-scroll-hint svg {
    animation: hintFloat 1.8s ease-in-out infinite;
}

@keyframes hintFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(6px); }
}

@keyframes hintFadeOut {
    to { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   УНИВЕРСАЛЬНАЯ КОЛОНКА 9:16 — без медиа-брейкпоинтов по ширине
   Логика:
     экран шире 9:16  → колонка = высота экрана × (9/16)
     экран уже  9:16  → колонка = полная ширина экрана
   Формула min(100vw, 100dvh × 9/16) даёт оба случая автоматически.
══════════════════════════════════════════════════════════════ */

:root {
    --phone-w:  min(100vw, calc(100dvh * 9 / 16));
    --col-left: calc(50% - var(--phone-w) / 2);
}

/* ── Страница не скроллится сама — скролл только внутри колонки */
html, body {
    overflow: hidden;
    height: 100dvh;
    background: #060606;
}

/* ── Тонкая рамка вокруг колонки + тени по бокам ────────────
   Когда колонка = 100vw (узкий телефон), рамка на краях экрана —
   не видна. Когда колонка < 100vw — видны боковые тени.        */
body::after {
    content: '';
    position: fixed;
    top: 0; bottom: 0;
    left: var(--col-left);
    width: var(--phone-w);
    outline: 1px solid rgba(255,255,255,.06);
    box-shadow:
        -100px 0 200px rgba(0,0,0,.98),
          100px 0 200px rgba(0,0,0,.98);
    pointer-events: none;
    z-index: 9000;
}

/* ── Подпись слева от колонки (видна только на широких экранах)
   Когда колонка = 100vw: right = 50% + 50vw + 20px = 100vw + 20px
   → уходит за край, не видна. Безопасно оставить всегда.       */
body::before {
    content: 'paushu.ru';
    position: fixed;
    left: 0;
    right: calc(50% + var(--phone-w) / 2 + 20px);
    bottom: 28px;
    text-align: right;
    font-family: var(--font-display);
    font-size: .6rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: rgba(255,255,255,.07);
    pointer-events: none;
    z-index: 8999;
}

/* ── Лента: фиксированная, в пределах колонки ──────────────── */
.reel-feed {
    position: fixed;
    top: 0; bottom: 0;
    left: var(--col-left);
    right: auto;
    width: var(--phone-w);
    height: 100dvh;
}

/* ── Одиночный пост (уже position:fixed) ────────────────────── */
.single-reel {
    left: var(--col-left);
    right: auto;
    width: var(--phone-w);
}

/* ── Rail и drawer'ы: прижать к правому краю колонки, не экрана ── */
.paushu-rail {
    right: var(--col-left);         /* симметрично от правого края колонки */
}
.rail-drawer__inner {
    right: calc(var(--col-left) + var(--rail-w));
    /* И не шире колонки за вычетом rail */
    max-width: calc(var(--phone-w) - var(--rail-w));
}

/* Тоаст и scroll-hint центрируем по колонке с учётом rail */
.paushu-toast,
.reel-scroll-hint {
    left: calc(var(--col-left) + (var(--phone-w) - var(--rail-w)) / 2);
}

/* ── Футер скрыт на всех лентах ─────────────────────────────── */
.home .site-footer,
.blog .site-footer,
.archive .site-footer,
.search .site-footer {
    display: none;
}

/* ── Scroll-hint и fixed-попапы уже используют left:50% + translateX(-50%)
   что всегда совпадает с центром колонки — менять не нужно.    */

/* ── Share modal (fallback когда нет navigator.share) ──────────────────── */
body.psm-open { overflow: hidden; }

.paushu-share-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    outline: none;
}
.paushu-share-modal.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.psm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.psm-card {
    position: relative;
    width: 100%;
    max-width: 340px;
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 24px 48px rgba(0,0,0,.5);
    transform: translateY(8px) scale(.98);
    transition: transform .22s ease;
}
.paushu-share-modal.is-visible .psm-card {
    transform: translateY(0) scale(1);
}

.psm-close {
    position: absolute;
    top: 6px; right: 8px;
    width: 32px; height: 32px;
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: background .15s, color .15s;
}
.psm-close:hover { background: rgba(255,255,255,.06); color: var(--text); }

/* Постер (картинка поста) — основной кликабельный элемент */
.psm-poster {
    display: block;
    width: 100%;
    aspect-ratio: 9 / 16;
    max-height: 320px;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(255,255,255,.04);
    margin-bottom: 14px;
    position: relative;
}
.psm-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s ease;
}
.psm-poster:hover img { transform: scale(1.03); }

/* Если картинки нет — покажем название крупно */
.psm-poster--nopic {
    aspect-ratio: auto;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}
.psm-poster-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text);
    line-height: 1.3;
}

.psm-quote {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--muted);
    font-size: .92rem;
    line-height: 1.45;
    padding: 0 8px;
    margin-bottom: 14px;
    border-left: 2px solid var(--accent);
    padding-left: 12px;
    max-height: 4.5em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.psm-networks {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.psm-net {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 2px;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: .66rem;
    transition: background .15s;
}
.psm-net:hover { background: rgba(255,255,255,.06); }

.psm-net-icon {
    width: 36px; height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    color: var(--text);
}
.psm-net--tg   .psm-net-icon { background: #2AABEE; color: #fff; }
.psm-net--wa   .psm-net-icon { background: #25D366; color: #fff; }
.psm-net--vk   .psm-net-icon { background: #0077FF; color: #fff; }
.psm-net--tw   .psm-net-icon { background: #000;    color: #fff; }
.psm-net--copy .psm-net-icon { background: rgba(255,255,255,.1); color: var(--text); }

.psm-net-label {
    color: var(--muted);
    letter-spacing: .02em;
}

/* Узкие экраны — 3 колонки в 2 ряда */
@media (max-width: 360px) {
    .psm-networks { grid-template-columns: repeat(3, 1fr); }
}


/* ════════════════════════════════════════════════════════════════════════
   PAUSHU RAIL — единая правая панель управления
   Поверх контента, полупрозрачный стиль, одна группа кнопок.
   Контент НЕ сдвигается — rail лежит оверлеем.
   ════════════════════════════════════════════════════════════════════════ */

:root {
    --rail-w:        56px;
    --rail-w-desk:   64px;
    --rail-btn-size: 44px;
    --rail-pad-v:    10px;
    --rail-gap:      8px;
    /* Стиль «стекла»: полупрозрачное чёрное со слабым блюром */
    --rail-btn-bg:        rgba(20, 20, 20, .38);
    --rail-btn-bg-hover:  rgba(20, 20, 20, .58);
    --rail-btn-border:    rgba(255, 255, 255, .12);
    --rail-btn-border-hv: rgba(255, 255, 255, .22);
}

/* ── Сам rail: fixed, прозрачный фон (никакого градиента/подложки) ──
   Контент виден насквозь; каждая кнопка сама несёт своё стекло. */
.paushu-rail {
    position: fixed;
    top: var(--safe-top);
    right: 0;
    bottom: var(--safe-bottom);
    width: var(--rail-w);
    z-index: 95;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;     /* центруем группу кнопок по вертикали */
    gap: var(--rail-gap);
    padding: var(--rail-pad-v) 0;
    pointer-events: none;        /* только кнопки перехватывают клики */
    -webkit-user-select: none;
    user-select: none;
}
@media (min-width: 600px) {
    .paushu-rail { width: var(--rail-w-desk); }
}

/* Видео-группа — визуально не отличается от остальных кнопок,
   просто ведёт себя как подгруппа (можно спрятать целиком). */
.rail-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--rail-gap);
}
.rail-group[hidden] { display: none; }

/* ── Универсальная кнопка rail ──────────────────────────────────── */
.rail-btn {
    width: var(--rail-btn-size);
    height: var(--rail-btn-size);
    border-radius: 50%;
    background: var(--rail-btn-bg);
    border: 1px solid var(--rail-btn-border);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0;
    flex-shrink: 0;
    pointer-events: auto;
    text-decoration: none;
    font-family: var(--font-body);
    transition: background .18s, border-color .18s, transform .12s, color .18s;
    -webkit-tap-highlight-color: transparent;
    animation: rail-fade-in .22s ease;
}
.rail-btn[hidden] { display: none !important; }
.rail-btn:hover {
    background: var(--rail-btn-bg-hover);
    border-color: var(--rail-btn-border-hv);
}
.rail-btn:active { transform: scale(.88); }

.rail-btn svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
    pointer-events: none;
}

/* Счётчик лайков под иконкой */
.rail-count {
    font-size: .56rem;
    font-weight: 700;
    line-height: 1;
    color: rgba(255,255,255,.88);
    pointer-events: none;
    letter-spacing: .01em;
}
.rail-count:empty { display: none; }

/* ── Play / Pause icon swap ─────────────────────────────────────── */
.rail-btn--play .ri--play  { display: none; }
.rail-btn--play .ri--pause { display: block; }
.paushu-rail.is-paused .rail-btn--play .ri--play  { display: block; }
.paushu-rail.is-paused .rail-btn--play .ri--pause { display: none; }

/* ── Mute icon swap ─────────────────────────────────────────────── */
.rail-btn--mute .ri--sound { display: block; }
.rail-btn--mute .ri--muted { display: none; }
.paushu-rail.is-muted .rail-btn--mute .ri--sound { display: none; }
.paushu-rail.is-muted .rail-btn--mute .ri--muted { display: block; }

/* ── Fullscreen icon swap ───────────────────────────────────────── */
/* fullscreen кнопка убрана */

/* ── Volume slider (вертикальный, круглый корпус как у кнопки) ─── */
.rail-vol-wrap {
    width: var(--rail-btn-size);
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rail-btn-bg);
    border: 1px solid var(--rail-btn-border);
    border-radius: 22px;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    pointer-events: auto;
    animation: rail-fade-in .22s ease;
}
.rail-vol {
    -webkit-appearance: none;
    appearance: none;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 4px;
    height: 52px;
    background: rgba(255,255,255,.2);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
    accent-color: #fff;
}
.rail-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 4px rgba(0,0,0,.5);
}

/* ── Скорость: текстовая кнопка ─────────────────────────────────── */
.rail-btn--speed { font-size: .72rem; font-weight: 700; letter-spacing: -.01em; }
.rail-speed-label { pointer-events: none; }

/* ── Лайк active ────────────────────────────────────────────────── */
.rail-btn--like svg { transition: fill .18s, stroke .18s, transform .18s; }
.rail-btn--like.is-liked svg {
    fill: var(--accent);
    stroke: var(--accent);
    transform: scale(1.18);
}
.rail-btn--like.is-liked { border-color: rgba(230,48,48,.4); }

/* ── Поиск / меню — тот же стиль что у остальных кнопок ─────────
   В активном состоянии (drawer открыт) — акцент, чтобы было видно. */
.rail-btn--search[aria-expanded="true"],
.rail-btn--menu[aria-expanded="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Появление кнопок при смене слайда ───────────────────────── */
@keyframes rail-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════════════════
   DRAWER — выпадающие панели поиска и меню (выезжают справа, прилипают к rail)
   ════════════════════════════════════════════════════════════════════════ */
body.rail-drawer-open { overflow: hidden; }

.rail-drawer {
    position: fixed;
    inset: 0;
    z-index: 96;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
}
.rail-drawer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.rail-drawer__inner {
    position: absolute;
    top: 0; bottom: 0;
    right: var(--rail-w);
    width: min(360px, calc(100vw - var(--rail-w)));
    background: rgba(16, 16, 16, .96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: calc(var(--safe-top) + 18px) 22px calc(var(--safe-bottom) + 22px);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.16,1,.3,1);
    box-shadow: -8px 0 24px rgba(0,0,0,.45);
}
@media (min-width: 600px) {
    .rail-drawer__inner { right: var(--rail-w-desk); }
}
.rail-drawer.is-open .rail-drawer__inner {
    transform: translateX(0);
}

.rail-drawer__close {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 26px;
    line-height: 1;
    width: 32px; height: 32px;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.rail-drawer__close:hover { background: rgba(255,255,255,.08); color: var(--text); }

/* ── Search drawer ──────────────────────────────────────────────── */
.rail-search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    padding-bottom: 10px;
}
.rail-search-form input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.25rem;
    padding: 6px 0;
    -webkit-appearance: none;
}
.rail-search-form input[type="search"]::placeholder {
    color: var(--muted);
    font-style: italic;
}
.rail-search-submit {
    background: transparent;
    border: 0;
    color: var(--text);
    width: 34px; height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background .15s;
    flex-shrink: 0;
}
.rail-search-submit:hover { background: rgba(255,255,255,.08); }

/* ── Menu popover ───────────────────────────────────────────────
   Выпадает рядом с кнопкой меню (справа внизу), не на весь экран.
   Пункты — пилулы в стилистике .reel-cat, только крупнее. */
.rail-drawer--menu.rail-popover {
    /* Бэкдроп прозрачный, но inset: 0 остаётся — чтобы клик мимо popover закрывал */
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.rail-drawer--menu.rail-popover.is-open {
    /* Не блокируем body scroll для такого компактного попапа */
}
body.rail-drawer-open:has(.rail-drawer--menu.is-open:not(.rail-drawer--search)) {
    overflow: auto;
}
.rail-drawer--menu.rail-popover .rail-drawer__inner,
.rail-popover__inner {
    position: absolute;
    /* Позиция рядом с кнопкой меню: справа, сверху (под кнопкой, т.к. меню теперь
       наверху rail). Popover выезжает из-под кнопки вниз. */
    top: calc(var(--safe-top) + var(--rail-pad-v) + var(--rail-btn-size) + 12px);
    bottom: auto;
    right: calc(var(--rail-w) + 8px);
    left: auto;
    width: auto;
    max-width: min(280px, calc(100vw - var(--rail-w) - 24px));
    padding: 8px;
    background: rgba(16, 16, 16, .92);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,.5);
    transform: translateX(8px) scale(.96);
    transform-origin: top right;
    transition: transform .22s cubic-bezier(.16,1,.3,1), opacity .18s;
    opacity: 0;
}
.rail-drawer--menu.rail-popover.is-open .rail-drawer__inner,
.rail-drawer--menu.rail-popover.is-open .rail-popover__inner {
    transform: translateX(0) scale(1);
    opacity: 1;
}
/* Десктоп: подтянуть popover к правому краю колонки */
@media (min-width: 600px) {
    .rail-drawer--menu.rail-popover .rail-drawer__inner,
    .rail-popover__inner {
        right: calc(var(--col-right, 0px) + var(--rail-w-desk) + 8px);
    }
}

.rail-popover .rail-menu-nav { margin: 0; }

.rail-popover .rail-menu-list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rail-popover .rail-menu-list li a {
    display: block;
    font-family: var(--font-body);
    font-size: .92rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--accent);
    background: rgba(230,48,48,.10);
    border: 1px solid rgba(230,48,48,.3);
    border-radius: 999px;
    padding: 8px 16px;
    text-decoration: none;
    transition: background .18s, border-color .18s, transform .15s, color .18s;
    text-align: center;
    white-space: nowrap;
}
.rail-popover .rail-menu-list li a:hover {
    background: rgba(230,48,48,.22);
    border-color: rgba(230,48,48,.5);
    color: #fff;
}
.rail-popover .rail-menu-list li a:active { transform: scale(.96); }

/* Текущий пункт меню (.current-menu-item от WP) — залит акцентом */
.rail-popover .rail-menu-list li.current-menu-item a,
.rail-popover .rail-menu-list li.current-menu-ancestor a {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ════════════════════════════════════════════════════════════════════════
   Контент НЕ сдвигается — rail лежит оверлеем.
   Но мелкие inline-элементы внизу карточки (.reel-info, .hero-content)
   чуть прижимаем к левому краю, чтобы не перекрываться кнопками.
   ════════════════════════════════════════════════════════════════════════ */
.reel-feed,
.single-reel {
    padding-right: 0;
}
.reel-slide .reel-info {
    padding-right: calc(var(--rail-w) + 4px);
}
@media (min-width: 600px) {
    .reel-slide .reel-info { padding-right: calc(var(--rail-w-desk) + 6px); }
}
/* Hero-текст в single-posts — то же */
.single-slide--hero .hero-content {
    padding-right: calc(var(--rail-w) + 4px);
}
@media (min-width: 600px) {
    .single-slide--hero .hero-content { padding-right: calc(var(--rail-w-desk) + 6px); }
}
/* Exit-слайд центрирован — никаких отступов не нужно, контент сам узкий */

/* Тоаст и scroll-hint центрируем по «видимой» части (без rail) */
.paushu-toast,
.reel-scroll-hint {
    left: calc(50% - var(--rail-w) / 2);
}
@media (min-width: 600px) {
    .paushu-toast,
    .reel-scroll-hint {
        left: calc(50% - var(--rail-w-desk) / 2);
    }
}

/* Rail и drawer прижаты к правому краю колонки 9:16 на десктопе */
@media (min-width: 600px) {
    :root { --col-right: calc(50vw - var(--phone-w) / 2); }
    .paushu-rail { right: var(--col-right); }
    .rail-drawer__inner {
        right: calc(var(--col-right) + var(--rail-w-desk));
        max-width: calc(var(--phone-w) - var(--rail-w-desk));
    }
    .paushu-toast,
    .reel-scroll-hint {
        left: calc(var(--col-left) + (var(--phone-w) - var(--rail-w-desk)) / 2);
    }
}

/* Узкие мобильные — ужимаем rail чтобы не доминировал */
@media (max-width: 360px) {
    :root {
        --rail-w: 50px;
        --rail-btn-size: 40px;
    }
    .rail-btn svg { width: 18px; height: 18px; }
}

/* Accessibility helper */
.screen-reader-text {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* ════════════════════════════════════════════════════════════════════════
   CYCLE DIVIDER — финальный слайд «вы досмотрели ленту»
   ════════════════════════════════════════════════════════════════════════ */
.reel-cycle-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--bg) 0%, #151012 100%);
    position: relative;
}

.cycle-inner {
    max-width: 280px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    padding-right: calc(var(--rail-w) + 20px); /* не под rail */
}
@media (min-width: 600px) {
    .cycle-inner { padding-right: calc(var(--rail-w-desk) + 24px); }
}

.cycle-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: var(--accent);
    margin-bottom: 4px;
    animation: cycle-arrow-bounce 1.6s ease-in-out infinite;
}

@keyframes cycle-arrow-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.cycle-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: .01em;
}

.cycle-sub {
    font-size: .85rem;
    color: var(--muted);
    line-height: 1.4;
    letter-spacing: .02em;
}

.cycle-back-btn {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: 0;
    padding: 12px 28px;
    border-radius: 28px;
    font-weight: 600;
    font-size: .9rem;
    letter-spacing: .04em;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background .2s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.cycle-back-btn:hover  { background: #c42020; }
.cycle-back-btn:active { transform: scale(.96); }

/* ════════════════════════════════════════════════════════════════════════
   PINNED категория/метка на страницах архива
   Та же стилистика что .reel-cat (пилула с полупрозрачным акцентом),
   но крупнее и прижата к верху экрана, поверх слайдов.
   ════════════════════════════════════════════════════════════════════════ */
.reel-pin {
    position: fixed;
    top: calc(var(--safe-top) + 14px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;              /* ниже rail (95), но выше overlay-ов слайда */
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    max-width: calc(100vw - var(--rail-w) - 32px);
    padding: 8px 18px;
    font-family: var(--font-body);
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(230, 48, 48, .14);
    border: 1px solid rgba(230, 48, 48, .45);
    border-radius: 999px;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
    text-decoration: none;
    transition: background .18s, border-color .18s, transform .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reel-pin:hover {
    background: rgba(230, 48, 48, .22);
    border-color: rgba(230, 48, 48, .6);
}
.reel-pin:active { transform: translateX(-50%) scale(.97); }

.reel-pin-prefix {
    font-weight: 700;
    opacity: .8;
}
.reel-pin-label { letter-spacing: .08em; }

/* На десктопе центрируем по колонке, с учётом rail */
@media (min-width: 600px) {
    .reel-pin {
        left: calc(var(--col-left) + (var(--phone-w) - var(--rail-w-desk)) / 2);
        transform: translateX(-50%);
        max-width: calc(var(--phone-w) - var(--rail-w-desk) - 32px);
    }
    .reel-pin:active { transform: translateX(-50%) scale(.97); }
}

/* На совсем узких — чуть компактнее */
@media (max-width: 360px) {
    .reel-pin {
        font-size: .75rem;
        padding: 6px 14px;
        letter-spacing: .08em;
    }
}

/* .rail-menu-list--nav / .rail-menu-special / .rail-menu-ico удалены —
   кнопки «Домой» и «Назад» переехали из меню прямо в rail. */

/* ════════════════════════════════════════════════════════════════════════
   UI HIDE — при классе body.ui-hidden прячем rail и все подписи
   (заголовок/рубрика/дата внизу, pin сверху). Контент (картинки/видео)
   остаётся виден. Повторный тап возвращает.
   ════════════════════════════════════════════════════════════════════════ */
body.ui-hidden .paushu-rail,
body.ui-hidden .reel-pin,
body.ui-hidden .reel-info,
body.ui-hidden .hero-content,
body.ui-hidden .block-actions,
body.ui-hidden .slide-next-peek,
body.ui-hidden .reel-scroll-hint {
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

/* Обратный переход — появление */
.paushu-rail,
.reel-pin,
.reel-info,
.hero-content,
.block-actions,
.slide-next-peek,
.reel-scroll-hint {
    transition: opacity .25s ease;
}

/* Чтобы тап был приятнее — меняем курсор на указатель в пустом месте слайда */
.reel-slide,
.single-slide {
    cursor: pointer;
}
/* Но на интерактивных — default курсор */
.reel-slide a, .reel-slide button,
.single-slide a, .single-slide button,
.paushu-rail, .paushu-rail * {
    cursor: auto;
}
.rail-btn, .reel-pin, .reel-cat, .rail-menu-list a {
    cursor: pointer;
}

/* ════════════════════════════════════════════════════════════════════════
   GALLERY MODE — горизонтальный свайп переключает reel в галерею 3×3.
   Слайды группируются в страницы по 9 через JS (.gallery-page).
   Страницы листаются вертикальным scroll-snap.
   ════════════════════════════════════════════════════════════════════════ */

/* Rail и pin прячем в галерее */
body.galleries-mode .paushu-rail,
body.galleries-mode .reel-pin {
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

/* ── Общий контейнер галереи (feed или single-reel) ────────── */
.reel-feed.galleries-mode,
.single-reel.galleries-mode {
    display: flex !important;
    flex-direction: column;
    gap: 0;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    background: var(--bg);
}
.reel-feed.galleries-mode::-webkit-scrollbar,
.single-reel.galleries-mode::-webkit-scrollbar { display: none; }

/* ── Страница галереи (ровно 9 тайлов) ──────────────────────── */
.gallery-page {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    padding: calc(var(--safe-top) + 8px) 8px calc(var(--safe-bottom) + 8px);
    height: 100dvh;
    min-height: 100dvh;
    flex: 0 0 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    align-content: stretch;
    justify-content: stretch;
    box-sizing: border-box;
}

/* Пагинатор — мелкие точки внизу страницы */
.gallery-page-indicator {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 12px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 97;
    pointer-events: none;
    transition: opacity .2s;
}
body:not(.galleries-mode) .gallery-page-indicator { opacity: 0; }
.gallery-page-indicator .dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,.35);
    transition: background .2s, transform .2s;
}
.gallery-page-indicator .dot.is-active {
    background: var(--accent);
    transform: scale(1.4);
}

/* ── Тайл в галерее (и для .reel-slide, и для .single-slide) ── */
.gallery-page .reel-slide,
.gallery-page .single-slide {
    height: auto !important;
    aspect-ratio: auto;
    width: 100%;
    scroll-snap-align: none;
    overflow: hidden;
    border-radius: 8px;
    display: block !important;
    position: relative;
    cursor: pointer;
    transition: transform .15s;
    background: var(--surface);
    min-height: 0; /* grid-child must shrink */
}
.gallery-page .reel-slide:active,
.gallery-page .single-slide:active {
    transform: scale(.96);
}

/* Медиа заполняет весь тайл */
.gallery-page .reel-media {
    position: absolute;
    inset: 0;
}
.gallery-page .reel-video,
.gallery-page .reel-img,
.gallery-page .reel-thumb-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-page .reel-no-media {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--surface) 0%, #1e1e1e 100%);
}

/* reel-info — узкий overlay снизу */
.gallery-page .reel-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 6px 8px !important;
    background: linear-gradient(to top, rgba(0,0,0,.88) 0%, transparent 100%);
    pointer-events: none;
    gap: 2px;
    margin-top: 0;
}
.gallery-page .reel-title {
    font-size: .65rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.gallery-page .reel-title a {
    color: #fff;
    text-decoration: none;
    pointer-events: none;
}
.gallery-page .reel-cat,
.gallery-page .reel-excerpt,
.gallery-page .reel-meta,
.gallery-page .reel-overlay {
    display: none;
}

/* Лоадер и cycle-divider в галерее не нужны — они не попадут в страницы */
.gallery-page .reel-loader,
.gallery-page .reel-cycle-divider { display: none; }

/* ── Hero-слайд single-поста в галерее ──────────────────────── */
.gallery-page .single-slide--hero .hero-image-wrap {
    position: absolute;
    inset: 0;
}
.gallery-page .single-slide--hero .hero-img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.gallery-page .single-slide--hero .hero-content {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 6px 8px !important;
    background: linear-gradient(to top, rgba(0,0,0,.88) 0%, transparent 100%);
    pointer-events: none;
}
.gallery-page .single-slide--hero .hero-title {
    font-size: .7rem !important;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}
.gallery-page .single-slide--hero .slide-cat,
.gallery-page .single-slide--hero .hero-meta,
.gallery-page .single-slide--hero .hero-hint,
.gallery-page .single-slide--hero .hero-img-overlay {
    display: none;
}

/* ── Block-тайл: мини-превью HTML ────────────────────────── */
.gallery-page .single-slide--block {
    background: var(--bg);
    border: 1px solid rgba(255,255,255,.08);
}
.gallery-page .single-slide--block .slide-inner {
    overflow: hidden;
    height: 100%;
}
.gallery-page .slide-content {
    font-size: 6px;
    line-height: 1.4;
    padding: 10px;
    color: rgba(255,255,255,.75);
    overflow: hidden;
    max-height: 100%;
}
.gallery-page .slide-content h1,
.gallery-page .slide-content h2,
.gallery-page .slide-content h3,
.gallery-page .slide-content h4 {
    font-size: 8px;
    margin: 0 0 4px;
}
.gallery-page .slide-content p { margin: 0 0 3px; }
.gallery-page .slide-content img {
    max-width: 100%; height: auto; display: block;
    border-radius: 3px; margin: 2px 0;
}

/* Блок с картинкой — картинка на весь тайл */
.gallery-page .single-slide--block[data-block-img]:not([data-block-img=""]) {
    background: #000;
}
.gallery-page .single-slide--block[data-block-img]:not([data-block-img=""]) .slide-content {
    position: absolute;
    inset: 0;
    padding: 0;
}
.gallery-page .single-slide--block[data-block-img]:not([data-block-img=""]) .slide-content img {
    width: 100%; height: 100%;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
}
.gallery-page .single-slide--block[data-block-img]:not([data-block-img=""]) .slide-content p,
.gallery-page .single-slide--block[data-block-img]:not([data-block-img=""]) .slide-content h1,
.gallery-page .single-slide--block[data-block-img]:not([data-block-img=""]) .slide-content h2 {
    display: none;
}

/* Служебные элементы блока прячем */
.gallery-page .slide-bottom-sentinel,
.gallery-page .slide-next-peek,
.gallery-page .block-actions { display: none; }

/* Номер блока в углу тайла */
.gallery-page .single-slide--block::before {
    content: attr(data-index);
    position: absolute;
    top: 4px; right: 6px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,.85);
    background: rgba(0,0,0,.55);
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
    font-family: var(--font-body);
}

/* Подсветка «текущего» тайла — с которого пришли */
.gallery-page .is-current-tile {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Колонка 9:16 на десктопе */
@media (min-width: 600px) {
    .reel-feed.galleries-mode,
    .single-reel.galleries-mode {
        left: var(--col-left);
        width: var(--phone-w);
    }
}

/* ── FAB — выход обратно в reel ─────────────────────────── */
.gallery-toggle-fab {
    display: none;
    position: fixed;
    bottom: calc(var(--safe-bottom) + 20px);
    right: 20px;
    z-index: 99;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent);
    border: 0;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,.5);
    align-items: center;
    justify-content: center;
    transition: transform .15s;
}
body.galleries-mode .gallery-toggle-fab {
    display: flex;
    animation: rail-fade-in .25s ease;
}
.gallery-toggle-fab:active { transform: scale(.92); }
.gallery-toggle-fab svg { width: 22px; height: 22px; }

@media (min-width: 600px) {
    .gallery-toggle-fab { right: calc(var(--col-left) + 20px); }
}
