:root {
    --bg-color: #f1f2f6;
    --text-color: #2f3542;
    --card-bg: #ffffff;
    --accent: #ff4757; /* More vibrant red */
    --secondary: #57606f;
    --sidebar-width: 320px;
    --sidebar-collapsed-width: 56px;
    --surface-color: #ffffff;
    --surface-muted: #f8fafc;
    --surface-border: rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg-color: #000000;
    --text-color: #ededed;
    --card-bg: #0a0a0a;
    --accent: #ff4757;
    --secondary: #888888;
    --surface-color: #000000;
    --surface-muted: #111111;
    --surface-border: #222222;
    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.8);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; /* Remove blue flash on mobile */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at top left, rgba(255, 71, 87, 0.05), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 71, 87, 0.03), transparent 25%),
        var(--bg-color);
}

.container { display: flex; min-height: 100vh; }

/* Desktop Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    padding: 30px;
    position: fixed;
    height: 100vh;
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.logo-area { margin-bottom: 25px; text-align: center; display: flex; flex-direction: column; gap: 15px; align-items: center; }
.logo-img { display: none !important; }
.logo-area h2 {
    font-size: 13px; 
    font-weight: 800; 
    color: var(--text-color);
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    white-space: nowrap; /* Force single line */
    width: 100%;
}

/* Info Icon (Question mark) */
.info-icon {
    display: inline-flex !important; 
    align-items: center !important; 
    justify-content: center !important;
    width: 20px !important; 
    height: 20px !important; 
    min-width: 20px !important; 
    min-height: 20px !important;
    border: 1.5px solid #d1d5db !important; 
    border-radius: 50% !important; /* Fixed: was square */
    font-weight: 700 !important;
    cursor: pointer !important;
    color: #9ca3af !important; 
    font-style: normal !important; 
    flex-shrink: 0 !important;
    transform-origin: 50% 50%;
    transition: transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.15s ease, border-color 0.15s ease;
    will-change: transform;
}

.info-icon:hover {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

html[data-theme="dark"] .info-icon {
    color: #cbd5e1 !important;
    border-color: rgba(203, 213, 225, 0.3) !important;
}

.search-container {
    margin-bottom: 25px;
}

.sidebar-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-color);
    transform: none;
    border-color: transparent;
}

.theme-toggle__icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle__icon svg {
    width: 18px;
    height: 18px;
}

.theme-toggle__icon--sun {
    display: none;
}

html[data-theme="dark"] .theme-toggle {
    background: transparent;
    color: var(--secondary);
    border-color: transparent;
    box-shadow: none;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: transparent;
    color: inherit;
}

html[data-theme="dark"] .theme-toggle__icon--moon {
    display: none;
}

html[data-theme="dark"] .theme-toggle__icon--sun {
    display: inline-flex;
}

.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
}

.sidebar-mobile-toggle {
    display: none;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    background: var(--surface-color);
    color: #64748b;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-mobile-toggle:hover {
    color: var(--accent);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
}

.sidebar-mobile-toggle svg {
    transition: transform 0.22s ease;
}

.search-input {
    width: 100%;
    padding: 13px 40px 13px 14px; /* Reduced right padding significantly: Placeholder must be visible */
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--surface-muted);
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
    text-overflow: clip; /* Ensure text doesn't ellipsis too early */
}

/* Increase padding only when the big reset label is actually visible */
.search-wrap:has(.reset-filter-label[style*="display: block"]) .search-input {
    padding-right: 125px;
}

.search-input:focus {
    border-color: var(--accent);
    background: var(--surface-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

html[data-theme="dark"] .search-input {
    color: #e5e7eb;
}

html[data-theme="dark"] .search-input::placeholder {
    color: #7c8aa5;
}

.reset-filter-label {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px; /* Reduced from 10.5px (approx 30% smaller) */
    font-weight: 800;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
    padding: 7px 34px 7px 11px; /* Re-balanced padding for smaller text */
    border-radius: 9px;
    cursor: pointer;
    white-space: nowrap;
    z-index: 5;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    letter-spacing: 0.1px;
}

/* Position cross inside the reset pill when filtering by user */
.reset-filter-label[style*="display: block"] ~ .search-clear {
    right: 9px !important; 
    top: calc(50% - 1px) !important; /* Lowered by 1px */
    color: #2563eb !important;
    z-index: 6;
    font-size: 18px; 
    pointer-events: none; /* Make click go through to the label block */
}

/* (hover state) */
.reset-filter-label:hover {
    background: rgba(37, 99, 235, 0.14);
}

/* Sidebar Bottom Group & Final CTA Style */
.sidebar-bottom-group {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 768px) {
    .sidebar-bottom-group {
        display: none !important;
    }
}

.how-to-join-btn {
    width: 100%;
    padding: 10px 14px; 
    border: 1px solid #e2e8f0; 
    background: #ffffff;
    text-align: left; 
    font-size: 13px; 
    cursor: pointer;
    border-radius: 12px; 
    color: #475569;
    font-weight: 600;
    display: flex; 
    align-items: center; 
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: all 0.2s ease;
}

.how-to-join-btn:hover {
    background: #f8fafc;
    border-color: var(--accent);
    color: var(--accent);
    transform: translateX(4px);
    box-shadow: none;
}

.how-to-join-btn .btn-emoji {
    font-size: 18px;
    width: auto; 
    height: auto;
    transition: transform 0.2s;
}

.how-to-join-btn:hover .btn-emoji {
    transform: scale(1.2) rotate(10deg);
}

.sidebar-footer-content {
    font-size: 12px;
    color: #64748b;
}

html[data-theme="dark"] .sidebar-footer-content,
html[data-theme="dark"] .footer-link,
html[data-theme="dark"] .footer-top {
    color: #94a3b8;
}

/* Cleanup old selectors if any conflict */
.how-to-join-card { display: none; }

/* (hover state) */
.reset-filter-label:hover {
    background: rgba(37, 99, 235, 0.14);
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    display: none;
    font-size: 20px;
    line-height: 1;
    z-index: 10;
}

.search-clear:hover { 
    background: transparent; 
    color: #4b5563; /* Darker gray on hover */
    transform: translateY(-50%) scale(1.1); /* Subtle scale effect instead of background */
}

html[data-theme="dark"] .search-clear {
    color: #94a3b8;
}

/* Specific hover tweak for user filtering case */
.reset-filter-label[style*="display: block"] ~ .search-clear:hover {
    background: transparent !important;
}

.filters { display: flex; flex-direction: column; gap: 10px; }

.filter-btn {
    padding: 12px; border: none; background: transparent;
    text-align: left; font-size: 15px; cursor: pointer;
    border-radius: 8px; color: var(--secondary);
    display: flex; align-items: center; gap: 10px;
}
.filter-btn:hover { background: #f1f2f6; }
.filter-btn.active { background: var(--accent); color: white; }
.filter-btn.active:hover { background: var(--accent); color: white; }

html[data-theme="dark"] .filter-btn {
    color: #d6d6d6;
}

html[data-theme="dark"] .filter-btn:hover {
    background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .filter-btn.active:hover {
    background: var(--accent);
    color: #fff;
}

.btn-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 20px;
    width: 20px;
    font-size: 16px;
    flex-shrink: 0;
}

.filter-btn.active .btn-emoji {
    filter: brightness(0) invert(1);
    transform: translateY(-0.5px); /* Fine-tune position when active */
}

/* Filter icons (SVG): red by default, white when active */
.btn-emoji.svg {
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-btn.active .btn-emoji.svg { color: #fff; }

.btn-emoji.svg svg {
    width: 16px;
    height: 16px;
    display: block;
}

.sidebar-footer { margin-top: auto; font-size: 13px; }
.footer-top { 
    margin-bottom: 12px; 
    color: #9ca3af; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
}
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-link { color: var(--secondary); cursor: pointer; transition: color 0.2s; }
.footer-link:hover { color: var(--accent); }

/* Gallery */
.gallery-wrapper { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); padding: 30px; }
.grid { width: 100%; }
.grid-sizer, .grid-item { width: calc(33.333% - 14px); margin-bottom: 20px; }

/* Embed mode: same ketogram cards/behavior, no sidebar chrome */
body.embed-mode .sidebar,
body.embed-mode .gallery-main-title,
body.embed-mode #joinFab,
body.embed-mode #backToTop,
body.embed-mode #staticLogoCard {
    display: none !important;
}

body.embed-mode .gallery-wrapper {
    margin-left: 0;
    width: 100%;
    padding: 12px;
}

body.embed-mode .grid-sizer,
body.embed-mode .grid-item {
    width: calc((100% - ((var(--embed-cols, 4) - 1) * 20px)) / var(--embed-cols, 4));
}

@media (max-width: 768px) {
    body.embed-mode .grid-sizer,
    body.embed-mode .grid-item {
        width: calc((100% - ((var(--embed-cols, 4) - 1) * 14px)) / var(--embed-cols, 4)) !important;
        margin-bottom: 14px;
    }
}

.grid-item {
    float: left; border-radius: 20px; overflow: hidden;
    background: var(--card-bg); position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    opacity: 0;
    /* Плавный выход и GPU-ускорение для Masonry */
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform, opacity;
    mask-image: radial-gradient(white, black);
    -webkit-mask-image: -webkit-radial-gradient(white, black); /* FIX: Force rounding/clipping on iOS Safari */
}
.grid-item.loaded { opacity: 1; }
.grid-item img { display: block; width: 100%; height: auto; }
.grid-item video { display: block; width: 100%; height: auto; }

html[data-theme="dark"] .grid-item {
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.28);
}

/* Masonry uses absolute positioning with translate() when transitionDuration is 0 */
/* This ensures smooth movement */
.grid-item[style*="position: absolute"] {
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

/* Skeleton loading */
.skeleton-item {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    opacity: 1 !important; /* Override .grid-item default opacity */
    transform: none !important;
    box-shadow: none;
}

html[data-theme="dark"] .skeleton-item {
    background: #0d0d0d;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #e5e7eb;
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .skeleton-img {
    background: #151515;
}

.skeleton-bar {
    height: 12px;
    margin: 14px 16px 16px;
    border-radius: 999px;
    background: #e5e7eb;
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .skeleton-bar {
    background: #1b1b1b;
}

.skeleton-img::after,
.skeleton-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
    animation: shimmer 1.2s infinite;
}

html[data-theme="dark"] .skeleton-img::after,
html[data-theme="dark"] .skeleton-bar::after {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.degree-badge {
    position: absolute; top: 15px; right: 15px;
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(4px);
    padding: 0;
    border-radius: 20px; font-size: 13px;
    font-weight: 700; color: #ff4757; z-index: 30;
    display: flex; align-items: center; justify-content: flex-start; /* Expand leftwards if needed */
    min-width: 78px;
    width: auto; /* Fit content */
    height: 32px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    border: none;
    transition: background 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    white-space: nowrap; /* No wrapping for large numbers */
}

.degree-badge.show-votes {
    background: #000; /* Parent background turns black to eliminate white borders */
}

.badge-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    padding: 0 14px;
    box-sizing: border-box;
}

/* Slider (votes info) */
.badge-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    gap: 4px;
    padding: 0 14px;
    box-sizing: border-box;
    z-index: 3;
}

.degree-badge.show-votes .badge-content {
    transform: translateX(-100%);
}

.degree-badge.show-votes .badge-slider {
    transform: translateX(0);
}

.votes-count { display: none !important; }

.overlay {
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%;
    /* Revert to automatic height based on content but cap it */
    max-height: 100%; 
    height: auto;
    padding: 20px; 
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.8) 100%);
    color: white; 
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s;
    transform: translateY(100%);
    opacity: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    z-index: 25; 
    pointer-events: none;
    overflow: hidden; /* Never show scrollbars; use "... еще" instead */
    max-height: 90% !important;
}

/* Not-keto warning styles */
.not-keto img {
    filter: blur(12px) grayscale(0.5);
    transition: filter 0.4s ease;
}

.not-keto-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 20px !important; /* Force radius */
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px); /* Trick Safari */
    /* Ensure parent clipping is respected by using mask if necessary, but radius usually works */
    background: rgba(0,0,0,0.3);
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
    pointer-events: none;
    overflow: hidden; /* Key for child clipping */
}

