/* 
   RBXSLOP Global Styles
   Здесь вы можете менять основные цвета и стили сайта.
*/

:root {
    /* Основные цвета (Металлический синий) */
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: rgba(59, 130, 246, 0.15);
    --primary-light-hover: rgba(59, 130, 246, 0.25);
    --primary-border: rgba(59, 130, 246, 0.2);
    --primary-border-hover: rgba(59, 130, 246, 0.3);
    --primary-glow: transparent;

    /* Цвета текста */
    --text-main: #e0e0e8;
    --text-muted: #a0a0b0;
    --text-bright: #ffffff;
    --text-link: #93c5fd;

    /* Фон и карточки */
    --bg-body: #020204;
    --bg-card-grad: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(148, 163, 184, 0.04));
    --bg-modal: rgba(0, 0, 0, 0.9);
    --bg-modal-box: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(10, 15, 30, 0.98));

    /* Вспомогательные цвета */
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warn: #fbbf24;
    --color-like: #ff4d4d;
    --content-max-width: 1200px;

    /* Новые настройки для клипа */
    --clip-sidebar-width: 300px;
}

/* Новая система отображения клипа */
.clip-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.clip-main {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 0;
}

.clip-sidebar {
    display: none;
    /* Скрыто в портретном режиме */
    width: var(--clip-sidebar-width);
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.4);
    border-left: 1px solid var(--primary-border);
    padding: 20px;
    overflow-y: auto;
    color: var(--text-main);
}

/* Ландшафтный режим (экран альбомной ориентации) */
@media (orientation: landscape) {
    .clip-layout {
        flex-direction: row;
    }

    .clip-sidebar {
        display: block;
    }

    .portrait-overlay {
        display: none !important;
    }

    #clipBox {
        flex-direction: row !important;
        inset: 10px;
        /* Больше места в ландшафте */
    }

    #clipBody {
        padding: 0 !important;
    }

    .modal-header {
        display: none !important;
        /* Скрываем стандартный хедер в ландшафте, если всё в сайдбаре */
    }
}

@media (orientation: portrait),
(max-width: 767px) {
    #clipBox {
        inset: 10px !important;
        /* Небольшой отступ от краев экрана */
        border-radius: 20px !important;
        border: 1px solid var(--primary-border) !important;
        max-width: none !important;
    }

    .clip-sidebar {
        display: none !important;
    }

    .portrait-overlay {
        display: flex !important;
    }

    /* Хедер модалки оставляем видимым */
}

/* Портретный режим (TikTok style) */
.portrait-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 40%, transparent 60%, rgba(0, 0, 0, 0.3) 100%);
    z-index: 5;
}

.overlay-right {
    position: absolute;
    right: 12px;
    bottom: 100px;
    /* Над автором */
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    pointer-events: auto;
}

.overlay-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px;
    color: #fff;
    pointer-events: auto;
}

.overlay-author-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.overlay-author-name {
    font-weight: 700;
    font-size: 16px;
}

.overlay-meta {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.overlay-item svg {
    /* filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.5)); */
}

.overlay-item .count-label {
    font-size: 13px;
    font-weight: 700;
}

.overlay-bottom {
    pointer-events: auto;
    max-width: 80%;
}

.overlay-author {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.overlay-title {
    font-size: 14px;
    margin-bottom: 14px;
    /* больше отступ снизу */
    opacity: 0.9;
    line-height: 1.4;

    /* allow up to 3 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.overlay-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.overlay-tag {
    color: var(--text-link);
    font-weight: 600;
    text-decoration: none;
    font-size: 13px;
}

/* Стили для сайдбара в ландшафте */
.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 500;
    /* Убрана сильная жирность */
    color: #fff;
    margin-bottom: 16px;
    /* больше воздуха снизу */
    line-height: 1.3;

    /* allow up to 3 lines */
    min-height: 3.9em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-author-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 12px;
}

.sidebar-author-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-author-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.sidebar-stat-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary-border);
    border-radius: 12px;
    padding: 0;
    /* Убираем паддинг, чтобы кнопка внутри заполнила всё пространство */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: all 0.2s;
    overflow: hidden;
}

.sidebar-stat-box:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary-border-hover);
}

