/* ========== 全局 CSS 变量（主题） ========== */
:root {
    --bg-color: #0e0e11;
    --sidebar-bg: #1e1f20;
    --card-bg: #1a1a1c;
    --card-hover: rgba(255, 255, 255, 0.08);
    --input-bg: #131314;
    --border-light: rgba(255, 255, 255, 0.04);
    --text-main: #e3e3e3;
    --text-sub: #c4c7c5;
    --text-muted: #8e918f;
    --accent-blue: #a8c7fa;
    --sidebar-width: 80px;
}

/* 浅色模式变量覆盖 */
body.light {
    --bg-color: #ffffff;
    --sidebar-bg: #f0f4f9;
    --card-bg: #f8fafd;
    --card-hover: rgba(0, 0, 0, 0.06);
    --input-bg: #e9eef6;
    --border-light: rgba(0, 0, 0, 0.05);
    --text-main: #1f1f1f;
    --text-sub: #444746;
    --text-muted: #757575;
    --accent-blue: #0b57d0;
}

/* 系统跟随模式（深色） */
@media (prefers-color-scheme: light) {
    body.system {
        --bg-color: #ffffff;
        --sidebar-bg: #f0f4f9;
        --card-bg: #f8fafd;
        --card-hover: rgba(0, 0, 0, 0.06);
        --input-bg: #e9eef6;
        --border-light: rgba(0, 0, 0, 0.05);
        --text-main: #1f1f1f;
        --text-sub: #444746;
        --text-muted: #757575;
        --accent-blue: #0b57d0;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Google Sans", "Segoe UI", system-ui, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    height: 100vh;
    display: flex;
    overflow: hidden;
    transition:
        background-color 0.3s,
        color 0.3s;
}

/* 隐藏所有滚动条（保持功能） */
*::-webkit-scrollbar {
    display: none;
}
* {
    scrollbar-width: none;
}

.material-icons-outlined {
    font-size: 20px;
}

/* ========== 侧边栏样式 ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1);
    z-index: 1000;
    border-right: 1px solid var(--border-light);
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.sidebar.mobile-open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 20px 0 12px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.logo-icon {
    width: 36px;
    height: 36px;
}
.brand-text {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-main);
    letter-spacing: 0.3px;
}

.sidebar-social {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 28px 0;
}
.sidebar-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-sub);
    transition: background-color 0.2s;
    text-decoration: none;
    background: none;
    border: none;
}
.sidebar-icon:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
}
.social-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
.sidebar-icon .material-icons-outlined {
    font-size: 22px;
}

.sidebar-footer {
    display: flex;
    justify-content: center;
    padding: 20px 0;
    border-top: 1px solid var(--border-light);
}
.menu-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-sub);
}
.menu-item:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
}
.menu-item .material-icons-outlined {
    font-size: 22px;
}

/* 侧边栏遮罩（移动端） */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* 设置菜单 */
#settingsMenu {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--sidebar-bg);
    border-radius: 20px;
    width: 180px;
    z-index: 1100;
    display: none;
    flex-direction: column;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    padding: 6px;
}
.settings-menu-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-sub);
    border-radius: 12px;
}
.settings-menu-item:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
}
.settings-menu-item.active {
    color: var(--accent-blue);
    background-color: rgba(168, 199, 250, 0.1);
}

/* ========== 右侧主内容区 ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-color);
    width: 100%;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

.main-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top: env(safe-area-inset-top, 0);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.mobile-logo-trigger {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
}
.mobile-logo-trigger:hover {
    background-color: var(--card-hover);
}
.mobile-logo-icon {
    width: 24px;
    height: 24px;
}
.version-badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-blue);
    background: var(--card-hover);
    padding: 4px 12px;
    border-radius: 12px;
}
.header-right {
    width: 40px;
}

/* 欢迎页 */
.welcome-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}
.welcome-content {
    width: 100%;
    max-width: 660px;
    text-align: center;
}
.welcome-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}
.welcome-logo .logo-icon {
    width: 40px;
    height: 40px;
}
.welcome-logo .brand-text {
    font-size: 32px;
    font-weight: 500;
    background: linear-gradient(74deg, #4285f4, #9b72cb, #d96570, #f4af60);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}
.welcome-subtitle {
    font-size: 20px;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 32px;
}
.welcome-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--input-bg);
    border-radius: 28px;
    padding: 6px 8px 6px 20px;
    border: 1px solid transparent;
}
.welcome-input-row:focus-within {
    background-color: var(--sidebar-bg);
    box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.25);
}
.welcome-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 16px;
    padding: 10px 0;
    resize: none;
    line-height: 1.4;
}
.welcome-send-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
}
.welcome-send-btn:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 16px 0;
    display: none;
    position: relative;
}
.chat-inner {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 80px;
}
.user-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.user-content {
    background: var(--card-bg);
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    word-break: break-all;
}
.assistant-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.assistant-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}
.assistant-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
}
.turn-marker {
    display: none;
}