.not-keto-icon {
    font-size: 56px;
    filter: drop-shadow(0 0 15px rgba(0,0,0,0.6));
}

/* On hover/tap: remove blur and show lighter overlay with text */
@media (min-width: 769px) {
    .grid-item.not-keto:hover img { filter: blur(0) grayscale(0); }
    .grid-item.not-keto:hover .not-keto-overlay { opacity: 0; }
}

.grid-item.not-keto.tapped img { filter: blur(0) grayscale(0) !important; }
.grid-item.not-keto.tapped .not-keto-overlay { opacity: 0 !important; }

/* Special overlay style for not-keto text */
.not-keto .overlay {
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 100%) !important;
    justify-content: center !important;
    align-items: center !important;
}

.not-keto-msg {
    text-align: center;
    font-weight: 800;
    font-size: 16px;
    line-height: 1.4;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    color: #fff;
    padding: 10px;
}

.not-keto-msg .highlight-red {
    border-bottom: 2px solid #ff4757;
    padding-bottom: 1px;
}

/* Desktop hover */
@media (min-width: 769px) {
    .grid-item:hover .overlay { transform: translateY(0); opacity: 1; pointer-events: auto; }
    /* Hide overlay when hovering over navigation arrows or dots to see the image better */
    .grid-item:hover:has(.card-nav-btn:hover, .card-dot:hover) .overlay { 
        transform: translateY(100%) !important; 
        opacity: 0 !important; 
        pointer-events: none !important; 
    }
}

/* Universal tapped state */
.grid-item.tapped .overlay { transform: translateY(0) !important; opacity: 1 !important; pointer-events: auto !important; }

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center; 
    margin-bottom: 8px;
    width: 100%;
}

.overlay h3 { 
    font-size: 14px; 
    margin-bottom: 0; 
    color: #fff; 
    font-weight: 700;
}

@media (max-width: 768px) {
    .search-input { padding-right: 40px; }
    .search-wrap:has(.reset-filter-label[style*="display: block"]) .search-input {
        padding-right: 125px; /* Same logic for mobile combined button */
    }
    
    .reset-filter-label {
        right: 6px; /* Resetting to combined look on mobile too */
        font-size: 8px;
        padding: 7px 34px 7px 11px;
    }
    
    .mobile-hidden { display: none !important; }

    /* Share button is moved to a floating top-left button on mobile */
    .overlay-share-btn {
        display: none !important;
    }
}

