/* 
HuiTV 全局样式
包含多个页面共享的基础样式
对于特定页面的样式，请参考:
- index.css: 首页特定样式
- player.css: 播放器页面特定样式
- watch.css: 重定向页面特定样式
- modals.css: 模态框和提示框样式
*/

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F1F5F9;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    z-index: 10;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #E2E8F0;
    color: #1E293B;
    transform: scale(1.08);
}

.close-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

:root {
    /* HuiTV 浅色主题配色方案 */
    --primary-color: #2563EB;       /* 活力蓝主色调 */
    --primary-light: #3B82F6;       /* 浅蓝色变体 */
    --secondary-color: #F97316;     /* 珊瑚橙强调色 */
    --accent-color: #F97316;        /* 珊瑚橙强调色 */
    --text-color: #1E293B;          /* 深 slate 主文本 */
    --text-muted: #64748B;          /* 灰色次级文本 */
    --border-color: #E2E8F0;        /* 浅灰边框 */
    --page-gradient-start: #FAFBFC; /* 极浅灰白起始色 */
    --page-gradient-end: #FFFFFF;   /* 纯白结束色 */
    --card-gradient-start: #FFFFFF; /* 卡片起始色 */
    --card-gradient-end: #F8FAFC;   /* 卡片结束色 */
    --card-accent: rgba(37, 99, 235, 0.08); /* 蓝色卡片强调色 */
    --card-hover-border: rgba(37, 99, 235, 0.3); /* 悬停边框颜色 */
    
    /* 新增浅色主题变量 */
    --bg-primary: #FAFBFC;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F1F5F9;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --accent-primary: #2563EB;
    --accent-secondary: #F97316;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    /* === M3 Design Tokens（蓝色主题覆盖） === */
    --m3-primary: #2563EB;
    --m3-on-primary: #FFFFFF;
    --m3-primary-container: #DBEAFE;
    --m3-on-primary-container: #1E3A5F;

    --m3-secondary: #475569;
    --m3-on-secondary: #FFFFFF;
    --m3-secondary-container: #E2E8F0;
    --m3-on-secondary-container: #0F172A;

    --m3-tertiary: #F97316;
    --m3-on-tertiary: #FFFFFF;
    --m3-tertiary-container: #FFEDD5;
    --m3-on-tertiary-container: #431407;

    --m3-error: #DC2626;
    --m3-on-error: #FFFFFF;
    --m3-error-container: #FEE2E2;
    --m3-on-error-container: #450A0A;

    --m3-surface: #FAFBFC;
    --m3-on-surface: #1E293B;
    --m3-on-surface-variant: #64748B;
    --m3-surface-variant: #E2E8F0;

    --m3-surface-container-lowest: #FFFFFF;
    --m3-surface-container-low: #F8FAFC;
    --m3-surface-container: #F1F5F9;
    --m3-surface-container-high: #E2E8F0;
    --m3-surface-container-highest: #CBD5E1;

    --m3-outline: #94A3B8;
    --m3-outline-variant: #CBD5E1;

    --m3-elevation-0: none;
    --m3-elevation-1: 0px 1px 2px 0px rgba(0,0,0,0.30), 0px 1px 3px 1px rgba(0,0,0,0.15);
    --m3-elevation-2: 0px 1px 2px 0px rgba(0,0,0,0.30), 0px 2px 6px 2px rgba(0,0,0,0.15);
    --m3-elevation-3: 0px 1px 3px 0px rgba(0,0,0,0.30), 0px 4px 8px 3px rgba(0,0,0,0.15);

    --m3-shape-xs: 4px;
    --m3-shape-sm: 8px;
    --m3-shape-md: 12px;
    --m3-shape-lg: 16px;
    --m3-shape-xl: 20px;
    --m3-shape-2xl: 24px;
    --m3-shape-full: 9999px;

    --m3-space-xs: 4px;
    --m3-space-sm: 8px;
    --m3-space-md: 12px;
    --m3-space-lg: 16px;
    --m3-space-xl: 24px;

    --m3-duration-short-3: 150ms;
    --m3-duration-short-4: 200ms;
    --m3-duration-medium-1: 250ms;
    --m3-duration-medium-2: 300ms;
    --m3-duration-long-2: 500ms;

    --m3-easing-standard: cubic-bezier(0.2, 0, 0, 1);
    --m3-easing-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1);
    --m3-easing-legacy: cubic-bezier(0.4, 0, 0.2, 1);

    --m3-state-hover-opacity: 0.08;
    --m3-state-focus-opacity: 0.12;
    --m3-state-press-opacity: 0.12;

    --m3-disabled-opacity: 0.38;
}

