* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    background: #101010;
    color: #f2f2f2;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

a {
    color: inherit;
}

.page-header {
    padding: 24px;
    background: #151515;
    border-bottom: 1px solid #2a2a2a;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    color: #aaa;
    font-size: 14px;
    text-decoration: none;
}

.back-link:hover {
    color: #f2f2f2;
}

.page-header p {
    margin: 6px 0 0;
    color: #999;
}

.page-content {
    padding: 24px;
}

.gallery {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.story-card {
    overflow: hidden;
    background: #191919;
    border: 1px solid #2b2b2b;
    border-radius: 12px;
}

.media-container {
    background: #000;
}

.media-container a {
    display: block;
}

.story-media {
    display: block;
    width: 100%;
    height: 420px;
    object-fit: contain;
    background: #000;
}

.story-details {
    padding: 14px;
}

.username {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.username a {
    text-decoration: none;
}

.username a:hover {
    text-decoration: underline;
}

.metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: #999;
    font-size: 13px;
}

.metadata a {
    color: #d3d3d3;
}

.missing-media {
    display: grid;
    min-height: 300px;
    place-items: center;
    background: #080808;
    color: #777;
}

.empty-state {
    padding: 48px 24px;
    color: #888;
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-link {
    display: inline-grid;
    min-width: 38px;
    min-height: 38px;
    padding: 8px;
    place-items: center;
    border: 1px solid #343434;
    border-radius: 8px;
    background: #191919;
    color: #d3d3d3;
    text-decoration: none;
}

a.pagination-link:hover {
    border-color: #666;
    background: #252525;
}

.pagination-link.active {
    border-color: #f2f2f2;
    background: #f2f2f2;
    color: #101010;
    font-weight: 600;
}

.pagination-link.disabled {
    color: #666;
    cursor: default;
}

.pagination-direction {
    min-width: 88px;
}

.pagination-ellipsis {
    padding: 0 3px;
    color: #777;
}

.story-update-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10;
    max-width: min(320px, calc(100vw - 32px));
    padding: 12px 16px;
    border: 1px solid #4b4b4b;
    border-radius: 10px;
    background: #f2f2f2;
    box-shadow: 0 8px 28px rgb(0 0 0 / 35%);
    color: #101010;
    font-size: 14px;
    font-weight: 600;
    animation: toast-in 180ms ease-out;
}

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

.story-update-toast.is-hiding {
    animation: toast-out 200ms ease-in forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (max-width: 600px) {
    .page-header,
    .page-content {
        padding: 16px;
    }

    .gallery {
        grid-template-columns: 1fr;
    }

    .story-media {
        height: auto;
        max-height: 75vh;
    }

    .pagination {
        align-items: stretch;
        gap: 8px;
    }

    .pagination-pages {
        display: none;
    }

    .pagination-direction {
        min-width: 0;
        flex: 1;
    }

    .story-update-toast {
        right: 16px;
        bottom: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .story-update-toast,
    .story-update-toast.is-hiding {
        animation: none;
    }

    .story-update-toast.is-hiding {
        opacity: 0;
    }
}
