/* Lock the page while a story is open. */
html:has(body.pse-story-open) {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

body.pse-story-open {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none;
}

/* Instagram-like category strip. */
.pse-story-strip {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    max-width: 100%;
    padding: 6px 2px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.pse-story-strip::-webkit-scrollbar {
    display: none;
}

.pse-story-circle {
    display: block !important;
    flex: 0 0 86px !important;
    width: 86px !important;
    min-width: 86px !important;
    max-width: 86px !important;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    appearance: none;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit;
    font: inherit;
    line-height: normal;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pse-story-ring {
    display: inline-grid !important;
    flex: 0 0 76px !important;
    width: 76px !important;
    height: 76px !important;
    min-width: 76px !important;
    min-height: 76px !important;
    max-width: 76px !important;
    max-height: 76px !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 auto;
    padding: 3px !important;
    place-items: center;
    border: 0 !important;
    border-radius: 999px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: conic-gradient(from 210deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5, #feda75);
    transition: transform .18s ease, filter .18s ease;
}

.pse-story-circle:hover .pse-story-ring {
    filter: brightness(1.04);
    transform: scale(1.035);
}

.pse-story-circle:active .pse-story-ring {
    transform: scale(.97);
}

.pse-story-circle:focus-visible {
    outline: 2px solid #405de6;
    outline-offset: 4px;
}

.pse-story-cover,
.pse-story-cover-fallback {
    display: grid !important;
    width: 70px !important;
    height: 70px !important;
    min-width: 70px !important;
    min-height: 70px !important;
    max-width: 70px !important;
    max-height: 70px !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    place-items: center;
    border: 3px solid #fff !important;
    border-radius: 999px !important;
    box-sizing: border-box !important;
    object-fit: cover !important;
    object-position: 50% 50% !important;
    overflow: hidden !important;
    background: #f2f2f2;
}

.pse-story-cover-fallback {
    background: #ff0033;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 25px;
    font-weight: 700;
    line-height: 1;
    text-indent: 3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .16);
}

.pse-story-cover-video {
    pointer-events: none;
}

.pse-story-title {
    display: block !important;
    clear: both !important;
    float: none !important;
    width: 86px !important;
    min-width: 86px !important;
    max-width: 86px !important;
    margin: 6px 0 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    color: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    text-align: center !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Full-screen layer above headers, menus, footers and theme popups. */
.pse-story-modal[hidden] {
    display: none !important;
}

.pse-story-modal {
    position: fixed !important;
    z-index: 2147483647 !important;
    inset: 0 !important;
    display: grid !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    place-items: center;
    overflow: hidden !important;
    overscroll-behavior: none;
    isolation: isolate;
    box-sizing: border-box;
    background: rgba(0, 0, 0, .96) !important;
    transform: translateZ(0);
}

.pse-story-dialog {
    position: relative !important;
    z-index: 1;
    width: min(100vw, 430px) !important;
    height: min(100dvh, 780px) !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    overscroll-behavior: none;
    border: 0;
    border-radius: 16px;
    box-sizing: border-box;
    background: #000 !important;
    color: #fff !important;
    box-shadow: 0 20px 80px rgba(0, 0, 0, .55);
}

.pse-progress-wrapper {
    position: absolute;
    z-index: 30;
    top: max(9px, env(safe-area-inset-top));
    right: 10px;
    left: 10px;
    display: flex;
    gap: 3px;
    direction: ltr;
    pointer-events: none;
}

.pse-progress-item {
    flex: 1 1 0;
    height: 3px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, .34);
}

.pse-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #fff;
}

.pse-story-topbar {
    position: absolute;
    z-index: 40;
    top: max(20px, calc(env(safe-area-inset-top) + 13px));
    right: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.pse-story-counter {
    min-width: 42px;
    padding: 5px 9px;
    border-radius: 999px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, .42);
    color: #fff;
    font: 600 12px/1.2 Arial, sans-serif;
    direction: ltr;
    text-align: center !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
    backdrop-filter: blur(6px);
}

.pse-story-close,
.pse-story-prev,
.pse-story-next,
.pse-story-play {
    margin: 0 !important;
    border: 0 !important;
    appearance: none;
    box-shadow: none !important;
    color: #fff !important;
    font-family: Arial, sans-serif;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pse-story-play[hidden] {
    display: none !important;
}

.pse-story-close {
    position: relative;
    z-index: 50;
    display: grid;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px;
    padding: 0 0 3px !important;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .28) !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, .58) !important;
    font-size: 32px !important;
    font-weight: 300;
    line-height: 1 !important;
    pointer-events: auto;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
    backdrop-filter: blur(8px);
}

.pse-story-close:hover,
.pse-story-close:focus-visible {
    background: rgba(30, 30, 30, .9) !important;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.pse-story-stage {
    position: absolute !important;
    z-index: 1;
    inset: 0 !important;
    display: grid;
    margin: 0 !important;
    padding: 0 !important;
    place-items: center;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    background: #000;
}

.pse-story-media {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    object-fit: contain;
    background: #000;
}

.pse-story-status {
    position: absolute;
    z-index: 10;
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 9px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    backdrop-filter: blur(6px);
}

.pse-story-status:empty {
    display: none;
}

.pse-story-cta {
    position: absolute !important;
    z-index: 35;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    max-width: calc(100% - 24px);
    margin: 0 !important;
    border: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none !important;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    box-shadow: 0 5px 18px rgba(0, 0, 0, .24);
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.pse-story-cta:hover,
.pse-story-cta:focus,
.pse-story-cta:visited {
    text-decoration: none !important;
}

.pse-story-cta:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.pse-story-cta-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
}

.pse-story-cta-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pse-story-cta-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 599px) {
    .pse-story-cta.pse-cta-hide-mobile { display: none !important; }
}

@media (min-width: 600px) {
    .pse-story-cta.pse-cta-hide-desktop { display: none !important; }
}

.pse-story-play {
    position: absolute;
    z-index: 20;
    display: grid;
    width: 72px !important;
    height: 72px !important;
    min-width: 72px !important;
    padding: 0 0 0 5px !important;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .35) !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, .72) !important;
    font: 600 30px/1 Arial, sans-serif !important;
    pointer-events: auto !important;
    touch-action: manipulation;
    backdrop-filter: blur(8px);
}

.pse-story-prev,
.pse-story-next {
    position: absolute !important;
    z-index: 25;
    top: 50%;
    display: grid;
    width: 42px !important;
    height: 52px !important;
    padding: 0 0 5px !important;
    place-items: center;
    border-radius: 999px !important;
    background: rgba(0, 0, 0, .28) !important;
    font-size: 34px !important;
    font-weight: 300;
    line-height: 1 !important;
    transform: translateY(-50%);
    backdrop-filter: blur(4px);
}

.pse-story-prev { left: 8px; }
.pse-story-next { right: 8px; }

.pse-story-prev:hover,
.pse-story-next:hover,
.pse-story-prev:focus-visible,
.pse-story-next:focus-visible {
    background: rgba(0, 0, 0, .62) !important;
    outline: 1px solid rgba(255, 255, 255, .7);
}

@media (max-width: 599px) {
    .pse-story-modal { place-items: stretch; }

    .pse-story-dialog {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        border-radius: 0;
        box-shadow: none;
    }

    .pse-story-prev,
    .pse-story-next {
        top: 54%;
        width: 38px !important;
        height: 48px !important;
        background: rgba(0, 0, 0, .18) !important;
        font-size: 31px !important;
    }

    .pse-story-prev { left: 4px; }
    .pse-story-next { right: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .pse-story-ring,
    .pse-progress-fill { transition: none; }
}
