* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --brand: #00b0c9;
    --brand-dark: #0093a8;
    --brand-glow: rgba(0, 176, 201, 0.3);
    --brand-soft: rgba(0, 176, 201, 0.12);
    --bg: #0f1419;
    --bg-elev: #1a1f24;
    --bg-elev-2: #232a30;
    --ink: #f5f5f7;
    --ink-muted: #9aa0a6;
    --ink-faint: #5f6368;
    --line: rgba(255, 255, 255, 0.08);
    --radius: 20px;
    --radius-sm: 12px;
    --radius-pill: 999px;
}

html, body { background: var(--bg); overflow: hidden; height: 100%; }

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Главный экран — скроллится сам по себе */
#screen-home {
    height: 100vh;
    overflow-y: auto;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 30px;
}
#screen-home::-webkit-scrollbar { width: 4px; }
#screen-home::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 4px; }

/* ============ HEADER ============ */
.app-header { text-align: center; padding: 20px 0 24px; transition: transform 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease; }
.app-header-pushing { transform: translateY(-160px); opacity: 0; }
.app-logo {
    height: 56px;
    width: auto;
    margin-bottom: 12px;
    /* Одинаковый padding для обеих тем, чтобы не прыгало */
    padding: 6px;
    box-sizing: content-box;
    border-radius: 12px;
    transition: background-color 0.3s ease;
    background: #ffffff;
}
:root[data-theme="light"] .app-logo {
    background: transparent;
}
.app-header h1 { font-size: 26px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.03em; }
.app-subtitle { font-size: 13px; color: var(--ink-muted); font-weight: 500; }

/* ============ BENTO GRID ============ */
.bento-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 140px;
    gap: 12px;
}

.bento-item {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    transition: transform 0.45s cubic-bezier(0.4,0,0.2,1), opacity 0.35s ease;
    will-change: transform, opacity;
}

/* уезд остальных */
.bento-item-pushing {
    pointer-events: none;
    transform: translateY(calc(var(--push-dir, -1) * 120vh)) scale(0.9);
    opacity: 0;
}
/* оригинал, из которого делаем overlay — прячем без сдвига сетки */
.bento-item-source-hidden { opacity: 0 !important; pointer-events: none; }

