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

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #242321;
    border: 1px solid #33312e;
    border-radius: 8px;
    padding: 6px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.close-btn:hover {
    background: #33312e;
    border-color: #555;
}

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

/* ★ 字体 @font-face 已抽到 css/fonts.css：
   中文子集 934KB + 950KB 是个大头，同步加载会跟首屏的关键资源抢带宽
   （80KB CSS + 20 个 JS 都要过同一条链路）。改为 media=print 非阻塞引入，
   配合 font-display:swap，首屏先用系统字体渲染，字体到了再无缝替换。 */


:root {
    /* ★ 字体栈 */
    --font-cn: "MiSans", "HarmonyOS Sans SC", "OPPO Sans", "vivo Sans", "HYQiHei",
               "PingFang SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei",
               "Heiti SC", sans-serif;
    --font-sans: "InterVariable", "HarmonyOS Sans SC Web", var(--font-cn);
    --font-mono: "JetBrainsMonoVariable", ui-monospace, SFMono-Regular, Menlo,
                 Consolas, monospace;

    /* 极客暗黑主题 — 一黑到底（暖黑底 + 暖白字 + 单一橙色点缀） */
    --primary-color: #ff9c48;       /* 橙色主强调 */
    --primary-light: #ffb36f;       /* 橙色亮变体 */
    --secondary-color: #121212;     /* 暖黑背景 */
    --accent-color: #ff9c48;        /* 强调色（与主色统一，极客风只留一个彩） */
    --text-color: #f6f3ed;          /* 暖白文本 */
    --text-muted: #aaa7a1;          /* 暖灰次级文本 */
    --border-color: #33312e;        /* hairline 描边 */
    /* 官网同款语义 token */
    --bg: #121212;                  /* 页面底 */
    --surface: #1b1b1b;             /* 卡片/面板面 */
    --soft: #242321;                /* 次级面（胶囊/输入内衬） */
    --line: #33312e;                /* 分割线 */
    --muted: #aaa7a1;               /* 次文字 */
    --accent: #ff9c48;
    --accent-hover: #ffb36f;
    --page-gradient-start: #121212; /* 一黑到底：无渐变 */
    --page-gradient-end: #121212;
    --card-gradient-start: #1b1b1b; /* 卡片面 */
    --card-gradient-end: #1b1b1b;
    --card-accent: rgba(255, 156, 72, 0.10);
    --card-hover-border: rgba(255, 156, 72, 0.45);
}

.page-bg {
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari: 100vh 含地址栏外区域，dvh 才是可视高度（旧浏览器忽略此行回退 vh） */
}

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

/* 改进卡片适应不同内容长度 */
.card-hover {
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--card-gradient-start), var(--card-gradient-end));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 确保卡片内容区域高度一致性 */
.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:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.gradient-text {
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 改进设置面板样式 */
.settings-panel {
    scrollbar-width: thin;
    scrollbar-color: #3d3a36 #242321;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    background: linear-gradient(135deg, var(--page-gradient-end), var(--page-gradient-start));
    /* 边框由 DOM 的 border-l border-[#33312e] 提供（灰色，与观看历史一致）；
       旧版这里的 border-left 是主题橙色 —— 就是左缘那条黄色细线，已去掉 */
}

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

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

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

.settings-panel::-webkit-scrollbar-thumb {
    background-color: #3d3a36;
    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: #161616;
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #3d3a36;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #33312e #161616;
}

.search-tag {
    background: linear-gradient(135deg, var(--card-gradient-start), var(--card-gradient-end));
    color: var(--text-color);
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.7rem;
    border: 1px solid var(--border-color);
    
}

.search-tag:hover {
    background: linear-gradient(135deg, var(--card-gradient-end), var(--card-gradient-start));
    border-color: var(--primary-color);
}

.footer {
    width: 100%;
    transition: all 0.3s ease;
    margin-top: auto;
    background: linear-gradient(to bottom, transparent, var(--page-gradient-start));
    border-top: 1px solid var(--border-color);
}

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

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    /* ★ 全站字体（覆盖 tailwind preflight 的 ui-sans-serif） */
    font-family: var(--font-sans);
    /* 暗底白字在 WebView 里默认会「发虚变粗」，关掉次像素渲染更干净 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* ⚠️ 这里【不能】写 text-rendering: optimizeLegibility：
       它会让每个文本 run 都做连字/字距计算，长列表（几百张卡）下是纯负担，
       实测比默认值更卡；标题级别的「精修」不值得全站买单。 */
}

