/* CSS 部分 */
:root { --ui-bg: rgba(20, 20, 20, 0.95); --hint-color: rgba(0, 122, 255, 0.4); }
body { margin: 0; background: #000; color: #fff; font-family: sans-serif; overflow: hidden; }

/* 顶层 UI 栏 */
#top-bar, #bottom-bar { position: fixed; left: 0; width: 100%; background: var(--ui-bg); transition: transform 0.3s ease-in-out; z-index: 9999 !important; }
#top-bar { top: 0; height: 50px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid #333; }
#bottom-bar { bottom: 0; height: 65px; display: flex; align-items: center; justify-content: space-around; border-top: 1px solid #333; }

/* 浮动按钮 */
#float-fav, #float-mode {
    position: fixed !important; 
    right: 20px !important;
    width: auto;
    height: 40px;
    padding: 0 15px;
    background: rgba(30, 30, 30, 0.9); 
    border: 1px solid #ffcc00; 
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important; 
    pointer-events: auto !important;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 14px;
    color: #fff;
}
#float-fav { bottom: 140px !important; }
#float-mode { bottom: 195px !important; }
#float-mode, #float-fav, #top-bar, #global-bottom-bar {
    z-index: 9999 !important;
    pointer-events: auto !important;
}

/* 隐藏状态控制 */
.ui-hidden-top { transform: translateY(-100%); }
.ui-hidden-bottom { transform: translateY(150%); } 
.ui-fav-hidden { transform: translateX(100px); opacity: 0; pointer-events: none; }

/* 内容容器 */
#container { width: 100vw; height: 100vh; overflow-x: hidden; position: relative; z-index: 10; }
#container:not(.page-mode) {
    width: 100vw;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; 
    position: relative;
}
#container:not(.page-mode) img { width: 100vw !important; display: block !important; }
.page-mode { overflow: hidden !important; }

/* 图片层默认不响应事件，缩放时由 JS 控制 pointer-events */
#container img, .manga-page, .page-mode img {
    user-select: none;
    z-index: 10;
}

/* 翻页模式样式 */
.page-mode img { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%) scale(0.95); 
    max-width: 100vw; 
    max-height: 100vh; 
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.4s ease, transform 0.3s ease; 
}
.page-mode img.active { opacity: 1; visibility: visible; z-index: 20; transform: translate(-50%, -50%) scale(1); }
#mode-hint, .mode-hint {
    display: none !important;
    pointer-events: none !important;
}
/* 付费页样式 */
#pay-page {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    background: #000 !important;
    min-height: 100vh;
    width: 100vw;
    z-index: 9000 !important; 
    position: relative;
    padding-top: 80px; 
    padding-bottom: 100px;
    box-sizing: border-box;
    pointer-events: auto !important;
}
.page-mode #pay-page { 
    position: absolute; 
    top: 0; 
    left: 0; 
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.4s ease;
    overflow-y: auto; 
    transform: none !important; 
}
.page-mode #pay-page.active { opacity: 1; visibility: visible; z-index: 9000; }

/* 核心：交互层网格重构，置于较高层级以便点击与提示可见 */
#interaction-layer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 500;
    display: grid;
    grid-template-columns: 4fr 2fr 4fr;
    grid-template-rows: 4fr 2fr 4fr;
    pointer-events: none;
}
#interaction-layer > * { pointer-events: auto; }

/* 区域对齐：上、左中右、下三行 */
.area-up     { grid-area: 1 / 1 / 2 / 4; }
.area-left   { grid-area: 2 / 1 / 3 / 2; }
.area-center { grid-area: 2 / 2 / 3 / 3; }
.area-right  { grid-area: 2 / 3 / 3 / 4; }
.area-down   { grid-area: 3 / 1 / 4 / 4; position: relative; }
.area-up, .area-down, .area-left, .area-right, .area-center {
    position: relative;
}

/* 区域提示：2 秒后自动隐藏 */
.area-hint {
    position: absolute;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease;
}
.area-hint-up {
    top: 12px;
    left: 12px;
    background: rgba(0, 180, 80, 0.75);
    color: #fff;
}
.area-hint-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
}
.area-hint-down {
    bottom: 12px;
    right: 12px;
    background: rgba(0, 120, 215, 0.75);
    color: #fff;
}
.area-hint.area-hint-hidden {
    opacity: 0;
    visibility: hidden;
}