.page-bg {
    background: linear-gradient(180deg, var(--page-gradient-start), var(--page-gradient-end));
    min-height: 100vh;
    /* 纯净浅色背景 */
    background-attachment: fixed;
}

button, .card-hover {
    transition: all 0.3s ease;
}

/* 改进卡片适应不同内容长度 */
.card-hover {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
}

/* 确保卡片内容区域高度一致性 */
.card-hover .flex-grow {
    min-height: unset; /* 移除最小高度限制，让内容自然流动 */
    display: flex;
    flex-direction: column;
}

/* 针对不同长度的标题优化显示 */
.card-hover h3 {
    min-height: unset;
    max-height: unset;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    line-height: 1.2rem;
    word-break: break-word; /* 允许在任何字符间断行 */
    hyphens: auto; /* 允许断词 */
}

.card-hover::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--card-accent), transparent);
    transition: left 0.6s ease;
}

.card-hover:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-hover:hover::before {
    left: 100%;
}

.gradient-text {
    background: linear-gradient(to right, #2563EB, #3B82F6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 改进设置面板样式 */
.settings-panel {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

/* 设置面板标题样式 */
.settings-panel h3 {
    color: var(--text-primary);
    font-weight: 700;
}

/* 设置面板区域卡片悬停效果 */
.settings-panel > div > div {
    transition: all 0.3s ease;
}

.settings-panel > div > div:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.settings-panel.show {
    transform: translateX(0);
}

.settings-panel::-webkit-scrollbar {
    width: 6px;
}

.settings-panel::-webkit-scrollbar-track {
    background: #F1F5F9;
}

.settings-panel::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 4px;
}

.search-button {
    background: var(--primary-color);
    color: var(--text-color);
}

.search-button:hover {
    background: var(--primary-light);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

.footer {
    width: 100%;
    transition: all 0.3s ease;
    margin-top: auto;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.footer a:hover {
    text-decoration: underline;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    flex: 1;
}

@media screen and (min-height: 800px) {
    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }
    
    .container {
        flex: 1;
    }
    
    .footer {
        margin-top: auto;
    }
}

@media screen and (max-width: 640px) {
    .footer {
        padding-bottom: 2rem;
    }
}

/* 移动端布局优化 */
@media screen and (max-width: 768px) {
    .card-hover h3 {
        min-height: 2.5rem;
    }
    
    .card-hover .flex-grow {
        min-height: 80px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

#modal.show {
    animation: fadeIn 0.3s forwards;
}

#modal.hide {
    animation: fadeOut 0.3s forwards;
}

#modal > div {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
}

/* ===== 选集按钮 — Apple 柔和触感风格 ===== */
.episode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 42px;
    padding: 0 12px;
    background: #F5F5F7;
    color: #1D1D1F;
    border: none;
    font-size: 15px;
    font-weight: 500;
    font-family: -apple-system, 'SF Pro Display', 'PingFang SC', sans-serif;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    border-radius: 14px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 0.5px 1px rgba(0,0,0,0.06), 0 0.5px 2px rgba(0,0,0,0.04);
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.episode-btn:hover {
    background: #E8E8ED;
    transform: scale(1.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
}
.episode-btn:active {
    transform: scale(0.97);
}
.episode-btn.is-active {
    background: #007AFF;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,122,255,0.25);
}
.episode-btn.is-active:hover {
    background: #0066D6;
    transform: scale(1.04);
    box-shadow: 0 4px 16px rgba(0,122,255,0.30);
}

/* 弹窗内选集按钮稍小 */
.modal-episode-btn {
    min-width: 44px;
    height: 38px;
    padding: 0 10px;
    font-size: 14px;
    border-radius: 12px;
}

/* #episodesGrid 网格容器保持 */
#episodesGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 8px;
}

/* 添加广告过滤开关的CSS */
#adFilterToggle:checked + .toggle-bg {
    background-color: black;
}

#adFilterToggle:checked ~ .toggle-dot {
    transform: translateX(1.5rem);
    background-color: white;
}