/* 清除对话按钮和全局弹出按钮的容器 */
.chat-clear-wrapper {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0 12px;
}
.chat-clear-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 40px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.chat-clear-btn:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
    border-color: var(--accent-blue);
}
.chat-clear-btn .material-icons-outlined {
    font-size: 18px;
}

.global-popout-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 40px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.global-popout-btn:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
    border-color: var(--accent-blue);
}
.global-popout-btn .material-icons-outlined {
    font-size: 18px;
}

/* 底部输入栏 */
.input-bar-container {
    flex-shrink: 0;
    background-color: var(--bg-color);
    padding: 12px 16px 20px;
    display: flex;
    justify-content: center;
    display: none;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}
.input-box-wrapper {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--input-bg);
    border-radius: 28px;
    padding: 6px 8px 6px 20px;
    border: 1px solid transparent;
}
.input-row:focus-within {
    background-color: var(--sidebar-bg);
    box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.25);
}
.main-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 16px;
    padding: 10px 0;
    resize: none;
    line-height: 1.4;
}
.send-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
}
.send-btn:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
}
.send-btn-active {
    color: var(--accent-blue) !important;
}
.footer-tips {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ========== 关键修复：为 .player-area 添加相对定位，使弹出按钮正确定位 ========== */
.player-area {
    position: relative; /* 这是关键！让 .popout-btn 相对此容器定位 */
    background-color: #000;
}

/* ========== iframe 嵌入式卡片比例自适应 ========== */
.player-area.iframe-fit {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.player-area.iframe-fit.portrait {
    aspect-ratio: 9 / 16;
}
.player-area.iframe-fit iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}
.player-area:not(.iframe-fit) video {
    width: 100%;
    height: auto;
    display: block;
}

/* 浮动播放器：自适应内容比例 + 桌面端最小宽度 1440px */
.floating-video {
    position: relative;
    width: 100%;
    background-color: #000;
}
.floating-video iframe,
.floating-video video {
    width: 100%;
    height: auto;
    display: block;
}

/* 弹窗播放器（浮动） */
.floating-player,
.floating-backdrop {
    display: none;
}
.floating-player.active {
    display: flex;
}
.floating-backdrop.active {
    display: block;
}
.floating-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 999;
}
.floating-player {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: auto;
    max-width: 90vw;
    background: #000;
    border-radius: 20px;
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition:
        transform 0.2s,
        opacity 0.2s;
    border: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}
.floating-player.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}
.floating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #0066ff;
    color: white;
}
.close-float {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
}
.floating-video {
    width: 100%;
    background: #000;
}

/* 电脑端适配（侧边栏常显 + 浮动播放器最小宽度 1440px） */
@media (min-width: 1024px) {
    .sidebar {
        position: relative;
        transform: none !important;
        width: var(--sidebar-width);
        left: auto;
    }
    .sidebar-overlay {
        display: none;
    }
    .mobile-logo-trigger {
        display: none !important;
    }
    .main-content {
        width: calc(100% - var(--sidebar-width));
    }
    .main-header {
        padding: 0 24px;
        height: 64px;
    }
    .version-badge {
        font-size: 13px;
    }
    .welcome-logo .logo-icon {
        width: 48px;
        height: 48px;
    }
    .welcome-logo .brand-text {
        font-size: 40px;
    }
    .welcome-subtitle {
        font-size: 28px;
        margin-bottom: 48px;
    }
    .welcome-input,
    .main-input {
        font-size: 16px;
        padding: 12px 0;
    }
    .user-content {
        font-size: 15px;
        padding: 12px 20px;
        max-width: 600px;
    }
    .chat-inner {
        margin: 0 auto;
    }
    .input-bar-container {
        padding: 16px 24px 28px;
    }
    .floating-player {
        min-width: 1440px;
    }
}

/* 移除所有播放器边框和阴影 */
.global-player-container,
.global-player-container .video-js,
.global-player-container .iframe-player,
.floating-player,
.floating-player .video-js,
.floating-player .iframe-player,
.video-js,
.video-js video {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background-color: #000000 !important;
}

video.video-js {
    background-color: #000000 !important;
}

body.light .global-player-container,
body.light .floating-player,
body.light .video-js {
    background-color: #000000 !important;
    border: none !important;
}

/* 弹出按钮交互 - 每个卡片内的弹出按钮 */
.video-card-wrapper .popout-btn {
    opacity: 0;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    pointer-events: none;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    background-color: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    backdrop-filter: blur(4px);
}
.video-card-wrapper .player-area:hover .popout-btn {
    opacity: 1;
    pointer-events: auto;
}
.video-card-wrapper .popout-btn:hover {
    background-color: rgba(0, 0, 0, 0.85);
    transform: scale(1.05);
}
@media (max-width: 1023px) {
    .video-card-wrapper .popout-btn {
        display: none !important;
    }
}

.info-area {
    color: var(--text-main);
}