/* 菜单弹窗 */
.menu-popup { 
    position: fixed; 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(-50%); 
    background: #1a1a1a; 
    border: 1px solid #444; 
    border-radius: 15px; 
    padding: 15px; 
    display: none; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 10px; 
    z-index: 9999 !important;
    pointer-events: auto !important; 
    width: 85%; 
    max-height: 60vh; 
    overflow-y: auto; 
}
.menu-item { background: #333; padding: 12px 8px; text-align: center; border-radius: 10px; font-size: 13px; }
#loading {
    text-align: center;
    padding-top: 45vh;
    color: #aaa;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 45vh;
    animation: loading-pulse 1.2s ease-in-out infinite;
}
@keyframes loading-pulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
.bottom-btn { cursor: pointer; display: flex; flex-direction: column; align-items: center; font-size: 12px; }
#global-bottom-bar {
    z-index: 9000;
    pointer-events: auto; /* 允许点击按钮 */
}
/* 进度预览条优化 */
#progress-bar {
    position: fixed !important;
    bottom: 75px !important; /* 稍微调高一点，视觉中心更好 */
    left: 10px; 
    right: 10px;
    height: 40px !important; 
    z-index: 100 !important;
    display: flex !important;
    align-items: center;
    gap: 4px; /* 点与点之间的间距 */
    background: transparent !important;
    pointer-events: auto !important;
    touch-action: none;
}
.progress-cell {
    flex: 1;
    height: 4px; /* 默认高度 */
    background: rgba(255, 255, 255, 0.2); /* 默认深灰色/半透明白 */
    border-radius: 2px;
    transition: all 0.2s ease;
    pointer-events: auto !important;
}

.progress-cell.active {
    height: 6px; /* 激活时稍微加粗一点点，更有层次感 */
    background: #00d2ff !important; /* 亮蓝色 */
    /* 核心：浅蓝色外发光效果 */
    box-shadow: 
        0 0 8px rgba(0, 210, 255, 0.8),  /* 核心光晕 */
        0 0 15px rgba(0, 210, 255, 0.4); /* 弥散光晕 */
    border-radius: 3px;
}

#progress-bar::before, #progress-bar::after {
    display: none !important;
    content: none !important;
}

/* 收藏夹 Overlay */
#fav-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 10000; display: none; overflow-y: auto; pointer-events: auto; transform: translateZ(9999px); }
#fav-header { position: sticky; top: 0; height: 50px; background: var(--ui-bg); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid #333; font-weight: bold; }
#fav-list { padding: 15px 10px 100px 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; }
.fav-card { display: flex; flex-direction: column; }
.fav-thumb { aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; background: #1a1a1a; }
.fav-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fav-title { margin-top: 6px; font-size: 11px; height: 32px; overflow: hidden; color: #ddd; }
#close-fav-btn { position: fixed; right: 20px; bottom: 30px; height: 40px; padding: 0 20px; background: var(--ui-bg); border: 1px solid #444; border-radius: 20px; display: flex; align-items: center; justify-content: center; z-index: 10001; }

/* VIP 引导内容 */
.vip-gate-container { position: relative; z-index: 9100; padding-top: 20px; padding-bottom: 50px; background: #1a1a1a; pointer-events: auto !important; }
.vip-card { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; padding: 20px; margin-bottom: 15px; width: 90%; position: relative; pointer-events: auto !important; }
.pay-btn, .share-btn, .center-btn { pointer-events: auto !important; z-index: 100000 !important; cursor: pointer; border: none; font-weight: bold; }
.pay-btn { background: #007aff; color: white; width: 100%; padding: 12px; border-radius: 10px; }
.share-btn { background: #34c759; color: white; width: 100%; padding: 12px; border-radius: 10px; margin-top: 10px; }
.center-btn { 
    width: 100%; padding: 12px; background: linear-gradient(90deg, #ffcc00 0%, #ff9500 100%); 
    border-radius: 12px; color: #000; font-size: 14px; display: flex; justify-content: space-between; align-items: center; 
}
.vip-header { font-size: 18px; font-weight: bold; color: #ffcc00; margin-bottom: 30px; line-height: 1.5; }
.agent-box { border: 1px dashed #ffcc00; background: rgba(255, 204, 0, 0.03); }
.agent-grid { display: flex; justify-content: space-around; margin: 15px 0; }
.label { display: block; font-size: 11px; color: #888; }
.value { font-size: 18px; font-weight: bold; color: #fff; }
.highlight { color: #ffcc00; }
.agent-features { text-align: left; margin-top: 15px; padding: 10px; background: rgba(255, 255, 255, 0.03); border-radius: 8px; }
.feature-item { font-size: 12px; color: #bbb; margin-bottom: 8px; line-height: 1.4; }
.remove-btn { 
    position: absolute !important; top: 5px !important; right: 5px !important; width: 28px !important; height: 28px !important; 
    background: #ff4d4f !important; color: white !important; border-radius: 50% !important; display: flex !important; 
    align-items: center !important; justify-content: center !important; z-index: 9999 !important; font-size: 18px !important; 
    border: 2px solid #fff !important; 
}
.manga-card { position: relative !important; overflow: visible !important; }
.cover-wrap { width: 100%; aspect-ratio: 3/4; background-size: cover; background-position: center; border-radius: 6px; }
#mode-hint, .mode-hint {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}