/* ----------------------------------------------------
   DESIGN SYSTEM & VARIABLES (Android 16 / Material You Style)
   ---------------------------------------------------- */
:root {
    /* Fonts - Manrope is a modern, geometric sans-serif */
    --font-primary: 'Manrope', sans-serif;
    --font-display: 'Manrope', sans-serif;
    
    /* Light Theme (Default - Soft Periwinkle & Creamy White) */
    --bg-primary: #f6f6f9;
    --bg-secondary: #eeeef4;
    --card-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.04);
    --border-color-hover: rgba(0, 0, 0, 0.08);
    
    --text-primary: #121217;
    --text-secondary: #5e5e6e;
    --text-muted: #8c8c9e;
    
    /* Brand Colors (Material You Tonal Scheme) */
    --brand-color: #9da1f8; /* Soft lavender periwinkle */
    --brand-light: #eaebff;
    --brand-dark: #666ae0;
    --accent-glow: rgba(157, 161, 248, 0.25);
    
    /* UI States */
    --like-color: #ff4a73;
    --like-light: #ffe6eb;
    --success-color: #34c759;
    
    /* Shadows - Soft organic shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.015);
    --shadow-md: 0 12px 30px rgba(157, 161, 248, 0.07);
    --shadow-lg: 0 24px 50px rgba(157, 161, 248, 0.12);
    --shadow-input: 0 0 0 4px rgba(157, 161, 248, 0.2);
    
    /* Structural variables */
    --header-height: 84px;
    --max-width: 1400px;
    --border-radius-sm: 10px;
    --border-radius-md: 20px; /* Rounded card layout */
    --border-radius-lg: 28px;
    --border-radius-pill: 9999px; /* Pill controls */
    
    /* Transitions - satisfying spring for layouts, smooth ease-out for hover scales */
    --transition-smooth: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-fast: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Explicit non-overshooting transition for scales, preventing pointer-flickers */
    --transition-hover: transform 0.22s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.2s ease, box-shadow 0.22s ease, opacity 0.2s ease;
}

.dark-theme {
    /* Dark Theme (Slate & Deep Periwinkle) */
    --bg-primary: #0a0a0e;
    --bg-secondary: #14141d;
    --card-bg: #191924;
    --border-color: rgba(255, 255, 255, 0.03);
    --border-color-hover: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f2f2f7;
    --text-secondary: #9ea0b0;
    --text-muted: #6b6c7a;
    
    --brand-color: #a9adff;
    --brand-light: #21233e;
    --brand-dark: #8b8eff;
    --accent-glow: rgba(169, 173, 255, 0.15);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
}

/* ----------------------------------------------------
   BASE STYLES & RESET
   ---------------------------------------------------- */
html {
    scroll-behavior: smooth; /* Native smooth page-scrolling */
    scrollbar-gutter: stable; /* Keeps scrollbar track space reserved, preventing layout jumps */
}