/* ★ 屏外卡片「跳过渲染」：content-visibility:auto 让浏览器对不在视口内的卡片
   直接跳过 layout + paint（连内部的封面图、角标、文字全都不算），
   滚动时只处理眼前这一屏。配合 contain-intrinsic-size(带 auto 记忆上次尺寸)
   保证滚动条长度不跳。rank.css 里 .rank-card 早就这么干了，这里补齐
   搜索结果卡与首页海报卡 —— 这几处才是数量最多的。
   老内核不支持时这两条声明被整体忽略，无副作用。 */
.search-card {
    content-visibility: auto;
    /* 搜索卡是横向布局：封面容器 100×150，卡高 ≈150 */
    contain-intrinsic-size: auto 150px;
}
.hot-card {
    content-visibility: auto;
    /* 首页海报卡 2/3 比例、手机两列 → 约 180 宽 × 270 高 */
    contain-intrinsic-size: auto 268px;
}

/* ★ 数据位用等宽字体 + 等宽数字：版本号/集数/时长/热度跳动时不会左右抖 */
.font-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.container {
    flex: 1;
}

@media screen and (min-height: 800px) {
    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .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;
}

/* ⚠️ 换源弹窗已改为底部抽屉（.src-modal-panel，样式在 player.css）。
   这条老规则用 ID 选择器会给面板强加 8px 圆角和蓝色描边，必须让位；
   同时只作用于直系子 div，避免误伤底部脚注等其它 #modal > div。 */
#modal > div:not(.src-modal-panel) {
    background: linear-gradient(135deg, var(--card-gradient-start), var(--card-gradient-end));
    border: 1px solid var(--primary-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(0, 204, 255, 0.1);
    border-radius: 8px;
}

#episodesGrid button {
    background: rgba(0, 204, 255, 0.08);
    border: 1px solid rgba(0, 204, 255, 0.2);
    transition: all 0.2s ease;
}

#episodesGrid button:hover {
    background: rgba(0, 204, 255, 0.15);
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(0, 204, 255, 0.3);
}

#yellowFilterToggle:checked + .toggle-bg {
    background-color: var(--primary-color);
}

#yellowFilterToggle:checked ~ .toggle-dot {
    transform: translateX(1.5rem);
}

#yellowFilterToggle:focus + .toggle-bg,
#yellowFilterToggle:hover + .toggle-bg {
    box-shadow: 0 0 0 2px rgba(0, 204, 255, 0.3);
}

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

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

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

.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;
}

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

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

/* 添加API复选框样式 */
.form-checkbox {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: 14px;
    width: 14px;
    background-color: #242321;
    border: 1px solid #33312e;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    outline: none;
}

.form-checkbox:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

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

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

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

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

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

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

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

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

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

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

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

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

.settings-panel::-webkit-scrollbar-thumb {
    background-color: #3d3a36;
    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-adult + label {
    color: #ff6b8b !important;
}

/* 添加警告图标和标签样式 */
.adult-warning {
    display: inline-flex;
    align-items: center;
    margin-left: 0.25rem;
    color: #ff6b8b;
}

.adult-warning svg {
    width: 12px;
    height: 12px;
    margin-right: 4px;
}

/* 过滤器禁用样式 */
.filter-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

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

.api-group-title.adult {
    color: #ff6b8b;
}

/* 过滤器禁用样式 - 改进版本 */
.filter-disabled {
    position: relative;
}

.filter-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    border-radius: 0.3rem;
    z-index: 5;
}