.sidebar-stat-box .stat-content {
    padding: 12px;
    display: flex !important;
    /* Гарантируем flex даже для кнопок с all:unset */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.sidebar-stat-box .stat-label {
    font-size: 10px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sidebar-desc {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Кастомный прогресс-бар видео */
.video-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 20;
    pointer-events: none;
}

.video-progress-bar {
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.7);
    /* box-shadow: 0 0 4px rgba(0, 0, 0, 0.5); */
    /* Убрали CSS transition, теперь плавность через requestAnimationFrame в JS */
}

/* Фикс синей вспышки при клике на мобилках */
.video-container,
.video-container video,
.portrait-overlay,
.likeBtn,
.overlay-item,
.share-main-btn,
.clip-close-button {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none;
    outline: none !important;
}

/* Скрываем таймер в портретном режиме */
@media (orientation: portrait),
(max-width: 767px) {
    .video-timer {
        display: none !important;
    }
}

/* Стили для кнопки закрытия внутри оверлея или сайдбара */
.clip-close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

/* Скрываем кнопку на видео в портретном режиме, так как есть кнопка в хедере */
@media (orientation: portrait),
(max-width: 767px) {
    .clip-close-button {
        display: none !important;
    }
}

@media (orientation: landscape) {
    .clip-close-button {
        position: static;
        margin-left: auto;
        margin-bottom: 20px;
        background: var(--primary-light);
        border-color: var(--primary-border);
        display: flex !important;
    }
}

/* Сброс и база */
* {
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
    /* Всегда резервируем место под скроллбар, чтобы сайт не прыгал */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
}

.container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
    padding: 0 20px 20px;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Глобальный фикс для четкости изображений в Chrome */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Шапка (Topbar) */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    margin-bottom: 24px;
    padding: 20px;
    border-bottom: 1px solid var(--primary-border);
    background: #0d0d12;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    min-width: 0;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-img {
    height: 28px;
    width: 28px;
    flex-shrink: 0;
    object-fit: contain;
    /* filter: drop-shadow(0 0 8px var(--primary-glow)); */
}

.logo-text {
    font-weight: 800;
    letter-spacing: 0.6px;
    font-size: 22px;
    color: var(--primary-color);
    /* Fallback color */
    background: linear-gradient(135deg, var(--primary-color), #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.topbar-sep {
    opacity: .4;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-section {
    color: var(--text-main);
    font-weight: 600;
    opacity: .9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

.topbar-link {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-link);
    white-space: nowrap;
}

.topbar-link:hover {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59, 130, 246, 0.45);
}

/* Зеленая кнопка "Добавить" */
.topbar-link.link-submit {
    background: linear-gradient(180deg, #388e3c 0%, #2e7d32 100%);
    border: 1.5px solid #1b5e20;
    /* Тонкая, очень темная зеленая окантовка */
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 700;
    padding: 4px 14px;
    /* Уменьшил отступы */
    border-radius: 50px;
    box-shadow: none;
    text-shadow: none;
    transition: all 0.2s ease;
}

.topbar-link.link-submit:hover {
    background: linear-gradient(180deg, #43a047 0%, #388e3c 100%);
    transform: translateY(-1px);
    box-shadow: none;
}

.topbar-link.link-submit .link-icon {
    margin-right: 0;
    font-size: 18px;
    /* Уменьшил размер плюса на десктопе */
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -1px;
}

/* Сетка карточек */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .container {
        padding: 0 6px 6px;
    }
}

@media (max-width: 400px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
}

.card {
    background: var(--bg-card-grad);
    border: 1px solid var(--primary-border);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
    backdrop-filter: blur(10px);
    position: relative;
    /* will-change: transform; - Убрано, так как в Chrome это может вызывать размытие */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    isolation: isolate;
    /* Изоляция для стабильного рендеринга слоев */
}

/* Фикс: выносим backdrop-filter в псевдоэлемент, чтобы он не влиял на четкость дочерних элементов (изображений) */
.card::before {
    content: "";
    position: absolute;
    inset: 0;
    backdrop-filter: blur(10px);
    border-radius: inherit;
    z-index: -1;
    pointer-events: none;
}


@media (max-width: 600px) {
    .card {
        border-radius: 12px;
    }
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-border-hover);
    box-shadow: none;
}

.card a {
    color: inherit;
    display: block;
    padding: 0;
}

.thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.15);
    /* Фикс Chrome: убирает размытие краев и контента при использовании border-radius */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    transform: translateZ(0);
}


@media (max-width: 600px) {
    .thumb-wrapper {
        border-radius: 12px;
    }
}

.thumb {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(148, 163, 184, 0.1));
    display: block;
    object-fit: cover;
    /* Ультимативный фикс размытости в Chrome */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.thumb-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.4), transparent);
    padding: 25px 10px 8px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.thumb-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
}