html.modal-open {
    overflow: hidden; /* Locks scroll natively */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

input, button, select, textarea {
    font-family: inherit;
    color: inherit;
    border: none;
    background: none;
    outline: none;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-hover);
    border-radius: var(--border-radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Hide scrollbar helper */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hidden {
    display: none !important;
}

/* ----------------------------------------------------
   TYPOGRAPHY
   ---------------------------------------------------- */
h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

/* ----------------------------------------------------
   BUTTONS (Pill-shaped Android 16 design)
   ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    transition: var(--transition-hover);
}

.btn:active {
    transform: scale(0.96) !important;
}

.btn-primary {
    background-color: var(--brand-color);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
    background-color: var(--brand-dark);
    transform: scale(1.02);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color-hover);
    transform: scale(1.02);
}

.btn-with-icon {
    gap: 8px;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition-hover);
    border: 1px solid var(--border-color);
}

.icon-btn:hover {
    background-color: var(--border-color-hover);
    transform: scale(1.08);
}
.icon-btn:active {
    transform: scale(0.94);
}

/* ----------------------------------------------------
   MAIN HEADER
   ---------------------------------------------------- */
.main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    background-color: rgba(246, 246, 249, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.dark-theme .main-header {
    background-color: rgba(10, 10, 14, 0.85);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--max-width);
    height: 100%;
    margin: 0 auto;
    padding: 0 32px;
    gap: 28px;
}

/* Logo styling */
.logo {
    display: flex;
    align-items: center;
    gap: 2px;
}

.logo:active {
    transform: scale(0.98);
}

.logo-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -2px;
    color: var(--brand-color);
    transition: color 0.4s ease;
}

/* Sparkle positioning aligned superscript - resolves extra pixel artifact */
.logo-sparkle {
    width: 22px;
    height: 22px;
    color: var(--brand-dark); /* Darker brand tone for better contrast in light mode */
    align-self: flex-start;
    margin-top: 2px;
    margin-left: 2px;
    overflow: visible !important; /* Prevents browser clipping of drop-shadow halos */
    display: inline-block;
    filter: drop-shadow(0 0 8px rgba(102, 106, 224, 0.7)); /* Static intense glow in light mode */
}

.dark-theme .logo-sparkle {
    color: var(--brand-color); /* Light periwinkle has superb contrast on dark background */
    filter: drop-shadow(0 0 12px rgba(169, 173, 255, 0.85)); /* Static intense glow in dark mode */
}

/* Search bar styling - Pill capsule */
.search-bar {
    position: relative;
    flex-grow: 1;
    max-width: 600px;
    display: flex;
    align-items: center;
}

.search-bar input {
    width: 100%;
    height: 48px;
    padding: 0 20px 0 52px;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--border-radius-pill);
    transition: var(--transition-fast);
}

.search-bar input:focus {
    background-color: var(--card-bg);
    border-color: var(--brand-color);
    box-shadow: var(--shadow-input);
}

.search-icon {
    position: absolute;
    left: 20px;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-clear-btn {
    position: absolute;
    right: 14px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-pill);
    color: var(--text-secondary);
    cursor: pointer;
}

.search-clear-btn:hover {
    background-color: var(--border-color-hover);
}

.search-clear-btn svg {
    width: 14px;
    height: 14px;
}

/* Actions - Theme Pill Toggle Switch (Android 16 Style) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-switch-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 58px;
    height: 32px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-pill);
    padding: 3px;
    cursor: pointer;
    transition: var(--transition-hover);
}

.theme-switch-pill:hover {
    background-color: var(--border-color-hover);
    border-color: var(--brand-color);
}

.theme-switch-pill:active {
    transform: scale(0.94);
}

.theme-switch-pill .thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: var(--brand-color);
    color: #ffffff;
    border-radius: 50%;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.theme-switch-pill .thumb svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.dark-theme .theme-switch-pill .thumb {
    transform: translateX(26px);
    background-color: #ffffff;
    color: #121219;
}

/* ----------------------------------------------------
   CATEGORIES SUB-NAVIGATION
   ---------------------------------------------------- */
.categories-nav {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px 32px 12px 32px;
    overflow-x: auto;
}

.categories-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-tab {
    padding: 10px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    white-space: nowrap;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.category-tab:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.category-tab:active {
    transform: scale(0.95);
}

.category-tab.active {
    background-color: var(--brand-light);
    color: var(--brand-dark);
}

.dark-theme .category-tab.active {
    background-color: var(--brand-color);
    color: #0a0a0e;
}

.tab-heart-icon {
    width: 12px;
    height: 12px;
    margin-right: 6px;
    display: inline-block;
    vertical-align: middle;
}

/* ----------------------------------------------------
   MAIN CONTENT & WELCOME BANNER
   ---------------------------------------------------- */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 32px 60px 32px;
}

.welcome-banner {
    position: relative;
    border-radius: var(--border-radius-lg);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    padding: 56px 48px;
    margin-bottom: 44px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition-smooth);
}

.dark-theme .welcome-banner {
    background-color: #111119;
}

/* Wavy decorative shapes in corners */
.banner-bg-waves {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.wave {
    position: absolute;
    width: 180px;
    height: 180px;
    background-color: var(--brand-color);
    opacity: 0.85;
    filter: blur(10px);
}

.wave-top-left {
    top: -65px;
    left: -65px;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    animation: waveFloat 10s infinite alternate ease-in-out;
}

.wave-bottom-right {
    bottom: -65px;
    right: -65px;
    border-radius: 60% 40% 30% 70% / 50% 60% 40% 50%;
    animation: waveFloat 12s infinite alternate-reverse ease-in-out;
}

.banner-content {
    position: relative;
    z-index: 2;
    max-width: 580px;
    margin: 0 auto;
    text-align: center;
}

.banner-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 3.8rem;
    font-weight: 700;
    color: var(--brand-color);
    letter-spacing: -3px;
    line-height: 1;
    margin-bottom: 24px;
}