#adFilterToggle:focus + .toggle-bg,
#adFilterToggle:hover + .toggle-bg {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.toggle-dot {
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-bg {
    transition: background-color 0.3s ease-in-out;
}

#adFilterToggle:checked ~ .toggle-dot {
    box-shadow: 0 2px 4px rgba(0, 204, 255, 0.3);
}

/* 豆瓣热门开关样式 */
#doubanToggle:checked + .toggle-bg {
    background-color: black;
}

#doubanToggle:checked ~ .toggle-dot {
    transform: translateX(1.5rem);
    background-color: white;
}

#doubanToggle:focus + .toggle-bg,
#doubanToggle:hover + .toggle-bg {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* 添加API复选框样式 - 黑白风格 */
.form-checkbox {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: 16px;
    width: 16px;
    background-color: white;
    border: 2px solid black;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: all 0.2s ease;
}

.form-checkbox:checked {
    background-color: black;
    border-color: black;
}

.form-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 0px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* API滚动区域美化 */
#apiCheckboxes {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

#apiCheckboxes::-webkit-scrollbar {
    width: 6px;
}

#apiCheckboxes::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 4px;
}

#apiCheckboxes::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 4px;
}

/* 自定义API列表样式 */
#customApisList {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

#customApisList::-webkit-scrollbar {
    width: 6px;
}

#customApisList::-webkit-scrollbar-track {
    background: #F1F5F9;
}

#customApisList::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 4px;
}

/* 设置面板滚动样式 */
.settings-panel {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

.settings-panel::-webkit-scrollbar {
    width: 6px;
}

.settings-panel::-webkit-scrollbar-track {
    background: #F1F5F9;
}

.settings-panel::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 4px;
}

/* 添加自定义API表单动画 */
#addCustomApiForm {
    transition: all 0.3s ease;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

#addCustomApiForm.hidden {
    max-height: 0;
    padding: 0;
    opacity: 0;
}

#addCustomApiForm:not(.hidden) {
    max-height: 230px;
    opacity: 1;
}

/* API组标题样式 */
.api-group-title {
    grid-column: span 2;
    padding: 0.25rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 编辑按钮样式 */
.custom-api-edit {
    color: #2563EB;
    transition: color 0.2s ease;
}

.custom-api-edit:hover {
    color: #1D4ED8;
}

/* 自定义API条目样式改进 */
#customApisList .api-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    background-color: var(--bg-tertiary);
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

#customApisList .api-item:hover {
    background-color: #E2E8F0;
}

/* 历史记录面板样式 */
.history-panel {
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease-in-out;
    overflow-y: scroll; /* 始终显示滚动条，防止宽度变化 */
    overflow-x: hidden; /* 防止水平滚动 */
    width: 320px; /* 固定宽度 */
    box-sizing: border-box; /* 确保padding不影响总宽度 */
    scrollbar-gutter: stable; /* 现代浏览器：为滚动条预留空间 */
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

.history-panel.show {
    transform: translateX(0);
}

#historyList {
    padding-right: 6px; /* 为滚动条预留空间，确保内容不被挤压 */
}

