:root {
    --primary: #007bff;
    --success: #28a745;
    --bg: #121212;
    --panel: #1e1e1e;
    --gap-sm: 8px;
    --gap-md: 15px;
    --gap-lg: 20px;
    --btn-min-height: 44px;
    --video-add-height:0px;
    /* 移动端最小点击高度，符合人机交互规范 */
}

* {
    box-sizing: border-box;
    /* 统一盒模型，避免尺寸错乱 */
}

body {
    background: var(--bg);
    color: #e0e0e0;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'SF Pro Text', sans-serif;
    /* 兼容苹果/安卓/PC字体 */
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    user-select: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-x: hidden;
    /* 禁止横向滚动 */
    overflow-y: auto;
    /* 允许纵向滚动 */
    height: auto;
    /* 确保高度随内容撑开 */
    -webkit-overflow-scrolling: touch;
    /* 增强 iOS 滚动流畅度 */
    /* 适配苹果刘海屏/底部安全区域 */
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: var(--gap-md);
    margin: 0 auto;
    margin-bottom: 500px;
}

/* 入口面板 - 响应式适配 */
#entry-panel {
    background: var(--panel);
    padding: clamp(30px, 8vh, 50px) clamp(15px, 5vw, 30px);
    /* 自适应内边距 */
    border-radius: 16px;
    text-align: center;
    margin-top: clamp(5vh, 10vh, 15vh);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid #333;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: var(--gap-md);
    justify-content: center;
    margin-top: var(--gap-lg);
    flex-wrap: wrap;
    /* 小屏自动换行 */
    align-items: center;
}

input {
    background: #000;
    border: 1px solid #444;
    color: #fff;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: 0.3s;
    min-height: var(--btn-min-height);
    /* 移动端点击友好 */
    width: clamp(180px, 30vw, 250px);
    /* 输入框自适应宽度 */
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.4);
}

button {
    cursor: pointer;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    transition: 0.2s;
    font-size: 15px;
    min-height: var(--btn-min-height);
    /* 移动端点击区域足够大 */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-main {
    background: var(--primary);
    color: white;
}

.btn-join {
    background: var(--success);
    color: white;
}

button:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* 移动端移除hover效果（无鼠标） */
@media (max-width: 768px) {
    button:hover {
        transform: none;
        opacity: 1;
    }

    button:active {
        opacity: 0.8;
        transform: scale(0.98);
        /* 移动端点击反馈 */
    }
}

/* 播放面板 */
#player-panel,
#p2p-panel {
    display: none;
    animation: fadeIn 0.5s;
    width: 100%;
    padding-bottom: 100px;
}

.room-bar,
.room-p2p {
    background: var(--panel);
    padding: 15px 25px;
    border-radius: 12px;
    margin-bottom: var(--gap-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #333;
    flex-wrap: wrap;
    /* 小屏换行 */
    gap: var(--gap-sm);
}

.room-id-tag {
    color: #00ff00;
    font-family: monospace;
    font-weight: bold;
    background: #000;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    word-break: break-all;
    /* 防止房间号溢出 */
}

.media-controls {
    background: var(--panel);
    padding: var(--gap-lg);
    border-radius: 12px;
    margin-bottom: var(--gap-lg);
    border: 1px solid #333;
    width: 100%;
}

.url-input-group {
    display: flex;
    gap: var(--gap-sm);
    margin-bottom: 15px;
    flex-wrap: wrap;
    /* 小屏自动换行 */
}

#videoUrl {
    flex: 1;
    min-width: 200px;
    /* 小屏输入框最小宽度 */
    width: 100%;
}

/* 视频容器 - 响应式高度，适配各种设备比例 */
.video-wrapper {
    position: relative;
    width: 100%;
    /* 自适应高度：16:9比例（可兼容4:3/21:9等视频），同时限制最大高度 */
    aspect-ratio: 16 / 9;
    max-height: clamp(200px, 70vh, 600px);
    min-height: 200px;
    background-color: #000;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.video-wrapper .video-js {
    width: 100%;
    height: 100%;
}

