/* Instagram Viewer - Story & Post Viewer Styles */

/* ============== Header Nav ============== */
.header-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-right: 12px;
}

.nav-link {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--item-bg);
}

.nav-link.active {
    color: var(--text-primary);
    background: var(--item-bg);
    font-weight: 500;
}

.nav-link.primary {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background .15s, color .15s;
    font-family: inherit;
}

.nav-dropdown-toggle:hover {
    color: var(--text-primary);
    background: var(--item-bg);
}

.nav-dropdown-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform .15s;
}

.nav-dropdown.open .nav-dropdown-toggle svg {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity .15s, transform .15s, visibility .15s;
    z-index: 1000;
}

.nav-dropdown.open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background .1s;
}

.nav-dropdown-item:hover {
    background: var(--item-bg);
}

.nav-dropdown-item svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    color: var(--text-secondary);
}

/* ============== Compact Profile Card ============== */
/* ============== Private Message ============== */
.private-message {
    text-align: center;
    padding: 32px 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

[data-theme="dark"] .private-message {
    border-color: transparent;
}

.private-message h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.private-message p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* ============== Content Container ============== */
.content-container {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 40px;
}

[data-theme="dark"] .content-container {
    border-color: transparent;
}

/* ============== Content Tabs ============== */
.content-tabs {
    display: flex;
    gap: 2px;
    padding: 4px;
    background: var(--item-bg);
    border-radius: 8px;
    margin: 8px 12px;
}

.content-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color .1s, background .1s;
}

.content-tab svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.content-tab:hover {
    color: var(--text-primary);
}

.content-tab.active {
    color: var(--text-primary);
    background: var(--card-bg);
}

[data-theme="dark"] .content-tab.active {
    background: var(--card-bg);
}

/* ============== Content Panels ============== */
.content-panel {
    display: none;
    padding: 16px;
    min-height: 300px;
}

.content-panel.active {
    display: block;
}

/* ============== View Toggle ============== */
.view-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin-bottom: 12px;
}

.view-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--item-bg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: background .12s, color .12s;
}

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

.view-btn:hover {
    background: var(--item-hover);
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--text-primary);
    color: var(--bg);
}

/* ============== Empty State ============== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: .6;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============== Story Viewer ============== */
.stories-story-view {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0;
}

.story-nav-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--item-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    transition: background .12s, transform .1s;
    flex-shrink: 0;
}

.story-nav-btn svg {
    width: 20px;
    height: 20px;
}

.story-nav-btn:hover {
    background: var(--item-hover);
}

.story-nav-btn:active {
    transform: scale(.95);
}

.story-viewer {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--overlay-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 9/16;
}

/* Story Progress Bars */
.story-progress {
    display: flex;
    gap: 4px;
    padding: 12px 12px 8px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,.4), transparent);
    pointer-events: auto;
}

.progress-bar {
    flex: 1;
    min-width: 2px; /* Ensure bars don't become invisible */
    height: 3px;
    background: rgba(255,255,255,.35);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    transition: transform 0.15s ease;
}

/* Expand clickable area without changing visual appearance */
.progress-bar::before {
    content: '';
    position: absolute;
    top: -8px;
    bottom: -8px;
    left: 0;
    right: 0;
}

.progress-bar:hover {
    transform: scaleY(1.4);
}

.progress-bar.done {
    background: var(--text-on-dark);
}

.progress-bar.active {
    background: rgba(255,255,255,.35);
}

.progress-bar.active::after {
    content: '';
    display: block;
    height: 100%;
    width: 100%;
    background: var(--text-on-dark);
    animation: progress 5s linear forwards;
}

@keyframes progress {
    from { width: 0; }
    to { width: 100%; }
}

/* Story Header */
.story-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    position: absolute;
    top: 24px;
    left: 0;
    right: 0;
    z-index: 10;
}

.story-header img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--text-on-dark);
    object-fit: cover;
}

.story-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.story-info span:first-child {
    color: var(--text-on-dark);
    font-size: 14px;
    font-weight: 600;
}

.story-info span:last-child {
    color: rgba(255,255,255,.7);
    font-size: 12px;
}

.story-download-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .5);
    border: 1.5px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-on-dark);
    backdrop-filter: blur(8px);
    transition: all .2s ease;
}