.bento-icon { font-size: 32px; margin-bottom: 8px; }
.bento-title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.bento-subtitle { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.bento-arrow { position: absolute; top: 16px; right: 16px; color: var(--brand); font-size: 20px; font-weight: 700; }

.bento-afisha {
    grid-column: 1 / -1;
    grid-row: span 2;
    background: linear-gradient(135deg, #1e3a44 0%, #1a1f24 100%);
    border-color: rgba(0, 176, 201, 0.3);
    justify-content: center;
    padding: 32px 24px;
}
.bento-afisha .bento-icon { font-size: 48px; margin-bottom: 12px; }
.bento-afisha .bento-title { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.bento-afisha .bento-subtitle { font-size: 14px; }
.bento-afisha-bg {
    position: absolute; top: -50%; right: -20%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(0,176,201,0.15) 0%, transparent 70%);
    pointer-events: none;
}
.bento-afisha .bento-arrow { top: 24px; right: 24px; font-size: 28px; }

.bento-about { background: linear-gradient(135deg, #1a2a3a 0%, #1a1f24 100%); }
.bento-contacts { background: linear-gradient(135deg, #2a1f1a 0%, #1a1f24 100%); }
.bento-howto { background: linear-gradient(135deg, #1f2a1a 0%, #1a1f24 100%); }
.bento-socials { background: linear-gradient(135deg, #2a1a2a 0%, #1a1f24 100%); }

/* ============ ПРЕВЬЮ ВИДЖЕТОВ (размытые) ============ */
.bento-preview {
    position: absolute; inset: 0;
    overflow: hidden;
    pointer-events: none;
    filter: blur(3px);
    opacity: 0.25;
    padding: 16px;
    transition: opacity 0.35s ease, filter 0.35s ease, transform 0.45s ease;
}
.bento-preview-text { font-size: 13px; line-height: 1.6; color: var(--ink); font-weight: 500; }

.bento-preview-map { padding: 0; filter: none; opacity: 0.35; background: #1a2a20; }
.bento-map-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(0,176,201,0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,176,201,0.2) 1px, transparent 1px);
    background-size: 20px 20px;
}
.bento-map-pin { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 32px; }

.bento-preview-socials { padding: 0; filter: blur(2px); opacity: 0.3; }
.bento-social-icons {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 48px; letter-spacing: 8px; flex-wrap: wrap; padding: 20px;
}

/* Превью афиши */
.bento-afisha-preview {
    position: absolute; inset: 0; padding: 20px;
    display: flex; flex-direction: column; gap: 10px;
    opacity: 0.35; filter: blur(1px);
    pointer-events: none;
    transition: opacity 0.35s ease, filter 0.35s ease, transform 0.45s ease;
    mask-image: linear-gradient(to bottom, black 0%, black 30%, transparent 70%);
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 30%, transparent 70%);
}
.mini-show-card { background: rgba(255,255,255,0.08); border-radius: 10px; padding: 10px 14px; border: 1px solid rgba(0,176,201,0.2); }
.mini-show-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-show-date { font-size: 11px; color: var(--brand); font-weight: 600; }

.bento-content { position: relative; z-index: 2; transition: opacity 0.3s ease, transform 0.45s ease; }
.bento-afisha .bento-content { justify-content: flex-end; display: flex; flex-direction: column; }

.bento-item::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(26,31,36,0.95) 0%, rgba(26,31,36,0.5) 40%, transparent 80%);
    z-index: 1; pointer-events: none;
    transition: opacity 0.3s ease;
}
.bento-afisha::after { background: linear-gradient(to top, rgba(30,58,68,0.95) 0%, rgba(26,31,36,0.6) 50%, transparent 85%); }

/* ============ OVERLAY ============ */
#overlay {
    position: fixed; inset: 0;
    z-index: 1000;
    pointer-events: none;
    visibility: hidden;
}
#overlay.overlay-active { visibility: visible; pointer-events: auto; }

#overlay-widget {
    position: fixed;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    overflow: hidden;
    transition:
        top 0.32s cubic-bezier(0.4,0,0.2,1),
        left 0.32s cubic-bezier(0.4,0,0.2,1),
        width 0.32s cubic-bezier(0.4,0,0.2,1),
        height 0.32s cubic-bezier(0.4,0,0.2,1),
        border-radius 0.32s cubic-bezier(0.4,0,0.2,1);
    will-change: top, left, width, height;
    display: flex;
    flex-direction: column;
}

/* Внутри overlay: превью становится чётче и уходит, контент появляется */
#overlay-widget .bento-preview,
#overlay-widget .bento-afisha-preview {
    transition: opacity 0.35s ease, filter 0.45s ease, transform 0.45s ease;
}
#overlay-widget.overlay-widget-expanded .bento-preview {
    opacity: 0.55;
    filter: blur(0);
    transform: scale(1.15);
}
#overlay-widget.overlay-widget-expanded .bento-afisha-preview {
    opacity: 0.5;
    filter: blur(0);
    transform: scale(1.1);
}
#overlay-widget.overlay-widget-expanded .bento-content {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
}
#overlay-widget.overlay-widget-expanded .bento-arrow,
#overlay-widget.overlay-widget-expanded::after {
    opacity: 0;
}

/* Контент раздела */
.overlay-content {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 30px;
    opacity: 0;
    transform: scale(0.94);
    filter: blur(10px);
    transition: opacity 0.4s ease, transform 0.45s cubic-bezier(0.4,0,0.2,1), filter 0.45s ease;
    transition-delay: 0.08s;
    will-change: opacity, transform, filter;
    background: var(--bg);
    z-index: 3;
}
#overlay-widget.overlay-widget-expanded .overlay-content {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
    transition-delay: 0.12s;
}
.overlay-content.overlay-content-hidden {
    opacity: 0 !important;
    transition-delay: 0s !important;
}
.overlay-content::-webkit-scrollbar { width: 4px; }
.overlay-content::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 4px; }

/* ============ CONTENT (внутри overlay) ============ */



.section-header { margin-bottom: 20px; }
.section-header h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

.content-card {
    background: var(--bg-elev);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--line);
    margin-bottom: 16px;
    font-size: 15px;
    line-height: 1.7;
}
.content-card p { margin-bottom: 12px; }
.content-card p:last-child { margin-bottom: 0; }
.muted { color: var(--ink-muted); }

.link-btn {
    display: inline-block; padding: 12px 18px;
    background: var(--brand-soft); color: var(--brand);
    border-radius: var(--radius-sm);
    text-decoration: none; font-weight: 600; font-size: 14px;
    border: 1px solid rgba(0, 176, 201, 0.3);
}
.link-btn:hover { background: rgba(0, 176, 201, 0.2); }

