:root {
    --background: #070910;
    --surface: #10121d;
    --surface-light: #171a29;
    --border: #292c3e;
    --text: #f4f4fa;
    --muted: #9699ae;
    --purple: #a855f7;
    --pink: #d400ff;
    --blue: #5900ff;
}

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

html,
body {
    width: 100%;
    height: 100%;
}

body {
    overflow: hidden;
    color: var(--text);
    background: var(--background);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

/* Header */

.viewer-header-bar {
    position: relative;
    z-index: 50;

    height: 64px;
    padding: 0 25px;

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

    background: rgba(7, 9, 16, 0.97);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.logo {
    flex-shrink: 0;

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

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

.header-link {
    margin-left: auto;
    color: #c4c5d3;
    font-size: 12px;
}

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

.source-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.source-controls select,
.source-controls input {
    height: 36px;
    padding: 0 10px;

    color: #e6e6f2;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;

    outline: none;
    font-size: 11px;
}

.source-controls select:focus,
.source-controls input:focus {
    border-color: var(--purple);
}

.source-controls input {
    width: 95px;
}

.source-controls input[hidden] {
    display: none;
}

.source-controls button {
    height: 36px;
    padding: 0 14px;

    color: white;
    background: linear-gradient(120deg, #a855f7, #5900ff);
    border: none;
    border-radius: 8px;

    font-size: 11px;
    cursor: pointer;
}

/* Scroll container */

#post-scroller {
    width: 100%;
    height: calc(100dvh - 64px);

    overflow-x: hidden;
    overflow-y: auto;

    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;

    scrollbar-width: none;
    -ms-overflow-style: none;

    overflow-anchor: none;
}

#post-scroller::-webkit-scrollbar {
    display: none;
}

/* Each post occupies one complete viewport */

.post-slide {
    width: 100%;
    height: 100%;
    min-height: 100%;

    padding: 14px 24px;

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

    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.post-frame {
    width: min(1250px, 100%);
    height: 100%;
    max-height: 820px;
    min-height: 0;

    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.75fr);

    overflow: hidden;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;

    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.25);
}

/* Main image */

.post-media {
    position: relative;
    min-width: 0;
    min-height: 0;

    overflow: hidden;

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

    background: #05060b;
}

.post-image {
    width: 100%;
    height: 100%;

    object-fit: contain;
    object-position: center;
}

.media-top {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;

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

    pointer-events: none;
}

.media-brand {
    padding: 7px 10px;

    color: white;
    background: rgba(7, 9, 16, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;

    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1.5px;

    backdrop-filter: blur(10px);
}

.media-post-id {
    color: rgba(255, 255, 255, 0.8);
    font-size: 10px;
    text-shadow: 0 1px 6px black;
}

.media-bottom {
    position: absolute;
    right: 23px;
    bottom: 24px;
    left: 23px;

    pointer-events: none;

    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.95);
}

.media-bottom h2 {
    font-size: clamp(20px, 2.5vw, 29px);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.media-bottom p {
    max-width: 510px;
    margin-top: 9px;

    color: #e2e2eb;
    font-size: 12px;
    line-height: 1.6;

    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Right panel */

.post-panel {
    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    background: var(--surface);
}

.post-author {
    min-height: 75px;
    padding: 16px;

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

    border-bottom: 1px solid var(--border);
}

.author-link {
    min-width: 0;
    flex: 1;

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

.author-avatar {
    width: 41px;
    height: 41px;
    flex-shrink: 0;

    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--purple);
}

.author-details {
    min-width: 0;
}

.author-details strong {
    display: block;

    font-size: 12px;
    overflow-wrap: anywhere;
}

.author-details small {
    display: block;
    margin-top: 5px;

    color: var(--muted);
    font-size: 10px;
}

.follow-btn {
    padding: 8px 11px;
    flex-shrink: 0;

    color: #e2ceff;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;

    font-size: 10px;
    cursor: pointer;
}

.follow-btn.following {
    color: #c6c8d6;
    background: #202333;
    border-color: #35394e;
}

.follow-btn[hidden] {
    display: none;
}

/* Title, caption, tags */

.post-caption {
    padding: 19px 17px 15px;
}

.post-caption h3 {
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.post-caption p {
    margin-top: 9px;

    color: #c0c2d1;
    font-size: 12px;
    line-height: 1.7;

    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;

    margin-top: 12px;
}

.post-tags span {
    padding: 5px 8px;

    color: #cda8fa;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 6px;

    font-size: 10px;
}

/* Actions */

.post-actions {
    padding: 13px 16px;

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

    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.action-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    color: var(--muted);
    font-size: 11px;
}

.action-button {
    width: 30px;
    height: 30px;

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

    color: #d3d4e2;
    background: transparent;
    border: none;
    border-radius: 8px;

    font-size: 23px;
    cursor: pointer;

    transition: background 0.15s, color 0.15s;
}

.action-button:hover {
    color: #d5a5ff;
    background: rgba(168, 85, 247, 0.1);
}

.action-button.liked {
    color: #ff4fa1;
}

.action-button.saved {
    color: #c084fc;
}

/* Comments */

.comments-heading {
    padding: 15px 17px 5px;

    color: #e0e1eb;
    font-size: 11px;
    font-weight: 800;
}

.comments-list {
    min-height: 0;
    flex: 1;

    overflow: hidden;
    padding: 5px 17px 12px;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 13px;
}

.no-comments {
    margin-top: 10px;

    color: #7d8198;
    font-size: 11px;
    line-height: 1.6;
}

.comment-item {
    display: flex;
    align-items: flex-start;
    gap: 9px;

    min-width: 0;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;

    object-fit: cover;
    border-radius: 50%;
}

.comment-body {
    min-width: 0;
    flex: 1;
}

.comment-body p {
    color: #d4d5e2;
    font-size: 11px;
    line-height: 1.6;

    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.comment-body strong {
    margin-right: 5px;
    color: white;
    font-weight: 750;
}

.comment-body time {
    display: block;
    margin-top: 5px;

    color: #71758a;
    font-size: 9px;
}

/* Comment form */

.comment-form {
    padding: 12px;

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

    border-top: 1px solid var(--border);
}

.comment-input {
    min-width: 0;
    flex: 1;
    height: 38px;
    padding: 0 11px;

    color: white;
    background: #0a0c14;
    border: 1px solid #292c3e;
    border-radius: 9px;

    outline: none;
    font-size: 11px;
}

.comment-input:focus {
    border-color: var(--purple);
}

.comment-input::placeholder {
    color: #777b91;
}

.comment-submit {
    height: 38px;
    padding: 0 12px;

    color: white;
    background: linear-gradient(120deg, #a855f7, #5900ff);
    border: none;
    border-radius: 9px;

    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
}

.comment-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.post-time {
    padding: 0 15px 12px;

    color: #74788d;
    font-size: 9px;
}

/* Loading and empty states */

.feed-message {
    width: 100%;
    height: 100%;
    min-height: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;

    color: var(--muted);
    text-align: center;
    font-size: 12px;
}

.feed-message h2 {
    color: white;
    font-size: 20px;
}

.feed-message p {
    max-width: 310px;
    margin-top: 8px;
    line-height: 1.7;
}

.loading-spinner {
    width: 30px;
    height: 30px;

    border: 3px solid #272a3a;
    border-top-color: var(--purple);
    border-radius: 50%;

    animation: spin 0.8s linear infinite;
}

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

/* Responsive */

@media (max-width: 850px) {
    .viewer-header-bar {
        padding: 0 15px;
        gap: 15px;
    }

    .post-slide {
        padding: 9px;
    }

    .post-frame {
        grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    }

    .post-actions {
        gap: 10px;
    }

    .post-caption {
        padding: 14px;
    }

    .comments-list {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (max-width: 620px) {
    .viewer-header-bar {
        height: 60px;
        padding: 0 12px;
        gap: 10px;
    }

    .logo {
        font-size: 20px;
    }

    .header-link {
        display: none;
    }

    .source-controls {
        flex: 1;
        justify-content: flex-end;
        gap: 5px;
    }

    .source-controls select {
        min-width: 0;
        width: 115px;
        padding: 0 5px;
        font-size: 10px;
    }

    .source-controls input {
        width: 72px;
    }

    .source-controls button {
        padding: 0 9px;
    }

    #post-scroller {
        height: calc(100dvh - 60px);
    }

    .post-slide {
        padding: 0;
    }

    .post-frame {
        width: 100%;
        height: 100%;
        max-height: none;

        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(220px, 44%) minmax(0, 1fr);

        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .post-media {
        grid-row: 1;
    }

    .post-image {
        object-fit: contain;
    }

    .media-top {
        top: 10px;
        left: 12px;
        right: 12px;
    }

    .media-bottom {
        right: 15px;
        bottom: 14px;
        left: 15px;
    }

    .media-bottom h2 {
        font-size: 18px;
    }

    .media-bottom p {
        margin-top: 5px;
        font-size: 10px;
        -webkit-line-clamp: 2;
    }

    .post-panel {
        grid-row: 2;
        min-height: 0;
    }

    .post-author {
        min-height: 57px;
        padding: 8px 12px;
        gap: 8px;
    }

    .author-avatar {
        width: 34px;
        height: 34px;
    }

    .author-details strong {
        font-size: 11px;
    }

    .author-details small {
        font-size: 9px;
    }

    .follow-btn {
        padding: 7px 9px;
    }

    .post-caption {
        padding: 9px 12px 10px;
    }

    .post-caption h3 {
        font-size: 12px;
    }

    .post-caption p {
        margin-top: 4px;
        font-size: 10px;
        line-height: 1.5;
    }

    .post-tags {
        margin-top: 7px;
        gap: 5px;
    }

    .post-tags span {
        padding: 4px 6px;
        font-size: 9px;
    }

    .post-actions {
        padding: 7px 12px;
        gap: 15px;
    }

    .action-button {
        width: 27px;
        height: 27px;
        font-size: 21px;
    }

    .comments-heading {
        padding: 8px 12px 2px;
        font-size: 10px;
    }

    .comments-list {
        padding: 5px 12px 7px;
        gap: 8px;
    }

    .comment-avatar {
        width: 24px;
        height: 24px;
    }

    .comment-body p {
        font-size: 10px;
    }

    .comment-body time {
        margin-top: 2px;
        font-size: 8px;
    }

    .comment-form {
        padding: 7px 10px;
    }

    .comment-input,
    .comment-submit {
        height: 34px;
        font-size: 10px;
    }

    .post-time {
        padding: 0 12px 6px;
        font-size: 8px;
    }
}

@media (max-height: 650px) and (min-width: 621px) {
    .post-slide {
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .post-frame {
        max-height: 100%;
    }

    .post-author {
        min-height: 57px;
        padding: 9px 13px;
    }

    .post-caption {
        padding: 10px 13px;
    }

    .post-caption p {
        margin-top: 5px;
    }

    .post-actions {
        padding: 7px 13px;
    }

    .comments-heading {
        padding-top: 8px;
    }

    .comment-form {
        padding: 7px 10px;
    }

    .comment-input,
    .comment-submit {
        height: 32px;
    }
}