:root {
    --ios-blur: blur(20px);
    --ios-glass: rgba(255, 255, 255, 0.12);
    --ios-border: rgba(255, 255, 255, 0.1);
    --accent: #ffffff;
    
    /* Feed-specific variables */
    --bg: #050505;
    --surface: rgba(255, 255, 255, 0.045);
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.48);
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-soft: cubic-bezier(0.25, 1, 0.5, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* --- Premium Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

body {
    background-color: #000;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    color: #fff;
    margin: 0;
    padding: 0;
}

/* Main Viewport Container */
#viewport-wrapper {
    position: relative;
    width: 95%;
    max-width: 440px;
    aspect-ratio: 3 / 4;
    max-height: calc(100dvh - 200px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    background: #111;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 0 1px var(--ios-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    /* Mirror for selfie */
    transition: opacity 0.4s ease, filter 0.4s ease;
}

/* Viewport Overlays */
.viewport-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    z-index: 5;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, transparent 15%, transparent 75%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
}

.viewport-overlay>* {
    pointer-events: auto;
}

.top-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quality-tag {
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    border: 0.5px solid rgba(255, 255, 255, 0.2);
}

.bottom-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    width: 100%;
}

.zoom-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 14px;
    border-radius: 18px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#zoom-slider {
    -webkit-appearance: none;
    width: 100px;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    outline: none;
}

#zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    border: 2px solid #fff;
}

.camera-actions {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}

.shutter-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shutter-outer {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 4px solid #fff;
    padding: 3px;
}

.shutter-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #fff;
    transition: all 0.2s ease;
}

.shutter-outer:active {
    transform: scale(0.9);
}

.shutter-outer:active .shutter-inner {
    transform: scale(0.8);
    background-color: rgba(255, 255, 255, 0.9);
}

.side-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;
}

.side-btn:active {
    transform: scale(0.85);
    background: rgba(255, 255, 255, 0.2);
}

.side-btn i {
    width: 20px;
    height: 20px;
}

/* Flash & Status */
#flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
}

@keyframes flashAnim {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.flash-active {
    animation: flashAnim 0.3s ease-out;
}

#status-msg {
    position: fixed;
    top: calc(90px + env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 24px;
    border-radius: 30px;
    color: #000;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 100;
    display: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: springIn 0.3s ease-out;
}

@keyframes springIn {
    from {
        transform: translateY(-50px) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Review State UI */
.review-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 20;
    display: none;
    flex-direction: column;
}

#review-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.review-ui {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 25px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

#caption-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 12px 16px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
}

#caption-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.post-btn {
    background: #fff;
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.post-btn:active {
    transform: scale(0.95);
}

.post-btn i {
    width: 16px;
    height: 16px;
}

.cancel-review-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30;
}

/* Mobile specific adjustments */
@media (max-height: 700px) {
    #viewport-wrapper {
        width: 85%;
    }

    .shutter-outer {
        width: 64px;
        height: 64px;
    }
}

/* ─── Unified Screen Layout ─── */
#app-container {
    width: 100%;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}

#camera-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: calc(80px + env(safe-area-inset-top)) 10px calc(100px + env(safe-area-inset-bottom)) 10px;
    z-index: 10;
    transform: translateY(0);
    opacity: 1;
}

#feed-screen {
    z-index: 20;
    transform: translateY(100%);
    background-color: #000;
    display: flex;
    flex-direction: column;
    padding: calc(80px + env(safe-area-inset-top)) 0 calc(100px + env(safe-area-inset-bottom)) 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#app-container.view-feed #camera-screen {
    transform: translateY(-25%) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

#app-container.view-feed #feed-screen {
    transform: translateY(0);
    opacity: 1;
}

/* ─── Swipe Up Indicator ─── */
.feed-swipe-indicator {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 6px 16px 6px 10px;
    border-radius: 24px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.23s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.feed-swipe-indicator:active {
    transform: scale(0.94);
    background: rgba(255, 255, 255, 0.16);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.feed-swipe-indicator.has-new {
    animation: pillGlow 3s infinite ease-in-out;
}

@keyframes pillGlow {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 0 4px rgba(255, 252, 0, 0.1);
        border-color: rgba(255, 255, 255, 0.12);
        background: rgba(255, 255, 255, 0.08);
    }
    50% {
        box-shadow: 0 4px 22px rgba(255, 252, 0, 0.2), 0 0 12px rgba(255, 252, 0, 0.35);
        border-color: rgba(255, 252, 0, 0.55);
        background: rgba(255, 252, 0, 0.04);
    }
}

.feed-preview-thumbnails {
    display: flex;
    align-items: center;
    position: relative;
    height: 24px;
    width: 36px;
}

.feed-preview-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid #000;
    position: absolute;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    background: #111;
    transition: transform 0.2s ease;
}

.feed-preview-thumbnails:hover .feed-preview-thumb {
    transform: scale(1.08);
}

.feed-preview-thumb:nth-child(1) {
    left: 0;
    z-index: 1;
}