/* Контакты */
.contact-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.contact-item:last-of-type { border-bottom: none; }
.contact-emoji { font-size: 32px; flex-shrink: 0; }
.contact-body { flex: 1; }
.contact-name { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.contact-role { font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; }
.contact-links { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.contact-link {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--brand); text-decoration: none;
    font-weight: 600; font-size: 14px; padding: 8px 0;
}

/* Карта */
.map-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; background: var(--bg-elev); line-height: 0; }
.map-wrap iframe { display: block; width: 100%; border: none; }

/* Фото */
.photo-card { background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; }
.photo-card img { display: block; width: 100%; max-height: 400px; object-fit: cover; }
.photo-caption { padding: 12px 18px; font-size: 13px; color: var(--ink-muted); text-align: center; background: var(--bg-elev-2); border-top: 1px solid var(--line); }

/* Соцсети */
.social-btn {
    display: flex; align-items: center; gap: 16px;
    padding: 18px; background: var(--bg-elev-2);
    border-radius: var(--radius-sm);
    text-decoration: none; color: var(--ink);
    margin-bottom: 10px; border: 1px solid var(--line);
}
.social-btn:hover { background: #2a3238; }
.social-icon { font-size: 28px; flex-shrink: 0; }
.social-btn > div { flex: 1; }
.social-title { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.social-url { font-size: 13px; color: var(--ink-muted); }
.social-arrow { font-size: 20px; color: var(--brand); font-weight: 700; }

/* ============ АФИША ============ */
.shows-list { display: flex; flex-direction: column; gap: 14px; }

.show-card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    cursor: pointer;
    opacity: 0;
    animation: cardIn 0.4s ease-out forwards;
}
.show-card:active { transform: scale(0.98); }
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.show-card-title { font-size: 18px; font-weight: 600; margin-top: 6px; }
.show-card-date { font-size: 14px; color: var(--brand); font-weight: 600; margin-bottom: 6px; margin-top: 10px; }
.show-card-price { font-size: 13px; color: var(--ink-muted); }

.badge {
    display: inline-block; padding: 4px 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff; border-radius: var(--radius-pill);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ============ ДЕТАЛКА ============ */
.detail-header { margin-bottom: 24px; }
.detail-title { font-size: 26px; font-weight: 700; line-height: 1.25; margin: 10px 0 12px; letter-spacing: -0.02em; }
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-badge { padding: 6px 14px; background: var(--bg-elev-2); border-radius: var(--radius-pill); font-size: 13px; font-weight: 600; border: 1px solid var(--line); }

.detail-info { background: var(--bg-elev); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 20px; border: 1px solid var(--line); }
.info-row { font-size: 15px; font-weight: 500; padding: 8px 0; display: flex; align-items: center; gap: 10px; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info-icon { font-size: 18px; flex-shrink: 0; }

.detail-section { background: var(--bg-elev); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; border: 1px solid var(--line); }
.detail-section h3 { font-size: 13px; font-weight: 700; color: var(--brand); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-desc { font-size: 15px; line-height: 1.7; }

.cast-grid { display: flex; flex-direction: column; gap: 16px; }
.cast-item { display: flex; align-items: center; gap: 14px; }
.cast-photo { width: 80px; height: 80px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; background: var(--bg-elev-2); }
.cast-photo-placeholder {
    width: 80px; height: 80px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand-soft), rgba(0, 176, 201, 0.05));
    color: var(--brand); font-weight: 700; font-size: 28px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cast-info { flex: 1; min-width: 0; }
.cast-name { font-size: 16px; font-weight: 600; line-height: 1.3; }
.cast-role { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }

.detail-ticket { position: sticky; bottom: 16px; margin-top: 8px; }
.btn-buy {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 18px; background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff; border-radius: var(--radius); font-size: 17px; font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 24px var(--brand-glow);
}
.btn-buy:active { transform: scale(0.98); }

/* Пусто */
.empty {
    text-align: center; padding: 60px 20px;
    color: var(--ink-muted); font-size: 15px;
    background: var(--bg-elev); border-radius: var(--radius); border: 1px solid var(--line);
}

/* ============ СКЕЛЕТОНЫ ============ */
.skeleton-card { background: var(--bg-elev); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px; border: 1px solid var(--line); }
.skeleton {
    background: linear-gradient(90deg, var(--bg-elev-2) 0%, #2e363d 50%, var(--bg-elev-2) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px; height: 16px; margin-bottom: 10px;
}
.skeleton-line-sm { width: 30%; height: 14px; }
.skeleton-line-md { width: 70%; }
.skeleton-line-lg { width: 90%; height: 22px; }
.skeleton:last-child { margin-bottom: 0; }
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Навигация в деталке спектакля */
.detail-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.detail-nav 

/* ============ Слои внутри overlay (афиша ↔ деталка) ============ */






/* ============ Тюнинг плавности афиша ↔ деталка ============ */

/* Перебиваем transition-delay у 

/* Новый слой: стартуем «за экраном», едем в 0 */


/* Целевое состояние «въехал» — с тем же transition, чтобы не было рывка */


/* Старый слой уезжает влево — плавно, без задержки */


/* Назад: деталка уезжает вправо */


/* Задний слой, из которого «возвращаемся» — едет обратно в 0 */


/* ============ Слои: переопределение (v2) ============ */

/* База для всех слоёв */


/* СТАРЫЙ слой — НАЧАЛО перехода: обычный вид */


/* СТАРЫЙ слой — КОНЕЦ: уехал влево-вглубь и размылся */


/* НОВЫЙ слой — НАЧАЛО: за правым краем, непрозрачный */


/* НОВЫЙ слой — КОНЕЦ: на месте */


/* НАЗАД: деталка уезжает вправо */



/* ============ Слои афиша ↔ деталка (финальные правила) ============ */

.overlay-content.layer-leaving-forward {
    transform: translateX(0) scale(1);
    opacity: 1;
    filter: blur(0);
    pointer-events: none;
    transition: transform .4s cubic-bezier(.4,0,.2,1),
                opacity   .4s ease,
                filter    .4s ease;
}

.overlay-content.layer-hidden-back {
    transform: translateX(-25%) scale(0.94);
    opacity: 0.35;
    filter: blur(3px);
    pointer-events: none;
    transition: transform .4s cubic-bezier(.4,0,.2,1),
                opacity   .4s ease,
                filter    .4s ease;
}

.overlay-content.layer-entering-forward {
    transform: translateX(100%) scale(1);
    opacity: 1;
    filter: blur(0);
    transition: transform .4s cubic-bezier(.4,0,.2,1),
                opacity   .4s ease,
                filter    .4s ease;
    will-change: transform;
}

.overlay-content.layer-visible {
    transform: translateX(0) scale(1);
    opacity: 1;
    filter: blur(0);
    transition: transform .4s cubic-bezier(.4,0,.2,1),
                opacity   .4s ease,
                filter    .4s ease;
}

.overlay-content.layer-leaving-back {
    transform: translateX(100%) scale(1);
    opacity: 1;
    filter: blur(0);
    transition: transform .4s cubic-bezier(.4,0,.2,1);
}

/* На мобиле кнопки "назад" прячем — навигация свайпом */


/* ============ ТЕМА: СВЕТЛАЯ ============ */
:root[data-theme="light"] {
    --brand: #007a8c;
    --brand-dark: #005f6e;
    --brand-glow: rgba(0, 122, 140, 0.25);
    --brand-soft: rgba(0, 122, 140, 0.12);
    --bg: #f5f5f7;
    --bg-elev: #ffffff;
    --bg-elev-2: #f0f0f3;
    --ink: #1a1a1e;
    --ink-muted: #5a5f66;
    --ink-faint: #9aa0a6;
    --line: rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] html,
:root[data-theme="light"] body { background: var(--bg); color: var(--ink); }
:root[data-theme="light"] .bento-afisha {
    background: linear-gradient(135deg, #d6ecf1 0%, #ffffff 100%);
    border-color: rgba(0, 122, 140, 0.3);
}
:root[data-theme="light"] .bento-about    { background: linear-gradient(135deg, #e8eef5 0%, #ffffff 100%); }
:root[data-theme="light"] .bento-contacts { background: linear-gradient(135deg, #f5ebe4 0%, #ffffff 100%); }
:root[data-theme="light"] .bento-howto    { background: linear-gradient(135deg, #e8f0e4 0%, #ffffff 100%); }
:root[data-theme="light"] .bento-socials  { background: linear-gradient(135deg, #f5e8f5 0%, #ffffff 100%); }
:root[data-theme="light"] .bento-item::after {
    background: linear-gradient(to top, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.5) 40%, transparent 80%);
}
:root[data-theme="light"] .bento-afisha::after {
    background: linear-gradient(to top, rgba(214,236,241,0.95) 0%, rgba(255,255,255,0.6) 50%, transparent 85%);
}
:root[data-theme="light"] .bento-afisha-preview .mini-show-card {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,122,140,0.25);
}
:root[data-theme="light"] .bento-preview-text { color: var(--ink-muted); }
:root[data-theme="light"] .overlay-content { background: var(--bg); }
:root[data-theme="light"] .skeleton {
    background: linear-gradient(90deg, #e8e8ec 0%, #f5f5f7 50%, #e8e8ec 100%);
    background-size: 200% 100%;
}
:root[data-theme="light"] .contact-link { color: var(--brand); }
:root[data-theme="light"] .social-btn:hover { background: #e5e5ea; }

/* ============ ЛОГОТИП: фон зависит от темы ============ */
/* По умолчанию (тёмная): белый фон + паддинг + скругление */
.app-logo {
    background: #ffffff;
    border-radius: 12px;
    padding: 6px;
    box-sizing: content-box;
}
/* На светлой теме фон не нужен */


/* ============ Плавный переход цветов темы ============ */
html { transition: background-color 0.3s ease; }

/* Чтобы он не наезжал на кнопку "Назад" в разделе (на всякий случай) */



/* ============ ТУМБЛЕР ТЕМЫ (ФИНАЛЬНЫЕ СТИЛИ) ============ */

/* Базовые стили для обоих тумблеров */
.theme-toggle {
    width: 64px;
    height: 34px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    display: block;
}
.theme-track {
    display: block;
    width: 64px;
    height: 34px;
    border-radius: 999px;
    position: relative;
    background: #2a3038;
    border: 1px solid rgba(255,255,255,0.08);
    transition: background-color 0.35s ease, border-color 0.35s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
}
.theme-thumb {
    position: absolute;
    top: 2px; /* чуть подправил из-за border */
    left: 2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), background-color 0.35s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    color: #2a3038;
}
.theme-icon {
    position: absolute;
    width: 16px;
    height: 16px;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* Тёмная тема (по умолчанию) */
:root[data-theme="dark"] .theme-icon-sun, :root:not([data-theme]) .theme-icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
:root[data-theme="dark"] .theme-icon-moon, :root:not([data-theme]) .theme-icon-moon { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="dark"] .theme-thumb, :root:not([data-theme]) .theme-thumb { transform: translateX(0); }

/* Светлая тема */
:root[data-theme="light"] .theme-track { background: #cfe8ec; border-color: rgba(0,0,0,0.06); }
:root[data-theme="light"] .theme-thumb { transform: translateX(30px); background: #ffffff; color: #e8b13a; }
:root[data-theme="light"] .theme-icon-sun { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="light"] .theme-icon-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }


/* 1. Оригинал на главной */
#theme-toggle {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    z-index: 2000;
    /* Анимация синхронна с #app-header */
    transition: transform 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
}
#theme-toggle.pushed {
    transform: translateY(-160px);
    opacity: 0;
    pointer-events: none;
}

/* 2. Клон в overlay */
#theme-toggle-overlay {
    position: fixed; /* fixed, чтобы не скроллился с контентом, как и на главной */
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    z-index: 1005; /* чуть выше overlay-widget (1000), но ниже чего-то другого */
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.4,0,0.2,1);
    pointer-events: none;
}
/* Появление клона при активации overlay */
#overlay.overlay-active #theme-toggle-overlay {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ============ IFRAME MODAL ============ */
.iframe-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.iframe-modal.active {
    opacity: 1;
    pointer-events: auto;
}
.iframe-modal-content {
    background: var(--bg-elev);
    width: 100%;
    max-width: 600px;
    height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.iframe-modal.active .iframe-modal-content {
    transform: scale(1);
}
.iframe-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}
.iframe-modal iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

@media (max-width: 768px) {
    .iframe-modal-content {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    .iframe-modal { padding: 0; }
}


#overlay 




@media (max-width: 768px) {
    #overlay 
}

/* ============ КНОПКИ НАЗАД (ФИНАЛЬНЫЙ ФИКС) ============ */
#overlay .back-btn,
#overlay .overlay-back-btn,


/* Контейнер навигации в деталке */
.detail-nav {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 16px !important;
    position: relative !important;
    z-index: 100 !important;
    padding-right: 80px; /* Отступ под тумблер темы */
}

/* ============ КНОПКИ НАЗАД (ЧИСТЫЙ СТИЛЬ) ============ */
#overlay .back-btn,
.overlay-back-btn {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 0 !important;
    background: transparent !important;
    border: none !important;
    color: var(--brand) !important;
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    text-decoration: none !important;
    z-index: 100 !important;
}

.detail-nav {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 16px !important;
    padding-right: 80px; /* Отступ от тумблера темы */
    z-index: 100 !important;
}