/* 历史记录项样式 - Google Drive gb_F 风格 */
.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 14px;
    color: #1F1F1F;
    position: relative;
    background: rgba(60, 64, 67, 0.06);
    border: none;
    box-shadow: none;
    margin-bottom: 4px;
    margin-top: 4px;
    width: 100%;
    overflow: visible;
}

.history-item:hover {
    background: rgba(60, 64, 67, 0.12);
    transform: none;
}

.history-item:active {
    background: rgba(60, 64, 67, 0.18);
}

/* 历史项左侧图标 */
.history-item__icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: #444746;
    margin-top: 2px;
}

/* 历史项删除按钮 - gb_F 风格 */
.history-item__delete {
    opacity: 0;
    transition: opacity 0.15s;
    color: #444746;
    padding: 6px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: -2px;
}

.history-item:hover .history-item__delete {
    opacity: 1;
}

.history-item__delete:hover {
    background: rgba(60, 64, 67, 0.08);
    color: #1F1F1F;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 500;
    font-size: 14px;
    color: #1F1F1F;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.history-meta {
    color: #5F6368;
    font-size: 12px;
    line-height: 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin-bottom: 4px;
}

.history-episode {
    color: #0B57D0;
}

.history-source {
    color: #5F6368;
}

.history-time {
    color: #5F6368;
    font-size: 12px;
    line-height: 18px;
}

.history-separator {
    color: #666;
}

.history-thumbnail {
    width: 100%;
    height: 90px;
    background-color: var(--bg-tertiary);
    overflow: hidden;
}

.history-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 500;
    font-size: 14px;
    color: #1F1F1F;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-time {
    color: #5F6368;
    font-size: 12px;
    line-height: 18px;
}

/* 添加播放进度条样式 */
.history-progress {
    margin: 4px 0;
}

.progress-bar {
    height: 3px;
    background-color: #E1E3E6;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 2px;
}

.progress-filled {
    height: 100%;
    background: #0B57D0;
    border-radius: 2px;
}

.progress-text {
    font-size: 11px;
    color: #5F6368;
    text-align: left;
}

/* 添加恢复播放提示样式 */
.position-restore-hint {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: rgba(30, 41, 59, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 100;
    opacity: 0;
    transition: all 0.3s ease;
}

.position-restore-hint.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 锁定控制时屏蔽交互 */
.player-container.controls-locked .dplayer-controller,
.player-container.controls-locked .dplayer-mask,
.player-container.controls-locked .dplayer-bar-wrap,
.player-container.controls-locked .dplayer-statusbar,
.player-container.controls-locked .shortcut-hint {
    opacity: 0 !important;
    pointer-events: none !important;
}
/* 保留锁按钮可见可点 */
.player-container.controls-locked #lockToggle {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* 播放器顶部header移动端优化 */
.player-header {
    gap: 0.5rem;
}
.custom-title-scroll {
    overflow-x: auto;
    white-space: nowrap;
    text-overflow: ellipsis;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.custom-title-scroll::-webkit-scrollbar {
    display: none;
}
.logo-clickable {
    cursor: pointer;
}
.logo-text {
    display: inline;
}
.home-btn-text {
    display: inline;
}
@media (max-width: 640px) {
    .logo-text {
        display: none;
    }
    .home-btn-text {
        display: none;
    }
    .logo-icon {
        margin-right: 0;
    }
    .home-btn svg {
        margin-right: 0;
    }
    .player-header {
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .custom-title-scroll {
        font-size: 1rem;
    }
}

/* ============================================
   搜索结果卡片样式 - M3 Elevated Card 水平布局
   ============================================ */

/* M3 搜索卡片容器 — 创意国际感 */
.m3-search-card {
    position: relative;
    display: flex;
    flex-direction: row;
    min-height: 140px;
    background: linear-gradient(135deg, #FFFFFF, #FAFAFA);
    border-radius: 18px;
    cursor: pointer;
    overflow: hidden;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 16px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    transition:
        box-shadow var(--m3-duration-medium-2) var(--m3-easing-standard),
        transform var(--m3-duration-medium-2) var(--m3-easing-emphasized);
}

.m3-search-card:hover {
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.06),
        0 8px 30px rgba(0, 0, 0, 0.10),
        0 0 0 1px rgba(37, 99, 235, 0.18);
    transform: translateY(-4px);
}

/* 状态层叠加 */
.m3-search-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: transparent;
    transition: background var(--m3-duration-short-4) var(--m3-easing-standard),
                opacity var(--m3-duration-short-4) var(--m3-easing-standard);
    pointer-events: none;
    z-index: 1;
}
.m3-search-card:hover::after {
    background: var(--m3-on-surface);
    opacity: 0.04;
}
.m3-search-card:active::after {
    background: var(--m3-on-surface);
    opacity: 0.08;
}

/* 海报区域 */
.m3-search-card__poster {
    position: relative;
    width: 100px;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--m3-surface-container);
    border-radius: 18px 0 0 18px;
    z-index: 0;
}

/* 海报 hover 品牌蓝渐变叠影 */
.m3-search-card__poster::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.04));
    opacity: 0;
    transition: opacity var(--m3-duration-medium-2) var(--m3-easing-standard);
    pointer-events: none;
    border-radius: inherit;
}
.m3-search-card:hover .m3-search-card__poster::before {
    opacity: 1;
}

