:root {
    --primary-color: #3b82f6;
    --reader-bg: #f8f9fa;
    --text-color: #333;
    --img-spacing-v: 0px;
    --img-spacing-h: 0px;
    --img-border: 1px;
}
body.dark-mode {
    --reader-bg: #121212;
    --text-color: #ddd;
}
body, html { 
    height: 100%; width: 100%; 
    background: var(--reader-bg); 
    color: var(--text-color);
    -webkit-tap-highlight-color: transparent;
    margin: 0; padding: 0;
}

/* 核心容器 */
#reader-stage {
    width: 100%; height: 100%; position: fixed; 
    top: 0; left: 0; z-index: 1;
    overflow-y: scroll; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* 强制隐藏 (显隐控制用) */
.force-hidden { display: none !important; }

/* 模式控制 */
body.mode-paged #reader-stage { overflow: hidden !important; display: flex; align-items: center; justify-content: center; }
body.mode-paged.view-double.dir-rtl #reader-stage { flex-direction: row-reverse !important; }

body.mode-horizontal #reader-stage { display: flex; flex-wrap: nowrap; overflow-x: auto !important; overflow-y: hidden !important; }
body.mode-horizontal.dir-rtl #reader-stage { direction: rtl !important; }

body.mode-vertical.view-double #reader-stage { display: flex !important; flex-wrap: wrap !important; }
body.mode-vertical.view-double.dir-rtl #reader-stage { direction: rtl !important; }

/* 图片容器 */
.page-wrap {
    position: relative; display: flex; justify-content: center; align-items: center;
    background: transparent; min-height: 50px; box-sizing: border-box;
    padding: var(--img-spacing-v) var(--img-spacing-h);
}
body.mode-vertical .page-wrap { width: 100%; margin-bottom: 0; }
body.mode-vertical.view-double .page-wrap { width: 50% !important; }
body.mode-vertical.view-double.first-spread #reader-stage .page-wrap:first-of-type { width: 100% !important; }
body.mode-vertical.view-double.dir-rtl #reader-stage .page-wrap { direction: ltr; }

body.mode-paged .page-wrap { width: auto; height: 100%; max-width: 100vw; background: transparent; }
body.mode-paged.view-double .page-wrap { max-width: 50vw; }

body.mode-horizontal .page-wrap { width: auto; height: 100%; flex-shrink: 0; margin-right: 0; }

/* 图片样式 */
.manga-img {
    display: block; width: auto; height: auto; max-width: 100%;
    opacity: 0; transition: opacity 0.3s;
    border: var(--img-border) solid #333;
}
.manga-img.loaded { opacity: 1; }
body.mode-paged .manga-img, body.mode-horizontal .manga-img { max-height: 100vh; object-fit: contain; }
body.mode-horizontal .manga-img { max-width: 100vw; }

/* 加载提示 */
.page-wrap::after { content: "Loading..."; position: absolute; color: #999; font-size: 12px; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 0; }
.page-wrap.end-page::after, .page-wrap.is-loaded::after { display: none; }

/* 角标页码 */
.img-page-num { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,0.5); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 10px; pointer-events: none; display: none; z-index: 10; }
body.show-indicator .img-page-num { display: block; }

/* UI 控件 */
.control-bar { position: fixed; left: 0; width: 100%; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); z-index: 1000; transition: transform 0.3s ease; box-shadow: 0 1px 5px rgba(0,0,0,0.1); }
body.dark-mode .control-bar { background: rgba(30, 30, 30, 0.95); color: #fff; }
.bar-top { top: 0; height: 50px; padding: 10px; display: flex; align-items: center; justify-content: space-between; }
.bar-bottom { bottom: 0; padding: 15px; padding-bottom: max(15px, env(safe-area-inset-bottom)); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.reader-icon-btn { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; }
.reader-bottom-tool { min-width: 64px; padding: 0; border: 0; background: transparent; color: inherit; line-height: 1.2; transition: none; }
.reader-bottom-tool:focus, .reader-icon-btn:focus { box-shadow: none; }
body.ui-hidden .bar-top { transform: translateY(-100%); }
body.ui-hidden .bar-bottom { transform: translateY(100%); }

/* 进度条 */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; height: 4px; border-radius: 2px; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { 
    -webkit-appearance: none; 
    height: 20px; width: 20px; 
    border-radius: 50%; 
    background: #fff; 
    margin-top: -8px; 
    box-shadow: 0 1px 4px rgba(0,0,0,0.3); 
    border: none; 
    transition: transform 0.1s;
}
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.1); }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; background: transparent; }

#page-indicator { position: fixed; bottom: 20px; right: 20px; background: rgba(0,0,0,0.6); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 12px; z-index: 800; pointer-events: none; transition: opacity 0.3s; opacity: 0; }
body.show-indicator #page-indicator { opacity: 0 !important; }

.offcanvas-bottom { height: auto !important; border-top-left-radius: 16px; border-top-right-radius: 16px; max-height: 85vh; }
body.dark-mode .offcanvas, body.dark-mode .modal-content { background-color: #1e1e1e; color: #fff; }
.settings-section { margin-bottom: 20px; }
.settings-title { font-size: 12px; color: #888; margin-bottom: 8px; font-weight: bold; }
.btn-group-custom { display: flex; background: rgba(0,0,0,0.05); border-radius: 20px; padding: 4px; }
body.dark-mode .btn-group-custom { background: rgba(255,255,255,0.1); }
.btn-group-custom .btn { flex: 1; border: none; border-radius: 16px; font-size: 13px; padding: 6px 0; color: #666; background: transparent; }
.btn-group-custom .btn.active { background: #fff; color: #000; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
body.dark-mode .btn-group-custom .btn.active { background: #3b82f6; color: #fff; }
.section-disabled { opacity: 0.4 !important; pointer-events: none !important; filter: grayscale(100%) !important; }
.end-nav-box { padding: 40px 20px; text-align: center; width: 100%; clear: both; }
.end-btn { display: inline-block; padding: 8px 20px; border-radius: 20px; background: var(--primary-color); color: #fff; text-decoration: none; margin: 0 5px; font-size: 14px; }
.end-btn.disabled { background: #ccc; pointer-events: none; }
