:root {
    --primary-color: #ff9a9e;
    --secondary-color: #fecfef;
    --bg-color: #050508;
    --text-color: #ffffff;
    --nav-height: 48px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    min-height: 100%;
    background: var(--bg-color);
    color: var(--text-color);
}

body {
    overflow-x: hidden;
}

body.feed-page {
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: pan-y;
}

::-webkit-scrollbar {
    width: 0;
    height: 0;
    background: transparent;
}

/* 顶部导航 */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: linear-gradient(to bottom, rgba(0,0,0,.72), rgba(0,0,0,.08));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: env(safe-area-inset-top) 16px 0;
    z-index: 10020;
    border-bottom: 0;
    pointer-events: none;
}

.nav-brand,
.nav-links {
    pointer-events: auto;
}

.nav-brand {
    font-size: 19px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    text-shadow: 0 2px 10px rgba(0,0,0,.65);
}

.nav-links {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.nav-links a {
    color: rgba(255,255,255,.9);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 9px;
    border-radius: 15px;
    background: rgba(0,0,0,.18);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* 短视频主容器 */
.short-video-app {
    position: relative;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    background: #000;
}

.video-feed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    background: #000;
}

.video-slide {
    position: relative;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    background: #000;
    touch-action: pan-y;
    isolation: isolate;
}

.feed-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    background: #000;
    transform: translateZ(0);
    will-change: opacity;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}


.video-slide.media-released::after {
    content: "正在恢复视频…";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    font-size: 13px;
    color: rgba(255,255,255,.75);
    background: rgba(0,0,0,.35);
    padding: 7px 11px;
    border-radius: 14px;
}

.video-shade {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(0,0,0,.28) 0%, transparent 18%, transparent 64%, rgba(0,0,0,.42) 100%);
}

.video-line-badge {
    position: absolute;
    left: 12px;
    bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
    z-index: 3;
    max-width: 55vw;
    padding: 5px 9px;
    border-radius: 12px;
    background: rgba(0,0,0,.28);
    color: rgba(255,255,255,.78);
    font-size: 11px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
}

/* 左上角统计 */
.top-bar {
    position: fixed;
    top: calc(var(--nav-height) + env(safe-area-inset-top) + 5px);
    left: 8px;
    z-index: 10015;
    display: flex;
    gap: 5px;
    pointer-events: none;
}

.top-bar .stats-item {
    background: rgba(0,0,0,.42);
    padding: 4px 7px;
    border-radius: 14px;
    font-size: 10px;
    color: rgba(255,255,255,.88);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    border: 1px solid rgba(255,255,255,.08);
}

/* 线路切换 */
.api-switcher-wrap {
    position: fixed;
    top: calc(var(--nav-height) + env(safe-area-inset-top) + 5px);
    right: 8px;
    z-index: 10015;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,.42);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 4px 7px;
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.api-switcher-label {
    font-size: 10px;
    color: rgba(255,255,255,.7);
}

.api-selector {
    max-width: 150px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
}

.api-selector option {
    color: #111;
    background: #fff;
}

.api-selector:disabled {
    opacity: .65;
}

/* 右侧操作 */
.right-actions {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(68px, calc(env(safe-area-inset-bottom) + 54px));
    z-index: 10012;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.action-btn {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(20,20,25,.42);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    transition: transform .18s ease, background .18s ease;
    font-size: 17px;
}

.action-btn:active,
.action-btn.tap-pop {
    transform: scale(1.18);
}

.action-btn.next-btn {
    background: rgba(255, 103, 132, .68);
}

.action-text {
    margin-top: 1px;
    font-size: 8px;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
}

.auto-play-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 5px;
    border-radius: 13px;
    background: rgba(20,20,25,.42);
    border: 1px solid rgba(255,255,255,.14);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

.toggle-text {
    font-size: 8px;
    color: rgba(255,255,255,.9);
}

.switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 16px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: rgba(200,200,205,.45);
    transition: .2s;
}

.slider::before {
    position: absolute;
    content: "";
    width: 12px;
    height: 12px;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    background: #fff;
    transition: .2s;
}

input:checked + .slider {
    background: rgba(255, 103, 132, .82);
}

input:checked + .slider::before {
    transform: translateX(14px);
}