/* Mobile floating share button (shows only when overlay is visible) */
@media (max-width: 768px) {
    .card-mobile-share-btn {
        position: absolute;
        top: 10px;
        left: 10px;
        z-index: 12;
        width: 26px;
        height: 26px;
        border: none;
        border-radius: 999px;
        background: rgba(0,0,0,0.40);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255,255,255,0.10);
        color: rgba(255,255,255,0.95);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
    }
    .card-mobile-share-btn svg {
        width: 14px;
        height: 14px;
        stroke-width: 2px;
    }
    .grid-item.tapped .card-mobile-share-btn {
        opacity: 0.95;
        pointer-events: auto;
    }

    /* If video is playing, hide the floating share (share is in mini panel) */
    .grid-item.has-playing-video .card-mobile-share-btn {
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

.overlay-share-btn {
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    opacity: 0.8;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    flex-shrink: 0;
    will-change: transform;
}

.overlay-expand-btn {
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    opacity: 0.8;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    flex-shrink: 0;
    will-change: transform;
}

.overlay-expand-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.overlay-expand-btn:active {
    transform: scale(0.9);
}

.overlay-expand-btn svg {
    width: 16px;
    height: 16px;
}

.overlay-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.overlay-video-btn {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    opacity: 0.9;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    flex-shrink: 0;
    text-decoration: none;
    will-change: transform;
}

.overlay-video-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.overlay-video-btn:active {
    transform: scale(0.9);
}

.overlay-video-btn svg {
    width: 18px;
    height: 18px;
}

/* Overlay icon should be neutral/white (as requested) */
.overlay-video-btn.video-btn--youtube,
.overlay-video-btn.video-btn--rutube,
.overlay-video-btn.video-btn--vkvideo {
    color: #ffffff;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.overlay-share-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.overlay-share-btn:active {
    transform: scale(0.9);
}

.overlay-share-btn svg {
    width: 16px;
    height: 16px;
}

.overlay p { 
    font-size: 13px; 
    line-height: 1.4; 
    color: rgba(255,255,255,0.9);
    margin-bottom: 0;
    word-wrap: break-word;
}

.more-link {
    color: #4dabf7 !important; 
    font-weight: 800;
    cursor: pointer;
    margin-left: 4px;
    display: inline-block;
    text-decoration: none; /* Removed underline */
}

.more-link:hover {
    text-decoration: underline;
}

.logo-card-item { 
    display: flex !important; 
    align-items: center; 
    justify-content: center; 
    background: #fff; 
    aspect-ratio: 1/1; 
    position: relative;
    overflow: hidden;
}

.logo-card-img {
    width: 64% !important;
    height: auto;
    display: block;
    z-index: 1;
}

/* Specific overlay for the info/logo card to cover full height if needed */
.logo-card-item .overlay {
    max-height: 100% !important;
    height: 100% !important;
    justify-content: flex-start !important;
    padding: 24px !important;
}

.logo-card-item .overlay h3 {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
    font-size: 18px;
    width: 100%;
    text-align: center;
    color: #fff;
    font-weight: 800;
}

.heart-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
    transform: translateY(27px); /* Lowered by another 5px (total +30px from original) */
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.4));
    user-select: none;
    transition: transform 0.3s ease;
}

.heart-icon svg {
    width: 46px;
    height: 46px;
    display: block;
    transition: fill 0.3s ease, filter 0.3s ease;
}

.logo-card-item:hover .heart-icon svg {
    fill: #ff4757;
    filter: drop-shadow(0 0 15px rgba(255, 71, 87, 0.6));
}

.logo-card-item .overlay p {
    font-size: 13px;
    line-height: 1.4;
    margin: 25px 0 0 0 !important; /* Pushed down by 25px total (added 5px more) */
    text-align: center;
}

.logo-card-item .overlay .overlay-header {
    display: none !important;
}

@media (max-width: 768px) {
    .heart-icon { display: none !important; }
    .logo-card-item .overlay h3 { display: none !important; }
    .logo-card-item .overlay {
        padding: 5px !important;
        justify-content: center !important;
        height: 100% !important;
    }
    .logo-card-item .overlay p {
        margin: 0 !important;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        line-height: 1.3;
    }
}

/* Desktop only improved typography for info card */
@media (min-width: 769px) {
    .logo-card-item .overlay h3 {
        font-size: 22px;
        margin-bottom: 2px !important;
        width: 100%;
        text-align: center;
    }

    .heart-icon svg {
        width: 69px;
        height: 69px;
    }

    .logo-card-item .overlay p {
        font-size: 16px;
        line-height: 1.5;
        padding: 0 20px;
        text-align: center;
    }
}

.gallery-main-title { display: none; }
.mobile-only { display: none; }

/* Empty state */
.empty-state {
    margin: 18px 0 10px;
    padding: 18px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #eef2f7;
    text-align: center;
}

