/* ============================================================
   SNP STORIES — Barre horizontale + Lecteur + Modales
   ============================================================ */

/* ============================================================
   1. BARRE HORIZONTALE (dans le feed)
   ============================================================ */
.snp-stories-bar {
    background: var(--snp-card-bg, #ffffff);
    border-radius: var(--snp-radius, 12px);
    padding: 12px 10px;
    margin: 12px 0;
    border: 1px solid var(--snp-border, #e9ecef);
    box-shadow: var(--snp-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
    overflow: hidden;
}

.snp-stories-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px;
    scroll-behavior: smooth;
}

.snp-stories-track::-webkit-scrollbar {
    display: none;
}

/* ============================================================
   2. ITEM INDIVIDUEL (cercle + nom)
   ============================================================ */
.snp-stories-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    max-width: 74px;
    transition: transform 0.15s ease;
}

.snp-stories-item:hover {
    transform: scale(1.05);
}

.snp-stories-item:active {
    transform: scale(0.98);
}

/* Anneau extérieur (avatar) */
.snp-stories-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    padding: 3px;
    background: #d1d5db;
    transition: all 0.2s ease;
    position: relative;
}

/* Anneau actif (gradient violet) */
.snp-stories-ring.snp-stories-ring-unseen {
    background: var(--snp-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

/* Anneau "mes stories" (gradient différent, plus discret) */
.snp-stories-ring.snp-stories-ring-self {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.35);
}

/* Anneau "bouton +" */
.snp-stories-ring.snp-stories-ring-add {
    background: var(--snp-border, #e9ecef);
    border: 2px dashed var(--snp-primary-light, #8a9bf0);
}

/* Avatar (cercle intérieur) */
.snp-stories-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: var(--snp-bg, #f8f9fa);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 3px solid var(--snp-card-bg, #ffffff);
}

.snp-stories-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.snp-stories-add-icon {
    font-size: 1.6rem;
    font-weight: 300;
    color: var(--snp-primary, #667eea);
    line-height: 1;
    background: var(--snp-card-bg, #ffffff);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Nom sous le cercle */
.snp-stories-name {
    font-size: var(--snp-font-xs, 11px);
    font-weight: 600;
    color: var(--snp-text, #1c1e21);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   3.1 STORIES — Titre de la barre
   ============================================================ */
.snp-stories-header {
    padding: 0 4px 10px 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--snp-border, #e9ecef);
}

.snp-stories-header h3 {
    margin: 0;
    font-size: var(--snp-font-base, 14px);
    font-weight: 700;
    color: var(--snp-text-strong, #050505);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.3;
}

.snp-stories-header h3 .snp-icon {
    color: var(--snp-primary, #667eea);
    flex-shrink: 0;
}

@media (max-width: 599px) {
    .snp-stories-header {
        padding-bottom: 8px;
        margin-bottom: 6px;
    }
    
    .snp-stories-header h3 {
        font-size: 13px;
        gap: 6px;
    }
}

/* ============================================================
   3.2. LECTEUR PLEIN ÉCRAN
   ============================================================ */
#snp-stories-viewer {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #000000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: snp-stories-fade-in 0.2s ease;
}

#snp-stories-viewer.active {
    display: flex;
}

@keyframes snp-stories-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Empêcher le scroll du body */
body.snp-stories-open {
    overflow: hidden !important;
}

.snp-stories-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000000;
}

/* --- HEADER --- */
.snp-stories-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    pointer-events: none;
}

.snp-stories-viewer-header > * {
    pointer-events: auto;
}

.snp-stories-viewer-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: #ffffff;
}

.snp-stories-viewer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.9);
}

.snp-stories-viewer-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
}

.snp-stories-viewer-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.snp-stories-self-badge {
    display: inline-block;
    padding: 1px 7px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
}

.snp-stories-viewer-time {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Boutons header */
.snp-stories-viewer-delete,
.snp-stories-viewer-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.snp-stories-viewer-delete:hover,
.snp-stories-viewer-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

.snp-stories-viewer-delete:hover {
    background: rgba(220, 53, 69, 0.9);
}

/* --- BARRE DE PROGRESSION --- */
.snp-stories-progress {
    position: absolute;
    top: 6px;
    left: 12px;
    right: 12px;
    z-index: 20;
    display: flex;
    gap: 4px;
    height: 3px;
}

.snp-stories-progress-bar {
    flex: 1;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.snp-stories-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffffff;
    border-radius: 2px;
    transition: width 0.05s linear;
}

.snp-stories-progress-done .snp-stories-progress-fill {
    width: 100% !important;
}

.snp-stories-progress-active .snp-stories-progress-fill {
    /* Sera animée via JS */
}

/* --- MÉDIA --- */
.snp-stories-media {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000000;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.snp-stories-media img,
.snp-stories-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    max-height: 100vh;
}

/* --- CAPTION --- */
.snp-stories-caption {
    position: absolute;
    bottom: 60px;
    left: 16px;
    right: 16px;
    z-index: 15;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
    word-wrap: break-word;
}

/* --- NAVIGATION --- */
.snp-stories-nav-prev,
.snp-stories-nav-next {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 5;
    -webkit-tap-highlight-color: transparent;
}

.snp-stories-nav-prev {
    left: 0;
}

.snp-stories-nav-next {
    right: 0;
}

/* Indicateur visuel au survol (desktop) */
@media (hover: hover) {
    .snp-stories-nav-prev:hover,
    .snp-stories-nav-next:hover {
        background: linear-gradient(
            to right,
            rgba(255,255,255,0.06) 0%,
            rgba(255,255,255,0) 100%
        );
    }

    .snp-stories-nav-next:hover {
        background: linear-gradient(
            to left,
            rgba(255,255,255,0.06) 0%,
            rgba(255,255,255,0) 100%
        );
    }
}

/* ============================================================
   4. MODALES (Ajouter + Gérer)
   ============================================================ */
#snp-stories-add-modal,
#snp-stories-manage-modal {
    position: fixed;
    inset: 0;
    z-index: 999998;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: snp-stories-fade-in 0.2s ease;
}

#snp-stories-add-modal.active,
#snp-stories-manage-modal.active {
    display: flex;
}

body.snp-stories-modal-open {
    overflow: hidden !important;
}

.snp-stories-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: snp-stories-modal-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

@keyframes snp-stories-modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header modal */
.snp-stories-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--snp-border, #e9ecef);
    flex-shrink: 0;
}