/* =========================================================
   ★ 设置页开关（内容过滤 / 分片广告过滤）
   为什么用纯 CSS 写死尺寸、而不是靠 Tailwind 类：
   tailwind.build.css 是【预构建产物】，源码里新写的类名（如 w-14 / h-8）
   根本没被编进去 → 开关会变成 0 宽、直接看不见。这里自给自足。
   尺寸：轨道 56×32，滚珠 24，左右各留 4 → 位移 24px（= 原 translateX(1.5rem)）。
   ========================================================= */
.toggle-wrap {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 32px;
    flex: 0 0 auto;
    vertical-align: middle;
    -webkit-user-select: none;
    user-select: none;
}
.toggle-wrap > input[type="checkbox"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    z-index: 10;
    cursor: pointer;
}
.toggle-wrap > .toggle-bg {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background-color: #33312e;
}
.toggle-wrap > .toggle-dot {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background-color: #fff;
}

.filter-disabled > * {
    opacity: 0.7;
}

.filter-disabled .toggle-bg {
    background-color: #33312e !important;
}

.filter-disabled .toggle-dot {
    transform: translateX(0) !important;
    background-color: #666 !important;
}

/* 改进过滤器禁用样式 */
.filter-disabled .filter-description {
    color: #ff6b8b !important;
    font-style: italic;
    font-weight: 500;
}

/* 修改过滤器禁用样式，确保文字清晰可见 */
.filter-disabled {
    position: relative;
}

.filter-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.3);
    border-radius: 0.3rem;
    z-index: 5;
}

.filter-disabled > * {
    opacity: 1; /* 提高子元素不透明度，保证可见性 */
    z-index: 6; /* 确保内容在遮罩上方 */
}

/* 改进过滤器禁用状态下的描述样式 */
.filter-disabled .filter-description {
    color: #ff7b9d !important; /* 更亮的粉色 */
    font-style: italic;
    font-weight: 500;
    text-shadow: 0 0 2px rgba(0,0,0,0.8); /* 添加文字阴影提高对比度 */
}

/* 开关的禁用样式 */
.filter-disabled .toggle-bg {
    background-color: #3d3a36 !important;
    opacity: 0.8;
}

.filter-disabled .toggle-dot {
    transform: translateX(0) ;
    background-color: #777 ;
    opacity: 0.9;
}

/* 警告提示样式改进 */
.filter-tooltip {
    background-color: rgba(255, 61, 87, 0.1);
    border: 1px solid rgba(255, 61, 87, 0.2);
    border-radius: 0.25rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    line-height: 1.25;
    position: relative;
    z-index: 10;
}

.filter-tooltip svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-right: 0.35rem;
}

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

.custom-api-edit:hover {
    color: #5fa0ff;
}

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

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

/* 成人内容标签样式 */
.adult-tag {
    display: inline-flex;
    align-items: center;
    color: #ff6b8b;
    font-size: 0.7rem;
    font-weight: 500;
    margin-right: 0.35rem;
}

/* 历史记录面板样式 */
.history-panel {
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);   /* 面板已移到右半屏，阴影朝左 */
    transform: translateX(100%);                /* ★ 隐藏态直写 CSS（tailwind 正方向类未被 JIT 编译，靠它会常驻屏幕） */
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
    width: 85vw;
    max-width: 320px;
    box-sizing: border-box;
    scrollbar-gutter: stable;
}

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

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

/* 历史记录项样式优化 */
.history-item {
    background: linear-gradient(135deg, var(--card-gradient-start), var(--card-gradient-end));
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.18s ease;
    padding: 10px 12px;
    position: relative;
    margin-bottom: 6px;
    width: 100%;
}

.history-item:hover {
    transform: translateY(-2px);
    border-color: #3d3a36;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 添加组悬停效果，使删除按钮在悬停时显示 */
.history-item .delete-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.history-info {
    padding: 0; /* 移除额外的内边距 */
    min-height: 70px;
}

.history-title {
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-color);
}

.history-meta {
    color: var(--text-muted);
    font-size: 0.72rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 2px;
}

.history-episode {
    color: #3b82f6;
}

.history-source {
    color: #10b981;
}