/* 关键：视频内容填充，但不影响 controls */
.video-wrapper .video-js video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
} */

/* 兼容iOS视频播放：禁止自动全屏 */
/* video::-webkit-media-controls {
    display: none !important;
} */

/* video[playsinline] {
    playsinline: true;
    webkit-playsinline: true;
} */

.drop-zone {
    margin-top: var(--gap-lg);
    border: 2px dashed #333;
    padding: 30px;
    text-align: center;
    border-radius: 12px;
    color: #666;
    transition: 0.3s;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: #1a1a1a;
    color: #aaa;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 控制标签页 - 响应式适配 */
.control-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    background: #000;
    padding: 5px;
    border-radius: 8px;
    width: fit-content;
    /* 小屏居中 */
    margin-left: auto;
    margin-right: auto;
}

.tab-btn {
    background: transparent;
    color: #888;
    padding: 8px 16px;
    font-size: 14px;
    min-height: unset;
    /* 标签按钮取消最小高度限制 */
}

.tab-btn.active {
    background: #2a2a2a;
    color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

.upload-card {
    background: #1a1a1a;
    border: 2px dashed #333;
    border-radius: 12px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: all 0.3s;
    flex-wrap: wrap;
    /* 小屏换行 */
}

.upload-card:hover {
    border-color: var(--primary);
    background: #222;
}

.upload-icon {
    font-size: 32px;
    filter: grayscale(1);
    flex-shrink: 0;
}

.upload-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
    min-width: 200px;
}

.upload-text strong {
    font-size: 16px;
    color: #fff;
}

.upload-text span {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.btn-outline {
    background: transparent;
    border: 1px solid #444;
    color: #ccc;
    padding: 6px 14px;
    font-size: 13px;
    min-height: unset;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.hint {
    font-size: 12px;
    color: #555;
    margin-top: 8px;
    text-align: center;
    /* 小屏提示文字居中 */
    padding: 0 var(--gap-sm);
}

/* 文件加载成功后的标签样式 */
.file-tag {
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.btn-sync-large {
    background: #444;
    color: #fff;
    padding: 12px 30px;
    font-size: 15px;
    font-weight: bold;
    border: 1px solid var(--primary);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* 移动端按钮全屏宽度，方便点击 */
    max-width: 400px;
    /* 大屏限制最大宽度 */
    margin: 0 auto;
}

.btn-sync-large:hover {
    background: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.btn-sync-large:active {
    transform: scale(0.95);
}

.btn-sync-large svg {
    width: 16px;
    height: 16px;
    fill: white;
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}

/* --- 控制栏样式 - 响应式优化 --- */
.controls-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: clamp(40px, 22%, 100px);
    /* 自适应高度 */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 11;
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
    /* 适配刘海屏左右边距 */
}

.video-wrapper:not(.is-pseudo-fullscreen):hover .controls-bar

/* .video-wrapper.dragging-mode .controls-bar, */
/* .video-wrapper.touch-active .controls-bar */
    {
    /* 移动端触控时显示控制栏 */
    opacity: 1;
}




.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    width: clamp(32px, 8vw, 36px);
    /* 自适应按钮大小 */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    padding: 0 !important;
    font-size: inherit !important;
    transition: opacity 0.3s ease, text-shadow 0.3s ease !important;
    transform: none !important;
    flex-shrink: 0;
}

.icon-btn2 {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    width: clamp(28px, 7vw, 36px);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    padding: 0 !important;
    font-size: inherit !important;
    transition: opacity 0.3s ease, text-shadow 0.3s ease !important;
    transform: none !important;
    flex-shrink: 0;
}

.icon-btn:hover {
    opacity: 1;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.icon-btn svg {
    width: clamp(18px, 5vw, 22px);
    height: clamp(18px, 5vw, 22px);
    fill: white;
    display: block;
    flex-shrink: 0;
}

.icon-btn2 svg {
    width: clamp(14px, 4vw, 16px);
    height: clamp(14px, 4vw, 16px);
    fill: white;
    display: block;
    flex-shrink: 0;
}

/* --- 进度条样式 - 移动端触控优化 --- */
.progress-container {
    position: absolute;
    top: -4px;
    left: 1%;
    width: 98%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: height 0.1s, top 0.1s;
    touch-action: manipulation;
    /* 优化移动端触控体验，防止滚动冲突 */
}

.progress-container:hover,
.progress-container.active,
.progress-container.touch-active {
    /* 移动端触控时进度条高亮 */
    height: 6px;
    top: -6px;
}

.progress-fill {
    height: 100%;
    background-color: #FB7299;
    width: 0%;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    transition: transform 0.1s;
}

.progress-container:hover .progress-fill::after,
.progress-container.active .progress-fill::after,
.progress-container.touch-active .progress-fill::after {
    transform: translateY(-50%) scale(1);
}

.time-display {
    color: white;
    font-size: clamp(10px, 2.5vw, 12px);
    margin-left: 10px;
    margin-right: auto;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    /* 防止时间文字换行 */
}

.right-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    padding-right: env(safe-area-inset-right);
    /* 适配苹果右侧安全区域 */
}

.sync-action-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: var(--gap-md);
    width: 100%;
}

/* 音量容器样式 - 移动端适配 */
.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
    flex-shrink: 0;

    /* 小屏隐藏音量条，只保留音量按钮 */
    @media (max-width: 480px) {
        .volume-bar-bg {
            display: none;
        }
    }
}