.snp-stories-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--snp-text-strong, #050505);
    display: flex;
    align-items: center;
    gap: 8px;
}

.snp-stories-modal-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--snp-text-secondary, #65676b);
    background: var(--snp-bg, #f8f9fa);
    padding: 3px 10px;
    border-radius: 10px;
}

.snp-stories-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--snp-bg, #f8f9fa);
    color: var(--snp-text-secondary, #65676b);
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.snp-stories-modal-close:hover {
    background: var(--snp-danger, #dc3545);
    color: #ffffff;
    transform: rotate(90deg);
}

.snp-stories-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.snp-stories-manage-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: var(--snp-bg, #f8f9fa);
    border: 1px solid var(--snp-border, #e9ecef);
    border-radius: var(--snp-radius-pill, 999px);
    color: var(--snp-text, #1c1e21);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--snp-transition, 0.25s ease);
    white-space: nowrap;
    line-height: 1;
}

.snp-stories-manage-link:hover {
    background: var(--snp-primary, #667eea);
    color: var(--snp-white, #ffffff);
    border-color: var(--snp-primary, #667eea);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.snp-stories-manage-link:active {
    transform: translateY(0);
}

/* Mobile : icône seule */
@media (max-width: 480px) {
    .snp-stories-manage-link {
        padding: 7px 10px;
        font-size: 0;
    }
    
    .snp-stories-manage-link .snp-icon {
        width: 18px;
        height: 18px;
    }
}

/* Body modal */
.snp-stories-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   5. MODALE AJOUTER — Contenu
   ============================================================ */
.snp-stories-add-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px 20px;
    background: var(--snp-bg, #f8f9fa);
    border: 2px dashed var(--snp-border-dark, #dee2e6);
    border-radius: 12px;
    margin-bottom: 16px;
    text-align: center;
    transition: all 0.2s ease;
}

.snp-stories-add-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--snp-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #ffffff;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

.snp-stories-add-upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.45);
}

.snp-stories-add-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--snp-text-secondary, #65676b);
    line-height: 1.4;
}

.snp-stories-add-hint strong {
    color: var(--snp-text-strong, #050505);
}

/* Preview */
.snp-stories-add-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    max-height: 340px;
    min-height: 200px;
}

.snp-stories-add-preview img,
.snp-stories-add-preview video {
    max-width: 100%;
    max-height: 340px;
    object-fit: contain;
    display: block;
}

/* Prévisualisation vidéo (carte statique empilée) */
.snp-stories-video-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 20px;
    background: #f5f5f7;
    border: 1px dashed #c7c7cc;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

/* Petit label "Vidéo" en haut */
.snp-stories-video-preview-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8e8e93;
}

/* Emoji centré, grand */
.snp-stories-video-preview-icon {
    font-size: 64px;
    line-height: 1;
    margin: 4px 0 8px;
}

/* Nom du fichier */
.snp-stories-video-preview-name {
    font-weight: 600;
    color: #1c1c1e;
    font-size: 15px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
    box-sizing: border-box;
}

/* Taille */
.snp-stories-video-preview-size {
    font-size: 13px;
    color: #6c6c70;
}

/* Caption */
.snp-stories-add-caption-wrapper {
    margin-bottom: 16px;
    position: relative;
}

.snp-stories-add-caption-wrapper label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--snp-text-strong, #050505);
    margin-bottom: 6px;
}

#snp-stories-add-caption {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--snp-border, #e9ecef);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--snp-bg, #f8f9fa);
    color: var(--snp-text, #1c1e21);
    resize: none;
    transition: all 0.2s ease;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.4;
}

#snp-stories-add-caption:focus {
    outline: none;
    border-color: var(--snp-primary, #667eea);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.snp-stories-add-char-counter {
    text-align: right;
    font-size: 0.72rem;
    color: var(--snp-text-light, #8a8d91);
    margin-top: 4px;
}

/* Progress */
.snp-stories-add-progress {
    margin-top: 12px;
    background: var(--snp-bg, #f8f9fa);
    border-radius: 8px;
    padding: 8px;
}

.snp-stories-add-progress .snp-stories-progress-fill {
    height: 6px;
    background: var(--snp-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border-radius: 3px;
    transition: width 0.2s ease;
    width: 0%;
}

/* Footer modal */
.snp-stories-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--snp-border, #e9ecef);
    background: #ffffff;
    flex-shrink: 0;
}

.snp-stories-modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.snp-stories-modal-btn-primary {
    background: var(--snp-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.snp-stories-modal-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.45);
}

.snp-stories-modal-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.snp-stories-modal-btn-secondary {
    background: var(--snp-bg, #f8f9fa);
    color: var(--snp-text, #1c1e21);
    border: 1px solid var(--snp-border, #e9ecef);
}

.snp-stories-modal-btn-secondary:hover {
    background: #ffffff;
    border-color: var(--snp-primary, #667eea);
    color: var(--snp-primary, #667eea);
}

/* ============================================================
   6. MODALE GÉRER — Liste
   ============================================================ */
.snp-stories-manage-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--snp-text-secondary, #65676b);
    font-style: italic;
    font-size: 0.9rem;
}

.snp-stories-manage-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--snp-text-secondary, #65676b);
}

.snp-stories-manage-empty-icon {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

.snp-stories-manage-empty p {
    margin: 0 0 4px;
    font-size: 0.95rem;
    font-weight: 600;
}

.snp-stories-manage-empty small {
    font-size: 0.8rem;
    color: var(--snp-text-light, #8a8d91);
}

.snp-stories-manage-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--snp-bg, #f8f9fa);
    border: 1px solid var(--snp-border, #e9ecef);
    border-radius: 12px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.snp-stories-manage-item:hover {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.snp-stories-manage-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #000000;
}

.snp-stories-manage-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.snp-stories-manage-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-size: 1.1rem;
    pointer-events: none;
}

.snp-stories-manage-info {
    flex: 1;
    min-width: 0;
}

.snp-stories-manage-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    color: var(--snp-text-secondary, #65676b);
}

.snp-stories-manage-remaining {
    color: var(--snp-warning, #f39c12);
    font-weight: 600;
}

.snp-stories-manage-views {
    font-size: 0.78rem;
    color: var(--snp-text-secondary, #65676b);
    font-weight: 600;
    margin-bottom: 3px;
}

.snp-stories-manage-caption {
    font-size: 0.85rem;
    color: var(--snp-text, #1c1e21);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-wrap: break-word;
}

.snp-stories-manage-delete {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    color: var(--snp-danger, #dc3545);
    border: 1px solid var(--snp-danger, #dc3545);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0;
}

.snp-stories-manage-delete:hover {
    background: var(--snp-danger, #dc3545);
    color: #ffffff;
    transform: scale(1.08);
}

/* ============================================================
   7. RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 599px) {
    .snp-stories-bar {
        border-radius: 0;
        margin-left: -1px;
        margin-right: -1px;
        padding: 10px 6px;
    }

    .snp-stories-track {
        gap: 10px;
    }

    .snp-stories-item {
        max-width: 66px;
    }

    .snp-stories-ring {
        width: 58px;
        height: 58px;
        padding: 2px;
    }

    .snp-stories-avatar {
        border-width: 2px;
    }

    .snp-stories-add-icon {
        font-size: 1.4rem;
    }

    .snp-stories-name {
        font-size: 10px;
    }

    /* Lecteur plein écran (déjà plein écran) */
    .snp-stories-viewer-container {
        max-width: 100%;
    }

    /* Modales : bottom sheet */
    #snp-stories-add-modal,
    #snp-stories-manage-modal {
        padding: 0;
        align-items: flex-end;
    }

    .snp-stories-modal-content {
        max-width: 100%;
        max-height: 94vh;
        border-radius: 20px 20px 0 0;
        animation: snp-stories-modal-slide-up-mobile 0.3s ease;
    }

    @keyframes snp-stories-modal-slide-up-mobile {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    .snp-stories-modal-header {
        padding: 14px 16px;
    }

    .snp-stories-modal-header h3 {
        font-size: 1rem;
    }

    .snp-stories-modal-body {
        padding: 16px;
    }

    .snp-stories-modal-footer {
        padding: 12px 16px;
        /* Safe area iOS */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .snp-stories-modal-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ============================================================
   8. RESPONSIVE — TRÈS PETITS ÉCRANS (< 400px)
   ============================================================ */
@media (max-width: 400px) {
    .snp-stories-modal-header h3 {
        font-size: 0.95rem;
    }

    .snp-stories-manage-thumb {
        width: 50px;
        height: 50px;
    }

    .snp-stories-manage-delete {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }
}

/* ============================================================
   9. ACCESSIBILITÉ
   ============================================================ */
.snp-stories-item:focus-visible,
.snp-stories-viewer-close:focus-visible,
.snp-stories-viewer-delete:focus-visible,
.snp-stories-modal-close:focus-visible,
.snp-stories-modal-btn:focus-visible,
.snp-stories-manage-delete:focus-visible {
    outline: 3px solid var(--snp-primary, #667eea);
    outline-offset: 2px;
}

/* Réduction des animations */
@media (prefers-reduced-motion: reduce) {
    .snp-stories-item,
    .snp-stories-viewer-close,
    .snp-stories-manage-delete,
    .snp-stories-modal-content {
        transition: none !important;
        animation: none !important;
    }
}

/* ============================================================
   10. COMPTEUR DE VUES (dans le lecteur, visible sur ses stories par l'auteur)
   ============================================================ */
.snp-stories-views {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
    user-select: none;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ✅ Quand le compteur devient un bouton (dans le lecteur), il doit être cliquable */
.snp-stories-views.snp-viewers-trigger {
    pointer-events: auto;
    cursor: pointer;
    border: none;
    font-family: inherit;
    position: relative;
    z-index: 25; /* Au-dessus des zones de navigation (.snp-stories-nav-prev est à z-index: 5) */
    transition: all 0.2s ease;
}

.snp-stories-views.snp-viewers-trigger:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: scale(1.05);
}

.snp-stories-views.snp-viewers-trigger:active {
    transform: scale(0.98);
}

.snp-stories-views-count {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

/* Mobile : légèrement plus compact */
@media (max-width: 599px) {
    .snp-stories-views {
        bottom: 12px;
        left: 12px;
        padding: 5px 10px;
        font-size: 0.78rem;
    }
}

/* ============================================================
   11. STORIES — Compteur de stories non vues pour les viewers
   ============================================================ */
/* Le ring doit être en position relative pour accueillir le badge en absolu */
.snp-stories-ring {
    position: relative;   /* déjà présent dans stories.css, on s'assure juste */
}

/* Badge circulaire en haut à droite du ring — inspiration feed-header-badge */
.snp-stories-badge-count {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 3;
    
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    
    background: var(--snp-white, #ffffff);
    color: var(--snp-primary, #667eea);
    
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    
    border-radius: var(--snp-radius-pill, 999px);
    border: 2px solid var(--snp-primary, #667eea);
    
    box-shadow:
        0 2px 6px rgba(102, 126, 234, 0.35),
        0 0 0 2px var(--snp-card-bg, #ffffff);
    
    pointer-events: none;
    user-select: none;
    
    animation: snp-stories-badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes snp-stories-badge-pop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Adaptation mobile : légèrement plus compact */
@media (max-width: 599px) {
    .snp-stories-badge-count {
        top: -1px;
        right: -1px;
        min-width: 18px;
        height: 18px;
        font-size: 10px;
        padding: 0 4px;
        border-width: 1.5px;
    }
}

/* ============================================
   MODALE DES SPECTATEURS
   ============================================ */

.snp-stories-modal-overlay-generic {
    position: fixed;
    inset: 0;
    z-index: 1000000; /* ✅ Au-dessus de tout (même au-dessus du lecteur) */
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.snp-stories-viewers-modal-content {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: snp-stories-modal-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.snp-stories-viewers-modal-content .snp-stories-modal-body {
    padding: 12px 16px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.snp-viewers-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-height: 400px;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.snp-viewers-list::-webkit-scrollbar { width: 6px; }
.snp-viewers-list::-webkit-scrollbar-track { background: transparent; }
.snp-viewers-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.snp-story-viewer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    transition: background 0.15s ease;
    margin-bottom: 2px;
}

.snp-story-viewer-item:hover {
    background: #f8f9fa;
}

.snp-story-viewer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.snp-story-viewer-link img {
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.snp-story-viewer-info {
    min-width: 0;
    flex: 1;
}

.snp-story-viewer-info strong {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    color: var(--snp-text-strong, #050505);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.snp-story-viewer-info span {
    display: block;
    font-size: 0.75rem;
    color: var(--snp-text-secondary, #65676b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.snp-story-viewer-self-badge {
    padding: 3px 10px;
    background: var(--snp-info-light, #d1ecf1);
    color: var(--snp-info, #3498db);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ✅ Rend le compteur cliquable dans la modale de gestion */
.snp-stories-manage-views.snp-viewers-trigger {
    cursor: pointer;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: -4px;
}

.snp-stories-manage-views.snp-viewers-trigger:hover {
    color: var(--snp-primary, #667eea);
    background: rgba(102, 126, 234, 0.08);
}

/* ✅ Bouton des vues dans le lecteur (remplace le div) */
.snp-stories-views.snp-viewers-trigger {
    border: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

.snp-stories-views.snp-viewers-trigger:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: scale(1.05);
}

/* Mobile */
@media (max-width: 599px) {
    .snp-stories-viewers-modal-content {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }

    .snp-viewers-list {
        max-height: 60vh;
    }
}

/* ============================================
   BOUTON PLAY/PAUSE DANS LE LECTEUR
   ============================================ */

.snp-stories-pause-btn {
    position: absolute;
    bottom: 12px;
    right: 16px;
    z-index: 25;
    
    width: 40px;
    height: 40px;
    padding: 0;
    flex-shrink: 0;
    
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all var(--snp-transition, 0.25s ease);
    
    -webkit-tap-highlight-color: transparent;
}

.snp-stories-pause-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

.snp-stories-pause-btn:active {
    transform: scale(0.95);
}

.snp-stories-pause-btn:focus-visible {
    outline: 3px solid var(--snp-primary, #667eea);
    outline-offset: 2px;
}

.snp-stories-pause-btn .snp-stories-pause-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    width: 20px;
    height: 20px;
}

.snp-stories-pause-btn .snp-icon {
    pointer-events: none;
}

/* État "en pause" : le bouton devient plus visible pour indiquer qu'il faut cliquer */
.snp-stories-pause-btn.is-paused {
    background: rgba(255, 255, 255, 0.95);
    color: var(--snp-text-strong, #050505);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.3);
}

/* ============================================
   CHARGEMENT INFINI DE LA BARRE (horizontal)
   ============================================ */

.snp-stories-sentinel {
    flex: 0 0 auto;
    width: 1px;
    height: 1px;
    /* ✅ Invisible mais présent dans le flux pour l'observer */
    pointer-events: none;
    opacity: 0;
}

/* Loader horizontal */
.snp-stories-loader {
    text-align: center;
    padding: 8px;
    width: 100%;
    display: none;
}

.snp-stories-loader .snp-loader {
    display: inline-block;
    color: var(--snp-text-secondary, #65676b);
    font-size: 0.85rem;
}