.thumb-stat svg {
    width: 14px;
    height: 14px;
    fill: #fff;
    opacity: 0.9;
}

/* Названия карточек */
.card-title {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 10px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.4), transparent);
    z-index: 2;

    /* Ограничение в 2 строки */
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    line-height: 1.4;
    word-wrap: break-word;
    max-height: 3.4em;
    /* 1.4 * 2 + небольшой запас */
}

@media (max-width: 600px) {
    .card-title {
        font-size: 10px;
        padding: 6px 8px 8px;
        max-height: 3.4em;
    }

    .thumb-overlay {
        padding: 15px 8px 5px;
        gap: 6px;
    }
}

/* Мета-информация и кнопки */
.meta {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 8px;
    color: var(--text-muted);
}

.pager {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin: 32px 0;
}

.pager a {
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: 12px;
    padding: 8px 16px;
    color: var(--text-link);
}

.pager a:hover {
    background: var(--primary-light-hover);
    border-color: var(--primary-border-hover);
    transform: translateY(-2px);
}

.pill {
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-link);
}

.pill a {
    color: #bfdbfe;
}

/* Кнопка лайка */
.likeBtn {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.likeBtn[aria-pressed="true"] {
    opacity: 1 !important;
}

.likeBtn[aria-pressed="true"] svg {
    fill: var(--color-like) !important;
    /* filter: drop-shadow(0 0 5px rgba(255, 77, 77, 0.4)); */
}

/* Модальное окно */
#clipModal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(8px);
    z-index: 9999;
}

#clipBox {
    position: absolute;
    inset: 20px;
    max-width: var(--content-max-width);
    margin: auto;
    background: var(--bg-modal-box);
    border: 1px solid var(--primary-border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 18px 18px;
    border-bottom: 1px solid var(--primary-glow);
    background: rgba(59, 130, 246, 0.05);
    flex: 0 0 auto;
}

#clipTitle {
    font-size: 18px;
    font-weight: 700;
    color: #fff;

    /* allow up to 3 lines (instead of single-line ellipsis) */
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-height: 1.25;

    /* keep room for the close button */
    max-width: calc(100% - 90px);
}

#clipClose {
    border: 1px solid var(--primary-border);
    border-radius: 10px;
    padding: 8px 14px;
    background: var(--primary-light);
    color: var(--text-link);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

#clipClose:hover {
    background: var(--primary-light-hover);
    border-color: var(--primary-border-hover);
}

#clipBody {
    padding: 0 12px 12px 12px;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Формы (Submit) */
label {
    display: block;
    margin: 18px 0 8px;
    font-weight: 500;
    color: #d1d5db;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--primary-border);
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.05);
    color: var(--text-main);
    font: inherit;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-border-hover);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: none;
}

/* Styling for select options */
select.form-input option {
    background-color: #1a1a2e;
    color: #ffffff;
    padding: 12px;
}

.submit-btn {
    margin-top: 20px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--primary-border);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(148, 163, 184, 0.15));
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.submit-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(148, 163, 184, 0.25));
    border-color: var(--primary-border-hover);
    transform: translateY(-2px);
    box-shadow: none;
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    filter: grayscale(0.8);
}

/* Админка (Admin) */
table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
    background: rgba(59, 130, 246, 0.02);
    border-radius: 12px;
    overflow: hidden;
}

th,
td {
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    padding: 14px;
    vertical-align: top;
}

th {
    font-size: 12px;
    opacity: .8;
    text-align: left;
    background: rgba(59, 130, 246, 0.05);
    color: var(--text-link);
    font-weight: 600;
}

tr:hover td {
    background: rgba(59, 130, 246, 0.05);
}

