:root {
    --safe-area-top: env(safe-area-inset-top, 10px);
    --safe-area-bottom: env(safe-area-inset-bottom, 10px);
    --main-button-color: #e62b33;
}
body.stories-view-active {
    overflow: hidden !important;
}
.stories-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #000; z-index: 99999;
    display: none;
    overflow: hidden; font-family: 'Cairo', sans-serif;
}
.stories-container.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}
.story-item {
    width: 100%;
    height: 100%;
    display: none;
    position: relative;
    flex-direction: column;
    background-color: #1a1a1a;
    overflow: hidden;
}
.story-item.active {
    display: flex !important;
}

.story-media-bg {
    position: absolute; top: -5%; left: -5%; width: 110%; height: 110%;
    filter: blur(20px) brightness(0.6); z-index: 0;
}

.story-media-container {
    width: 100%; flex: 1 1 auto; position: relative; z-index: 1; display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    background-color: #000;
}

.story-media-container img.story-media,
.story-media-container video.story-media,
.story-media-container img.story-media-bg,
.story-media-container video.story-media-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.story-text-container {
    width: 100%; flex: 0 0 auto; padding: 25px 25px calc(var(--safe-area-bottom) + 25px) 25px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; text-align: right; color: #FFFFFF; z-index: 1; background-image: linear-gradient(to top, rgba(17, 17, 17, 1) 0%, rgba(17, 17, 17, 0) 100%); border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.story-item.active .story-text-container {
    animation: slideUpText 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s forwards;
    transform: translateY(100%);
    opacity: 0;
}
@keyframes slideUpText {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.story-text-container h2 { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: clamp(1.2rem, 5vw, 1.5rem); line-height: 1.4; margin: 0 0 15px; }
.story-summary-wrapper { display: flex; flex-direction: row; gap: 15px; align-items: flex-start; margin-bottom: 20px; }
.summary-accent-bar { flex-shrink: 0; width: 5px; background-color: var(--main-button-color); border-radius: 2.5px; }
.story-summary { font-family: 'Tajawal', sans-serif; font-weight: 400; font-size: clamp(0.9rem, 3vw, 1rem); line-height: 1.8; color: rgba(255, 255, 255, 0.85); margin: 0; }
.story-text-container a { background-color: var(--main-button-color); color: #FFFFFF; border-radius: 50px; padding: 12px 35px; font-weight: bold; text-decoration: none; transition: all 0.2s ease-in-out; align-self: flex-start; }
.story-text-container a:hover { transform: scale(1.05); filter: brightness(1.1); }

.story-header, .progress-bars-container {
    position: absolute;
    z-index: 10002;
}

.desktop-nav {
    display: flex;
    position: absolute;
    z-index: 10002;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
    justify-content: space-between;
    pointer-events: none;
}

/* --- بداية التعديل --- */
/* تم نقل هذه القواعد إلى هنا لتطبيقها على جميع الشاشات */
.nav-button {
    background-color: var(--main-button-color);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, background-color 0.2s, filter 0.2s;
    box-shadow: none;
    pointer-events: all;
}
.nav-button:hover {
    filter: brightness(1.15);
    transform: scale(1.1);
}
.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
    background-color: var(--main-button-color);
    filter: grayscale(50%);
}
/* --- نهاية التعديل --- */


.progress-bars-container { top: 0; left: 0; right: 0; display: flex; gap: 4px; height: 3px; padding: var(--safe-area-top) 10px 0 10px; box-sizing: border-box; }
.progress-bar { flex: 1; background-color: rgba(255, 255, 255, 0.3); border-radius: 2px; overflow: hidden; }
.progress-bar-inner { 
    height: 100%; 
    width: 0; 
    background-color: var(--main-button-color); 
    border-radius: 2px; 
    transition: width 0.3s linear; 
}
.story-header { top: 0; left: 0; width: 100%; padding: calc(var(--safe-area-top) + 15px) 20px 15px; display: flex; justify-content: space-between; align-items: center; }
.story-header .logo { color: white; font-weight: bold; font-size: 1.2rem; height: 35px; display: flex; align-items: center; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.story-header .logo img { max-height: 100%; width: auto; display: block; }
.back-arrow { color: white; font-size: 2rem; cursor: pointer; transform: scaleX(-1); text-shadow: 0 1px 3px rgba(0,0,0,0.5); background:none;border:0; }
.sound-control { position: absolute; top: calc(var(--safe-area-top) + 60px); right: 15px; width: 30px; height: 30px; background-color: rgba(0,0,0,0.5); border-radius: 50%; cursor: pointer; z-index: 10004; background-position: center; background-repeat: no-repeat; background-size: 60%; }
.sound-control.muted { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><line x1="23" y1="9" x2="17" y2="15"></line><line x1="17" y1="9" x2="23" y2="15"></line></svg>'); }
.sound-control:not(.muted) { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>'); }
.story-controls-mobile { position: absolute; bottom: 0; right: 0; z-index: 10002; padding: 20px; }
.copy-notification { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background-color: #28a745; color: white; padding: 10px 20px; border-radius: 20px; z-index: 10003; opacity: 0; visibility: hidden; transition: all 0.3s; }
.copy-notification.show { opacity: 1; visibility: visible; bottom: 50px; }
.no-stories-msg { color: white; font-size: 1.2rem; text-align: center; width: 100%; position: absolute; top: 50%; transform: translateY(-50%); }

.stories-shortcode-trigger a.button { background-color: var(--main-button-color); color: white; padding: 10px 25px; border-radius: 25px; text-decoration: none; font-weight: bold; display: inline-block; border: none; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.stories-shortcode-trigger a.button:hover { color: white; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.mns-floating-fab { position: fixed; bottom: 20px; right: 20px; left: auto; z-index: 9999; transition: transform 0.3s ease, opacity 0.3s ease; }
html:not([dir='rtl']) .mns-floating-fab { left: 20px; right: auto; }
.mns-floating-fab a { background-color: var(--main-button-color); color: white !important; padding: 10px 20px; border-radius: 30px; text-decoration: none; font-weight: bold; display: flex !important; align-items: center; gap: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); font-size: 1rem; height: 50px; box-sizing: border-box; }
.mns-floating-fab a:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
.mns-floating-fab .play-icon { display: inline-block; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid white; opacity: 0.9; transition: opacity 0.3s ease; }
.mns-floating-fab a:hover .play-icon { opacity: 1; }
.stories-container.active + .mns-floating-fab { opacity: 0; transform: translateY(20px); pointer-events: none; }

/* -------------------------------------------------------------------------- */
/* NEW: Story Groups Widget Styles                                            */
/* -------------------------------------------------------------------------- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mns-story-groups-widget-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Always 4 columns */
    gap: 15px;
}

.story-group-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
}

.story-group-icon-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 3px;
    box-sizing: border-box;
}

.story-group-icon-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px dashed var(--main-button-color);
    transition: transform 0.3s ease-out;
}

.story-group-item:hover .story-group-icon-wrapper::before {
    animation: spin 4s linear infinite;
}

.story-group-icon-wrapper img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background-color: #eee; /* Fallback color if no image */
}

/* MODIFIED BLOCK */
.story-group-name {
    font-size: 22px;     /* Increased from 13px */
    margin-top: 6px;     /* Decreased from 8px */
    text-align: center;
    color: inherit;
    font-weight: 700;    /* Increased from 500 */
    line-height: 1.3;
}
/* For smaller sidebars, make grid 2x2 */
@media (max-width: 250px) {
    .mns-story-groups-widget-container {
        grid-template-columns: 1fr 1fr;
    }
}


/* -------------------------------------------------------------------------- */
/* Media Queries & Responsive                                                 */
/* -------------------------------------------------------------------------- */

@media (max-width: 600px) {
    .mns-floating-fab { bottom: 15px; right: 15px; left: auto; }
    html:not([dir='rtl']) .mns-floating-fab { left: 15px; right: auto; }
    .mns-floating-fab a { padding: 8px 15px; font-size: 0.9rem; height: 45px; }
    .mns-floating-fab .play-icon { border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid white; }
}

@media (min-width: 768px) {
    .stories-container.active { background-color: rgba(0, 0, 0, 0.85); padding: 20px; }
    .story-item {
        position: relative;
        max-width: 420px;
        max-height: 90vh;
        aspect-ratio: 9 / 16;
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    }
    
    .story-controls-mobile {
        display: none;
    }
}

/* Image Animation Effects */
@keyframes zoomInEffect {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}
@keyframes zoomOutEffect {
  from { transform: scale(1.15); }
  to { transform: scale(1); }
}
.story-media.anim-zoom-in,
.story-media.anim-zoom-out {
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
.story-media.anim-zoom-in { animation-name: zoomInEffect; }
.story-media.anim-zoom-out { animation-name: zoomOutEffect; }

/* Prefers reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .story-item.active .story-text-container,
    .story-media.anim-zoom-in,
    .story-media.anim-zoom-out {
        animation: none !important;
        transition: none !important;
    }
    .story-group-item:hover .story-group-icon-wrapper::before {
        animation: none !important; /* Also disable widget animation */
    }
}