.banner-title span {
    display: inline-block;
    font-size: 1.8rem;
    vertical-align: super;
    margin-left: 2px;
}

.banner-description {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--brand-dark);
    margin-bottom: 36px;
    line-height: 1.6;
    letter-spacing: -0.015em;
}

.dark-theme .banner-description {
    color: #cbd0ff;
}

.banner-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.banner-subtitle {
    font-size: 0.95rem;
    letter-spacing: 1.5px;
    color: var(--brand-color);
    font-weight: 600;
    text-transform: uppercase;
}

.banner-cta {
    background-color: var(--brand-color);
    color: white;
    padding: 12px 28px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: var(--transition-hover);
}

.banner-cta:hover {
    background-color: var(--brand-dark);
    transform: scale(1.05);
}

.banner-close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-pill);
    color: var(--text-muted);
    cursor: pointer;
    z-index: 3;
    transition: var(--transition-hover);
}

.banner-close-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.banner-close-btn svg {
    width: 16px;
    height: 16px;
}

/* No results state */
.no-results {
    padding: 100px 0;
    text-align: center;
}

.no-results-content {
    max-width: 400px;
    margin: 0 auto;
}

.no-results-icon {
    width: 48px;
    height: 48px;
    color: var(--brand-color);
    margin-bottom: 20px;
    animation: pulse 2s infinite ease-in-out;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ----------------------------------------------------
   MASONRY GRID & CARDS (3 Columns for Larger Photos)
   ---------------------------------------------------- */
.masonry-grid {
    column-count: 3; /* Reduced from 4 to 3: enlarges feed photo sizes by 33% */
    column-gap: 28px;
    width: 100%;
}

.grid-item {
    break-inside: avoid;
    margin-bottom: 28px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    
    /* Cascading entry animation logic hooks */
    opacity: 0; 
    animation: fadeIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: transform 0.28s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.28s ease, border-color 0.28s ease;
}

.grid-item:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color-hover);
}

/* Pinterest Aspect Ratios (Mismatch formats) */
.ratio-square { aspect-ratio: 1 / 1; }
.ratio-portrait { aspect-ratio: 3 / 4; } /* Taller ratios */
.ratio-tall { aspect-ratio: 2 / 3; }
.ratio-super-tall { aspect-ratio: 9 / 16; }
.ratio-wide { aspect-ratio: 3 / 2; }

.card-media {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.card-media img {
    width: 100%;
    height: 100%; /* Force image to fill whatever aspect ratio is set on parent */
    display: block;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.grid-item:hover .card-media img {
    transform: scale(1.04);
}

/* Card hover actions overlay (Pinterest layout) */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.45) 100%);
    opacity: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    transition: opacity 0.24s cubic-bezier(0.25, 1, 0.5, 1);
}

.grid-item:hover .card-overlay {
    opacity: 1;
}

.card-overlay-top {
    display: flex;
    justify-content: flex-end;
}

.card-overlay-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* Pinterest Pill Button "Сохранить" - flicker-free hover scale transition */
.save-btn-pill {
    background-color: var(--brand-color);
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(157, 161, 248, 0.3);
    transition: var(--transition-hover);
}

.save-btn-pill:hover {
    background-color: var(--brand-dark);
    transform: scale(1.04);
}
.save-btn-pill:active {
    transform: scale(0.96);
}

.save-btn-pill.liked {
    background-color: #34374c;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.dark-theme .save-btn-pill.liked {
    background-color: #f2f2f7;
    color: #0a0a0e;
}

/* Pinterest capsule link to Telegram - flicker-free scale transition */
.tg-handle-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #121217;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    transition: var(--transition-hover);
    max-width: 140px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tg-handle-pill:hover {
    background-color: #ffffff;
    transform: scale(1.04);
}
.tg-handle-pill:active {
    transform: scale(0.96);
}

.dark-theme .tg-handle-pill {
    background-color: rgba(20, 20, 29, 0.9);
    color: #f2f2f7;
}