.empty-title { font-weight: 800; font-size: 16px; color: var(--text-color); margin-bottom: 6px; }
.empty-subtitle { font-size: 13px; color: #6b7280; margin-bottom: 12px; }
.empty-reset {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
}

html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .error-banner {
    background: var(--surface-color);
    border-color: var(--surface-border);
}

/* Back-to-top */
.back-to-top {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.06);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    color: #1a1a1a;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

.back-to-top .icon-close { display: none; }
.back-to-top.as-close .icon-up { display: none; }
.back-to-top.as-close .icon-close { display: block; }

@media (max-width: 768px) {
    /* On mobile we close via the floating button */
    .close-modal { display: none !important; }
}

.back-to-top svg {
    width: 26px;
    height: 26px;
    stroke: #000;
    stroke-width: 4px;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

html[data-theme="dark"] .back-to-top {
    background: rgba(15, 23, 42, 0.94);
    border-color: rgba(148, 163, 184, 0.16);
    color: #f8fafc;
}

html[data-theme="dark"] .back-to-top svg {
    stroke: #f8fafc;
}

.back-to-top:active {
    transform: scale(0.9);
}

/* Share button styling */
.share-btn-round {
    background: #f1f2f6;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #2f3542;
    transition: all 0.2s ease;
}

.video-btn-round {
    background: #f1f2f6;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #2f3542 !important; /* Force to match share button color */
    transition: all 0.2s ease;
    text-decoration: none;
    flex-shrink: 0;
}

.video-btn-round:hover {
    background: #e1e2e6;
    color: var(--accent) !important;
}

.video-btn-round:active {
    transform: scale(0.92);
}

.video-btn-round svg {
    width: 20px;
    height: 20px;
}

/* Removed specific provider colors to match share button */

.share-btn-round:hover {
    background: #e1e2e6;
    color: var(--accent);
}

.share-btn-round:active {
    transform: scale(0.92);
}

html[data-theme="dark"] .share-btn-round,
html[data-theme="dark"] .video-btn-round {
    background: #111c30;
    color: #e2e8f0 !important;
}

.share-btn-round.is-copied,
.overlay-share-btn.is-copied,
.card-mobile-share-btn.is-copied,
.mvctl-share.is-copied {
    color: #16a34a;
}

.overlay-author {
    cursor: default !important;
    transition: none;
    pointer-events: auto !important;
    display: flex !important;
    align-items: center;
    gap: 0;
    min-width: 0;
    overflow: visible;
    z-index: 6;
}

.overlay-author__text {
    cursor: pointer !important;
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s ease;
}

@media (max-width: 768px) {
    /* Prefer adaptive shrinking (JS) + clipping over "..." */
    .overlay-author__text {
        text-overflow: clip;
    }

    .overlay-actions {
        gap: 4px;
    }

    .overlay-video-btn {
        width: 22px;
        height: 22px;
    }
    .overlay-video-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Keep verification badge compact inside overlay headers */
    .overlay-author-wrapper .ver-badge {
        width: 14px;
        height: 14px;
        margin-left: 6px;
    }
}

.overlay-author-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.overlay-author-wrapper .ver-badge {
    margin-left: 6px;
    flex: 0 0 auto;
    pointer-events: auto;
}

/* Ensure hover state also has pointer cursor explicitly */
.overlay-author__text:hover,
.desc-author:hover,
.post-author:hover {
    cursor: pointer !important;
}

@media (min-width: 769px) {
    .overlay-author__text:hover,
    .desc-author:hover,
    .post-author:hover {
        color: #3498db !important;
        text-decoration: none;
    }
}

/* Deep-link blur */
body.deeplink-active .container {
    filter: blur(10px);
    pointer-events: none;
    user-select: none;
}

/* Onboarding */
.onboarding-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(400px, calc(100% - 32px));
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    padding: 20px;
    z-index: 2200;
    text-align: center;
}

.onboarding-title { 
    font-weight: 800; 
    font-size: 18px;
    margin-bottom: 12px; 
    color: var(--text-color);
}

.onboarding-line { 
    font-size: 14px; 
    color: #4b5563; 
    margin: 8px 0; 
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.onboarding-icon {
    font-size: 18px;
    min-width: 24px;
}

.onboarding-actions { margin-top: 20px; }
.onboarding-btn {
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 14px;
    padding: 12px 30px;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    width: 100%;
}

.onboarding-btn:active { transform: scale(0.96); }

/* Mobile Only */
@media (max-width: 768px) {
    .degree-badge {
        min-width: 60px;
        height: 26px;
        font-size: 11px;
        padding: 0;
        top: 10px;
        right: 10px;
    }
    
    .badge-content {
        padding: 0 10px;
    }

    .badge-slider {
        font-size: 11px;
    }

    .mobile-only { display: block !important; }
    .container { flex-direction: column; }
    .sidebar {
        width: 100% !important; height: auto !important; position: sticky !important; top: 0 !important;
        padding: 10px 15px !important; border-right: none !important; border-bottom: 1px solid #eee !important;
        display: block !important; z-index: 1000 !important; background: #fff !important;
    }
    html[data-theme="dark"] .sidebar {
        background: #050505 !important;
        border-bottom-color: #1b1b1b !important;
        box-shadow: 0 18px 34px rgba(0, 0, 0, 0.36);
    }
    .logo-area, .sidebar-footer { display: none !important; }
    
    .search-container { display: block !important; margin-bottom: 10px !important; }
    .sidebar-search-row {
        gap: 8px !important;
    }
    .sidebar-mobile-toggle {
        display: inline-flex !important;
    }
    html[data-theme="dark"] .sidebar-mobile-toggle {
        background: #101010;
        border-color: #232323;
        color: #94a3b8;
        box-shadow: none;
    }
    
    .gallery-main-title {
        display: flex !important; align-items: center !important; justify-content: center !important;
        gap: 6px !important; font-size: 16px !important; margin: 10px 0 !important;
        font-weight: 800 !important; text-transform: uppercase !important; width: 100% !important;
        flex-wrap: nowrap !important; /* Force single line again as text is shorter */
        white-space: nowrap !important;
        text-align: center !important;
    }
    .filters {
        display: flex !important; flex-direction: row !important;
        overflow-x: auto !important; gap: 6px !important; width: 100% !important;
        padding: 5px 112px 10px 0 !important;
        position: relative !important;
        scrollbar-width: none;
        flex-wrap: nowrap !important; 
        -webkit-overflow-scrolling: touch;
    }
    .filters::-webkit-scrollbar { display: none; }

    .filters-mobile-actions {
        position: absolute;
        top: 5px;
        right: 0;
        z-index: 12;
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
    }
    
    .filter-btn {
        display: flex !important; background: #f1f2f6; white-space: nowrap;
        padding: 5px 10px; font-size: 11px; flex-shrink: 0 !important; border-radius: 8px;
        height: 28px !important; align-items: center !important;
        border: 1px solid transparent;
    }
    html[data-theme="dark"] .filter-btn {
        background: #101010;
        border-color: #222222;
        color: #e7e7e7;
    }
    html[data-theme="dark"] .filter-btn.active {
        background: linear-gradient(135deg, #bb3645 0%, #ff5a5f 100%);
        border-color: transparent;
        color: #fff;
    }
    html[data-theme="dark"] .filter-btn.active:hover {
        background: linear-gradient(135deg, #bb3645 0%, #ff5a5f 100%);
        border-color: transparent;
        color: #fff;
    }

    .mobile-only-menu {
        display: flex !important;
        height: 28px !important; background: #fff !important; border: 1.5px solid #eee !important;
        min-width: 64px !important;
        padding: 0 10px !important;
        justify-content: center !important;
        align-items: center !important; z-index: 10;
        font-size: 11px !important;
        box-shadow: none;
    }

    html[data-theme="dark"] .mobile-only-menu {
        background: #101010 !important;
        border-color: #232323 !important;
        box-shadow: none;
    }

    html[data-theme="dark"] .search-input {
        background: #0d0d0d;
        border-color: #202020;
        color: #ececec;
    }

    html[data-theme="dark"] .search-input:focus {
        background: #111111;
        border-color: rgba(255, 71, 87, 0.3);
        box-shadow: 0 0 0 1px rgba(255, 71, 87, 0.14);
    }

    .gallery-wrapper { margin-left: 0; width: 100%; padding: 10px; }
    .grid-sizer, .grid-item { width: calc(50% - 7px); margin-bottom: 14px; }
    .logo-card-img { width: 64% !important; max-width: 64% !important; height: auto; z-index: 1; }

    .sidebar-primary-controls {
        display: block;
    }

    body.mobile-sidebar-menu-collapsed .sidebar-primary-controls {
        display: none !important;
    }

    body.mobile-sidebar-menu-collapsed .search-container {
        margin-bottom: 0 !important;
    }

    body.mobile-sidebar-menu-collapsed .sidebar-mobile-toggle svg {
        transform: rotate(180deg);
    }
}

/* Modals Refined */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(10px);
    z-index: 2000; display: none; align-items: center; justify-content: center;
    opacity: 0; transition: all 0.3s;
}
.modal-overlay.active { display: flex; opacity: 1; }
.modal {
    background: #fff; width: 92%; max-width: 450px; 
    /* Default padding for info-modals */
    padding: 30px 25px 40px;
    border-radius: 30px; position: relative; max-height: 88%; 
    display: flex; flex-direction: column;
    overflow: hidden; /* Prevent double scroll when inner content-scroll is used */
    -webkit-overflow-scrolling: touch;
    transform: scale(0.9) translateY(20px); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

html[data-theme="dark"] .modal {
    background: var(--card-bg);
    color: #edf2f7;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8);
    border: 1px solid #222;
}

html[data-theme="dark"] .modal h2,
html[data-theme="dark"] .modal p,
html[data-theme="dark"] .modal a,
html[data-theme="dark"] .menu-footer,
html[data-theme="dark"] .menu-item,
html[data-theme="dark"] .modal-back-btn {
    color: #e2e8f0;
}

html[data-theme="dark"] .modal-list li,
html[data-theme="dark"] .menu-item {
    background: #111111;
    border-color: #232323;
}

/* More compact layout for Menu/How-to on mobile to avoid scroll */
#menu-modal, 
#how-to, 
#help, 
#contacts, 
#info-keto, 
#ketosis-info,
#classic-details,
#carnivore-details,
#lchf-details {
    padding: 25px 22px 15px 22px !important; /* Added more freedom/breathing room */
    display: flex;
    flex-direction: column;
}

@media (max-width: 380px) {
    #info-keto, #how-to, #help {
        padding: 18px 16px 10px 16px !important;
    }
}

#how-to h2, 
#help h2, 
#info-keto h2, 
#classic-details h2, 
#carnivore-details h2, 
#lchf-details h2,
#contacts h2 {
    margin-top: 0;
    margin-bottom: 8px; /* Even tighter title */
    font-size: 17px;
}

#how-to p, #how-to ul, 
#help p, #help ul, 
#info-keto p, #info-keto ul, 
#classic-details p, #classic-details ul,
#carnivore-details p, #carnivore-details ul,
#lchf-details p, #lchf-details ul,
#contacts p {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
}

#how-to .modal-list, 
#help .modal-list, 
#info-keto .modal-list, 
#classic-details .modal-list, 
#carnivore-details .modal-list, 
#lchf-details .modal-list {
    margin-bottom: 8px;
}

#how-to .modal-list li, 
#help .modal-list li, 
#info-keto .modal-list li, 
#classic-details .modal-list li, 
#carnivore-details .modal-list li, 
#lchf-details .modal-list li {
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
}

#how-to .modal-list li strong, 
#help .modal-list li strong, 
#info-keto .modal-list li strong, 
#classic-details .modal-list li strong, 
#carnivore-details .modal-list li strong, 
#lchf-details .modal-list li strong {
    margin-bottom: 2px;
}

#menu-modal .menu-list { gap: 10px; }

