/* Instagram-style stories strip & viewer */
.home-stories-section {
    --story-ring-size: 58px;
    --story-gap: 8px;
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 8px 12px 4px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.home-stories-scroll {
    display: flex;
    gap: var(--story-gap);
    align-items: flex-start;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    padding: 2px 0 4px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.home-stories-scroll::-webkit-scrollbar {
    display: none;
}

.home-story-item {
    flex: 0 0 auto;
    width: 76px;
    min-width: 76px;
    max-width: 76px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.home-story-ring {
    width: var(--story-ring-size);
    height: var(--story-ring-size);
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    margin: 0 auto 4px;
    transition: transform 0.15s ease;
}

.home-story-item:hover .home-story-ring {
    transform: scale(1.04);
}

.home-story-ring-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #fff;
    overflow: hidden;
    background: #f5f5f5;
}

.home-story-ring-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.home-stories-section .home-story-name {
    font-size: 11px !important;
    line-height: 1.2 !important;
    color: #262626;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
    max-width: 100%;
}

/* Fullscreen viewer */
.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.story-viewer.is-open {
    display: flex;
    touch-action: none;
    overscroll-behavior: none;
}

html.story-viewer-open,
body.story-viewer-open {
    overflow: hidden !important;
    height: 100%;
    overscroll-behavior: none;
}

body.story-viewer-open {
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

.story-viewer__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 8px;
    gap: 10px;
}

.story-viewer__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 100vh;
    margin: 0 auto;
    background: #000;
    overflow: hidden;
}

@media (min-width: 768px) {
    .story-viewer__inner {
        height: min(90vh, 780px);
        max-height: min(90vh, 780px);
        border-radius: 12px;
    }
}

@media (max-width: 767px) {
    .story-viewer {
        padding: 0;
    }

    .story-viewer__stage {
        max-width: 100%;
        padding: 0;
        gap: 0;
    }

    .story-viewer__inner {
        max-width: 100%;
        border-radius: 0;
    }

    .story-viewer__header {
        padding-top: max(12px, env(safe-area-inset-top));
    }
}

.story-viewer__header {
    position: relative;
    flex: 0 0 auto;
    z-index: 5;
    padding: 12px 12px 10px;
    background: #000;
}

.story-viewer__progress {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.story-viewer__progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255,255,255,0.35);
    border-radius: 2px;
    overflow: hidden;
}

.story-viewer__progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 2px;
    transition: width linear;
}

.story-viewer__progress-fill.is-done {
    width: 100%;
    transition: none;
}

.story-viewer__user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    min-height: 40px;
}

.story-viewer__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.35);
    flex-shrink: 0;
}

.story-viewer__username {
    font-size: 14px !important;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    line-height: 1.2 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-viewer__sound {
    background: transparent;
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.story-viewer__sound:hover {
    opacity: 0.85;
}

.story-viewer__close {
    background: transparent;
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: opacity 0.15s ease;
}

.story-viewer__close:hover {
    opacity: 0.85;
}

.story-viewer__close svg,
.story-viewer__sound svg,
.story-viewer__nav svg {
    display: block;
    width: 22px;
    height: 22px;
    fill: currentColor;
    color: #fff;
}

.story-viewer__content {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    touch-action: none;
    overscroll-behavior: none;
}

.story-viewer__media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-viewer__media img,
.story-viewer__media video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.story-viewer__tap-left,
.story-viewer__tap-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    z-index: 4;
    cursor: pointer;
}

.story-viewer__tap-left { left: 0; }
.story-viewer__tap-right { right: 0; }

.story-viewer__nav {
    flex: 0 0 auto;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.55);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.story-viewer__nav:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

@media (min-width: 768px) {
    .story-viewer__nav {
        display: inline-flex;
    }
}

@media (max-width: 767px) {
    .story-viewer__nav {
        display: none !important;
    }
}