.history-time {
    color: #888;
    font-size: 0.7rem; /* 减小字体大小 */
    margin-top: 1px; /* 减小顶部边距 */
}

.history-separator {
    color: var(--muted);
}

.history-thumbnail {
    width: 100%;
    height: 90px;
    background-color: #242321;
    overflow: hidden;
}

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

/* ★ 历史记录：左封面缩略图 + 右文字 布局（tailwind 预编译无此组合，写显式规则） */
.history-item {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

/* 左竖版封面（约 2:3），圆角裁图 */
.history-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 84px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #242321;
    position: relative;
}

.history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 无封面 / 加载失败占位：灰底 + 标题首字 */
.history-thumb--ph {
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-thumb--ph::after {
    content: attr(data-ph);
    color: var(--muted);
    font-size: 22px;
    font-weight: 600;
    line-height: 1;
}

/* 右侧文字区：占满剩余宽度，防溢出 */
.history-info {
    flex: 1;
    min-width: 0;
}

.history-info {
    padding: 10px;
}

.history-time {
    color: #888;
    font-size: 0.8rem;
    margin-top: 4px;
}

.history-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.progress-bar {
    height: 3px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 2px;
}

.progress-filled {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

.progress-text {
    font-size: 10px;
    color: #888;
    text-align: right;
}

/* 添加恢复播放提示样式 */
.position-restore-hint {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: rgba(0, 0, 0, 0.7);
    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-text {
    display: inline;
}
.home-btn-text {
    display: inline;
}
@media (max-width: 640px) {
    /* ★ 手机上不再隐藏「轻影」品牌名：用户要的是 logo + 名字一起显示。
       原来为了给标题腾空间把它藏了，结果顶栏只剩一个孤零零的图标。 */
    .home-btn-text {
        display: none;
    }
    .logo-icon {
        margin-right: 6px;
    }
    .home-btn svg {
        margin-right: 0;
    }
    .player-header {
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .custom-title-scroll {
        font-size: 1rem;
    }
}

/* 搜索结果卡片优化：横向布局 */
.search-card-img-container {
    width: 100px;  /* 增加宽度，从80px到100px */
    height: 150px; /* 增加高度，从120px到150px */
    overflow: hidden;
    background-color: #262422;
}

/* 确保图片不会被拉伸，并且能够正确显示 */
.search-card-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 针对搜索结果卡片修改网格布局以适应横向卡片 */
@media (max-width: 640px) {
    #results {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
}

/* 响应式调整：在小屏幕上依然保持较好的视觉效果 */
@media (min-width: 641px) and (max-width: 768px) {
    #results {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* 调整网格布局，减少每行卡片数量以适应更大尺寸的卡片 */
@media (min-width: 769px) and (max-width: 1024px) {
    #results {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1025px) {
    #results {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    }
}

/* 首页热门流(hot-grid) / 分块网格(hb-grid)：平板放宽列数
   手机端 <641px 保持 grid-cols-3（与 home.js 基线一致，行为不变）；
   641+ 4列 / 769+ 5列 / 1025+ 6列。
   说明：home.js 已写 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6，
   但当前预编译 tailwind.build.css 未含 md:grid-cols-5 / lg:grid-cols-6，
   故在此用与 #results 同款显式媒体查询兜底，保证大屏真实渲染。 */
@media (min-width: 641px) {
    .hot-grid, .hb-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 769px) {
    .hot-grid, .hb-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1025px) {
    .hot-grid, .hb-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    }
}

/* 加载中 / 空态占位在任何列数下都占满整行（手机端 3 列时与原 col-span-3 视觉完全一致） */
.hot-grid > .col-span-3, .hb-grid > .col-span-3 {
    grid-column: 1 / -1;
}

/* 优化卡片内元素间距 */
.card-hover .p-2 {
    padding: 0.75rem; /* 增加内边距 */
}

/* 增加卡片内字体大小 */
.card-hover h3 {
    font-size: 0.95rem; /* 增加标题字体大小 */
    line-height: 1.3rem;
    margin-bottom: 0.5rem;
}

.card-hover p {
    font-size: 0.8rem; /* 增加描述字体大小 */
}

/* 优化卡片内元素间距 */
.card-hover .p-2 {
    padding: 0.5rem;
}

/* 确保Toast显示在顶层并有适当的转换效果 */
#toast {
    z-index: 9999; /* 确保显示在最上层 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    text-align: center;
    pointer-events: none; /* 防止toast阻挡点击事件 */
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

/* 详情模态框样式优化 */
#modal .modal-detail-info {
    background: linear-gradient(135deg, #0d0d0d, #161616);
    border: 1px solid #242321;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

#modal .detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    font-size: 0.7rem;
}

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

#modal .detail-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#modal .detail-label {
    color: #9ca3af;
    font-weight: 500;
    min-width: 3rem;
    flex-shrink: 0;
}

#modal .detail-value {
    color: white;
    flex: 1;
    word-break: break-word;
}

#modal .detail-desc {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #33312e;
}

#modal .detail-desc-content {
    color: #d1d5db;
    font-size: 0.7rem;
    line-height: 1.6;
    max-height: 8rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3d3a36 #242321;
}