/* Verification Badge */
.ver-badge {
    display: inline-block;
    vertical-align: middle;
    width: 19px;
    height: 19px;
    margin-left: 8px;
    cursor: pointer;
    position: relative;
    background: url('ver.png') no-repeat center center;
    background-size: contain;
    image-rendering: auto;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.ver-badge.active {
    filter: brightness(0.85);
    transform: scale(1.02);
}

/* Avoid “sticky hover” on mobile Safari/Telegram webview */
@media (hover: hover) and (pointer: fine) {
    .ver-badge:hover {
        filter: brightness(0.85);
        transform: scale(1.02);
    }
}

@media (max-width: 768px) {
    .ver-badge {
        margin-left: 11px; /* Even more space on mobile to prevent accidental nick click */
        margin-top: 0px; /* Refined alignment for mobile fonts: lowered as requested */
        width: 16px;
        height: 16px;
    }
    /* Larger verification badge specifically for modals */
    .modal .ver-badge {
        width: 25px;
        height: 25px;
        margin-left: 10px;
        margin-top: -1px;
    }
}

/* Global verification tooltip (JS-driven; consistent across mobile/desktop) */
.ver-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100000;
    pointer-events: none; /* click-through; any click closes via JS */
    max-width: min(240px, calc(100vw - 32px));
    will-change: transform, opacity;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease-out, transform 0.15s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.ver-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}

.ver-tooltip__bubble {
    background: #1e293b; /* Solid color to match arrow exactly */
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    text-align: left;
    position: relative;
    z-index: 2;
}

.ver-tooltip__title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
    color: #fff;
    line-height: 1.2;
}

.ver-tooltip__desc {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.3;
}

.ver-tooltip__arrow {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #1e293b; /* Must match bubble background exactly */
    z-index: 3; /* On top of bubble to mask the bubble's own border at the junction */
    transform: rotate(45deg);
}

.ver-tooltip[data-placement="top"] .ver-tooltip__arrow {
    bottom: -5px; /* Dropped by 1px (from -4px) */
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.ver-tooltip[data-placement="bottom"] .ver-tooltip__arrow {
    top: -7px; /* Dropped by 1px (from -8px) */
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}


.modal-content-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding-right: 5px; /* space for scrollbar if any */
}

/* Hide scrollbar for cleaner look if content fits or just keep standard */
.modal-content-scroll::-webkit-scrollbar {
    width: 4px;
}
.modal-content-scroll::-webkit-scrollbar-thumb {
    background: #eee;
    border-radius: 10px;
}
#menu-modal .menu-item { padding: 15px; border-radius: 15px; }
#menu-modal .menu-footer { margin-top: 15px; }
#menu-modal h2 { margin-bottom: 12px; }

.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255,255,255,0.96);
    color: #111;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: none;
    cursor: pointer !important; /* Force pointer cursor for clickability */
    font-size: 32px;
    line-height: 1;
    z-index: 10;
    padding-bottom: 4px; /* Shifting X symbol UP by roughly 2px */
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

.close-modal:hover {
    background: #fff;
    color: var(--accent);
    transform: scale(1.15) translateZ(0);
}

html[data-theme="dark"] .close-modal {
    background: rgba(15, 23, 42, 0.96);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.14);
}

/* Specific style for info modals (no circles) */
#menu-modal .close-modal,
#info-keto .close-modal,
#how-to .close-modal,
#help .close-modal,
#contacts .close-modal,
#classic-details .close-modal,
#carnivore-details .close-modal,
#ketosis-info .close-modal,
#lchf-details .close-modal {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

#menu-modal .close-modal:hover,
#info-keto .close-modal:hover,
#how-to .close-modal:hover,
#help .close-modal:hover,
#contacts .close-modal:hover,
#classic-details .close-modal:hover,
#carnivore-details .close-modal:hover,
#ketosis-info .close-modal:hover,
#lchf-details .close-modal:hover {
    background: transparent !important;
    transform: scale(1.2);
}

/* Desktop alignment for Close button in Info Modals */
@media (min-width: 769px) {
    #info-keto .close-modal,
    #how-to .close-modal,
    #help .close-modal,
    #contacts .close-modal,
    #classic-details .close-modal,
    #carnivore-details .close-modal,
    #ketosis-info .close-modal,
    #lchf-details .close-modal {
        top: 10px !important; /* Moved UP significantly to align center with Title */
        right: 15px !important;
    }
}

/* In long description modals: keep image fixed and scroll only text */
#description-modal,
#post-modal {
    overflow: hidden !important; 
    display: none; /* Will be set to flex by JS */
    flex-direction: column;
    padding: 0 !important; 
    max-height: 88vh; /* Use vh for iOS stability */
    position: relative;
    background: #f7f5f1 !important;
    mask-image: radial-gradient(white, black);
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    border-radius: 30px; /* Explicitly ensure radius is here */
    transform: translateZ(0); /* Hardware acceleration for cleaner clipping */
}

html[data-theme="dark"] #description-modal,
html[data-theme="dark"] #post-modal,
html[data-theme="dark"] #description-modal .modal-header,
html[data-theme="dark"] #post-modal .modal-header,
html[data-theme="dark"] #description-modal .desc-text,
html[data-theme="dark"] #post-modal .post-caption,
html[data-theme="dark"] .modal-divider {
    background: #050505 !important;
    color: #e5e7eb;
}

html[data-theme="dark"] .modal-divider::after {
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .desc-stats,
html[data-theme="dark"] .post-stats,
html[data-theme="dark"] .empty-subtitle,
html[data-theme="dark"] .error-subtitle {
    color: #94a3b8;
}

/* Scroll Fade Indicator */
#description-modal::after,
#post-modal::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px; /* Gradient height */
    background: linear-gradient(to top, 
        rgba(255,255,255,1) 0%, 
        rgba(255,255,255,0.85) 30%, 
        rgba(255,255,255,0) 100%);
    pointer-events: none;
    z-index: 5;
    border-radius: 0 0 30px 30px;
}

html[data-theme="dark"] #description-modal::after,
html[data-theme="dark"] #post-modal::after {
    background: linear-gradient(to top,
        rgba(5, 5, 5, 1) 0%,
        rgba(5, 5, 5, 0.88) 34%,
        rgba(5, 5, 5, 0) 100%);
}

#description-modal .desc-image-container,
#post-modal .desc-image-container {
    flex: 0 0 auto;
    width: 100%;
    margin: 0 !important;
    border-radius: 0 !important; 
    overflow: hidden;
    max-height: 50vh; 
    background-color: #000;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Blurred background for padding area */
.desc-image-container-blur-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(25px) brightness(0.7);
    transform: scale(1.1);
    z-index: 1;
    pointer-events: none;
}

/* Ensure video in modal is contained and fits within the 50vh area */
.gallery-video-container video,
#description-modal .desc-image-container video,
#post-modal .desc-image-container video {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 50vh !important;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 2; /* Still above blur bg */
}

/* Container for video to prevent overflow */
.gallery-video-container {
    width: 100%;
    height: auto;
    max-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Blurred background extension */
#description-modal .desc-image-container::before,
#post-modal .desc-image-container::before {
    content: "";
    position: absolute;
    top: -30px; left: -30px; right: -30px; bottom: -30px;
    background: inherit;
    filter: blur(20px) brightness(0.9);
    z-index: -1;
}

#description-modal .desc-image-container img,
#post-modal .desc-image-container img {
    width: 100%;
    height: auto;
    max-height: 50vh;
    object-fit: contain; 
    display: block;
    position: relative;
    z-index: 2;
}

/* Hide broken or empty image icons that can appear on mobile/Safari before load */
#description-modal .desc-image-container img:not([src]),
#post-modal .desc-image-container img:not([src]),
#description-modal .desc-image-container img[src=""],
#post-modal .desc-image-container img[src=""] {
    visibility: hidden;
}

/* Header and stats area inside description/post modals */
#description-modal .modal-header,
#post-modal .modal-header {
   padding: 20px 25px 0 25px;
   flex: 0 0 auto;
    background: #fff;
}

#description-modal .desc-text,
#post-modal .post-caption {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: scroll; /* Force scroll area in Safari */
    -webkit-overflow-scrolling: touch;
    padding: 5px 25px 65px 25px; /* Balanced spacing around divider */
    scrollbar-width: thin;
    font-size: 16px;
    line-height: 1.6;
    color: #2d3436;
    white-space: pre-wrap;
    background: #fff;
    border-radius: 0 0 30px 30px;
}