.story-download-btn.downloading {
    background: rgba(76, 175, 80, .9);
    border-color: rgba(76, 175, 80, 1);
    transform: scale(1.1);
}

.story-download-btn.downloading svg {
    animation: checkPop .3s ease;
}

@keyframes checkPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.story-download-btn svg {
    width: 18px;
    height: 18px;
}

.story-download-btn:hover {
    background: rgba(0, 0, 0, .7);
    border-color: rgba(255, 255, 255, .5);
}

.story-download-btn:disabled {
    cursor: default;
}

/* Story Media */
.story-media {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-media img,
.story-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Story Loading Indicator */
.story-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.spinner-ring {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: rgba(255,255,255,.6);
    border-radius: 50%;
    animation: spin .8s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

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

/* ============== Media Grid ============== */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.media-item {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: linear-gradient(110deg, #d0d0d0 30%, #ffffff 50%, #d0d0d0 70%);
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
    cursor: pointer;
    border-radius: 4px;
}
[data-theme="dark"] .media-item {
    background: linear-gradient(110deg, #0f0f0f 30%, #4a4a4a 50%, #0f0f0f 70%);
    background-size: 200% 100%;
}
.media-item.loaded {
    animation: none;
    background: var(--item-bg);
}

/* Stories-specific styling - portrait phone-like format */
#stories-grid-view {
    gap: 20px;
    grid-template-columns: repeat(4, 1fr);
    max-width: 1200px;
    margin: 0 auto;
}

#stories-grid-view .media-item {
    aspect-ratio: 9 / 16;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    transition: all .25s cubic-bezier(.4,0,.2,1);
    /* Don't override shimmer background - let it animate until loaded */
}

#stories-grid-view .media-item.loaded {
    background: linear-gradient(135deg, var(--item-bg) 0%, var(--panel-bg) 100%);
}

#stories-grid-view .media-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

#stories-grid-view .media-item img {
    border-radius: 12px;
}

#stories-grid-view .media-type-badge {
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(8px);
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

#stories-grid-view .media-overlay {
    background: linear-gradient(to top, rgba(0,0,0,.6) 0%, transparent 50%);
    opacity: 1;
    align-items: flex-end;
    padding: 12px;
}

#stories-grid-view .media-item:hover .media-overlay {
    background: linear-gradient(to top, rgba(0,0,0,.65) 0%, rgba(0,0,0,.1) 50%);
}

#stories-grid-view .media-overlay span {
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s, opacity .2s ease-out;
    opacity: 0;
}
.media-item.loaded img {
    opacity: 1;
}

.media-item:hover img {
    transform: scale(1.02);
}

.media-type-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    color: var(--text-on-dark);
    padding: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.media-type-badge svg {
    display: block;
}

.media-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0));
    padding: 24px 8px 8px 8px;
    color: var(--text-on-dark);
    font-size: 11px;
    display: flex;
    gap: 12px;
    pointer-events: none;
}

.media-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.media-stats svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.media-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
}

.media-item:hover .media-overlay {
    opacity: 1;
}

.media-overlay span {
    color: var(--text-on-dark);
    font-size: 13px;
    font-weight: 500;
}

/* ============== Highlights ============== */
.highlights-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.highlights-tray {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 20px;
    justify-items: center;
}

.highlight-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.highlight-cover {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border);
    padding: 2px;
    background: linear-gradient(110deg, #d0d0d0 30%, #f0f0f0 50%, #d0d0d0 70%);
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
    transition: border-color .15s;
}

[data-theme="dark"] .highlight-cover {
    background: linear-gradient(110deg, #0f0f0f 30%, #4a4a4a 50%, #0f0f0f 70%);
    background-size: 200% 100%;
}

.highlight-item.loaded .highlight-cover {
    background: var(--card-bg);
    animation: none;
}

.highlight-item:hover .highlight-cover {
    border-color: var(--accent-color);
}

.highlight-cover img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .2s ease-in-out;
}

.highlight-item.loaded .highlight-cover img {
    opacity: 1;
}

.highlight-title {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* ============== Media Modal ============== */
.media-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-modal.hidden {
    display: none;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.1);
    border: none;
    border-radius: 50%;
    font-size: 28px;
    color: var(--text-on-dark);
    cursor: pointer;
    transition: background .12s;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(255,255,255,.2);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.15);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-on-dark);
    transition: background .12s;
    z-index: 10;
}