#modal .detail-desc-content::-webkit-scrollbar {
    width: 6px;
}

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

#modal .detail-desc-content::-webkit-scrollbar-thumb {
    background-color: #3d3a36;
    border-radius: 4px;
}

/* 集数统计信息样式 */
#modal .episode-stats {
    color: #9ca3af;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 移动端优化 */
@media (max-width: 640px) {
    #modal .detail-grid {
        gap: 0.5rem;
        font-size: 0.8rem;
    }
    
    #modal .detail-label {
        min-width: 2.5rem;
    }
    
    #modal .detail-desc-content {
        max-height: 6rem;
        font-size: 0.8rem;
    }
}

/* ══════════ UI 美化优化（暗色调保持） ══════════ */

/* 全局平滑 */
* {
    -webkit-tap-highlight-color: transparent;
}

/* 统一按钮 */
button, .btn, input[type="button"], input[type="submit"] {
    transition: all 0.18s ease;
    border-radius: 8px;
}

/* 主按钮 */
button[type="submit"], .bg-gradient-to-r {
    box-shadow: 0 2px 8px rgba(0, 204, 255, 0.15);
}
button[type="submit"]:hover {
    box-shadow: 0 4px 16px rgba(0, 204, 255, 0.3);
    transform: translateY(-1px);
}
button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 204, 255, 0.2);
}

/* 搜索框 */
input[type="text"], input[type="search"], input[type="password"], textarea, select {
    border-radius: 8px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input[type="text"]:focus, input[type="search"]:focus, input[type="password"]:focus, textarea:focus {
    outline: none;
    border-color: rgba(0, 204, 255, 0.4) !important;
    box-shadow: 0 0 0 3px rgba(0, 204, 255, 0.08);
}

/* 卡片/面板统一圆角 */
.rounded-lg, .rounded-xl {
    border-radius: 10px;
}

/* 搜索历史标签更紧凑 */
.search-tag {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}
.search-tag:hover {
    transform: translateY(-1px);
}

/* 设置面板分组标题 */
.api-group-title {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

/* 复选框放大点击区域 */
input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 204, 255, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 204, 255, 0.3);
}

/* 链接颜色统一 */
a {
    transition: color 0.15s ease;
}

/* 模态框阴影更柔和 */
.modal, [role="dialog"] {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* 进度条平滑 */
video::-webkit-media-controls-timeline {
    height: 4px !important;
}

/* 首页快捷入口卡片 */
.home-quick a {
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.home-quick a:hover {
    transform: translateY(-2px);
}


/* ══════════ iOS Safari 适配（2026-10） ══════════ */
/* 去除点按灰色高亮块（iOS 默认给可点元素加半透明遮罩，观感差） */
* { -webkit-tap-highlight-color: transparent; }
/* 禁止橡皮筋滚动露底（Safari 16+ 支持） */
html, body { overscroll-behavior-y: none; }

/* ══════════ 移动端降级：禁用 backdrop-filter（滚动合成层开销大） ══════════ */
@media (max-width: 480px) {
  * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}