.m3-search-card__poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--m3-duration-long-2) var(--m3-easing-emphasized);
}

/* 卡片全覆盖透明链接层 — 用于右键"在新标签页打开" */
.m3-search-card__overlay-link,
.m3-video-card__overlay-link {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.m3-search-card:hover .m3-search-card__poster img {
    transform: scale(1.03);
}

/* 图片加载失败占位 */
.m3-search-card__fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--m3-surface-container);
    color: var(--m3-on-surface-variant);
}
.m3-search-card__fallback svg {
    width: 32px;
    height: 32px;
    stroke-width: 1.5;
}

/* ============================================
   Google 风格全局 Loading 样式
   ============================================ */

.g-loading-card {
    background: #FFFFFF;
    padding: 32px 40px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
    transform: scale(0.95);
    animation: g-loading-in 0.3s ease forwards;
}

@keyframes g-loading-in {
    to { transform: scale(1); }
}

.g-loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #E8EAED;
    border-top-color: #1A73E8;
    border-radius: 50%;
    animation: g-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.g-loading-text {
    color: #5F6368;
    font-size: 16px;
    font-weight: 500;
    font-family: "Google Sans", "Noto Sans SC", Arial, sans-serif;
    white-space: nowrap;
}

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

/* ============================================
   Google 风格骨架屏（Shimmer）
   ============================================ */

.skeleton {
    background: #F1F3F4;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.5) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.skeleton-card {
    background: #FFFFFF;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8EAED;
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 3/4;
    background: #F1F3F4;
    position: relative;
    overflow: hidden;
}