.modal-nav.prev { left: 16px; }
.modal-nav.next { right: 16px; }

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

.modal-nav:hover {
    background: rgba(255,255,255,.25);
}

.modal-content {
    display: flex;
    max-width: 95vw;
    max-height: 95vh;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.modal-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    min-width: 400px;
    position: relative;
}

.modal-media img,
.modal-media video {
    height: 85vh;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Carousel navigation */
.carousel-nav {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #262626;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.carousel-btn.carousel-prev {
    left: 16px;
}

.carousel-btn.carousel-next {
    right: 16px;
}

.carousel-btn:hover:not(:disabled) {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.carousel-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    align-items: center;
    pointer-events: auto;
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.carousel-dot.active {
    background: white;
    width: 7px;
    height: 7px;
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.9);
}

.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.modal-loading .spinner-ring {
    border-color: rgba(255,255,255,.15);
    border-top-color: rgba(255,255,255,.6);
}

.modal-info {
    width: 300px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}

.modal-info p {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    overflow-y: auto;
    margin-bottom: 16px;
}

.modal-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.modal-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--text-primary);
    color: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
}

.modal-download-btn.downloading {
    background: #4caf50;
    transform: scale(1.05);
}

.modal-download-btn.downloading svg {
    animation: checkPop .3s ease;
}

.modal-download-btn svg {
    width: 18px;
    height: 18px;
}

.modal-download-btn:hover {
    opacity: .85;
}

.modal-download-btn:disabled {
    cursor: default;
    opacity: 1;
}

/* ============== Highlight Modal ============== */
.highlight-viewer {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--overlay-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 9/16;
}

.highlight-viewer .story-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.15);
    color: var(--text-on-dark);
}

.highlight-viewer .story-nav-btn.prev { left: 8px; }
.highlight-viewer .story-nav-btn.next { right: 8px; }
.highlight-viewer .story-nav-btn:hover { background: rgba(255,255,255,.3); }

.highlight-title-row {
    flex: 1;
    color: var(--text-on-dark);
    font-size: 14px;
    font-weight: 600;
}

/* ============== Responsive ============== */
@media (max-width: 768px) {
    .header-nav {
        position: static;
        transform: none;
    }
    
    .nav-link {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .content-tabs {
        padding: 0;
    }
    
    /* Stories grid tablet adjustments */
    #stories-grid-view {
        gap: 14px;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .content-tab {
        padding: 12px 8px;
        font-size: 12px;
    }
    
    .content-tab svg {
        display: none;
    }
    
    /* Post/Reel grid tablet - 2 columns */
    .media-grid:not(#stories-grid-view) {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    /* Highlight bubbles tablet size */
    .highlights-tray {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 18px;
    }
    
    .highlight-cover {
        width: 76px;
        height: 76px;
    }
    
    .highlight-title {
        max-width: 76px;
    }
    
    .stories-story-view {
        flex-direction: column;
        gap: 8px;
    }
    
    /* Hide story nav buttons in grid view only, not in modal */
    .stories-story-view .story-nav-btn {
        display: none;
    }
    
    .story-viewer {
        max-width: 100%;
        border-radius: 0;
    }
    
    .modal-content {
        flex-direction: column;
        max-width: 100%;
        max-height: 100vh;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .modal-media {
        min-width: auto;
        flex: 1;
        width: 100%;
    }
    
    .modal-media img,
    .modal-media video {
        height: auto;
        max-height: 85vh;
        width: 100%;
        max-width: 100%;
    }
    
    .modal-info {
        width: 100%;
        max-height: 30vh;
        padding: 16px;
        border-top: 1px solid var(--border);
        overflow-y: auto;
    }
    
    .modal-info p {
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    .modal-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 22px;
        background: rgba(0,0,0,.6);
        backdrop-filter: blur(10px);
    }
    
    .modal-nav {
        width: 40px;
        height: 40px;
        background: rgba(0,0,0,.5);
        backdrop-filter: blur(8px);
    }
    
    .modal-nav svg {
        width: 20px;
        height: 20px;
    }
    
    .modal-nav.prev { left: 8px; }
    .modal-nav.next { right: 8px; }
    
    /* Carousel controls mobile */
    .carousel-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
        background: rgba(0,0,0,.6);
        backdrop-filter: blur(8px);
    }
    
    .carousel-btn.carousel-prev {
        left: 8px;
    }
    
    .carousel-btn.carousel-next {
        right: 8px;
    }
    
    .carousel-dots {
        bottom: 12px;
    }
    
    .carousel-dot {
        width: 5px;
        height: 5px;
    }
    
    .carousel-dot.active {
        width: 6px;
        height: 6px;
    }
    
    /* Story modal mobile */
    .story-modal-content {
        max-width: 100%;
        padding: 0 12px;
    }
    
    /* Close button - position to .story-modal (fixed), not .story-modal-content */
    .story-modal > .story-modal-content > .modal-close {
        position: fixed;
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,.25);
        backdrop-filter: blur(10px);
        z-index: 1100;
    }
    
    .story-modal .modal-close svg {
        width: 18px;
        height: 18px;
    }
    
    /* Story/Highlight nav buttons overlaid on mobile */
    .story-modal-content .story-nav-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 32px;
        height: 32px;
        background: rgba(0,0,0,.4);
        backdrop-filter: blur(8px);
        color: white;
        z-index: 50;
        display: flex;
    }
    
    .story-modal-content .story-nav-btn.prev {
        left: 20px;
    }
    
    .story-modal-content .story-nav-btn.next {
        right: 20px;
    }
    
    .story-modal-content .story-nav-btn svg {
        width: 14px;
        height: 14px;
    }
    
    /* Highlight viewer nav buttons on mobile - overlaid */
    .highlight-viewer .story-nav-btn {
        width: 36px;
        height: 36px;
        background: rgba(0,0,0,.4);
        backdrop-filter: blur(8px);
        z-index: 50;
    }
    
    .highlight-viewer .story-nav-btn.prev { left: 8px; }
    .highlight-viewer .story-nav-btn.next { right: 8px; }
    
    /* Highlight modal mobile */
    .highlight-viewer {
        max-width: 100%;
        border-radius: 0;
        height: 100vh;
    }
}

