/* XSSM stories */

[hidden],
#story-editor-modal [hidden],
#story-viewer[hidden],
#story-viewer [hidden] {
    display: none !important;
}

.story-advanced-options{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:12px}.story-advanced-options>label{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:11px 12px;border:1px solid var(--border-color);border-radius:13px;background:color-mix(in srgb,var(--bg-primary) 72%,transparent)}.story-advanced-options>label>span{display:flex;align-items:center;gap:8px;font-size:.74rem}.story-advanced-options select{min-height:32px;padding:4px 8px;border:1px solid var(--border-color);border-radius:9px;color:var(--text-primary);background:var(--bg-secondary)}.story-advanced-options input{width:20px;height:20px;accent-color:#8b7cf6}.story-quick-reactions{display:flex;gap:5px;margin-right:auto}.story-quick-reactions button{width:36px;height:36px;border:1px solid rgba(255,255,255,.12);border-radius:12px;background:rgba(255,255,255,.08);font-size:1rem;cursor:pointer;transition:.16s ease}.story-quick-reactions button:hover{transform:translateY(-2px);background:rgba(139,124,246,.28)}@media(max-width:600px){.story-advanced-options{grid-template-columns:1fr}.story-quick-reactions{gap:3px}.story-quick-reactions button{width:32px;height:32px;border-radius:10px}}

/* Header story shortcut: create when empty, open the user's story when active. */
.sidebar-story-anchor {
    position: relative;
    display: block;
    width: 0;
    height: 0;
    flex: 0 0 auto;
    pointer-events: none;
    overflow: hidden;
}

.sidebar-story-btn {
    overflow: visible !important;
    padding: 0 !important;
}

.sidebar-story-ring {
    position: relative;
    display: grid;
    width: 31px;
    height: 31px;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.075);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.055);
    transition: transform 180ms ease, filter 180ms ease;
}

.sidebar-story-btn:hover .sidebar-story-ring {
    transform: scale(1.045);
    filter: brightness(1.08);
}