.volume-bar-bg {
    width: clamp(60px, 10vw, 240px);
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    transition: height 0.2s;
    touch-action: manipulation;
}

.volume-bar-bg:hover,
.volume-bar-bg.dragging,
.volume-bar-bg.touch-active {
    height: 8px;
}

.volume-fill {
    width: 80%;
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    position: relative !important;
    pointer-events: none;
}

.volume-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease;
    z-index: 10;
}

.volume-container:hover .volume-fill::after,
.volume-bar-bg.dragging .volume-fill::after,
.volume-bar-bg.touch-active .volume-fill::after {
    transform: translateY(-50%) scale(1) !important;
}

/* 播放列表 - 响应式优化 */
.playlist-container {
    background: var(--panel);
    border: 1px solid #333;
    border-radius: 12px;
    margin-bottom: var(--gap-lg);
    overflow: hidden;
    width: 100%;
}

.playlist-header {
    padding: 10px 15px;
    background: #252525;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(12px, 3vw, 14px);
    flex-wrap: wrap;
    gap: var(--gap-sm);
}

.playlist-items {
    background: #1a1a1a;
    border-radius: 8px;
    max-height: clamp(150px, 30vh, 250px);
    /* 自适应最大高度 */
    overflow-y: auto;
}

.playlist-item {
    padding: 10px 15px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: 0.2s;
    flex-wrap: wrap;
    gap: var(--gap-sm);
}

.playlist-item:hover {
    background: #2a2a2a;
}

.playlist-item.active {
    border-left: 3px solid var(--primary);
    background: #1a242f;
}

.playlist-item .item-type {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    margin-right: 10px;
    background: #444;
    flex-shrink: 0;
}

.playlist-item .item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(11px, 2.5vw, 13px);
    min-width: 150px;
}

.empty-hint {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: clamp(11px, 2.5vw, 13px);
}

/* 滚动条美化 - 兼容不同浏览器 */
.playlist-items::-webkit-scrollbar {
    width: 6px;
}

.playlist-items::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

.playlist-items::-moz-scrollbar {
    width: 6px;
}

.playlist-items::-moz-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

/* --- 媒体查询：针对不同设备尺寸精细化适配 --- */
/* 小屏手机（竖屏，<480px） */
@media (max-width: 480px) {
    .app-container {
        padding: var(--gap-sm);
    }

    .btn-group {
        gap: var(--gap-sm);
    }

    input {
        width: 100%;
        /* 手机端输入框全屏宽度 */
    }

    .room-bar,
    .room-p2p {
        padding: 12px 15px;
    }

    .media-controls {
        padding: var(--gap-md);
    }

    .upload-card {
        padding: 15px;
        gap: 15px;
    }

    .icon-btn,
    .icon-btn2 {
        width: 32px;
    }
}