@media (max-width: 480px) {
    .media-grid {
        gap: 2px;
    }
    
    .media-item {
        border-radius: 2px;
    }
    
    /* Stories grid mobile adjustments */
    #stories-grid-view {
        gap: 12px;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    #stories-grid-view .media-item {
        border-radius: 10px;
        box-shadow: 0 1px 4px rgba(0,0,0,.1);
    }
    
    #stories-grid-view .media-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,.15);
    }
    
    /* ============== MOBILE MINIMAL POST/REEL STATS ============== */
    /* Hide detailed stats on mobile for posts & reels - keep it cleaner */
    .media-stats {
        padding: 16px 6px 6px 6px;
        gap: 8px;
        font-size: 10px;
    }
    
    .media-stats svg {
        width: 12px;
        height: 12px;
    }
    
    /* Hide date/time info on mobile for cleaner look (last span with margin-left:auto) */
    .media-stats span:last-child {
        display: none;
    }
    
    /* Always show likes (first child) */
    .media-stats span:first-child {
        display: flex;
    }
    
    /* Simplify type badge */
    .media-type-badge {
        top: 6px;
        right: 6px;
    }
    
    .media-type-badge svg {
        width: 16px;
        height: 16px;
    }
    
    /* ============== LARGER HIGHLIGHT BUBBLES ON MOBILE ============== */
    .highlights-tray {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 16px;
    }
    
    .highlight-cover {
        width: 72px;
        height: 72px;
        border: 2.5px solid var(--border);
        padding: 2.5px;
    }
    
    .highlight-title {
        font-size: 11px;
        max-width: 72px;
    }
    
    /* Larger modal controls on small phones */
    .modal-close {
        width: 38px;
        height: 38px;
    }
    
    .modal-nav {
        width: 42px;
        height: 42px;
    }
}

/* ============== Story Modal ============== */
.story-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    animation: fadeIn .2s ease;
}

.story-modal.hidden {
    display: none;
}

.story-modal-overlay {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.story-modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1;
}

.story-modal .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.15);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-on-dark);
    transition: background .12s;
    z-index: 2;
}

.story-modal .modal-close:hover {
    background: rgba(255,255,255,.3);
}

/* ============== Animations ============== */
@keyframes shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.story-modal .modal-close svg {
    width: 20px;
    height: 20px;
}

.story-modal-content .story-viewer {
    max-width: 100%;
}