.sidebar-story-btn.has-story .sidebar-story-ring {
    padding: 2px;
    background: conic-gradient(from 12deg, #ff4f9a, #ad5cf3 34%, #6c7cff 66%, #32b8ff 82%, #ff4f9a);
    box-shadow: 0 4px 13px rgba(100, 73, 197, 0.28);
}

.sidebar-story-btn.has-story.seen .sidebar-story-ring {
    background: rgba(151, 149, 166, 0.3);
    box-shadow: none;
}

.sidebar-story-avatar {
    display: grid;
    width: 27px;
    height: 27px;
    place-items: center;
    overflow: hidden;
    border: 1.5px solid rgba(11, 14, 27, 0.94);
    border-radius: 50%;
    background: linear-gradient(145deg, #7966d8, #4d52ad);
    background-position: center;
    background-size: cover;
    color: #fff;
    font-size: 0.57rem;
    font-weight: 780;
}

.sidebar-story-create {
    position: absolute;
    right: -3px;
    bottom: -2px;
    display: grid;
    width: 15px;
    height: 15px;
    place-items: center;
    border: 2px solid rgba(11, 14, 27, 0.96);
    border-radius: 50%;
    background: linear-gradient(145deg, #9a80f4, #6171e7);
    color: #fff;
    font-size: 0.38rem;
    box-shadow: 0 3px 8px rgba(78, 57, 178, 0.34);
}

.sidebar-story-btn.has-story .sidebar-story-create {
    display: none;
}

.stories-rail {
    position: relative;
    z-index: 2;
    min-height: 0;
    margin: 0 1px 7px;
    padding: 3px 1px 9px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    will-change: height, margin-bottom;
}
.stories-docked .stories-rail {
    pointer-events: none;
}

.stories-rail::after {
    position: absolute;
    right: 8px;
    bottom: 0;
    left: 8px;
    height: 1px;
    content: "";
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.075) 12%, rgba(255, 255, 255, 0.075) 88%, transparent);
    opacity: var(--stories-divider-opacity, 1);
    transform-origin: center;
    transition: opacity 120ms linear;
}

.stories-rail-head {
    display: none;
}

.stories-rail-heading {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.stories-rail-heading > span {
    color: rgba(242, 241, 250, 0.82);
    font-size: 0.68rem;
    font-weight: 760;
    letter-spacing: 0.015em;
}

.stories-rail-heading > small {
    overflow: hidden;
    color: rgba(196, 193, 211, 0.36);
    font-size: 0.53rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stories-rail-add {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(178, 157, 255, 0.15);
    border-radius: 9px;
    color: #b7a4ff;
    background: rgba(139, 112, 232, 0.09);
    cursor: pointer;
    font-size: 0.58rem;
    transition: transform 180ms ease, color 180ms ease, background 180ms ease;
}

.stories-rail-add:hover {
    color: #fff;
    background: rgba(139, 112, 232, 0.18);
    transform: rotate(4deg) scale(1.05);
}

.stories-list {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 4px 4px;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 4px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.stories-list::-webkit-scrollbar {
    display: none;
}

.stories-contact-list {
    display: contents;
}

/* STORIES — «stagger fly» анимация управляется из JS (paintDock). */
.stories-list .story-tile {
    will-change: transform, opacity;
    transition-property: width, flex-basis, gap;
}

/* Мини-стак кружков у кнопки «Новый чат» — виден когда rail свёрнут */
.stories-dock {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    /* Перекрытая стопка */
    direction: ltr;
    isolation: isolate;
    min-width:54px;
    padding:3px 7px 3px 5px;
    border:1px solid rgba(255,255,255,.075);
    border-radius:999px;
    background:rgba(11,14,27,.58);
    box-shadow:0 8px 24px rgba(0,0,0,.2),inset 0 1px 0 rgba(255,255,255,.07);
    transition:background 180ms ease,box-shadow 180ms ease,transform 180ms ease;
}
.stories-dock:not(.visible) { border-color:transparent;background:transparent;box-shadow:none; }
.stories-dock.visible:hover { background:rgba(18,21,37,.78);box-shadow:0 10px 30px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.1); }
.stories-dock:empty { display: none; }
.stories-dock:not(.visible) .stories-dock-item { pointer-events: none; }
.stories-dock-item {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    /* Плотный стак как в Telegram: перекрываем ~60% круга */
    margin-left: -23px;
    display: grid;
    place-items: center;
    opacity: 0;
    transform: scale(0.25) translateY(8px);
    will-change: transform, opacity, filter;
    transition:
        box-shadow 180ms ease,
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        margin-left 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.stories-dock-item:first-child { margin-left: 0; }

/* Каждая следующая лежит слегка сверху — как наклейки в стопке */
.stories-dock-item:nth-last-child(1) { z-index: 30; }
.stories-dock-item:nth-last-child(2) { z-index: 29; }
.stories-dock-item:nth-last-child(3) { z-index: 28; }
.stories-dock-item:nth-last-child(4) { z-index: 27; }
.stories-dock-item:nth-last-child(n+5) { z-index: 26; }

/* При наведении весь стак «разъезжается», как в Telegram */
.stories-dock:hover .stories-dock-item { margin-left: -13px; }
.stories-dock.visible .stories-dock-item {
    opacity: 1;
    transform: none;
}
.stories-dock-item:hover {
    transform: scale(1.18) translateY(-3px);
    z-index: 40 !important;
    margin-left: -8px;
}

[data-theme="light"] .stories-dock.visible {
    border-color:rgba(65,55,96,.1);
    background:rgba(245,245,250,.74);
    box-shadow:0 8px 22px rgba(65,54,99,.11),inset 0 1px 0 rgba(255,255,255,.88);
}
[data-theme="light"] .stories-dock-ring {
    box-shadow:0 4px 13px rgba(92,69,174,.17),0 0 0 1.5px rgba(248,248,252,.96),inset 0 1px 0 rgba(255,255,255,.35);
}
.stories-dock-item:active {
    transform: scale(0.94);
}
.stories-dock-ring {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(from 12deg, #ff4f9a, #ad5cf3 34%, #6c7cff 66%, #32b8ff 82%, #ff4f9a);
    box-shadow:
        0 4px 14px rgba(100, 73, 197, 0.32),
        0 0 0 1.5px rgba(14, 17, 32, 0.92),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    position: relative;
    z-index: 1;
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), filter 180ms ease, box-shadow 180ms ease;
}
.stories-dock-item:hover .stories-dock-ring {
    transform: translateY(-2px) scale(1.07);
    filter: brightness(1.08);
}
.stories-dock-item.seen .stories-dock-ring {
    background: rgba(151, 149, 166, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), 0 0 0 1.5px rgba(14, 17, 32, 0.92);
}
.stories-dock-ring .story-avatar {
    width: 33px;
    height: 33px;
    border-width: 2px;
    font-size: 0.66rem;
}
.stories-dock-ring-plus {
    color: #c5b3ff;
    background: rgba(139, 112, 232, 0.2);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    box-shadow: inset 0 0 0 1.5px rgba(178, 157, 255, 0.32), 0 0 0 1.5px rgba(14, 17, 32, 0.92);
}
.stories-dock-item:hover .stories-dock-ring-plus {
    background: rgba(139, 112, 232, 0.32);
}

/* На мобиле стак компактнее и не «распирает» header */
@media (max-width: 768px) {
    .stories-dock-item,
    .stories-dock-ring {
        width: 40px;
        height: 40px;
    }
    .stories-dock-item {
        margin-left: -18px;
    }
    .stories-dock:hover .stories-dock-item {
        margin-left: -3px;
    }
    .stories-dock-ring .story-avatar {
        width: 35px;
        height: 35px;
        font-size: 0.7rem;
    }
}

/* Мобильный режим: rail остаётся видимым, чуть компактнее */
@media (min-width: 769px) {
    .modern-sidebar > .stories-rail {
        margin-right: 9px;
        margin-left: 9px;
    }
}

.story-tile {
    width: 52px;
    flex: 0 0 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    color: inherit;
    background: transparent;
    cursor: pointer;
    font: inherit;
    scroll-snap-align: start;
    transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1), flex-basis 300ms cubic-bezier(0.16, 1, 0.3, 1), gap 280ms ease, transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.story-ring {
    position: relative;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(from 12deg, #ff4f9a, #ad5cf3 34%, #6c7cff 66%, #32b8ff 82%, #ff4f9a);
    box-shadow: 0 4px 13px rgba(100, 73, 197, 0.2);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), filter 180ms ease, width 320ms cubic-bezier(0.16, 1, 0.3, 1), height 320ms cubic-bezier(0.16, 1, 0.3, 1), background 260ms ease, box-shadow 220ms ease;
}

.story-tile.seen .story-ring {
    background: rgba(151, 149, 166, 0.28);
    box-shadow: none;
}

.story-tile:hover .story-ring {
    filter: brightness(1.08);
    transform: translateY(-2px) scale(1.035);
}

.story-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 2px solid #10131f;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #7966d8, #4d52ad);
    background-position: center;
    background-size: cover;
    font-size: 0.72rem;
    font-weight: 780;
    letter-spacing: -0.02em;
    transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1), height 300ms cubic-bezier(0.16, 1, 0.3, 1), border-width 260ms ease, font-size 240ms ease;
}

.story-tile-own .story-ring {
    background: rgba(255, 255, 255, 0.085);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.055);
}

.story-tile-own.has-story .story-ring {
    background: conic-gradient(from 12deg, #ff4f9a, #ad5cf3 34%, #6c7cff 66%, #32b8ff 82%, #ff4f9a);
}

.story-add-badge {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 19px;
    height: 19px;
    display: grid;
    place-items: center;
    border: 2px solid #101320;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #8a7bf1, #586de0);
    font-size: 0.5rem;
    box-shadow: 0 3px 9px rgba(83, 62, 186, 0.32);
    transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1), height 300ms cubic-bezier(0.16, 1, 0.3, 1), border-width 240ms ease, font-size 220ms ease;
}

.story-tile-own.has-story .story-add-badge {
    width: 17px;
    height: 17px;
}

.story-tile-name {
    width: 100%;
    overflow: hidden;
    color: rgba(224, 222, 235, 0.57);
    font-size: 0.52rem;
    font-weight: 570;
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 240ms ease, transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.story-tile:not(.seen) .story-tile-name {
    color: rgba(242, 240, 250, 0.82);
}

.story-tile-loading .story-ring {
    background: rgba(255, 255, 255, 0.08);
    animation: storySkeleton 1.2s ease-in-out infinite;
}

@media (min-width: 769px) {
    .modern-sidebar > .stories-rail {
        margin-right: 9px;
        margin-left: 9px;
    }
}

@keyframes storySkeleton {
    50% { opacity: 0.5; }
}

/* Shared story backgrounds */
.story-bg-violet { background: radial-gradient(circle at 16% 10%, rgba(255, 255, 255, 0.2), transparent 30%), linear-gradient(145deg, #8d67e8, #5a42bc 55%, #292357); }
.story-bg-sunset { background: radial-gradient(circle at 76% 18%, rgba(255, 240, 190, 0.3), transparent 28%), linear-gradient(155deg, #ff9b6a, #d95078 52%, #65356f); }
.story-bg-ocean { background: radial-gradient(circle at 20% 20%, rgba(159, 245, 255, 0.22), transparent 30%), linear-gradient(155deg, #26a9ca, #2472ba 52%, #253c7c); }
.story-bg-forest { background: radial-gradient(circle at 80% 12%, rgba(201, 255, 208, 0.18), transparent 30%), linear-gradient(155deg, #4bba85, #247456 52%, #173d36); }
.story-bg-night { background: radial-gradient(circle at 75% 18%, rgba(132, 155, 255, 0.24), transparent 28%), linear-gradient(155deg, #363a70, #191d3d 56%, #090b18); }
.story-bg-rose { background: radial-gradient(circle at 20% 12%, rgba(255, 236, 245, 0.26), transparent 30%), linear-gradient(155deg, #e979ad, #be4f91 52%, #682f70); }

/* Editor */
#story-editor-modal.story-editor-overlay {
    padding: 24px !important;
    background:
        radial-gradient(circle at 15% 10%, rgba(129, 95, 224, 0.2), transparent 34%),
        radial-gradient(circle at 88% 90%, rgba(35, 153, 205, 0.12), transparent 33%),
        rgba(2, 4, 12, 0.78) !important;
    -webkit-backdrop-filter: blur(22px) saturate(145%) !important;
    backdrop-filter: blur(22px) saturate(145%) !important;
}

#story-editor-modal .story-editor-card {
    width: min(940px, calc(100vw - 48px)) !important;
    max-width: 940px !important;
    height: min(760px, calc(100dvh - 48px)) !important;
    max-height: 760px !important;
    min-height: min(620px, calc(100dvh - 48px));
    padding: 0 !important;
    isolation: isolate;
    overflow: hidden !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 34px !important;
    background:
        radial-gradient(circle at 24% -10%, rgba(136, 105, 227, 0.15), transparent 35%),
        rgba(8, 11, 23, 0.92) !important;
    box-shadow: 0 44px 140px rgba(0, 0, 0, 0.72), inset 0 1.5px 1px rgba(255, 255, 255, 0.22) !important;
}

.story-sheet-handle {
    display: none;
}

.story-editor-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 19px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
    background: rgba(255, 255, 255, 0.025);
}

.story-editor-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.story-editor-brand-icon {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(185, 165, 255, 0.22);
    border-radius: 17px;
    color: #d2c6ff;
    background: linear-gradient(145deg, rgba(151, 119, 240, 0.24), rgba(92, 75, 179, 0.11));
    box-shadow: 0 10px 25px rgba(74, 51, 168, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.22);
}

.story-editor-kicker {
    display: block;
    margin-bottom: 2px;
    color: rgba(190, 179, 246, 0.62);
    font-size: 0.61rem;
    font-weight: 760;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.story-editor-brand h2 {
    margin: 0;
    color: #f6f5fb;
    font-size: 1.3rem;
    font-weight: 780;
    letter-spacing: -0.035em;
}

.story-editor-brand p {
    margin: 3px 0 0;
    color: rgba(205, 201, 218, 0.48);
    font-size: 0.7rem;
}

.story-editor-close,
.story-viewer-close,
.story-viewer-sound,
#story-viewers-close {
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
}

.story-editor-close {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: rgba(222, 218, 233, 0.52);
    background: rgba(255, 255, 255, 0.045);
}

.story-editor-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.story-editor-layout {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(260px, 0.78fr) minmax(420px, 1.22fr);
    overflow: hidden;
}

.story-editor-preview-column {
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 19px;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(1, 3, 12, 0.22);
}

.story-editor-preview {
    position: relative;
    isolation: isolate;
    width: min(100%, 286px);
    aspect-ratio: 9 / 15.5;
    max-height: 500px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 28px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.22);
}

.story-editor-preview::after,
.story-viewer-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.13), transparent 25%, transparent 68%, rgba(0, 0, 0, 0.35));
}

.story-preview-placeholder {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px;
    color: rgba(255, 255, 255, 0.78);
    text-align: center;
}

.story-preview-placeholder > span {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 13px;
    border: 1px solid rgba(255, 255, 255, 0.17);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.story-preview-placeholder strong {
    font-size: 0.82rem;
}

.story-preview-placeholder small {
    max-width: 180px;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.62rem;
    line-height: 1.45;
}

#story-preview-image,
#story-preview-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-preview-text {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 38px 26px;
    color: #fff;
    font-size: clamp(1.1rem, 2.4vw, 1.6rem);
    font-weight: 760;
    line-height: 1.25;
    text-align: center;
    text-wrap: balance;
    word-break: break-word;
    text-shadow: 0 2px 15px rgba(0, 0, 0, 0.22);
}

.story-preview-caption {
    position: absolute;
    right: 18px;
    bottom: 22px;
    left: 18px;
    z-index: 3;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.91);
    background: rgba(7, 8, 16, 0.35);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    font-size: 0.66rem;
    line-height: 1.4;
}

.story-preview-time {
    position: absolute;
    z-index: 3;
    top: 13px;
    right: 13px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 99px;
    color: rgba(255, 255, 255, 0.73);
    background: rgba(4, 5, 13, 0.25);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font-size: 0.54rem;
    font-weight: 650;
}

.story-editor-controls {
    min-height: 0;
    overflow-y: auto;
    padding: 18px 20px 20px;
    scrollbar-gutter: stable;
}

.story-mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 14px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 16px;
    background: rgba(1, 3, 12, 0.25);
}

.story-mode-tab {
    min-height: 41px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: rgba(202, 199, 215, 0.48);
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 650;
}

.story-mode-tab:hover {
    color: rgba(241, 239, 248, 0.78);
    background: rgba(255, 255, 255, 0.035);
}

.story-mode-tab.active {
    color: #e8e2ff;
    border-color: rgba(157, 132, 240, 0.18);
    background: rgba(126, 99, 216, 0.13);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.story-upload-zone {
    width: 100%;
    min-height: 74px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: 1px dashed rgba(173, 151, 247, 0.24);
    border-radius: 18px;
    color: inherit;
    background: linear-gradient(115deg, rgba(126, 96, 218, 0.09), rgba(255, 255, 255, 0.025));
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.story-upload-zone:hover,
.story-upload-zone.dragover {
    border-color: rgba(184, 161, 255, 0.48);
    background: linear-gradient(115deg, rgba(126, 96, 218, 0.16), rgba(255, 255, 255, 0.045));
    transform: translateY(-1px);
}

.story-upload-zone.has-file {
    border-style: solid;
    border-color: rgba(52, 211, 153, 0.25);
    background: rgba(16, 185, 129, 0.065);
}

.story-upload-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #b4a1fa;
    background: rgba(130, 103, 222, 0.13);
}

.story-upload-zone.has-file .story-upload-icon {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.12);
}

.story-upload-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.story-upload-copy strong,
.story-upload-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-upload-copy strong {
    color: rgba(242, 240, 249, 0.84);
    font-size: 0.73rem;
    font-weight: 670;
}

.story-upload-copy small {
    margin-top: 4px;
    color: rgba(196, 192, 210, 0.4);
    font-size: 0.59rem;
}

.story-upload-action {
    flex: 0 0 auto;
    padding: 6px 9px;
    border-radius: 9px;
    color: #b5a5ee;
    background: rgba(134, 108, 220, 0.12);
    font-size: 0.58rem;
    font-weight: 670;
}

.story-text-field,
.story-caption-field,
.story-background-field,
.story-privacy-field {
    min-width: 0;
    margin: 14px 0 0;
    padding: 0;
    border: 0;
}

.story-text-field > span,
.story-caption-field > span,
.story-background-field > legend,
.story-privacy-field > legend {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
    color: rgba(224, 221, 234, 0.58);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.story-text-field > span small,
.story-caption-field > span small {
    color: rgba(194, 190, 207, 0.35);
    font-size: 0.56rem;
    letter-spacing: 0;
    text-transform: none;
}

.story-text-field textarea,
.story-caption-field textarea {
    width: 100%;
    min-height: 68px;
    padding: 11px 12px;
    resize: vertical;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 15px;
    outline: 0;
    color: rgba(244, 242, 249, 0.88);
    background: rgba(255, 255, 255, 0.045);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.035);
    font: inherit;
    font-size: 0.73rem;
    line-height: 1.45;
}

.story-text-field textarea {
    min-height: 106px;
}

.story-text-field textarea:focus,
.story-caption-field textarea:focus {
    border-color: rgba(155, 131, 239, 0.4);
    background: rgba(255, 255, 255, 0.065);
    box-shadow: 0 0 0 4px rgba(126, 96, 218, 0.09);
}

.story-backgrounds {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.story-background {
    position: relative;
    aspect-ratio: 1.35;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 13px;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.17);
}

.story-background.active {
    border-color: #c6b5ff;
    box-shadow: 0 0 0 3px rgba(157, 132, 239, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.story-privacy-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.story-privacy-option {
    min-width: 0;
    min-height: 64px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 15px;
    color: rgba(211, 207, 220, 0.55);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
}

.story-privacy-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.story-privacy-option.active {
    color: rgba(241, 239, 248, 0.86);
    border-color: rgba(154, 130, 239, 0.2);
    background: rgba(126, 96, 218, 0.1);
}

.story-privacy-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: rgba(196, 186, 233, 0.58);
    background: rgba(255, 255, 255, 0.045);
    font-size: 0.69rem;
}

.story-privacy-option.active .story-privacy-icon {
    color: #c4b4ff;
    background: rgba(130, 103, 222, 0.14);
}

.story-privacy-option > span:nth-child(3) {
    min-width: 0;
}

.story-privacy-option strong,
.story-privacy-option small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-privacy-option strong {
    color: inherit;
    font-size: 0.67rem;
    font-weight: 660;
}

.story-privacy-option small {
    margin-top: 3px;
    color: rgba(194, 190, 207, 0.38);
    font-size: 0.53rem;
}

.story-privacy-check {
    color: rgba(180, 164, 235, 0.13);
    font-size: 0.7rem;
}

.story-privacy-option.active .story-privacy-check {
    color: #a995ee;
}

.story-editor-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(1, 3, 12, 0.22);
}

.story-editor-note {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(193, 190, 206, 0.38);
    font-size: 0.59rem;
}

.story-editor-note i {
    color: rgba(110, 231, 183, 0.56);
}

.story-editor-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.story-editor-cancel,
.story-editor-publish {
    height: 41px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 15px;
    border-radius: 13px;
    cursor: pointer;
    font: inherit;
    font-size: 0.69rem;
    font-weight: 670;
}

.story-editor-cancel {
    border: 1px solid transparent;
    color: rgba(215, 211, 225, 0.5);
    background: transparent;
}

.story-editor-cancel:hover {
    color: rgba(244, 242, 249, 0.88);
    border-color: rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.04);
}

.story-editor-publish {
    min-width: 138px;
    border: 1px solid rgba(199, 184, 255, 0.21);
    color: #fff;
    background: linear-gradient(135deg, #9675ec, #6858d7 58%, #5574d8);
    box-shadow: 0 9px 23px rgba(75, 55, 185, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

.story-editor-publish:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(80, 59, 193, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.story-editor-publish:disabled {
    opacity: 0.34;
    cursor: not-allowed;
    filter: saturate(0.55);
    box-shadow: none;
}

.story-editor-publish.loading i {
    animation: storyPublishSpin 700ms linear infinite;
}

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

/* Immersive viewer */
.story-viewer[hidden] {
    display: none !important;
}

.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 420;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 18px;
}

.story-viewer-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 10%, rgba(114, 79, 210, 0.19), transparent 34%),
        radial-gradient(circle at 82% 90%, rgba(35, 133, 181, 0.11), transparent 30%),
        rgba(1, 2, 7, 0.94);
    -webkit-backdrop-filter: blur(28px) saturate(130%);
    backdrop-filter: blur(28px) saturate(130%);
}

.story-viewer-shell {
    position: relative;
    z-index: 2;
    width: min(430px, calc(100vw - 36px));
    height: min(820px, calc(100dvh - 36px));
    max-height: 820px;
    isolation: isolate;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 29px;
    color: #fff;
    background: #0b0d16;
    box-shadow: 0 42px 130px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    animation: storyViewerIn 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes storyViewerIn {
    from { opacity: 0; transform: translateY(10px) scale(0.965); }
    to { opacity: 1; transform: none; }
}

.story-progress {
    position: absolute;
    z-index: 10;
    top: 11px;
    right: 11px;
    left: 11px;
    display: flex;
    gap: 4px;
}

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

.story-progress-fill {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.96);
    transform: scaleX(0);
    transform-origin: left;
}

.story-progress-segment.done .story-progress-fill {
    transform: scaleX(1);
}

.story-viewer-header {
    position: absolute;
    z-index: 9;
    top: 21px;
    right: 13px;
    left: 13px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.story-viewer-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1.5px solid rgba(255, 255, 255, 0.58);
    border-radius: 50%;
    background: linear-gradient(145deg, #8c6fe6, #5258b7);
    background-position: center;
    background-size: cover;
    font-size: 0.68rem;
    font-weight: 780;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.22);
}

button.story-viewer-avatar {
    padding: 0;
    border: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

button.story-viewer-avatar:not(:disabled):hover,
button.story-viewer-avatar:not(:disabled):focus-visible {
    transform: scale(1.06);
    box-shadow: 0 0 0 3px rgba(255,255,255,.16), 0 8px 24px rgba(0,0,0,.22);
}

button.story-viewer-avatar:disabled { cursor: default; }

.story-viewer-owner {
    min-width: 0;
    flex: 1 1 auto;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.story-viewer-owner strong,
.story-viewer-owner small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-viewer-owner strong {
    color: #fff;
    font-size: 0.76rem;
    font-weight: 700;
}

.story-viewer-owner small {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.57rem;
}

.story-viewer-close,
.story-viewer-sound {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    color: rgba(255, 255, 255, 0.78);
    background: rgba(6, 7, 13, 0.25);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.story-viewer-close:hover,
.story-viewer-sound:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.13);
}

.story-viewer-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: linear-gradient(145deg, #1a1c2b, #090a10);
}

.story-viewer-image,
.story-viewer-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-viewer-text {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 86px 34px 110px;
    color: #fff;
    font-size: clamp(1.45rem, 6vw, 2.2rem);
    font-weight: 780;
    line-height: 1.24;
    text-align: center;
    text-wrap: balance;
    word-break: break-word;
    text-shadow: 0 3px 20px rgba(0, 0, 0, 0.24);
}

.story-viewer-caption {
    position: absolute;
    z-index: 6;
    right: 18px;
    bottom: 72px;
    left: 18px;
    max-height: 116px;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 15px;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(6, 7, 14, 0.34);
    -webkit-backdrop-filter: blur(20px) saturate(125%);
    backdrop-filter: blur(20px) saturate(125%);
    font-size: 0.72rem;
    line-height: 1.45;
}

.story-nav {
    position: absolute;
    z-index: 7;
    top: 50%;
    width: 39px;
    height: 55px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    background: rgba(5, 6, 12, 0.22);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    cursor: pointer;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 160ms ease, background 160ms ease;
}

.story-viewer-shell:hover .story-nav {
    opacity: 1;
}

.story-nav:hover {
    color: #fff;
    background: rgba(5, 6, 12, 0.42);
}

.story-nav-prev {
    left: 10px;
    border-radius: 15px;
}

.story-nav-next {
    right: 10px;
    border-radius: 15px;
}

.story-viewer-footer {
    position: absolute;
    z-index: 8;
    right: 13px;
    bottom: 13px;
    left: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.story-view-count,
.story-viewer-delete,
.story-viewer-privacy {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 11px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 13px;
    color: rgba(255, 255, 255, 0.76);
    background: rgba(6, 7, 14, 0.3);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    font: inherit;
    font-size: 0.61rem;
    font-weight: 620;
}

.story-view-count,
.story-viewer-delete {
    cursor: pointer;
}

.story-view-count:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.story-viewer-delete {
    color: #ff9aaa;
}

.story-viewer-delete:hover {
    color: #fff;
    border-color: rgba(255, 99, 123, 0.28);
    background: rgba(239, 68, 88, 0.18);
}

.story-viewers-panel {
    position: absolute;
    z-index: 12;
    top: 18px;
    right: max(18px, calc(50vw - 430px));
    bottom: 18px;
    width: min(340px, calc(100vw - 36px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 26px;
    color: #fff;
    background: rgba(12, 14, 24, 0.92);
    -webkit-backdrop-filter: blur(42px) saturate(145%);
    backdrop-filter: blur(42px) saturate(145%);
    box-shadow: 0 35px 100px rgba(0, 0, 0, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease;
}

.story-viewers-panel.open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
}

.story-viewers-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 17px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}

.story-viewers-panel > header span,
.story-viewers-panel > header small {
    display: block;
}

.story-viewers-panel > header span {
    color: rgba(247, 245, 252, 0.9);
    font-size: 0.84rem;
    font-weight: 720;
}

.story-viewers-panel > header small {
    margin-top: 3px;
    color: rgba(198, 194, 210, 0.42);
    font-size: 0.58rem;
}

#story-viewers-close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: rgba(222, 218, 233, 0.55);
    background: rgba(255, 255, 255, 0.045);
}

.story-viewers-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px;
}

button.story-viewer-person {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

button.story-viewer-person:hover,
button.story-viewer-person:focus-visible {
    border-color: rgba(170,151,255,.22);
    background: rgba(139,116,225,.09);
    transform: translateY(-1px);
}

.story-viewer-person {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 57px;
    padding: 7px 8px;
    border-radius: 15px;
}

.story-viewer-person:hover {
    background: rgba(255, 255, 255, 0.045);
}

.story-viewer-person-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #856de0, #5057b3);
    background-position: center;
    background-size: cover;
    font-size: 0.68rem;
    font-weight: 750;
}

.story-viewer-person-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.story-viewer-person-copy strong,
.story-viewer-person-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-viewer-person-copy strong {
    color: rgba(243, 241, 249, 0.85);
    font-size: 0.7rem;
    font-weight: 650;
}

.story-viewer-person-copy small {
    margin-top: 3px;
    color: rgba(197, 193, 209, 0.4);
    font-size: 0.56rem;
}

.story-viewers-empty,
.story-viewers-loading {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: rgba(201, 197, 212, 0.42);
    font-size: 0.64rem;
    text-align: center;
}

.story-viewers-empty i {
    color: rgba(177, 157, 238, 0.56);
    font-size: 1.2rem;
}

/* Light appearance */
[data-theme="light"] .stories-rail {
    border: 0;
    background: transparent;
    box-shadow: none;
}

[data-theme="light"] .stories-rail::after {
    background: linear-gradient(90deg, transparent, rgba(52, 45, 75, 0.105) 12%, rgba(52, 45, 75, 0.105) 88%, transparent);
}

[data-theme="light"] .stories-rail-heading > span,
[data-theme="light"] .story-tile:not(.seen) .story-tile-name {
    color: #34313f;
}

[data-theme="light"] .stories-rail-heading > small,
[data-theme="light"] .story-tile-name {
    color: #797b89;
}

[data-theme="light"] .stories-rail-add {
    border-color: rgba(115, 95, 211, 0.17);
    color: #6e59c7;
    background: rgba(115, 95, 211, 0.1);
}

[data-theme="light"] .story-avatar {
    border-color: #e8eaf0;
}

[data-theme="light"] .story-tile-own .story-ring {
    background: rgba(71, 61, 103, 0.13);
    box-shadow: inset 0 0 0 1px rgba(55, 47, 80, 0.07);
}

[data-theme="light"] .story-add-badge {
    border-color: #e8eaf0;
}

[data-theme="light"] .sidebar-story-avatar,
[data-theme="light"] .sidebar-story-create {
    border-color: rgba(242, 244, 249, 0.98);
}

[data-theme="light"] .sidebar-story-ring {
    background: rgba(75, 61, 110, 0.11);
    box-shadow: inset 0 0 0 1px rgba(55, 47, 80, 0.075);
}

[data-theme="light"] .sidebar-story-btn.has-story .sidebar-story-ring {
    background: conic-gradient(from 12deg, #ec4f94, #9d58e5 34%, #6978f1 66%, #2fa8eb 82%, #ec4f94);
}

[data-theme="light"] #story-editor-modal.story-editor-overlay {
    background:
        radial-gradient(circle at 15% 10%, rgba(126, 103, 214, 0.15), transparent 35%),
        radial-gradient(circle at 88% 90%, rgba(51, 162, 208, 0.09), transparent 33%),
        rgba(215, 220, 232, 0.72) !important;
}

[data-theme="light"] #story-editor-modal .story-editor-card {
    color: #282934;
    border-color: rgba(255, 255, 255, 0.92) !important;
    background:
        radial-gradient(circle at 24% -10%, rgba(128, 104, 214, 0.1), transparent 36%),
        linear-gradient(145deg, #f9fafc, #e9ecf3) !important;
    box-shadow: 0 42px 110px rgba(43, 48, 70, 0.22), 0 0 0 1px rgba(56, 48, 82, 0.07), inset 0 1px 0 #fff !important;
}

[data-theme="light"] .story-editor-header,
[data-theme="light"] .story-editor-footer {
    border-color: rgba(55, 47, 80, 0.1);
    background: rgba(235, 237, 244, 0.68);
}

[data-theme="light"] .story-editor-brand-icon {
    border-color: rgba(115, 95, 211, 0.17);
    color: #6e59c7;
    background: rgba(115, 95, 211, 0.1);
    box-shadow: 0 8px 20px rgba(68, 53, 124, 0.09), inset 0 1px 0 #fff;
}

[data-theme="light"] .story-editor-kicker {
    color: #7060b5;
}

[data-theme="light"] .story-editor-brand h2,
[data-theme="light"] .story-upload-copy strong,
[data-theme="light"] .story-privacy-option strong {
    color: #292a36;
}

[data-theme="light"] .story-editor-brand p,
[data-theme="light"] .story-upload-copy small,
[data-theme="light"] .story-privacy-option small,
[data-theme="light"] .story-editor-note {
    color: #737786;
}

[data-theme="light"] .story-editor-close {
    border-color: rgba(55, 47, 80, 0.1);
    color: #686b78;
    background: rgba(66, 56, 96, 0.07);
}

[data-theme="light"] .story-editor-preview-column {
    border-color: rgba(55, 47, 80, 0.09);
    background: rgba(221, 224, 233, 0.55);
}

[data-theme="light"] .story-mode-tabs {
    border-color: rgba(55, 47, 80, 0.1);
    background: rgba(70, 59, 102, 0.07);
}

[data-theme="light"] .story-mode-tab {
    color: #6f7280;
}

[data-theme="light"] .story-mode-tab:hover {
    color: #34323f;
    background: rgba(255, 255, 255, 0.48);
}

[data-theme="light"] .story-mode-tab.active {
    color: #493b84;
    border-color: rgba(115, 95, 211, 0.16);
    background: rgba(255, 255, 255, 0.76);
    box-shadow: 0 5px 15px rgba(48, 41, 72, 0.07), inset 0 1px 0 #fff;
}

[data-theme="light"] .story-upload-zone {
    border-color: rgba(115, 95, 211, 0.24);
    background: linear-gradient(115deg, rgba(115, 95, 211, 0.1), rgba(255, 255, 255, 0.5));
}

[data-theme="light"] .story-upload-icon {
    color: #6c58c3;
    background: rgba(115, 95, 211, 0.1);
}

[data-theme="light"] .story-upload-action {
    color: #5f4db2;
    background: rgba(115, 95, 211, 0.11);
}

[data-theme="light"] :is(.story-text-field > span, .story-caption-field > span, .story-background-field > legend, .story-privacy-field > legend) {
    color: #666a78;
}

[data-theme="light"] :is(.story-text-field textarea, .story-caption-field textarea) {
    border-color: rgba(55, 47, 80, 0.11);
    color: #292a36;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 #fff;
}

[data-theme="light"] .story-privacy-option {
    color: #616573;
    border-color: rgba(55, 47, 80, 0.095);
    background: rgba(255, 255, 255, 0.47);
}

[data-theme="light"] .story-privacy-option.active {
    color: #3e346a;
    border-color: rgba(115, 95, 211, 0.19);
    background: rgba(115, 95, 211, 0.09);
}

[data-theme="light"] .story-privacy-icon {
    color: #727584;
    background: rgba(66, 56, 96, 0.07);
}

[data-theme="light"] .story-editor-cancel {
    color: #656977;
}

@media (max-width: 768px) {
    .stories-rail {
        margin: 1px 0 8px;
        padding: 5px 0 10px;
        border-radius: 0;
    }

    .stories-rail::after {
        right: var(--mobile-inbox-pad, 14px);
        left: var(--mobile-inbox-pad, 14px);
    }

    .stories-list {
        gap: 4px;
        padding: 5px var(--mobile-inbox-pad, 14px) 4px;
        scroll-padding-inline: var(--mobile-inbox-pad, 14px);
    }

    .story-tile {
        width: 59px;
        flex-basis: 59px;
    }

    .story-ring {
        width: 51px;
        height: 51px;
    }

    .story-avatar {
        width: 45px;
        height: 45px;
    }

    .stories-rail.is-compact {
        z-index: 40;
        max-height: 40px;
        margin-bottom: 3px;
        padding-bottom: 4px;
        transform: translate(var(--story-dock-x, 18px), var(--story-dock-y, -48px));
    }

    .stories-rail.is-compact .stories-list {
        padding-right: var(--mobile-inbox-pad, 14px);
        padding-left: var(--mobile-inbox-pad, 14px);
        gap: 4px;
        align-items: center;
        justify-content: flex-end;
        padding-top: 0;
        padding-bottom: 0;
        overflow: visible;
    }

    .stories-rail.is-compact .stories-list .story-tile {
        width: 32px;
        flex-basis: 32px;
        gap: 0;
    }

    .stories-rail.is-compact .stories-list .story-tile-own .story-ring,
    .stories-rail.is-compact .stories-list .story-ring {
        width: 30px;
        height: 30px;
    }

    .stories-rail.is-compact .stories-list .story-avatar {
        width: 25px;
        height: 25px;
        border-width: 1.5px;
        font-size: 0.52rem;
    }

    .stories-rail.is-compact .stories-list .story-tile-name,
    .stories-rail.is-compact .stories-list .story-add-badge {
        opacity: 0;
        pointer-events: none;
    }

    .stories-rail.is-compact .stories-list .story-tile-name {
        transform: translateY(-8px);
    }

    .stories-rail.is-compact::after {
        opacity: 0.4;
    }

    #story-editor-modal.story-editor-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    #story-editor-modal .story-editor-card {
        width: 100vw !important;
        max-width: none !important;
        height: 96dvh !important;
        max-height: 96dvh !important;
        min-height: 0 !important;
        border-right: 0 !important;
        border-bottom: 0 !important;
        border-left: 0 !important;
        border-radius: 29px 29px 0 0 !important;
        transform: translateY(24px) !important;
    }

    #story-editor-modal.active .story-editor-card {
        transform: none !important;
    }

    .story-sheet-handle {
        position: absolute;
        z-index: 20;
        top: 7px;
        left: 50%;
        width: 38px;
        height: 5px;
        display: block;
        border-radius: 99px;
        background: rgba(255, 255, 255, 0.2);
        transform: translateX(-50%);
    }

    [data-theme="light"] .story-sheet-handle {
        background: rgba(42, 37, 59, 0.2);
    }

    .story-editor-header {
        padding: 20px 14px 12px;
    }

    .story-editor-brand-icon {
        width: 43px;
        height: 43px;
        flex-basis: 43px;
        border-radius: 14px;
    }

    .story-editor-brand p,
    .story-editor-kicker {
        display: none;
    }

    .story-editor-brand h2 {
        font-size: 1.15rem;
    }

    .story-editor-layout {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .story-editor-preview-column {
        flex: 0 0 auto;
        padding: 12px 14px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }

    .story-editor-preview {
        width: 100%;
        max-width: none;
        height: 205px;
        max-height: 205px;
        aspect-ratio: auto;
        border-radius: 21px;
    }

    .story-preview-text {
        padding: 34px 22px;
        font-size: 1.22rem;
    }

    .story-editor-controls {
        flex: 0 0 auto;
        overflow: visible;
        padding: 13px 12px 15px;
    }

    .story-privacy-options {
        grid-template-columns: 1fr;
    }

    .story-editor-footer {
        padding: 9px 12px max(11px, env(safe-area-inset-bottom));
    }

    .story-editor-note {
        display: none;
    }

    .story-editor-actions {
        width: 100%;
    }

    .story-editor-publish {
        min-width: 0;
        flex: 1 1 auto;
    }

    .story-viewer {
        padding: 0;
        background: #05060a;
    }

    .story-viewer-shell {
        width: 100vw;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .story-progress {
        top: max(9px, env(safe-area-inset-top));
    }

    .story-viewer-header {
        top: max(19px, calc(env(safe-area-inset-top) + 10px));
    }

    .story-nav {
        width: 30%;
        height: 65%;
        top: 18%;
        border: 0;
        background: transparent !important;
        opacity: 1;
        transform: none;
    }

    .story-nav i {
        display: none;
    }

    .story-nav-prev {
        left: 0;
    }

    .story-nav-next {
        right: 0;
    }

    .story-viewers-panel {
        z-index: 22;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 68dvh;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 27px 27px 0 0;
        transform: translateY(100%);
    }

    .story-viewers-panel.open {
        transform: none;
    }
}

@media (max-width: 390px) {
    .stories-rail-heading > small {
        display: none;
    }

    .story-editor-preview {
        height: 178px;
    }

    .story-backgrounds {
        gap: 6px;
    }

    .story-upload-action {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .story-ring,
    .story-viewer-shell,
    .story-viewers-panel,
    .story-editor-card,
    .story-editor-publish {
        animation: none !important;
        transition: none !important;
    }
}

/* Story studio: richer controls, state feedback and viewer polish. */
.story-editor-header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 9px;
}

.story-draft-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(110, 231, 183, 0.14);
    border-radius: 999px;
    color: rgba(171, 238, 210, 0.72);
    background: rgba(16, 185, 129, 0.07);
    font-size: 0.57rem;
    font-weight: 650;
    white-space: nowrap;
}

.story-text-style-field,
.story-media-style-field,
.story-duration-field {
    min-width: 0;
    margin: 14px 0 0;
    padding: 0;
    border: 0;
}

.story-text-style-field > legend,
.story-media-style-field > legend {
    width: 100%;
    margin-bottom: 7px;
    color: rgba(224, 221, 234, 0.58);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.story-style-row {
    display: grid;
    grid-template-columns: 1.35fr 0.72fr 0.93fr;
    gap: 8px;
}

.story-style-row > div > span {
    display: block;
    margin: 0 0 5px 2px;
    color: rgba(194, 190, 207, 0.42);
    font-size: 0.54rem;
    font-weight: 620;
}

.story-style-segmented {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 3px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 12px;
    background: rgba(1, 3, 12, 0.22);
}

.story-style-segmented button {
    min-width: 0;
    height: 31px;
    padding: 0 8px;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 9px;
    color: rgba(206, 202, 216, 0.48);
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 0.57rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.story-style-segmented button:hover {
    color: rgba(242, 240, 249, 0.8);
    background: rgba(255, 255, 255, 0.045);
}

.story-style-segmented button.active {
    color: #e7e0ff;
    border-color: rgba(166, 141, 246, 0.2);
    background: rgba(128, 99, 221, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.story-fit-picker button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.story-duration-field {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(130px, 1.2fr) 48px;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.025);
}

.story-duration-field > span strong,
.story-duration-field > span small {
    display: block;
}

.story-duration-field > span strong {
    color: rgba(230, 227, 238, 0.72);
    font-size: 0.61rem;
    font-weight: 670;
}

.story-duration-field > span small {
    margin-top: 2px;
    color: rgba(194, 190, 207, 0.36);
    font-size: 0.51rem;
}

.story-duration-field input[type="range"] {
    width: 100%;
    accent-color: #9174e7;
    cursor: pointer;
}

.story-duration-field output {
    padding: 5px 7px;
    border-radius: 9px;
    color: #cfc2ff;
    background: rgba(129, 101, 221, 0.13);
    font-size: 0.56rem;
    font-weight: 720;
    text-align: center;
}

.story-text-font-modern { font-family: Inter, "Segoe UI", system-ui, sans-serif; }
.story-text-font-classic { font-family: Georgia, "Times New Roman", serif; font-weight: 650; }
.story-text-font-mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-weight: 700; letter-spacing: -0.04em; }

.story-preview-text.story-text-size-small { font-size: clamp(0.9rem, 1.8vw, 1.16rem); }
.story-preview-text.story-text-size-medium { font-size: clamp(1.1rem, 2.4vw, 1.6rem); }
.story-preview-text.story-text-size-large { font-size: clamp(1.38rem, 3vw, 2rem); }
.story-viewer-text.story-text-size-small { font-size: clamp(1.1rem, 4.5vw, 1.55rem); }
.story-viewer-text.story-text-size-medium { font-size: clamp(1.45rem, 6vw, 2.2rem); }
.story-viewer-text.story-text-size-large { font-size: clamp(1.85rem, 7.5vw, 2.85rem); }

.story-preview-text.story-text-align-left,
.story-viewer-text.story-text-align-left { justify-content: flex-start; text-align: left; text-wrap: pretty; }
.story-preview-text.story-text-align-center,
.story-viewer-text.story-text-align-center { justify-content: center; text-align: center; }
.story-preview-text.story-text-align-right,
.story-viewer-text.story-text-align-right { justify-content: flex-end; text-align: right; text-wrap: pretty; }

.story-ring .story-count-badge,
.stories-dock-ring .story-count-badge {
    position: absolute;
    z-index: 3;
    right: -4px;
    top: -3px;
    min-width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border: 2px solid #0d101d;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(145deg, #ab79f2, #6674df);
    box-shadow: 0 4px 10px rgba(54, 38, 137, 0.36);
    font-size: 0.46rem;
    font-weight: 800;
}

.stories-dock-ring {
    position: relative;
}

.stories-dock-ring .story-count-badge {
    right: -5px;
    top: -5px;
    transform: scale(0.86);
}

.story-viewer-owner > span {
    display: flex;
    align-items: center;
    gap: 7px;
}

.story-viewer-owner > span small + small::before {
    content: "•";
    margin-right: 7px;
    color: rgba(255, 255, 255, 0.34);
}

.story-viewer-loading {
    position: absolute;
    z-index: 5;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.68);
    background: rgba(5, 7, 15, 0.28);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    font-size: 0.62rem;
}

.story-viewer-loading i {
    font-size: 1.15rem;
}

.story-gesture-hint {
    position: absolute;
    z-index: 7;
    left: 50%;
    bottom: 74px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(7, 8, 15, 0.38);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    font-size: 0.55rem;
    white-space: nowrap;
    transform: translateX(-50%);
    transition: opacity 200ms ease, transform 200ms ease;
    animation: storyGestureHint 550ms 900ms both;
    pointer-events: none;
}

.story-gesture-hint.dismissed {
    opacity: 0;
    transform: translate(-50%, 5px);
}

@keyframes storyGestureHint {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

[data-theme="light"] .story-draft-state {
    border-color: rgba(5, 150, 105, 0.14);
    color: #287c62;
    background: rgba(16, 185, 129, 0.08);
}

[data-theme="light"] .story-text-style-field > legend,
[data-theme="light"] .story-media-style-field > legend,
[data-theme="light"] .story-style-row > div > span {
    color: #717481;
}

[data-theme="light"] .story-style-segmented,
[data-theme="light"] .story-duration-field {
    border-color: rgba(55, 47, 80, 0.1);
    background: rgba(70, 59, 102, 0.055);
}

[data-theme="light"] .story-style-segmented button,
[data-theme="light"] .story-duration-field > span small {
    color: #777985;
}

[data-theme="light"] .story-style-segmented button.active {
    color: #4e4089;
    border-color: rgba(115, 95, 211, 0.15);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(48, 41, 72, 0.06);
}

[data-theme="light"] .story-duration-field > span strong { color: #3c3d48; }
[data-theme="light"] .story-duration-field output { color: #59479f; }
[data-theme="light"] .story-ring .story-count-badge { border-color: #e9ebf1; }

@media (max-width: 768px) {
    .story-draft-state span { display: none; }
    .story-draft-state { width: 30px; justify-content: center; padding: 0; }
    .story-style-row { grid-template-columns: 1fr; }
    .story-duration-field { grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) 45px; }
    .story-gesture-hint { bottom: max(72px, calc(env(safe-area-inset-bottom) + 62px)); }
}

@media (max-width: 390px) {
    .story-duration-field { grid-template-columns: 1fr 44px; }
    .story-duration-field > span { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .story-gesture-hint { animation: none; }
}

/* Media selection is kept visible while the browser validates the local Blob. */
.story-upload-zone.is-reading .story-upload-icon {
    animation: storyMediaReading 900ms ease-in-out infinite alternate;
}

.story-upload-zone.is-reading .story-upload-action {
    color: rgba(196, 185, 239, 0.72);
}

.story-editor-overlay.publishing :is(
    .story-editor-close,
    .story-editor-cancel,
    .story-mode-tab,
    .story-upload-zone,
    .story-editor-controls input,
    .story-editor-controls textarea,
    .story-editor-controls button
) {
    pointer-events: none;
}

@keyframes storyMediaReading {
    from { transform: scale(0.96); box-shadow: 0 0 0 rgba(110, 231, 183, 0); }
    to { transform: scale(1.04); box-shadow: 0 0 0 5px rgba(110, 231, 183, 0.06); }
}

/* Immersive media viewer: blurred scene, useful controls and resilient states. */
@media (min-width: 769px) {
    .story-viewer-shell {
        width: min(470px, calc(100vw - 36px), calc((100dvh - 36px) * 0.5625));
        height: auto;
        aspect-ratio: 9 / 16;
    }
}

.story-viewer-backdrop {
    background:
        radial-gradient(circle at 18% 8%, rgba(128, 91, 231, 0.25), transparent 34%),
        radial-gradient(circle at 88% 88%, rgba(42, 151, 202, 0.17), transparent 32%),
        linear-gradient(145deg, rgba(8, 9, 18, 0.96), rgba(1, 2, 7, 0.985));
}

.story-viewer-shell {
    border-color: rgba(255, 255, 255, 0.18);
    background: #080a11;
    box-shadow:
        0 50px 150px rgba(0, 0, 0, 0.76),
        0 0 0 1px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.17);
}

.story-viewer-stage {
    isolation: isolate;
    touch-action: pan-y;
}

.story-viewer-stage.has-story-media::before {
    content: "";
    position: absolute;
    z-index: 0;
    inset: -42px;
    background-image:
        linear-gradient(rgba(8, 9, 16, 0.12), rgba(8, 9, 16, 0.12)),
        var(--story-media-backdrop, linear-gradient(145deg, #25203d, #090b14));
    background-position: center;
    background-size: cover;
    filter: blur(30px) saturate(1.18);
    opacity: 0.48;
    transform: scale(1.12);
    transition: opacity 220ms ease;
    pointer-events: none;
}

.story-viewer-stage.has-story-media::after {
    content: "";
    position: absolute;
    z-index: 2;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(2, 3, 8, 0.7) 0, rgba(2, 3, 8, 0.13) 19%, transparent 38%),
        linear-gradient(0deg, rgba(2, 3, 8, 0.72) 0, rgba(2, 3, 8, 0.13) 21%, transparent 39%),
        linear-gradient(90deg, rgba(0, 0, 0, 0.13), transparent 14%, transparent 86%, rgba(0, 0, 0, 0.13));
    pointer-events: none;
}

.story-viewer-stage.is-contain::before {
    opacity: 0.78;
}

.story-viewer-image,
.story-viewer-video {
    z-index: 1;
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 220ms ease, transform 300ms cubic-bezier(0.16, 1, 0.3, 1), filter 220ms ease;
    will-change: transform;
}

.story-viewer-stage.is-contain :is(.story-viewer-image, .story-viewer-video) {
    filter: drop-shadow(0 16px 38px rgba(0, 0, 0, 0.34));
}

.story-viewer-stage.is-loading > :is(.story-viewer-image, .story-viewer-video) {
    opacity: 0.22;
}

.story-viewer-stage.is-image:not(.is-zoomed) .story-viewer-image {
    cursor: zoom-in;
}

.story-viewer-stage.is-zoomed {
    touch-action: none;
}

.story-viewer-stage.is-zoomed .story-viewer-image {
    z-index: 3;
    cursor: zoom-out;
}

.story-viewer-stage.is-zoomed .story-nav {
    opacity: 0;
    pointer-events: none;
}

.story-viewer-stage.is-zoomed::after {
    opacity: 0.42;
}

.story-viewer-text {
    z-index: 3;
}

.story-progress {
    gap: 5px;
}

.story-progress-segment {
    height: 3.5px;
    background: rgba(255, 255, 255, 0.23);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
}

.story-progress-fill {
    background: linear-gradient(90deg, #fff, rgba(237, 232, 255, 0.96));
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.24);
}

.story-viewer-header {
    gap: 7px;
}

button.story-viewer-avatar {
    border: 1.5px solid rgba(255, 255, 255, 0.58);
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.story-viewer-tool {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(5, 7, 13, 0.27);
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    backdrop-filter: blur(18px) saturate(125%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.13);
    cursor: pointer;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.story-viewer-tool:hover,
.story-viewer-tool:focus-visible {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.13);
    transform: translateY(-1px);
}

.story-viewer-tool[hidden] {
    display: none;
}

.story-viewer-caption {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.story-playback-state {
    position: absolute;
    z-index: 8;
    top: 50%;
    left: 50%;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(5, 7, 13, 0.52);
    -webkit-backdrop-filter: blur(22px) saturate(130%);
    backdrop-filter: blur(22px) saturate(130%);
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-size: 0.62rem;
    font-weight: 680;
    opacity: 0;
    transform: translate(-50%, -44%) scale(0.92);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
}

.story-playback-state.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.story-playback-state[hidden] {
    display: none;
}

.story-viewer-loading {
    z-index: 8;
    gap: 11px;
    padding: 24px;
    color: rgba(255, 255, 255, 0.78);
    background: radial-gradient(circle at center, rgba(8, 10, 19, 0.42), rgba(5, 7, 15, 0.2) 48%, transparent 72%);
    text-align: center;
}

.story-viewer-loading > i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    background: rgba(7, 9, 17, 0.36);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.story-viewer-loading.is-error {
    background: rgba(5, 7, 14, 0.52);
}

.story-viewer-loading.is-error > i {
    color: #ffc08a;
    border-color: rgba(255, 181, 115, 0.2);
    background: rgba(245, 158, 88, 0.1);
}

.story-viewer-loading.is-error > span {
    max-width: 240px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.66rem;
    line-height: 1.45;
}

.story-viewer-loading.is-error button {
    min-height: 37px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 2px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    font: inherit;
    font-size: 0.61rem;
    font-weight: 670;
}

.story-viewer-loading.is-error button:hover,
.story-viewer-loading.is-error button:focus-visible {
    border-color: rgba(183, 164, 255, 0.3);
    background: rgba(139, 116, 225, 0.2);
}

.story-viewer-stage.is-manually-paused .story-progress-fill {
    box-shadow: 0 0 10px rgba(196, 184, 255, 0.34);
}

@media (max-width: 768px) {
    .story-viewer-header {
        right: 11px;
        left: 11px;
    }

    .story-viewer-tool,
    .story-viewer-close,
    .story-viewer-sound {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .story-viewer-caption {
        right: 12px;
        bottom: max(68px, calc(env(safe-area-inset-bottom) + 58px));
        left: 12px;
        max-height: min(126px, 22dvh);
    }

    .story-viewer-footer {
        right: 11px;
        bottom: max(10px, env(safe-area-inset-bottom));
        left: 11px;
    }

    .story-playback-state {
        top: 47%;
    }
}

@media (max-width: 360px) {
    .story-viewer-owner > span small + small {
        display: none;
    }

    .story-viewer-header {
        gap: 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .story-upload-zone.is-reading .story-upload-icon {
        animation: none;
    }

    .story-viewer-image,
    .story-viewer-video,
    .story-playback-state,
    .story-viewer-tool {
        transition: none;
    }
}
.stories-rail-actions{display:flex;align-items:center;gap:6px}.stories-rail-archive{width:32px;height:32px;display:grid;place-items:center;border:1px solid color-mix(in srgb,var(--border-color) 78%,transparent);border-radius:11px;color:var(--text-muted);background:color-mix(in srgb,var(--surface-2,#171722) 82%,transparent);cursor:pointer;transition:color .18s ease,transform .18s ease,background .18s ease}.stories-rail-archive:hover{color:var(--purple,#8b7cf6);background:color-mix(in srgb,var(--purple,#8b7cf6) 12%,transparent);transform:translateY(-1px)}