.pill-tg-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.tg-handle-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Circular share button - flicker-free scale transition */
.card-action-btn-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #121217;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: none;
    flex-shrink: 0;
}

.card-action-btn-circle:hover {
    background-color: #ffffff;
    transform: scale(1.08);
}
.card-action-btn-circle:active {
    transform: scale(0.92);
}

.dark-theme .card-action-btn-circle {
    background-color: rgba(20, 20, 29, 0.9);
    color: #f2f2f7;
}

.card-action-btn-circle svg {
    width: 14px;
    height: 14px;
}

/* Skeleton loader cards (adapted for text-only layouts) */
.grid-item.skeleton {
    cursor: default;
    pointer-events: none;
}

.skeleton-image {
    width: 100%;
    padding-top: 120%;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.skeleton-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
    transform: translateX(-100%);
}

.dark-theme .skeleton-image::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
}

/* Infinite Scroll Sentinel */
.sentinel {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 40px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3.5px solid var(--border-color);
    border-top: 3.5px solid var(--brand-color);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

/* ----------------------------------------------------
   MODALS (FLEX-BASED CONTAINER - ZERO OVERLAPS)
   ---------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: overlayFadeIn 0.25s ease-out forwards;
}

.modal-container {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 960px;
    height: 640px; /* Fixed height for uniform post sizing on desktop */
    max-height: calc(100vh - 48px);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    
    /* Smooth scale-up and slide-up container transition */
    animation: modalScaleUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-body {
    display: flex;
    flex-direction: row;
    height: 100%;
    overflow: hidden; /* Lock scrollbar track */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.modal-body::-webkit-scrollbar {
    display: none; /* Hide scrollbars natively */
}

/* Left Pane: Media (Maintains vertical aspect format filling height) */
.modal-media-pane {
    flex: 1.25;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 100%;
}

.modal-media-pane img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Right Pane: Details Content */
.modal-content-pane {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100%;
    border-left: 1px solid var(--border-color);
    -ms-overflow-style: none; /* Hide scrollbars but allow trackpad scroll */
    scrollbar-width: none;
}
.modal-content-pane::-webkit-scrollbar {
    display: none;
}

/* Inline Spoiler expand button styling */
.desc-toggle-link {
    background: none;
    border: none;
    color: var(--brand-color);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 4px;
    padding: 0;
    display: inline-block;
    transition: var(--transition-fast);
}
.desc-toggle-link:hover {
    color: var(--brand-dark);
    text-decoration: underline;
}
.dark-theme .desc-toggle-link:hover {
    color: #ffffff;
}

/* Flex header - keeps close button inline with Telegram open */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 4px;
}

.channel-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.channel-avatar-large {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-pill);
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.channel-meta-large {
    min-width: 0;
}

.channel-meta-large h2 {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-link {
    font-size: 0.92rem;
    color: var(--brand-color);
    font-weight: 600;
}

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

/* Flex Actions Bar (Inline Close Button) - flicker-free transitions */
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.modal-tg-action {
    padding: 10px 18px;
    font-size: 0.88rem;
}

.close-modal-btn-inline {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-pill);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-hover);
}

.close-modal-btn-inline:hover {
    background-color: var(--border-color-hover);
    transform: scale(1.08) rotate(90deg);
}
.close-modal-btn-inline:active {
    transform: scale(0.92);
}

.close-modal-btn-inline svg {
    width: 16px;
    height: 16px;
}

/* Details descriptions */
.modal-description-section {
    margin-bottom: 30px;
}

.modal-post-text {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 18px;
    white-space: pre-wrap;
    font-weight: 400;
}

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

.tag {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}
.tag:hover {
    background-color: var(--border-color-hover);
    color: var(--text-primary);
}

/* Stats badges */
.modal-stats-section {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.stat-badge {
    font-size: 0.85rem;
    font-weight: 500;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--border-radius-pill);
}

.stat-badge strong {
    color: var(--text-primary);
}

.category-badge {
    background-color: var(--brand-light);
    color: var(--brand-dark);
    font-weight: 600;
}

.dark-theme .category-badge {
    background-color: var(--brand-light);
    color: var(--brand-color);
}

/* Actions footer */
.modal-footer-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 36px;
}

.modal-footer-actions .btn {
    flex: 1;
}

