/* ================================================================
   ★★★ 沉浸式报亭 - 完整样式（含分类Tab） ★★★
   ================================================================ */

/* ===== 全局变量 ===== */
:root {
    --bg-primary: #f0f2f5;
    --bg-card: #ededed;/* ===== rgba(255,255,255,0.7) ===== */
    --bg-card-solid: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8a8aa0;
    --accent: #5b6abf;
    --accent-light: #7c8cdb;
    --border: rgba(0,0,0,0.06);
    --shadow: 0 8px 32px rgba(0,0,0,0.08);
    --radius: 24px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --glass-bg: rgba(255,255,255,0.3);
    --glass-border: rgba(255,255,255,0.2);
    --backdrop: blur(12px);
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #12121a;
        --bg-card: #111111;/* ===== rgba(30,30,46,0.7) ===== */
        --bg-card-solid: #1e1e2e;
        --text-primary: #e0e0f0;
        --text-secondary: #a0a0b8;
        --text-muted: #6a6a80;
        --accent: #7c8cdb;
        --accent-light: #9aabf0;
        --border: rgba(255,255,255,0.06);
        --shadow: 0 8px 32px rgba(0,0,0,0.3);
        --glass-bg: rgba(30,30,46,0.5);
        --glass-border: rgba(255,255,255,0.05);
    }
}

/* ===== 重置 ===== */
* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s;
}

/* ===== 应用容器 ===== */
.reader-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    background: var(--bg-primary);
}

/* ===== 顶部导航条 ===== */
.reader-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    background: var(--bg-card);
    backdrop-filter: var(--backdrop);
    -webkit-backdrop-filter: var(--backdrop);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-left .brand {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}
.nav-left .brand img {
    border-radius:50%;border: 1px solid var(--border-color);background: var(--accent-color);padding:0;vertical-align: middle;object-fit:cover;
}
.nav-center {
    flex: 1;
    text-align: center;
    font-weight: 500;
    font-size: 16px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-right button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}
.nav-right button:hover {
    background: var(--border);
    color: var(--accent);
}
.nav-right .fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    transition: color 0.25s ease, transform 0.15s ease;
}
.nav-right .fav-btn:hover {
    color: #ff6b6b;
    transform: scale(1.1);
}
.nav-right .fav-btn.active {
    color: #ff4757;
}
.nav-right .fav-btn.active svg g path[opacity=".5"] {
    opacity: 0.85;
}
@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.nav-right .fav-btn.active svg {
    animation: heartPop 0.35s ease;
}
.nav-right .share-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}
.nav-right .share-btn:hover {
    background: var(--border);
    color: var(--accent);
}

/* ===== 主体 iframe ===== */
.reader-body {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}
.reader-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    transition: opacity 0.3s;
}
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 5;
    pointer-events: none;
}
.loading-indicator.show {
    display: flex;
}
.loading-indicator .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-indicator .label {
    font-size: 14px;
    color: var(--text-muted);
}

.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    z-index: 20;
    cursor: pointer;
}
.error-overlay.show {
    display: flex;
}
.error-content {
    background: var(--bg-card-solid);
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    max-width: 320px;
    box-shadow: var(--shadow);
    cursor: default;
    pointer-events: auto;
    animation: popIn 0.25s ease-out;
}
@keyframes popIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.error-content p {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.error-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.error-actions button {
    white-space: nowrap;
    padding: 6px 16px;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    cursor: pointer;
    background: var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
    flex: 1;
    min-width: 70px;
}
.error-actions button:hover {
    background: var(--accent);
    color: white;
}
.error-actions button#ignoreBtn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.error-actions button#ignoreBtn:hover {
    background: var(--border);
    color: var(--text-primary);
}
.http-notice {
    background: var(--bg-card-solid);
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    max-width: 320px;
    box-shadow: var(--shadow);
    cursor: default;
    pointer-events: auto;
    animation: popIn 0.25s ease-out;
}
.http-notice p {
    font-size: 15px;
    margin-bottom: 16px;
    color: var(--text-primary);
    line-height: 1.6;
}
.http-notice strong {
    color: var(--accent);
}
.http-notice button {
    padding: 6px 24px;
    border: none;
    border-radius: 30px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.http-notice button:hover {
    background: var(--accent-light);
}

/* ===== 悬浮翻页胶囊 ===== */
.capsule-container {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
    touch-action: none;
}
.capsule {
    pointer-events: auto;
    background: var(--bg-card);
    backdrop-filter: var(--backdrop);
    -webkit-backdrop-filter: var(--backdrop);
    border: 1px solid var(--border);
    border-radius: 40px;
    box-shadow: var(--shadow);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow: hidden;
    max-width: 280px;
    min-height: 40px;
}
.capsule.collapsed {
    width: 48px;
    padding: 6px;
    justify-content: center;
    cursor: pointer;
    min-height: 40px;
}
.capsule.collapsed .capsule-content {
    opacity: 0;
    width: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
}
.capsule-content {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s, width 0.3s;
    opacity: 1;
    width: auto;
}
.capsule .toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background 0.2s, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}
.capsule .toggle-btn:hover {
    background: var(--border);
}
.capsule .arrow-icon {
    transition: transform 0.3s ease;
}
.capsule.collapsed .arrow-icon {
    transform: rotate(180deg);
}
.capsule .nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    font-weight: 500;
}
.capsule .nav-btn:hover {
    color: var(--accent);
}
.capsule .count {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 56px;
    text-align: center;
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .capsule-container { bottom: 20px; right: 12px; }
    .capsule { padding: 4px 10px; min-height: 36px; }
    .capsule.collapsed { width: 40px; padding: 4px; min-height: 36px; }
    .capsule .toggle-btn { width: 24px; height: 24px; }
    .capsule .nav-btn { font-size: 13px; }
    .capsule .count { font-size: 12px; min-width: 48px; }
}
@media (max-width: 480px) {
    .capsule-container { bottom: 16px; right: 8px; }
    .capsule .count { font-size: 11px; min-width: 40px; }
    .capsule .nav-btn { font-size: 12px!important; }
    .capsule { padding: 4px 8px; min-height: 32px; }
    .capsule.collapsed { width: 36px; padding: 4px; min-height: 32px; }
    .nav-right .share-btn { width: 28px; height: 28px; }
}

        .ad-banner {
            width: 100%;
            max-width: 420px;
            border-radius: 12px;
            overflow: hidden;
            margin-top: 0;
            margin-bottom: 10px;
            height: 60px;
            line-height: 0;
            background: var(--bg-card);
            backdrop-filter: var(--backdrop);
            border: 1px solid var(--glass-border);
            box-shadow: var(--shadow);
        }
        .ad-banner a {
            display: block;
            width: 100%;
            height: 100%;
        }
        .ad-banner img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        