.skeleton-img::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-body {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skeleton-title {
    height: 16px;
    background: #F1F3F4;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-title::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-title-sm {
    width: 60%;
    height: 12px;
    background: #F1F3F4;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-title-sm::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-text {
    height: 14px;
    background: #F1F3F4;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-text::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

/* 水平卡片骨架屏（搜索结果页 - M3 匹配） */
.m3-search-card--skeleton {
    display: flex;
    flex-direction: row;
    height: 140px;
    background: linear-gradient(135deg, #FFFFFF, #FAFAFA);
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 16px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    cursor: default;
    pointer-events: none;
}

.m3-search-card--skeleton .m3-search-card__poster {
    width: 100px;
    height: 100%;
    flex-shrink: 0;
    background: var(--m3-surface-container-high);
    position: relative;
    overflow: hidden;
    border-radius: 18px 0 0 18px;
}

.m3-search-card--skeleton .m3-search-card__poster::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

.m3-search-card--skeleton .m3-search-card__body {
    padding: var(--m3-space-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 骨架内部脉冲条 */
.m3-skeleton-line {
    height: 14px;
    background: var(--m3-surface-container-high);
    border-radius: var(--m3-shape-xs);
    position: relative;
    overflow: hidden;
}
.m3-skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}
.m3-skeleton-line--w70 { width: 70%; }
.m3-skeleton-line--w40 { width: 40%; }
.m3-skeleton-line--w80 { width: 80%; }
.m3-skeleton-line--w30 { width: 30%; }

/* 信息区域 */
.m3-search-card__body {
    padding: 14px var(--m3-space-lg);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    flex: 1;
    min-width: 0;
    z-index: 0;
}

/* 标题 */
.m3-search-card__title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    letter-spacing: -0.2px;
}

/* 副标题 — 更新/备注信息 */
.m3-search-card__subtitle {
    font-size: 13px;
    color: #64748B;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    font-weight: 400;
}

/* 标签区域 */
.m3-search-card__tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: auto;
    align-content: flex-start;
}

/* 类型标签 — 柔和填充 + hover 反转动画 */
.m3-search-card__chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: #DBEAFE;
    color: #1E40AF;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--m3-shape-full);
    letter-spacing: 0.2px;
    transition:
        background var(--m3-duration-medium-1) var(--m3-easing-standard),
        color var(--m3-duration-medium-1) var(--m3-easing-standard),
        transform var(--m3-duration-medium-1) var(--m3-easing-emphasized);
}
.m3-search-card:hover .m3-search-card__chip {
    background: #2563EB;
    color: #FFFFFF;
    transform: scale(1.05);
}

/* 年份标签 — 描边胶囊 + hover 变色 + 微缩放 */
.m3-search-card__chip--outlined {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: transparent;
    color: #6B7280;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--m3-shape-full);
    letter-spacing: 0.2px;
    border: 1px solid #D1D5DB;
    transition:
        border-color var(--m3-duration-medium-1) var(--m3-easing-standard),
        color var(--m3-duration-medium-1) var(--m3-easing-standard),
        transform var(--m3-duration-medium-1) var(--m3-easing-emphasized);
}
.m3-search-card:hover .m3-search-card__chip--outlined {
    border-color: #2563EB;
    color: #2563EB;
    transform: scale(1.05);
}

/* 来源徽章 — 精致小标 */
.m3-search-card__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #F1F5F9;
    color: #94A3B8;
    font-size: 10px;
    font-weight: 500;
    border-radius: 6px;
    letter-spacing: 0.3px;
    margin-left: auto;
    transition:
        background var(--m3-duration-medium-1) var(--m3-easing-standard),
        color var(--m3-duration-medium-1) var(--m3-easing-standard);
    flex-shrink: 0;
}
.m3-search-card:hover .m3-search-card__badge {
    background: #E2E8F0;
    color: #64748B;
}

/* 保留旧类名兼容 */
.m3-search-card__meta {
    font-size: 13px;
    color: #64748B;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    font-weight: 400;
}

.m3-search-card__source {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: auto;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   M3 按钮系统 — 统一设计语言
   变体: filled / outlined / ghost / chip / icon / close
   ============================================ */

.m3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    outline: none;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.m3-btn:active {
    transform: scale(0.97);
}

/* Filled — 主要操作 */
.m3-btn--filled {
    background: #2563EB;
    color: #FFFFFF;
    border-radius: 9999px;
    padding: 10px 20px;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12);
}
.m3-btn--filled:hover {
    background: #1D4ED8;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.28);
}