.btn {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid;
    background: var(--primary-light);
    color: var(--text-link);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-ok {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

.btn-bad {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.btn-warn {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.15);
    color: #fde047;
}

.btn-del {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.badge-ok {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

.badge-bad {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.hint {
    font-size: 12px;
    opacity: .7;
    color: var(--text-muted);
    margin-top: 4px;
}

.tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.tab {
    padding: 8px 14px;
    border: 1px solid var(--primary-border);
    border-radius: 999px;
    text-decoration: none;
    background: rgba(59, 130, 246, 0.05);
    color: var(--text-link);
    transition: all 0.2s;
    font-size: 13px;
}

.tab:hover {
    background: var(--primary-light);
    border-color: var(--primary-border-hover);
}

.tab.on {
    background: var(--primary-light-hover);
    border-color: var(--primary-border-hover);
    color: #bfdbfe;
}

/* Layout (Standalone Pages) */
.page {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.top {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--primary-border);
    background: rgba(59, 130, 246, 0.05);
    backdrop-filter: blur(10px);
}

.content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    background: #020204;
}

/* --- Topbar & Modals (from topbar.php) --- */
.lang-switchers {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-right: 15px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.lang-switcher {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lang-switcher label {
    display: block;
    margin: 0;
    font-size: 10px;
    opacity: 0.6;
    color: var(--text-muted);
    font-weight: 400;
}

.lang-switcher select {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary-border);
    border-radius: 6px;
    color: var(--text-link);
    font-size: 12px;
    padding: 2px 4px;
    cursor: pointer;
    outline: none;
}

.lang-switcher select:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Custom Select with Flags Support */
.custom-select {
    position: relative;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary-border);
    border-radius: 6px;
    color: var(--text-link);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.custom-select-trigger {
    padding: 3px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    justify-content: space-between;
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1b1e;
    border: 1px solid var(--primary-border);
    border-radius: 6px;
    margin-top: 4px;
    display: none;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 140px;
}

.custom-select.open .custom-options {
    display: block;
}

.custom-option {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.custom-option:hover {
    background: rgba(59, 130, 246, 0.15);
}

.custom-select .chevron {
    font-size: 10px;
    opacity: 0.5;
}

.mobile-native-select {
    display: none;
}

@media (max-width: 768px) {
    .mobile-native-select {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        z-index: 10;
        cursor: pointer;
        -webkit-appearance: menulist-button;
        /* Helps with some mobile browsers */
    }
}

.topbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
}

.topbar-right-scrollable {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.topbar-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.link-icon {
    display: none;
}

.link-submit .link-icon {
    display: flex;
}


/* User Area Styles */
.user-area {
    margin-left: 15px;
    flex-shrink: 0;
}

.login-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: none;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: none;
    filter: brightness(1.1);
}

.user-menu-container {
    position: relative;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-link);
}

.user-chevron {
    font-size: 10px;
    opacity: 0.5;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: #1a1b1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    min-width: 160px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
    animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-link);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.logout {
    color: #ff4d4d;
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.dropdown-item .icon {
    font-size: 16px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: #1a1b1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    color: #000;
    text-decoration: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;

    /* make buttons/links same width in login modal */
    width: 100%;
    border: none;
    cursor: pointer;
}

.google-login-btn:hover {
    background: #f1f1f1;
    transform: translateY(-2px);
    box-shadow: none;
}

.google-login-btn img {
    width: 20px;
    height: 20px;
}

.telegram-login-container {
    margin-top: 15px;
    display: flex;
    justify-content: center;
}

.telegram-bot-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #1d86ba;
    /* Темнее, чем стандартный ТГ цвет */
    color: #fff;
    text-decoration: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    width: 100%;
    border: none;
    cursor: pointer;
}

.telegram-bot-login-btn:hover {
    background: #176a94;
    transform: translateY(-2px);
    box-shadow: none;
}

/* Telegram Auth Modal Specific Styles */
.tg-auth-modal {
    max-width: 440px !important;
    text-align: center;
}

.tg-modal-desc {
    font-size: 16px;
    margin-bottom: 20px;
    color: #fff;
}

#qrcode-container {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 20px;
}

#qrcode img {
    display: block;
    margin: 0 auto;
}

.tg-timer {
    font-size: 18px;
    margin-bottom: 25px;
    color: #fff;
}

.tg-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tg-btn-primary {
    background: #a855f7;
    /* Фиолетовый как на скрине */
    color: #fff;
    text-decoration: none;
    padding: 14px;
    border-radius: 999px;
    font-weight: 600;
    transition: all 0.2s;
}

.tg-btn-primary:hover {
    background: #9333ea;
    transform: translateY(-1px);
}

.tg-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
    padding: 12px;
    border-radius: 999px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.tg-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.telegram-bot-login-btn img {
    width: 24px;
    height: 24px;
}

/* ========== SWIPE NAVIGATION ========== */

/* Навигационные стрелки в модальном окне */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 100;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.nav-arrow svg {
    width: 28px;
    height: 28px;
}

.nav-arrow:hover {
    background: rgba(59, 130, 246, 0.4);
    transform: translateY(-50%) scale(1.1);
    box-shadow: none;
}

.nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.nav-prev {
    left: -60px;
}

.nav-next {
    right: -60px;
}


/* Адаптив для навигационных стрелок */
@media (max-width: 1400px) {
    .nav-prev {
        left: 10px;
    }

    .nav-next {
        right: 10px;
    }

    .nav-arrow {
        background: rgba(0, 0, 0, 0.6);
        width: 40px;
        height: 40px;
    }

    .nav-arrow svg {
        width: 24px;
        height: 24px;
    }
}

/* Фикс для альбомной ориентации на ПК и смартфонах: стрелки не должны заходить на сайдбар */
@media (orientation: landscape) {
    .nav-arrow {
        display: flex !important;
        /* Всегда показываем в ландшафте */
    }

    .nav-prev {
        left: 20px;
    }

    .nav-next {
        /* Сдвигаем правую стрелку, чтобы она была в конце видео-панели, а не на сайдбаре */
        right: calc(var(--clip-sidebar-width) + 20px);
    }
}

@media (max-width: 768px) and (orientation: portrait) {

    /* На мобильных в ПОРТРЕТНОМ режиме скрываем стрелки - используем свайпы */
    .nav-arrow {
        display: none;
    }

    .swipe-hint {
        font-size: 48px;
    }
}

/* ========== END SWIPE NAVIGATION ========== */

@media (max-width: 768px) {
    .topbar {
        zoom: 1;
        /* Исправлено: zoom < 1 в Chrome вызывает сильное размытие изображений */
        flex-direction: column;
        align-items: center;
        padding: 15px 10px;
        gap: 15px;
    }

    .topbar-left {
        width: 100%;
        justify-content: center;
        flex-wrap: nowrap;
    }

    .topbar-right {
        width: 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 12px;
        margin: 0;
        padding: 5px 0;
    }

    .topbar-right-scrollable {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex: 0 1 auto;
        min-width: 0;
    }

    .topbar-right-scrollable::-webkit-scrollbar {
        display: none;
    }

    .topbar {
        /* zoom: 0.95; - Убрано, так как zoom в Chrome вызывает размытие. Используйте медиа-запросы для изменения размеров */
    }

    .lang-switchers {
        width: auto;
        margin: 0;
        gap: 8px;
        flex-shrink: 0;
    }

    .lang-switcher select {
        max-width: none;
        /* Reset to allow natural width by default */
        font-size: 11px;
        padding: 2px;
    }

    /* Only shrink language selects if the screen is very narrow */
    @media (max-width: 400px) {
        .lang-switcher select {
            max-width: 65px;
        }
    }

    .lang-switcher label {
        font-size: 9px;
    }

    .link-submit .link-text {
        display: none;
    }

    .link-submit .link-icon {
        display: flex;
        font-size: 32px;
        /* Уменьшил плюс до адекватного размера */
        font-weight: 800;
        margin-right: 0;
        width: auto;
        height: auto;
        line-height: 1;
    }

    .link-submit {
        background: linear-gradient(180deg, #388e3c 0%, #2e7d32 100%) !important;
        border: 2px solid #1b5e20 !important;
        /* Тёмная рамка */
        color: #ffffff !important;
        box-shadow: none !important;
        text-shadow: none !important;
        padding: 6px 10px !important;
        /* Уменьшил отступы на мобилке */
        border-radius: 12px !important;
    }

    .topbar-link {
        padding: 5px 10px;
    }

    .topbar-nav {
        margin: 0;
        gap: 5px;
        flex-shrink: 0;
    }

    .user-area {
        margin: 0;
        flex-shrink: 0;
    }

    .user-name {
        display: none;
    }

    .user-profile {
        padding: 4px 8px;
    }

    .user-chevron {
        display: none;
    }

    .filter-bar {
        zoom: 1;
        /* Исправлено: удален zoom, вызывающий размытие в Chrome */
        justify-content: center;
        padding: 8px;
        flex-wrap: nowrap;
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }

    /* Scale down the whole filter bar if it's too wide for the screen */
    @media (max-width: 500px) {
        .filter-bar {
            /* zoom: 0.85; - Убрано из-за размытия в Chrome */
        }
    }

    @media (max-width: 400px) {
        .filter-bar {
            /* zoom: 0.75; - Убрано из-за размытия в Chrome */
        }
    }

    .filter-group {
        width: auto;
        justify-content: center;
        padding: 4px 12px 4px 4px;
    }
}