:root {
    --background: #070910;
    --surface: #10121d;
    --surface-hover: #191c2a;
    --border: #25283a;
    --text: #f4f4fa;
    --muted: #9295aa;
    --purple: #a855f7;
    --pink: #d400ff;
    --blue: #5900ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

body.viewer-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}


/* Header */

.stories-header {
    position: sticky;
    top: 0;
    z-index: 50;

    width: 100%;
    height: 76px;
    padding: 0 5%;

    display: flex;
    align-items: center;
    gap: 40px;

    background: rgba(7, 9, 16, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(20px);
}

.logo {
    flex-shrink: 0;

    font-size: 25px;
    font-weight: 900;
    letter-spacing: 2px;

    background: linear-gradient(135deg, #d400ff, #5900ff);
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
}

.header-search {
    flex: 1;
    max-width: 500px;
    height: 42px;
    padding: 0 14px;

    display: flex;
    align-items: center;
    gap: 12px;

    border: 1px solid var(--border);
    border-radius: 10px;
    background: #11131e;

    transition: border-color 0.2s;
}

.header-search:focus-within {
    border-color: var(--purple);
}

.header-search svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;

    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
}

.header-search input {
    width: 100%;
    min-width: 0;
    height: 100%;

    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
}

.header-search input::placeholder {
    color: #777b90;
}

.header-actions {
    margin-left: auto;

    display: flex;
    align-items: center;
    gap: 22px;
}

.header-actions a {
    color: #c4c5d2;
    font-size: 13px;
    transition: color 0.2s;
}

.header-actions a:hover {
    color: var(--purple);
}

.header-actions .profile-link {
    display: flex;
}

.profile-link img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--purple);
}


/* Page */

.stories-page {
    width: min(1320px, 100%);
    margin: 0 auto;
    padding: 45px 28px 70px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 35px;
}

.eyebrow {
    margin-bottom: 10px;
    color: var(--purple);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
}

.page-heading h1 {
    font-size: clamp(28px, 4vw, 38px);
    letter-spacing: -1px;
}

.subtitle {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.create-story-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 12px 17px;

    color: white;
    background: linear-gradient(120deg, #d400ff, #5900ff);
    border-radius: 10px;

    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;

    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.create-story-btn:hover {
    transform: translateY(-2px);
}

.create-story-btn span {
    font-size: 21px;
    line-height: 1;
}


/* Filters */

.story-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    margin-bottom: 24px;
}

.story-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.filter-btn {
    padding: 10px 17px;
    flex-shrink: 0;

    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;

    font-size: 12px;
    cursor: pointer;

    transition: 0.2s;
}

.filter-btn:hover {
    color: white;
    background: var(--surface-hover);
}

.filter-btn.active {
    color: #e9d5ff;
    background: rgba(168, 85, 247, 0.13);
    border-color: rgba(168, 85, 247, 0.3);
}

#story-count {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 12px;
}


/* Stories grid */

.stories-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.story-card {
    position: relative;
    display: block;

    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;

    padding: 0;

    background: var(--surface);
    border: 1px solid #292b3a;
    border-radius: 15px;

    text-align: left;
    cursor: pointer;

    isolation: isolate;
    transition: transform 0.25s, border-color 0.25s;
}

.story-card:hover {
    transform: translateY(-4px);
    border-color: #8249b9;
}

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

.story-cover {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;

    transition: transform 0.5s;
}

.story-card:hover .story-cover {
    transform: scale(1.06);
}

.story-gradient {
    position: absolute;
    inset: 0;
    z-index: 1;

    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.28) 0%,
        transparent 30%,
        transparent 48%,
        rgba(0, 0, 0, 0.78) 100%
    );
}

.story-user {
    position: absolute;
    top: 15px;
    left: 15px;

    width: 46px;
    height: 46px;

    z-index: 2;
}

.story-user img {
    width: 100%;
    height: 100%;
    object-fit: cover;

    border-radius: 50%;
    border: 3px solid #10121d;
}