/* High-emphasis — Google About 风格（一比一复刻 glue-button--high-emphasis） */
.m3-btn--tonal {
    background-color: #1a73e8;
    color: #fff;
    border-radius: 48px;
    border: 1px solid transparent;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    line-height: 1.5;
    min-height: 48px;
    min-width: 96px;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
    transition: background-color .2s, box-shadow .2s, color .2s;
    transform: none;
}
.m3-btn--tonal:hover {
    background-color: #185abc;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
}
.m3-btn--tonal:focus {
    background-color: #185abc;
    border-color: #fff;
    box-shadow: 0 0 0 2px #185abc;
    outline: 2px solid transparent;
}
.m3-btn--tonal:active {
    background-color: #185abc;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 2px 6px 2px rgba(60, 64, 67, .15);
    transform: none;
}

/* Outlined — 次要操作 */
.m3-btn--outlined {
    border: 1.5px solid #2563EB;
    color: #2563EB;
    background: transparent;
    border-radius: 9999px;
    padding: 8px 18px;
}
.m3-btn--outlined:hover {
    background: #2563EB;
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.20);
}

/* Ghost — 低强调操作 */
.m3-btn--ghost {
    background: #F1F5F9;
    color: #475569;
    border-radius: 9999px;
    padding: 8px 18px;
}
.m3-btn--ghost:hover {
    background: #E2E8F0;
    color: #1E293B;
    transform: translateY(-1px);
}

/* Chip — 标签/筛选切换 */
.m3-btn--chip {
    background: #FFFFFF;
    color: #475569;
    border: 1px solid #E2E8F0;
    border-radius: 9999px;
    padding: 6px 14px;
    font-size: 13px;
}
.m3-btn--chip:hover {
    border-color: #2563EB;
    color: #2563EB;
    transform: translateY(-1px);
}
.m3-btn--chip.is-active {
    background: #1E293B;
    color: #FFFFFF;
    border-color: #1E293B;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.m3-btn--chip.is-active:hover {
    background: #0F172A;
    color: #FFFFFF;
}

/* Icon — 圆形图标按钮 */
.m3-btn--icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    background: #FFFFFF;
    color: #64748B;
    border: 1px solid #E2E8F0;
}
.m3-btn--icon:hover {
    background: #F8FAFC;
    color: #1E293B;
    border-color: #CBD5E1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Close — 面板/弹窗关闭 (M3 覆盖) */
.m3-btn--close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F1F5F9;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    z-index: 10;
    transition: all 0.2s ease;
}
.m3-btn--close:hover {
    background: #E2E8F0;
    color: #1E293B;
    transform: scale(1.08);
}
.m3-btn--close svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* 尺寸辅助 */
.m3-btn--sm {
    padding: 6px 14px;
    font-size: 12px;
    gap: 4px;
}
.m3-btn--md {
    padding: 10px 20px;
    font-size: 14px;
}
.m3-btn--lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* 全宽 */
.m3-btn--block {
    width: 100%;
}

/* ============================================
   搜索结果网格布局 - M3 适配
   ============================================ */

#resultsGrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--m3-space-lg);
}

@media (max-width: 1200px) {
    #resultsGrid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    #resultsGrid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
}

@media (max-width: 640px) {
    #resultsGrid {
        grid-template-columns: repeat(1, 1fr);
        gap: var(--m3-space-md);
    }

    .m3-search-card {
        min-height: 120px;
        border-radius: 14px;
    }

    .m3-search-card__poster {
        width: 85px;
        border-radius: 14px 0 0 14px;
    }

    .m3-search-card__body {
        padding: 10px var(--m3-space-md);
        gap: 5px;
    }

    .m3-search-card__title {
        font-size: 14px;
    }

    .m3-search-card__subtitle {
        font-size: 12px;
    }

    .m3-search-card__meta {
        font-size: 12px;
    }

    .m3-search-card__tags {
        gap: 4px;
    }

    .m3-search-card__chip,
    .m3-search-card__chip--outlined {
        padding: 2px 8px;
        font-size: 10px;
    }

    .m3-search-card__badge {
        padding: 1px 6px;
        font-size: 9px;
    }
}