.feed-preview-thumb:nth-child(2) {
    left: 12px;
    z-index: 2;
}

.swipe-text-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.feed-swipe-indicator i {
    width: 14px;
    height: 14px;
    stroke-width: 2.5px;
    animation: swipeUpBounce 1.5s infinite;
}

@keyframes swipeUpBounce {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

/* ─── Pull Down Handle ─── */
.feed-pull-down {
    width: 100%;
    padding: 12px 0 16px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: transparent;
    user-select: none;
    flex-shrink: 0;
    gap: 6px;
}

.feed-pull-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

.feed-pull-text {
    font-size: 10px;
    color: var(--muted);
    font-weight: 500;
}

.feed-pull-down:hover .feed-pull-handle {
    background: rgba(255, 255, 255, 0.4);
}

.feed-pull-down:active .feed-pull-handle {
    transform: scaleX(1.2);
}

/* ─── Feed Container ─── */
.feed-container {
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
    padding: 10px 14px;
}

/* ─── Post Card ─── */
.post-card {
    background: var(--surface);
    border-radius: 24px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--ios-border);
    animation: cardIn 0.45s var(--spring-soft) both;
    opacity: 0;
    contain: layout style;
    transition: transform 0.18s var(--spring), box-shadow 0.18s ease;
    cursor: default;
}

.post-card:active {
    transform: scale(0.985);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Post Header ─── */
.post-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a1a1a;
    border: 1.5px solid var(--ios-border);
    object-fit: cover;
    transition: transform 0.2s var(--spring);
}
.user-avatar:active { transform: scale(0.9); }

.username {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: -0.1px;
}

.post-time {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 400;
    margin-top: 1px;
}

/* ─── Post Image ─── */
.post-image {
    width: 100%;
    background-color: #0a0a0a;
    position: relative;
    overflow: hidden;
    aspect-ratio: 3 / 4;
}

.post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: translateZ(0);
}

/* ─── Post Content ─── */
.post-content {
    padding: 12px 16px 16px;
}

.post-text {
    font-size: 0.9rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.85);
}

.post-text .author {
    font-weight: 700;
    margin-right: 6px;
    color: #fff;
}

.post-text .caption { font-weight: 400; }

/* ─── Loading ─── */
.loading-text {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ─── Like Button ─── */
@keyframes heartBurst {
    0%  { transform: scale(1);   opacity: 1; fill: none; }
    40% { transform: scale(1.7); opacity: 1; fill: #ff3b30; color: #ff3b30; }
    70% { transform: scale(2.2); opacity: 0.6; }
    100%{ transform: scale(2.5); opacity: 0; }
}

.anim-burst {
    animation: heartBurst 0.38s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    pointer-events: none;
    color: #ff3b30;
}

.like-text {
    font-weight: 700;
    color: #ff3b30;
    font-size: 0.88rem;
}

@keyframes likePop {
    0%  { transform: translateY(6px) scale(0.8); opacity: 0; }
    60% { transform: translateY(-2px) scale(1.08); opacity: 1; }
    100%{ transform: translateY(0) scale(1); opacity: 1; }
}

.like-text.just-liked {
    animation: likePop 0.4s var(--spring) forwards;
}

/* ─── Bottom Sheet Modals ─── */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sheet-overlay.active {
    display: block;
    opacity: 1;
}
.sheet-content {
    position: fixed;
    bottom: calc(90px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    background: rgba(18, 18, 18, 0.95);
    border-radius: 24px;
    padding: 20px;
    z-index: 1001;
    transform: translateY(150%);
    transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
    max-width: 420px;
    margin: 0 auto;
    border: 1px solid var(--ios-border);
    max-height: calc(75vh - 90px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.sheet-content.active {
    transform: translateY(0);
}
.sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: -8px auto 16px;
    flex-shrink: 0;
}
.sheet-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
    flex-shrink: 0;
}
.comments-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}
.comment-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: commentIn 0.3s var(--spring-soft) both;
}
@keyframes commentIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--ios-border);
    background: #1a1a1a;
}
.comment-body {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid var(--ios-border);
}
.comment-user {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 3px;
    color: #fff;
}
.comment-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}
.comment-time {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 4px;
    display: block;
}
.comment-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--ios-border);
    border-radius: 20px;
    padding: 6px 6px 6px 14px;
    margin-top: auto;
    flex-shrink: 0;
}
.comment-input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    padding: 8px 0;
    font-family: inherit;
}
.comment-input-wrapper button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s var(--spring);
}
.comment-input-wrapper button:active {
    transform: scale(0.88);
}
body.no-scroll {
    overflow: hidden;
}

/* Style for comment count icon button */
.comment-action-btn {
    cursor: pointer;
    width: 24px;
    transition: transform 0.2s var(--spring);
}
.comment-action-btn:active {
    transform: scale(0.82);
}
.comment-count-text {
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 500;
    margin-left: 2px;
}

.reply-tag {
    color: #3897f0;
    font-weight: 600;
    margin-right: 4px;
    cursor: pointer;
}