/* New Minimalist Divider */
.modal-divider {
    height: 1px;
    background: #fff;
    flex: 0 0 auto;
    padding: 10px 0 5px 0;
    position: relative;
}

.modal-divider::after {
    content: '';
    display: block;
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 0 25px;
}

/* Author Hover in Modals */
.desc-author, .post-author {
    cursor: default !important;
    transition: none;
    pointer-events: auto !important;
    display: inline-flex !important;
    align-items: center;
    z-index: 6;
}

.desc-author__text, .post-author__text {
    cursor: pointer !important;
    transition: color 0.15s ease-out;
}

@media (min-width: 769px) {
    .desc-author__text:hover, .post-author__text:hover {
        color: #3498db !important; /* Unified blue color from the overlay hover */
        text-decoration: none;
    }
}

.desc-stats, .post-stats {
    font-size: 14px;
    color: #6b7280;
    font-weight: 600;
}

.post-direct-link {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.45;
    color: #3498db;
    text-decoration: none;
    word-break: break-all;
}

.post-direct-link:hover {
    text-decoration: underline;
}

/* Error banner */
.error-banner {
    margin: 14px 0 10px;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(255,71,87,0.25);
    box-shadow: 0 12px 30px rgba(0,0,0,0.06);
    text-align: center;
}