/* ===== 抽屉 ===== */
.playlist-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 100;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.playlist-overlay.show {
    display: block;
    opacity: 1;
}
.playlist-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: var(--bg-card-solid);
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(20px + var(--safe-bottom));
    z-index: 101;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.1);
}
.playlist-drawer.show {
    transform: translateY(0);
}
.playlist-drawer .handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.playlist-drawer .search-box {
    width: 100%;
    padding: 10px 14px;
    border-radius: 30px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 14px;
}
.drawer-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.drawer-tabs .tab-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.drawer-tabs .tab-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.drawer-tabs .tab-btn:hover {
    background: var(--border);
}

/* ===== 列表项 ===== */
.playlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}
.playlist-item:hover {
    background: var(--border);
}
.playlist-item.active {
    background: rgba(91,106,191,0.12);
    border-left: 4px solid var(--accent);
}
.playlist-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}
.playlist-item .name {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}
.playlist-item .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.playlist-item .meta .fav-icon {
    color: #ff4757;
}
.playlist-item .now {
    color: var(--accent);
    font-weight: 500;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card-solid);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 30px;
    box-shadow: var(--shadow);
    font-size: 14px;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    border: 1px solid var(--border);
}
.toast.show {
    opacity: 1;
}

/* ===== ★★★ 分享浮层 ★★★ ===== */
.share-overlay-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: none;
}
.share-overlay-backdrop.show {
    display: block;
}
.share-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card-solid);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    padding: 20px 20px 30px;
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 500px;
    margin: 0 auto;
}
.share-overlay.show {
    transform: translateY(0);
}
.share-overlay .handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.share-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}
.share-item {
    flex: 0 0 calc(33.33% - 12px);
    max-width: calc(33.33% - 12px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    border-radius: 12px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    font-family: inherit;
    color: var(--text-primary);
    width: 100%;
}
.share-item:hover {
    background: rgba(91,106,191,0.1);
}
.share-item .icon {
    font-size: 22px;
    margin-bottom: 4px;
}
.share-item .label {
    font-size: 12px;
    color: var(--text-secondary);
}
.share-close {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    text-align: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s;
}
.share-close:hover {
    background: rgba(0,0,0,0.04);
}
@media (max-width: 480px) {
    .share-item .icon {
        font-size: 24px;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
    .reader-nav { height: 46px; padding: 0 10px; }
    .nav-center { font-size: 14px; }
    .nav-right button { width: 28px; height: 28px; }
    .error-content { padding: 20px 16px; max-width: 280px; }
    .error-actions button { font-size: 12px; padding: 4px 10px; }
}
@media (min-width: 768px) and (max-width: 1024px) {
    .reader-nav { height: 56px; padding: 0 24px; }
    .nav-center { font-size: 18px; }
    .capsule-container { bottom: 40px; right: 30px; }
    .capsule { padding: 8px 16px; }
    .capsule .nav-btn { font-size: 16px; }
    .capsule .count { font-size: 14px; min-width: 60px; }
}