.like-action-btn.btn-primary {
    background-color: var(--like-color) !important;
    border-color: var(--like-color) !important;
    box-shadow: 0 4px 12px rgba(255, 74, 115, 0.3) !important;
}

/* Recommended Section */
.modal-recommendations h3 {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.recommendations-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.recommendation-card {
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    cursor: pointer;
    background-color: var(--bg-secondary);
    height: 84px;
    transition: var(--transition-hover);
}

.recommendation-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
    filter: brightness(0.95);
}

.recommendation-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ----------------------------------------------------
   NOTIFICATION TOAST
   ---------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 14px 28px;
    border-radius: var(--border-radius-pill);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
    opacity: 1;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(40px);
    pointer-events: none;
}

/* ----------------------------------------------------
   ANIMATIONS & KEYFRAMES (Cinematic Transitions)
   ---------------------------------------------------- */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: scale(0.95) translateY(24px); 
        filter: blur(2px); /* Staggered grid cards fade-in sequence */
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
        filter: blur(0);
    }
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalScaleUp {
    from { 
        opacity: 0; 
        transform: scale(0.96) translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

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

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

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.1); opacity: 1; }
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(0.85);
        opacity: 0.55;
        filter: drop-shadow(0 0 2px rgba(102, 106, 224, 0.3));
    }
    50% {
        transform: scale(1.22);
        opacity: 1;
        filter: drop-shadow(0 0 12px rgba(102, 106, 224, 0.9));
    }
}

@keyframes logoPulseDark {
    0%, 100% {
        transform: scale(0.85);
        opacity: 0.55;
        filter: drop-shadow(0 0 2px rgba(169, 173, 255, 0.3));
    }
    50% {
        transform: scale(1.22);
        opacity: 1;
        filter: drop-shadow(0 0 16px rgba(169, 173, 255, 0.95));
    }
}

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

@keyframes waveFloat {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { transform: translate(18px, 18px) scale(1.1) rotate(15deg); }
}

/* ----------------------------------------------------
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ---------------------------------------------------- */
@media (max-width: 1200px) {
    .masonry-grid {
        column-count: 3;
    }
}

@media (max-width: 900px) {
    .masonry-grid {
        column-count: 2;
        column-gap: 16px;
    }
    
    .grid-item {
        margin-bottom: 16px;
        margin-bottom: 20px;
    }
    
    .modal-container {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
    }
    
    .modal-body {
        flex-direction: column;
    }
    
    .modal-media-pane {
        flex: none;
        max-height: 40vh;
        height: 40vh;
    }
    
    .modal-content-pane {
        flex: 1;
        padding: 24px;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: none;
    }
}

@media (max-width: 600px) {
    .header-container {
        padding: 0 16px;
        gap: 12px;
    }
    
    .logo-text {
        font-size: 1.7rem;
    }
    
    .search-bar input {
        padding-left: 44px;
        font-size: 0.85rem;
        height: 42px;
    }
    
    .search-icon {
        left: 16px;
        width: 16px;
        height: 16px;
    }
    
    .categories-nav {
        padding: 14px 16px;
    }
    
    .category-tab {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .main-content {
        padding: 0 16px 40px 16px;
    }
    
    .welcome-banner {
        padding: 40px 24px;
        margin-bottom: 24px;
    }
    
    .banner-title {
        font-size: 2.8rem;
    }
    
    .banner-description {
        font-size: 1.05rem;
        margin-bottom: 28px;
    }
    
    .masonry-grid {
        column-count: 1;
        column-gap: 0;
    }
    
    .header-actions .btn span {
        display: none;
    }
    
    .header-actions .btn {
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: var(--border-radius-pill);
    }
    
    .header-actions .btn-icon {
        margin: 0;
        width: 20px;
        height: 20px;
    }
    
    .modal-header {
        flex-direction: row;
        align-items: center;
    }
    
    .modal-header-actions {
        gap: 8px;
    }
    
    .modal-tg-action {
        padding: 8px 12px;
        font-size: 0.82rem;
    }
    
    .modal-tg-action span {
        display: none;
    }
    
    .modal-tg-action .btn-icon {
        margin: 0;
    }
    
    .recommendations-row {
        grid-template-columns: repeat(3, 1fr);
    }
}