.error-title { font-weight: 900; font-size: 16px; color: var(--text-color); margin-bottom: 6px; }
.error-subtitle { font-size: 13px; color: #6b7280; margin-bottom: 12px; }

.error-retry {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 900;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
}

.error-retry:active { transform: scale(0.98); }

/* Modal Content Formatting */
.modal h2 { font-size: 22px; font-weight: 800; margin-bottom: 20px; color: var(--text-color); text-transform: uppercase; border-bottom: 2px solid #f0f0f0; padding-bottom: 10px; }
.modal p { font-size: 15px; line-height: 1.6; color: #4b5563; margin-bottom: 20px; }
.modal-list { list-style: none; margin-bottom: 25px; }
.modal-list li { 
    background: #f9fafb; padding: 15px; border-radius: 15px; margin-bottom: 20px; 
    font-size: 14px; line-height: 1.5; border: 1px solid #f0f0f0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.details-link-wrap {
    margin-top: 8px;
    display: block;
}

.details-link {
    cursor: pointer;
    color: #3498db !important;
    font-size: 13px;
    font-weight: 600;
}
.modal-list li strong { color: var(--accent); display: block; margin-bottom: 4px; }
.modal a {
    color: #1e3799;
    text-decoration: none;
    font-weight: 700;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.modal a:hover { text-decoration: underline; }

/* Menu Specific */
.mobile-menu-content h2 { border: none; text-align: center; }
.menu-list { display: flex; flex-direction: column; gap: 12px; }
.menu-item { 
    background: #f3f4f6; padding: 18px; border-radius: 18px; 
    font-weight: 700; text-align: center; cursor: pointer; transition: background 0.2s; 
}
.menu-footer {
    margin-top: 30px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
    word-break: break-word; /* Ensure deep links don't overflow */
    padding: 0 10px;
}

.modal-back-btn {
    display: block;
    width: 100%;
    margin-top: 20px; /* Added more space before the button */
    padding: 12px;
    text-align: center;
    color: var(--secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-top: 1px solid #f0f0f0;
    flex: 0 0 auto; /* Ensure it stays at bottom without growing */
}

.details-link {
    color: #4dabf7;
    font-weight: 700;
    cursor: pointer;
    margin-left: 5px;
    font-size: 13px;
    text-decoration: none;
}

.inline-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #f1f2f6;
    border-radius: 50%;
    font-size: 11px;
    color: var(--secondary);
    cursor: pointer;
    margin-left: 4px;
    font-style: normal;
    border: 1px solid #ddd;
    vertical-align: middle;
}
.spinner { width: 35px; height: 35px; border: 4px solid #f3f3f3; border-top: 4px solid var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- Floating "Разместить" (+) button --- */
.join-fab {
    position: fixed;
    left: calc(50vw + var(--sidebar-width) / 2);
    bottom: 52px;
    transform: translateX(-50%);
    z-index: 9500;
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

body.sidebar-collapsed .join-fab {
    left: calc(50vw + var(--sidebar-collapsed-width) / 2);
}

.join-fab.is-quiet .join-fab__btn {
    opacity: 0.2;
}

.join-fab.is-copy-mode .join-fab__btn {
    opacity: 1 !important;
    background: #ffffff;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.2);
}

/* On mobile sidebar becomes top; pin to screen edge */
@media (max-width: 900px) {
    .join-fab { left: 50%; bottom: 52px; transform: translateX(-50%); }
}

.join-fab__btn {
    width: 66px;
    height: 66px;
    background: #26a5e4;
    border-radius: 50%;
    box-shadow: 0 14px 40px rgba(38, 165, 228, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 5;
}
.join-fab__btn:hover { transform: scale(1.06); }
.join-fab__btn:active { transform: scale(0.96); }

/* When open: Rotate to X, change color to white */
.join-fab.is-open .join-fab__btn {
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transform: rotate(45deg); /* Rotate + to make it look like x */
}

.join-fab__plus {
    font-size: 42px;
    line-height: 1;
    font-weight: 300;
    color: #fff;
    z-index: 2;
    transform: translateY(-2px); /* optical centering */
    transition: color 0.3s ease;
}

.join-fab__copyicon {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #0f172a;
    z-index: 2;
}

.join-fab__copyicon svg {
    width: 28px;
    height: 28px;
}

.join-fab.is-copy-mode .join-fab__plus {
    display: none;
}

.join-fab.is-copy-mode .join-fab__copyicon {
    display: inline-flex;
}

.join-fab.is-open .join-fab__plus {
    color: var(--accent); /* Icon becomes reddish/accent color instead of blue */
}

/* pulse layer exists always, but animates only when enabled */
.join-fab__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(38, 165, 228, 0.28);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}
.join-fab.is-open .join-fab__pulse { display: none; } /* Hide pulse when open */

.join-fab.is-pulsing .join-fab__pulse {
    opacity: 1;
    animation: joinFabPulse 1.9s ease-out infinite;
}

@keyframes joinFabPulse {
    0% { transform: scale(1); opacity: 0.65; }
    100% { transform: scale(1.85); opacity: 0; }
}

.join-fab__popup {
    position: absolute;
    left: 50%;
    bottom: 82px;
    width: 320px;
    background: #fff;
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 18px 60px rgba(0,0,0,0.22);
    transform: translateX(-50%) translateY(18px) scale(0.92);
    opacity: 0;
    visibility: hidden;
    transition: all 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.join-fab.is-open .join-fab__popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

.join-fab.is-copy-mode .join-fab__popup {
    display: none;
}

html[data-theme="dark"] .join-fab.is-copy-mode .join-fab__btn {
    background: #ffffff;
}

html[data-theme="dark"] .join-fab__popup {
    background: #0f172a;
    box-shadow: 0 22px 60px rgba(2, 6, 23, 0.4);
}

html[data-theme="dark"] .join-fab__popup p {
    color: #f8fafc;
}

.join-fab__feedback {
    position: absolute;
    left: 50%;
    bottom: 84px;
    transform: translateX(-50%) translateY(10px);
    min-width: 220px;
    max-width: 280px;
    padding: 12px 16px;
    border-radius: 18px;
    background: rgba(17, 24, 39, 0.94);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s ease;
}

.join-fab__feedback.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.join-fab__popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.join-fab__popup p {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
    text-align: center;
    letter-spacing: 0.5px;
}

.join-fab__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.join-fab__action-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: #26a5e4;
    color: #fff;
    border-radius: 16px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: background 0.2s ease;
}
.join-fab__action-btn:hover { background: #1e8cc4; }

.join-fab__action-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
}

.join-fab__action-text {
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.join-fab__icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Ensure white icon if tela.png is colored? Assuming tela.png is white or colored. If colored, remove filter. */
}

@media (max-width: 480px) {
    .join-fab__popup { width: 250px; }
    .join-fab__btn { width: 62px; height: 62px; }
    .join-fab__plus { font-size: 38px; }
    .join-fab__copyicon {
        width: 24px;
        height: 24px;
    }
    .join-fab__copyicon svg {
        width: 24px;
        height: 24px;
    }
    .join-fab__feedback {
        min-width: 190px;
        max-width: 240px;
        padding: 11px 14px;
        font-size: 13px;
    }
}



/* Gallery Slider Styles */
.gallery-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

.gallery-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.gallery-slide {
    min-width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.gallery-slide img, .gallery-slide video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;                  
    height: 100%;                 
    object-fit: contain;          
    display: block;
}

/* Arrows */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s, opacity 0.2s;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-nav.prev { left: 15px; }
.gallery-nav.next { right: 15px; }

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.4);
}

.gallery-nav svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gallery-nav.hidden {
    display: none;
    pointer-events: none;
}

/* Counter */
.gallery-counter {
    position: absolute;
    top: 15px;
    left: 15px;
    right: auto;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* Video Play Button */
.gallery-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-play-btn {
    position: absolute;
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255,255,255,0.2);
    z-index: 5;
}

.media-play-btn svg {
    width: 32px;
    height: 32px;
    fill: #fff;
    margin-left: 4px; /* Optical adjustment */
}

.media-play-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 40, 40, 0.8);
    border-color: rgba(255, 40, 40, 0.8);
}

/* Hide play button when playing */
.gallery-video-container.playing .media-play-btn {
    opacity: 0;
    pointer-events: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .gallery-nav {
        width: 36px;
        height: 36px;
    }
    .gallery-nav.prev { left: 10px; }
    .gallery-nav.next { right: 10px; }
    .media-play-btn { width: 56px; height: 56px; }
}
/* =========================================
   CARD SLIDER STYLES
   ========================================= */
.card-slider {
    position: relative;
    width: 100%;
    /* No fixed height, relies on active slide content */
    overflow: hidden;
    background: #f0f0f0;
    /* transition: height 0.35s ease; REMOVED to align with Masonry */
}

.card-slide {
    width: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    position: relative;
}
.card-slide.active { display: flex; }

.card-slide img, .card-slide video {
    width: 100%;
    height: auto;
    display: block;   
    object-fit: contain; /* or cover, depending on masonry requirements */
    object-position: center center;
}

/* Nav Arrows */
.card-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 5;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    .card-nav-btn {
        opacity: 0.8 !important; /* На мобилках всегда видны */
        width: 32px;
        height: 32px;
        background: rgba(0,0,0,0.4);
    }
    .overlay-expand-btn {
        display: none !important;
    }
    .card-item-counter {
        display: none !important;
    }
}

.card-nav-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.card-nav-btn.prev { left: 8px; }
.card-nav-btn.next { right: 8px; }

/* Show arrows on hover (desktop only usually) */
.grid-item:hover .card-nav-btn { opacity: 1; }
.card-nav-btn:hover { background: rgba(0,0,0,0.8); transform: translateY(-50%) scale(1.1); }
.card-nav-btn:active { transform: translateY(-50%) scale(0.95); }

.grid-item.tapped .card-nav-btn { opacity: 1; }

/* Dots */
.card-dots {
    position: absolute;
    bottom: 12px; /* Чуть выше для заметности */
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 15; /* Всегда поверх оверлея */
    pointer-events: none; 
}

@media (max-width: 768px) {
    .card-dots {
        opacity: 1 !important; /* На мобилках всегда видны */
        pointer-events: auto;
    }
}

.grid-item:hover .card-dots { opacity: 1; pointer-events: auto; }
.grid-item.tapped .card-dots { opacity: 1; pointer-events: auto; }

@media (min-width: 769px) {
    .card-dots {
        display: none !important;
    }
}

.card-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: all 0.2s;
}
.card-dot.active {
    background: #fff;
    transform: scale(1.4);
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.card-item-counter {
    position: absolute;
    top: 15px;
    left: 15px; /* moved to top-left */
    right: auto;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    z-index: 6;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Custom video play button */
.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(6px);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 20; 
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.video-play-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: rgba(0, 0, 0, 0.45);
    border-color: #fff;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
}

.video-play-button::after {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent #fff;
    margin-left: 4px;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
}

.video-play-button.playing {
    opacity: 0;
    pointer-events: none;
}

/* Grid behavior: show play button initially, hide on hover (desktop). */
@media (hover: hover) and (pointer: fine) {
    .grid-item .video-play-button {
        opacity: 1;
        pointer-events: auto;
        transform: translate(-50%, -50%) scale(1);
    }
    .grid-item:hover .video-play-button,
    .grid-item.tapped .video-play-button {
        opacity: 0;
        pointer-events: none;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Fix mobile modal double play button and grid play button overlap */
.modal .video-play-button.playing,
.grid-item .video-play-button.playing {
    display: none !important;
}

/* Mobile: keep play button accessible (no hover). */
@media (hover: none), (pointer: coarse) {
    .grid-item .video-play-button {
        opacity: 1;
        pointer-events: auto;
        width: 48px;
        height: 48px;
        background: rgba(0, 0, 0, 0.1);
        border-width: 1px;
        border-color: rgba(255, 255, 255, 0.4);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }
    .grid-item .video-play-button::after {
        border-width: 8px 0 8px 14px;
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
    }
}

/* Mobile and Desktop minimal controls near degree badge (pause/time/sound/fullscreen) */
.card-video-mini-controls {
    position: absolute;
    top: 15px;
    left: 15px; /* Moved to left side */
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0px; 
    padding: 0 8px; /* Slightly more padding for Desktop */
    height: 32px; /* Identical to degree badge */
    min-width: unset; 
    justify-content: center;
    box-sizing: border-box;
    border-radius: 999px; /* Pill shape */
    background: rgba(0,0,0,0.40);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.10);
    pointer-events: auto;
}

@media (hover: hover) {
    .card-video-mini-controls {
        gap: 6px; /* Uniform spacing between elements on desktop */
    }
}

@media (max-width: 768px) {
    .card-video-mini-controls {
        top: 10px;
        left: 5px;
        height: 26px;
        padding: 0 5px;
        gap: 2px !important; /* Exactly 2 pixels gap as requested */
        min-width: unset !important;
        width: auto;
    }
    .card-video-mini-controls .mvctl-time {
        font-size: 10px;
        min-width: 0 !important;
        letter-spacing: -0.1px;
        padding: 0 1px !important;
        margin: 0; /* Removed negative margins */
    }
    .card-video-mini-controls .mvctl-btn {
        width: 18px !important; 
        flex: 0 0 18px;
        padding: 0 !important;
        margin: 0 !important;
    }
    .card-video-mini-controls .mvctl-btn svg {
        width: 14px;
        height: 14px;
    }
    /* Hide center play button on mobile once playing */
    .grid-item .video-play-button.playing {
        display: none !important;
    }
}

.card-video-mini-controls .mvctl-time {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    letter-spacing: 0.1px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    min-width: unset;
    padding: 0; /* Gap handles spacing now */
    text-align: center;
}

/* Hide pause button on desktop (hoverable devices) */
@media (hover: hover) {
    .card-video-mini-controls .mvctl-pause {
        display: none !important;
    }
}

.card-video-mini-controls .mvctl-btn {
    width: 26px; /* Exact width for Desktop buttons */
    height: 26px;
    border: none;
    background: transparent;
    color: #fff;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.95;
    cursor: pointer;
}

.card-video-mini-controls .mvctl-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2px;
}

.card-video-mini-controls .mvctl-ico-mute { display: none; }
.card-video-mini-controls.is-muted .mvctl-ico-wave { display: none; }
.card-video-mini-controls.is-muted .mvctl-ico-mute { display: inline; }

.card-slide {
    position: relative;
}

.card-slide video {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.desc-image-container video {
    cursor: pointer;
}

.gallery-slide {
    position: relative;
}

.gallery-slide video {
    cursor: pointer;
}

/* Modal Enhancements */
/* Minimalist gallery nav in modal */
.desc-image-container .gallery-nav {
    width: 44px;
    height: 44px;
    background: rgba(40, 40, 40, 0.6);
    backdrop-filter: blur(6px);
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s ease;
}
.desc-image-container .gallery-nav svg {
    stroke-width: 1.5;
}
.desc-image-container .gallery-nav:hover {
    background: rgba(40, 40, 40, 0.9);
    transform: translateY(-50%) scale(1.05);
}

@media (min-width: 769px) {
    .desc-image-container .gallery-nav {
        width: 28px;
        height: 28px;
        background: transparent;
        backdrop-filter: none;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .desc-image-container .gallery-nav:hover {
        background: transparent;
        transform: translateY(-50%) scale(1.08);
    }

    .desc-image-container .gallery-nav svg {
        width: 26px;
        height: 26px;
        stroke-width: 2;
    }
}

.gallery-counter {
    background: rgba(40, 40, 40, 0.6);
    backdrop-filter: blur(6px);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Video inside slider */
video {
    background: #000;
}

/* === Filter And Admin UI === */
.sidebar {
    transition: transform 0.32s ease, box-shadow 0.32s ease;
}

.gallery-wrapper {
    transition: margin-left 0.32s ease, width 0.32s ease, padding 0.32s ease;
}

.sidebar-toggle {
    position: absolute;
    right: 12px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(71, 85, 105, 0.68);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: color 0.2s ease, opacity 0.2s ease;
    z-index: 120;
    opacity: 0.9;
}

.sidebar-toggle:hover {
    color: var(--accent);
    opacity: 1;
}

.sidebar-toggle--bottom {
    bottom: 28px;
}

.sidebar-toggle svg {
    transition: transform 0.22s ease;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width) + var(--sidebar-collapsed-width)));
    box-shadow: none;
}

body.sidebar-collapsed .gallery-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

body.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

body.sidebar-collapsed .logo-area,
body.sidebar-collapsed .search-container,
body.sidebar-collapsed .filters,
body.sidebar-collapsed .tag-filter-card,
body.sidebar-collapsed .sidebar-footer-content {
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar-toggle {
    right: 16px;
}

.tag-filter-card {
    margin-top: 18px;
    padding: 14px;
    border-radius: 18px;
    background: linear-gradient(180deg, #faf7f2 0%, #fffaf6 100%);
    border: 1px solid rgba(77, 55, 34, 0.08);
    box-shadow: 0 14px 30px rgba(53, 33, 15, 0.06);
}

html[data-theme="dark"] .tag-filter-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.01) 100%);
    border-color: #1f1f1f;
    box-shadow: 0 22px 40px rgba(0, 0, 0, 0.34);
}