/* 平板设备（768px-1024px） */
@media (min-width: 768px) and (max-width: 1024px) {
    .video-wrapper {
        aspect-ratio: 4 / 3;
        /* 平板横屏适配更舒适的比例 */
        max-height: 75vh;
    }

    .btn-sync-large {
        max-width: 500px;
    }

    .volume-bar-bg {
        display: none;
    }
}

/* 大屏设备（>1200px） */
@media (min-width: 1200px) {
    .app-container {
        padding: var(--gap-lg);
    }

    .video-wrapper {
        max-height: 80vh;
    }
}

/* 横屏/竖屏适配 */
@media (orientation: landscape) and (max-width: 768px) {
    .video-wrapper {
        max-height: 85vh;
        /* 手机横屏时视频占比更高 */
    }

    .sync-action-bar {
        margin-top: var(--gap-sm);
    }
}

#myUidDisplay:hover {
    background: rgba(0, 123, 255, 0.15) !important;
    border: 1px solid #007bff55 !important;
}

#myUidDisplay:empty:before {
    content: "请输入名字";
    color: #555;
}

/* 产品介绍模块整体容器 */
.product-intro {
    background: linear-gradient(145deg, #1e1e1e, #161616);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.brand-name {
    color: #007bff;
    font-size: 1.5rem;
    margin: 0 0 8px 0;
    letter-spacing: 1px;
}

.brand-desc {
    color: #aaa;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* 链接区域布局 */
.intro-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #2a2a2a;
}

.link-item {
    color: #eee;
    text-decoration: none;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
    background: #252525;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #333;
}

.link-item:hover {
    color: #007bff;
    background: #2a2a2a;
    border-color: #007bff;
}

.link-item .icon {
    font-style: normal;
}

/* 适配手机端 */
@media (max-width: 480px) {
    .intro-links {
        gap: 8px;
    }

    .link-item {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
}

/* 使用普通类名控制，避开伪类兼容性问题 */
.video-wrapper.is-fullscreen .controls-bar {
    opacity: 1 !important;
    /* display: none !important; */
}

/* 默认全屏时，如果带有这个类，则隐藏 */
.video-wrapper.is-fullscreen.hide-controls .controls-bar {
    opacity: 0 !important;
    pointer-events: none;
    /* 隐藏时禁止点击，防止误触 */
    transition: opacity 0.5s ease;
    /* 增加平滑过渡 */
}




/* 视频加载动画 */
/* Loading 覆盖层 */
.video-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    /* 不挡操作 */
    opacity: 0;
    transition: opacity 0.2s;
}

.video-loading.show {
    opacity: 1;
}

/* 圆形转圈 */
.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-text {
    margin-top: 10px;
    color: #fff;
    font-size: 14px;
    opacity: 0.9;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}



/* 当 body 被 JS 加上这个类时，触发全屏样式 */
body.page-fullscreen {
    /* overflow: hidden !important; */
    /* 禁止背景滚动 */
    /* position: fixed;
    width: 100%;
    height: 100%; */
}

body.page-fullscreen .video-wrapper {
    position: fixed !important;
    /* inset: 0; */
    top: 0 !important;
    left: 0 !important;
    max-height: none;
    max-width: none;
    width: 100vw !important;
    height:100dvh !important;
    z-index: 99999 !important;
    /* 确保盖住所有其他页面元素 */
    background: #000;
    /* 全屏背景变黑 */
}

/* 针对 iOS 全屏顶部的控制条避让（可选） */
/* body.ios-fullscreen-top-controls .video-wrapper {
    padding-top: env(safe-area-inset-top);

} */

/* 确保视频本身在容器内撑满 */
body.page-fullscreen #vPlayer {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}