.story-ring {
    position: absolute;
    inset: -4px;

    border: 2px solid transparent;
    border-radius: 50%;

    background:
        linear-gradient(#10121d, #10121d) padding-box,
        linear-gradient(135deg, #d400ff, #5900ff, #ff65c5) border-box;

    pointer-events: none;
}

.story-card-info {
    position: absolute;
    left: 17px;
    right: 12px;
    bottom: 17px;

    display: flex;
    flex-direction: column;
    gap: 6px;

    z-index: 2;
    color: white;
}

.story-card-info b {
    font-size: 14px;
    overflow-wrap: anywhere;
}

.story-card-info small {
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
}

.story-live-dot {
    position: absolute;
    top: 18px;
    right: 17px;
    z-index: 2;

    width: 8px;
    height: 8px;

    border-radius: 50%;
    background: #c084fc;
    box-shadow: 0 0 12px rgba(192, 132, 252, 0.7);
}


/* Empty state */

.empty-state {
    padding: 70px 20px;
    text-align: center;
}

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

.empty-state h2 {
    font-size: 21px;
}

.empty-state p {
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}


/* Story viewer overlay */

.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 200;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 0.22s, visibility 0.22s;
}

.story-viewer.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
}

.viewer-container {
    position: relative;
    z-index: 1;

    width: min(430px, 100%);
    height: min(790px, calc(100dvh - 40px));

    overflow: hidden;
    background: #11121b;
    border: 1px solid #343144;
    border-radius: 16px;

    box-shadow: 0 25px 100px rgba(0, 0, 0, 0.5);

    transform: scale(0.97);
    transition: transform 0.22s;
}

.story-viewer.active .viewer-container {
    transform: scale(1);
}

.viewer-image {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: contain;
    background: #080910;
}

.viewer-progress {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;

    height: 3px;
    z-index: 5;

    overflow: hidden;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.3);
}

#viewer-progress-fill {
    width: 0;
    height: 100%;

    background: white;
    border-radius: 10px;
}

.viewer-header {
    position: absolute;
    top: 22px;
    left: 15px;
    right: 15px;
    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.viewer-author {
    display: flex;
    align-items: center;
    gap: 10px;

    min-width: 0;
    color: white;
}

.viewer-author > img {
    width: 39px;
    height: 39px;
    flex-shrink: 0;

    object-fit: cover;
    border: 2px solid #d400ff;
    border-radius: 50%;
}

.viewer-author b,
.viewer-author small {
    display: block;
    overflow-wrap: anywhere;
}

.viewer-author b {
    font-size: 13px;
}

.viewer-author small {
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
}

.viewer-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;

    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;

    font-size: 25px;
    line-height: 1;

    cursor: pointer;
}

.viewer-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.viewer-nav {
    position: absolute;
    top: 50%;
    z-index: 5;

    width: 38px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    transform: translateY(-50%);

    border: 1px solid rgba(255, 255, 255, 0.17);
    border-radius: 10px;

    background: rgba(0, 0, 0, 0.35);
    color: white;

    font-size: 34px;
    line-height: 1;

    cursor: pointer;
    transition: background 0.2s;
}

.viewer-nav:hover {
    background: rgba(168, 85, 247, 0.65);
}

.viewer-prev {
    left: 12px;
}

.viewer-next {
    right: 12px;
}

.viewer-footer {
    position: absolute;
    right: 15px;
    bottom: 15px;
    left: 15px;

    z-index: 5;

    display: flex;
    justify-content: space-between;
    gap: 10px;

    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;

    text-shadow: 0 1px 5px black;
}


/* Responsive */

@media (max-width: 1000px) {
    .stories-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }

    .stories-header {
        gap: 25px;
        padding: 0 25px;
    }
}

@media (max-width: 700px) {
    .stories-header {
        height: auto;
        min-height: 70px;

        flex-wrap: wrap;
        gap: 14px;

        padding: 14px 18px;
    }

    .logo {
        font-size: 22px;
    }

    .header-actions {
        gap: 14px;
    }

    .header-actions a {
        font-size: 12px;
    }

    .header-search {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }

    .stories-page {
        padding: 30px 16px 50px;
    }

    .page-heading {
        align-items: flex-start;
    }

    .page-heading h1 {
        font-size: 29px;
    }

    .subtitle {
        font-size: 12px;
    }

    .create-story-btn {
        padding: 11px;
        font-size: 11px;
    }

    .create-story-btn span {
        font-size: 17px;
    }

    .stories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .story-user {
        top: 12px;
        left: 12px;

        width: 40px;
        height: 40px;
    }

    .story-card-info {
        left: 12px;
        bottom: 12px;
    }

    .story-card-info b {
        font-size: 12px;
    }

    .story-card-info small {
        font-size: 10px;
    }
}

@media (max-width: 380px) {
    .header-actions {
        gap: 10px;
    }

    .header-actions a {
        font-size: 11px;
    }

    .story-filters {
        gap: 2px;
    }

    .filter-btn {
        padding: 9px 10px;
        font-size: 11px;
    }

    #story-count {
        font-size: 10px;
    }
}