/* 确保Toast显示在顶层并有适当的转换效果 */
#toast {
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    text-align: center;
    pointer-events: none;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-100%);
}

/* ============================================
   详情弹窗样式 — M3 创意国际感
   ============================================ */

/* 信息卡片容器 */
#detailModal .modal-detail-info {
    background: linear-gradient(135deg, #F8FAFC, #F1F5F9);
    border: none;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 20px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.03),
        0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* 详情网格 */
#detailModal .detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    font-size: 14px;
}

@media (min-width: 768px) {
    #detailModal .detail-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px 24px;
    }
}

/* 单个信息项 */
#detailModal .detail-item {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

/* 标签 */
#detailModal .detail-label {
    color: #94A3B8;
    font-weight: 500;
    font-size: 13px;
    min-width: 3rem;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}

/* 值 */
#detailModal .detail-value {
    color: #1E293B;
    font-weight: 500;
    font-size: 13px;
    flex: 1;
    word-break: break-word;
}

/* 简介区域 */
#detailModal .detail-desc {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #E2E8F0;
}

#detailModal .detail-desc .detail-label {
    margin-bottom: 6px;
}

#detailModal .detail-desc-content {
    color: #64748B;
    font-size: 13px;
    line-height: 1.7;
    max-height: 120px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

#detailModal .detail-desc-content::-webkit-scrollbar {
    width: 4px;
}

#detailModal .detail-desc-content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

#detailModal .detail-desc-content::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 4px;
}

/* 集数统计 */
#detailModal .episode-stats {
    color: #64748B;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 移动端优化 */
@media (max-width: 640px) {
    #detailModal .modal-detail-info {
        padding: 14px;
        border-radius: 12px;
    }

    #detailModal .detail-grid {
        gap: 8px;
        font-size: 13px;
    }

    #detailModal .detail-label {
        min-width: 2.5rem;
        font-size: 12px;
    }

    #detailModal .detail-value {
        font-size: 12px;
    }

    #detailModal .detail-desc-content {
        max-height: 90px;
        font-size: 12px;
    }
}

/* ========== 底部 Logo 版本号徽章 ========== */
.footer-logo-wrap {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.footer-version-badge {
    position: absolute;
    left: calc(100% + 6px);
    bottom: 0;
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 1px 5px;
    border-radius: 9999px;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
    white-space: nowrap;
    pointer-events: none;
}

/* ===== M3 Filled Card - 视频卡片 ===== */
.m3-video-card {
    position: relative;
    background: var(--m3-surface-container);
    border-radius: var(--m3-shape-lg);
    overflow: hidden;
    transition: background 0.3s ease;
    cursor: pointer;
}

.m3-video-card:hover {
    background: var(--m3-surface-container-high);
}

.m3-video-card .card-image-wrapper {
    position: relative;
    aspect-ratio: 2/3;
    overflow: hidden;
    border-radius: var(--m3-shape-lg) var(--m3-shape-lg) 0 0;
}

.m3-video-card .card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.m3-video-card .card-gradient-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    z-index: 3;
}

.m3-video-card .card-rating-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: var(--m3-primary);
    color: white;
    padding: 4px 10px;
    border-radius: var(--m3-shape-full);
    font-size: 12px;
    font-weight: 700;
    z-index: 4;
}

.m3-video-card .card-douban-link {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: var(--m3-shape-sm);
    font-size: 12px;
    text-decoration: none;
    z-index: 4;
}

.m3-video-card .card-content-wrapper {
    padding: 14px;
}

.m3-video-card .card-title-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--m3-on-surface);
    line-height: 1.4;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