.tag-filter-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.tag-filter-card__status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tag-filter-card__status {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
}

.tag-filter-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag-filter-chip {
    display: block;
    cursor: pointer;
}

.tag-filter-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tag-filter-chip__ui {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    background: #fffdf9;
    color: #46362a;
    border: 1px solid rgba(125, 93, 62, 0.16);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
    font-weight: 600;
}

html[data-theme="dark"] .tag-filter-chip__ui {
    background: #0f0f0f;
    color: #ece7e1;
    border-color: #242424;
}

.tag-filter-chip:hover .tag-filter-chip__ui {
    transform: translateY(-1px);
    border-color: rgba(255, 71, 87, 0.28);
}

.tag-filter-chip input:checked + .tag-filter-chip__ui {
    color: #fff;
    background: linear-gradient(135deg, #b73c49 0%, #ff5b5f 100%);
    border-color: transparent;
    box-shadow: 0 14px 30px rgba(183, 60, 73, 0.28);
}

.tag-filter-chip--subtle input:checked + .tag-filter-chip__ui {
    background: linear-gradient(135deg, #3b312b 0%, #5b4d43 100%);
    box-shadow: 0 14px 28px rgba(59, 49, 43, 0.22);
}

.tag-admin-savebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.tag-admin-savebar__text {
    font-size: 12px;
    color: #64748b;
}

.tag-admin-savebar__button {
    border: 0;
    min-height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #111827 0%, #334155 100%);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.tag-admin-savebar__button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.tag-admin-savebar__button:disabled {
    opacity: 0.45;
    cursor: default;
}

.tag-admin-savebar__button:not(:disabled) {
    opacity: 1;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

.card-admin-panel {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 35;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100% - 90px);
}

.card-admin-pill {
    border: 0;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.94);
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.card-admin-pill:hover {
    transform: translateY(-1px);
}

.card-admin-pill.is-active {
    background: #111827;
    color: #fff;
}

.card-admin-panel.has-pending-save {
    filter: saturate(1.05);
}

.loading,
#loader {
    display: none !important;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .tag-filter-card {
        margin-top: 14px;
        padding: 14px;
        border-radius: 16px;
    }

    .tag-filter-chip__ui {
        min-height: 44px;
        padding: 0 12px;
    }

    .card-admin-panel {
        top: 10px;
        left: 10px;
        gap: 5px;
        max-width: calc(100% - 76px);
    }

    .card-admin-pill {
        min-height: 26px;
        padding: 0 9px;
        font-size: 10px;
    }
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sidebar {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.grid-item {
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.3s ease, box-shadow 0.3s ease;
}

.sidebar-toggle--bottom {
    bottom: 28px !important;
}

.theme-toggle-sidebar,
.sidebar-toggle {
    color: rgba(71, 85, 105, 0.68);
}

html[data-theme="dark"] .theme-toggle-sidebar,
html[data-theme="dark"] .sidebar-toggle {
    color: #94a3b8;
}

.theme-toggle-sidebar {
    position: absolute;
    right: 12px;
    bottom: 62px;
    width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none !important;
    transition: color 0.2s ease, opacity 0.2s ease;
    z-index: 120;
    opacity: 0.9;
}

.theme-toggle-sidebar:hover {
    color: var(--accent) !important;
    opacity: 1;
}

.theme-toggle-sidebar svg {
    width: 22px;
    height: 22px;
}

body.sidebar-collapsed .theme-toggle-sidebar,
body.sidebar-collapsed .sidebar-toggle {
    right: 16px;
}

body.sidebar-collapsed .theme-toggle-sidebar {
    opacity: 0;
    pointer-events: none;
}

.theme-toggle-sidebar .theme-toggle__icon--moon { display: inline-flex; }
.theme-toggle-sidebar .theme-toggle__icon--sun { display: none; }
html[data-theme="dark"] .theme-toggle-sidebar .theme-toggle__icon--moon { display: none; }
html[data-theme="dark"] .theme-toggle-sidebar .theme-toggle__icon--sun { display: inline-flex; }

.filter-theme-btn {
    display: none !important;
}

@media (max-width: 768px) {
    .filter-theme-btn {
        display: inline-flex !important;
        width: 28px;
        height: 28px !important;
        min-width: 28px;
        padding: 0;
        align-items: center !important;
        justify-content: center;
        border-radius: 8px;
        border: 1px solid transparent;
        background: #f1f2f6;
        color: rgba(71, 85, 105, 0.68);
        cursor: pointer;
        box-shadow: none;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .filter-theme-btn .theme-toggle__icon {
        width: 14px;
        height: 14px;
    }

    .filter-theme-btn .theme-toggle__icon svg {
        width: 14px;
        height: 14px;
    }

    html[data-theme="dark"] .filter-theme-btn {
        background: #101010;
        border-color: #232323;
        color: #94a3b8;
        box-shadow: none;
    }
}

.filter-theme-btn .theme-toggle__icon--moon { display: inline-flex; }
.filter-theme-btn .theme-toggle__icon--sun { display: none; }
html[data-theme="dark"] .filter-theme-btn .theme-toggle__icon--moon { display: none; }
html[data-theme="dark"] .filter-theme-btn .theme-toggle__icon--sun { display: inline-flex; }