.gesture-tip {
    position: fixed;
    left: 50%;
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
    transform: translate(-50%, 10px);
    z-index: 10016;
    max-width: 82vw;
    padding: 7px 12px;
    border-radius: 16px;
    background: rgba(0,0,0,.48);
    color: rgba(255,255,255,.92);
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gesture-tip.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* 中间播放按钮：专门解决 iOS/Safari 自动播放被拦截时“点哪里都没反应”的问题 */
.center-play {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 12;
    transform: translate(-50%, -50%) scale(.92);
    width: 118px;
    height: 118px;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 50%;
    background: rgba(12,12,18,.54);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
    box-shadow: 0 0 0 8px rgba(255,255,255,.05), 0 12px 38px rgba(0,0,0,.38);
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

.center-play.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.center-play:active {
    transform: translate(-50%, -50%) scale(.94);
}

.center-play-icon {
    width: 0;
    height: 0;
    margin-left: 8px;
    border-top: 22px solid transparent;
    border-bottom: 22px solid transparent;
    border-left: 34px solid #fff;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.35));
}

.center-play-label {
    font-size: 15px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: .5px;
    text-shadow: 0 2px 8px rgba(0,0,0,.55);
}

@media (max-width: 600px) {
    .center-play {
        width: 108px;
        height: 108px;
    }

    .center-play-icon {
        border-top-width: 20px;
        border-bottom-width: 20px;
        border-left-width: 31px;
    }

    .center-play-label {
        font-size: 14px;
    }
}

/* 加载层 */
.loading-overlay {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10100;
    min-width: 210px;
    max-width: 82vw;
    padding: 20px 24px;
    border-radius: 18px;
    background: rgba(12,12,16,.70);
    border: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 12px 35px rgba(0,0,0,.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.loading-overlay p {
    margin-top: 12px;
    font-size: 13px;
    color: rgba(255,255,255,.92);
    text-align: center;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid rgba(255,255,255,.16);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin .78s linear infinite;
}

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

/* 点赞动画 */
.heart-animation {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 8;
    transform: translate(-50%, -50%) scale(.2);
    font-size: 82px;
    pointer-events: none;
    animation: heartPop 1.1s ease-out forwards;
    filter: drop-shadow(0 4px 15px rgba(255,50,90,.4));
}

@keyframes heartPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.16); }
    35% { transform: translate(-50%, -50%) scale(.98); }
    100% { opacity: 0; transform: translate(-50%, -75%) scale(1.38); }
}

/* Toast */
.anime-toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 40px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 11000;
    pointer-events: none;
}

.anime-toast {
    margin-top: 8px;
    padding: 9px 15px;
    border-radius: 18px;
    background: rgba(20,20,25,.80);
    border: 1px solid rgba(255,255,255,.12);
    color: #fff;
    font-size: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: toastInOut 3s ease forwards;
}

@keyframes toastInOut {
    0% { opacity: 0; transform: translateY(-8px); }
    10%, 85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-8px); }
}

/* 其他页面复用 */
.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: 0;
    padding: 12px 28px;
    border-radius: 24px;
    color: #222;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 600px) {
    :root { --nav-height: 42px; }

    .main-nav {
        padding-left: 8px;
        padding-right: 6px;
    }

    .nav-brand {
        max-width: 47vw;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }

    .nav-links {
        gap: 2px;
    }

    .nav-links a {
        padding: 5px 6px;
        font-size: 11px;
        background: rgba(0,0,0,.12);
    }

    .api-switcher-wrap {
        max-width: 49vw;
    }

    .api-selector {
        max-width: 118px;
    }

    .right-actions {
        right: 8px;
        bottom: max(62px, calc(env(safe-area-inset-bottom) + 48px));
    }

    .action-btn {
        width: 42px;
        height: 42px;
    }
}

@media (min-width: 900px) {
    .video-feed {
        background: radial-gradient(circle at center, #181820 0%, #050508 62%);
    }

    .video-slide {
        width: min(100vw, 620px);
        margin: 0 auto;
        box-shadow: 0 0 60px rgba(0,0,0,.45);
    }

    .right-actions {
        right: calc((100vw - min(100vw, 620px)) / 2 + 18px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .video-feed { scroll-behavior: auto; }
    .feed-video,
    .gesture-tip,
    .action-btn { transition: none; }
}
