@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=Merriweather:wght@300;400;700;900&display=swap');

:root {
    --bg-dark: #121212; 
    --bg-panel: #181818; 
    --bg-item: #222222; 
    --bg-item-hover: #2a2a2a;
    --text-main: #e0e0e0; 
    --text-muted: #888888; 
    --border: #333333;
    --accent: #ce0000; 
    --font-ui: "Inter", sans-serif; --font-read: "Merriweather", serif;
    --story-font-size: 1.25rem; --sidebar-width: 320px; --header-height: 60px;
}

body { margin: 0; background: var(--bg-dark); color: var(--text-main); font-family: var(--font-ui); overflow: hidden; font-weight: 400; }
#wpadminbar { display: none !important; }
a { text-decoration: none; color: inherit; transition: 0.2s; }

#app-container { 
    display: flex; flex-direction: column; height: 100vh; width: 100vw;
    position: fixed; top: 0; left: 0; 
    z-index: 10000; background: var(--bg-dark);
}
#app-container.ir-full-page { z-index: 10000 !important; }

#top-nav {
    height: var(--header-height); background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(15px); border-bottom: 1px solid var(--border);
    position: relative; z-index: 500; width: 100%; flex-shrink: 0;
}
.nav-inner {
    width: 100%; max-width: 1600px; margin: 0 auto; height: 100%;
    display: flex; align-items: center; justify-content: space-between; padding: 0 20px; box-sizing: border-box;
}
.nav-brand { font-weight: 700; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; font-size: 13px; flex-shrink: 0; }
.brand-arrow-icon { width: 20px; height: 20px; stroke: #888; transition: 0.2s; }
.nav-brand:hover .brand-arrow-icon { stroke: var(--accent); transform: translateX(-3px); }
.nav-brand:hover .brand-text { color: #fff; }
.brand-logo { height: 32px !important; width: auto; border-radius: 4px; }
.brand-text { color: #ccc; transition: 0.2s; }

.nav-controls { display: flex; align-items: center; gap: 20px; height: 100%; margin-left: auto; }

#workspace { display: flex; flex: 1; overflow: hidden; position: relative; }
#sidebar { width: var(--sidebar-width); background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 400; transition: transform 0.3s ease; }

.sidebar-filters { padding: 15px; border-bottom: 1px solid var(--border); background: #151515; }
.sf-row { margin-bottom: 10px; }
.sf-row:last-child { margin-bottom: 0; }
#sb-search, #sb-sort, #sb-cat, #sb-tag { 
    width: 100%; padding: 10px; 
    background: #050505 !important; 
    border: 1px solid #ff0000 !important; 
    color: #e0e0e0 !important; 
    border-radius: 4px; font-family: inherit; font-size: 13px; 
    color-scheme: dark;
}
#sb-search:focus, #sb-sort:focus, #sb-cat:focus, #sb-tag:focus { border-color: var(--accent); outline: none; }
.sf-check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: #aaa; user-select: none; }
.sf-check input { display: none; }
.checkmark { width: 16px; height: 16px; background: #000; border: 1px solid #333; border-radius: 3px; position: relative; transition: 0.2s; }
.sf-check input:checked ~ .checkmark { background: var(--accent); border-color: var(--accent); }
.sf-check:hover .checkmark { border-color: #666; }

.post-list { flex: 1; overflow-y: auto; padding: 10px; }
.post-card { padding: 15px; margin-bottom: 8px; background: var(--bg-item); border-radius: 8px; border-left: 3px solid transparent; cursor: pointer; transition: 0.2s; }
.post-card:hover { background: var(--bg-item-hover); }
.post-card.active { background: #333; border-left-color: var(--accent); }
.pc-title { font-weight: 600; font-size: 14px; margin-bottom: 5px; display: block; line-height: 1.3; }
.pc-meta { font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }
.pc-icon { display: inline-block; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }

#reader { 
    flex: 1; overflow-y: auto; background: var(--bg-dark); scroll-behavior: smooth; 
    position: relative;
}

.hero-section { 
    min-height: 60vh; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    justify-content: flex-end; 
    overflow: hidden; 
    background-color: #000 !important; 
}

/* Grid for Multiple Images */
.hero-grid {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-flow: dense;
    gap: 4px; /* A few pixels between */
    z-index: 0;
}

.hero-item {
    position: relative;
    width: 100%; height: 100%;
    min-height: 200px;
    overflow: hidden;
    cursor: pointer;
}

.hero-img-grid {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.hero-item:hover .hero-img-grid {
    transform: scale(1.05);
}

/* Mobile: Keep grid but allow tiny thumbnails */
@media (max-width: 600px) {
    .hero-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* Tiny thumbs on mobile */
    }
    .hero-item {
        min-height: 120px; /* Shorter cells on mobile */
    }
}

.hero-bg { 
    position: absolute !important; 
    top: 0 !important; 
    left: 0 !important; 
    width: 100% !important; 
    height: 100% !important; 
    object-fit: contain !important; 
    object-position: center !important; 
    opacity: 0.6; 
    z-index: 0; 
    will-change: transform;
    pointer-events: none;
    transition: none !important; 
}

.hero-vignette { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    background: 
        linear-gradient(to top, var(--bg-dark) 15%, transparent 80%),
        linear-gradient(to right, var(--bg-dark) 0%, transparent 15%, transparent 85%, var(--bg-dark) 100%);
    z-index: 1; 
    pointer-events: none;
}

.hero-content { position: relative; z-index: 5; padding: 60px 40px 40px; max-width: 800px; margin: 0 auto; width: 100%; }
.story-title { font-family: var(--font-read); font-size: 3.5rem; line-height: 1.1; margin-bottom: 5px; text-shadow: 0 4px 30px rgba(0,0,0,0.8); color:#fff; font-weight: 900; text-align: center; }

/* Styles for Info Bar below Hero */
.story-info-bar {
    position: relative;
    z-index: 10;
    max-width: 800px;
    margin: 20px auto 40px;
    padding: 0 20px;
    text-align: center;
}

.story-desc { 
    font-size: 1.15rem; 
    line-height: 1.6; 
    color: #ccc; 
    margin-bottom: 25px; 
    font-style: italic; 
    font-weight: 400; 
    max-width: 700px; 
    margin-left: auto; 
    margin-right: auto; 
}

.story-meta-row { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 30px; 
    justify-content: center; 
}

.story-actions { 
    display: flex; 
    gap: 15px; 
    justify-content: center; 
}

#init-audio-btn {
    padding: 8px 25px;
    font-size: 0.85rem;
    border-radius: 50px;
    background: transparent;
    color: #888;
    border: 1px solid #333;
    box-shadow: none;
    transition: all 0.2s ease;
    max-width: none !important; /* Override inline styles */
    text-transform: uppercase;
    letter-spacing: 1px;
}

#init-audio-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.05);
    border-color: #666;
    color: #e0e0e0;
}

.meta-pill { background: rgba(50,50,50,0.5); padding: 5px 15px; border-radius: 20px; backdrop-filter: blur(5px); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: #fff; font-weight: 600; border: 1px solid rgba(255,255,255,0.1); }

.body-container { max-width: 760px; margin: 0 auto; padding: 0 20px 150px; position: relative; z-index: 5; }
.story-text { font-family: var(--font-read); font-size: var(--story-font-size); line-height: 1.9; color: #ddd; font-weight: 400; }
.story-text p { margin-bottom: 1.8em; }
.story-text strong, .story-text b { font-weight: 700; color: #fff; }

.tip-inline-wrap { margin-top: 80px; padding: 40px; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 12px; text-align: center; }
.tip-label { font-size: 1.1rem; color: #fff; margin-bottom: 20px; font-weight: 600; }
.tip-grid { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tip-chip { background: transparent; color: #ccc; border: 1px solid #444; padding: 10px 25px; border-radius: 30px; cursor: pointer; transition: 0.2s; font-weight: 600; }
.tip-chip:hover { border-color: var(--accent); color: #fff; background: rgba(206, 0, 0, 0.2); }
.tip-btn-yes { background: var(--accent); color: #fff; border: none; padding: 10px 30px; border-radius: 30px; font-weight: bold; cursor: pointer; margin-right: 10px; }
.tip-btn-no { background: #333; color: #ccc; border: none; padding: 10px 30px; border-radius: 30px; cursor: pointer; }

/* Lightbox Styles */
.ir-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    display: flex; align-items: center; justify-content: center;
    z-index: 25000;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.ir-lightbox.active { opacity: 1; pointer-events: auto; }
#ir-lb-img {
    max-width: 95%; max-height: 95%;
    object-fit: contain;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}
#ir-lb-close {
    position: absolute; top: 20px; right: 20px;
    background: none; border: none; color: #fff; font-size: 40px;
    cursor: pointer; z-index: 25001;
}

.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.8); z-index: 30000 !important; 
    display: flex; align-items: center; justify-content: center; 
    opacity: 0; pointer-events: none; transition: 0.3s; backdrop-filter: blur(8px); 
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal-box { background: #1a1a1a; border: 1px solid #333; padding: 40px; border-radius: 12px; width: 90%; max-width: 420px; text-align: center; color: #fff; transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.visible .modal-box { transform: translateY(0); }
.modal-title { font-size: 1.8rem; margin-bottom: 15px; font-weight: 800; color: #fff; }
.modal-text { font-size: 0.95rem; line-height: 1.6; color: #aaa; margin-bottom: 25px; }
.modal-section-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: #666; margin-bottom: 12px; font-weight: 700; text-align: left; border-bottom: 1px solid #333; padding-bottom: 5px; }
.modal-voice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 25px; max-height: 180px; overflow-y: auto; padding-right: 5px; }
.voice-bubble { display: flex; align-items: center; justify-content: space-between; background: #222; border: 1px solid #333; padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: all 0.2s ease; }
.voice-bubble:hover { background: #2a2a2a; border-color: #555; }
.voice-bubble.active { background: #333; border-color: #ce0000; }
.voice-name { font-size: 0.9rem; font-weight: 500; color: #ddd; pointer-events: none; }
.voice-preview-btn { width: 32px; height: 32px; border-radius: 50%; background: #222; border: 1px solid #444; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; transition: 0.2s; }
.voice-preview-btn:hover { background: #ce0000; color: #fff; border-color: #ce0000; }
.voice-preview-btn.playing { background: #ce0000; color: #fff; border-color: #ce0000; animation: pulse-ring 1.5s infinite; }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(206, 0, 0, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(206, 0, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(206, 0, 0, 0); } }
.voice-owned-badge { color: #ce0000; font-size: 14px; font-weight: bold; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.modal-stat-row { padding: 10px 15px; background: #222; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center; }
.stat-val { font-weight: 700; font-size: 1rem; color: #fff; }
.stat-val.good { color: #46b450; } .stat-val.bad { color: #ff3b3b; }
.btn-row { display: flex; gap: 15px; margin-top: 30px; }
.modal-btn { flex: 1; padding: 14px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; text-transform: uppercase; font-size: 0.9rem; letter-spacing: 0.5px; transition: all 0.2s; }
.btn-cancel { background: transparent; border: 1px solid #444; color: #aaa; }
.btn-cancel:hover { border-color: #fff; color: #fff; }
.btn-confirm { background: #ce0000; color: #fff; border: 1px solid #ce0000; }
.btn-confirm:hover { background: #ff0000; }
.btn-confirm:disabled { background: #333; color: #666; border-color: #333; cursor: not-allowed; }
.spinner-btn { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s ease-in-out infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-note { font-size: 0.8rem; color: var(--accent); text-transform: uppercase; font-weight: 700; margin-bottom: 10px; display: none; animation: pulse-text 1.5s infinite; }
@keyframes pulse-text { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

.control-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main); cursor: pointer; font-weight: 600; padding: 8px 16px;
    border-radius: 20px; transition: 0.2s; display: flex; align-items: center; gap: 8px;
    font-size: 12px; text-transform: uppercase; white-space: nowrap;
}
.control-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.control-btn.icon-only { padding: 8px; border-radius: 50%; width: 36px; height: 36px; justify-content: center; font-size: 14px; }
.control-btn.action-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.control-btn.action-btn:hover { filter: brightness(1.2); }
.control-btn.audiobook-btn { border-color: #444; color: #eee; }

#cinema-exit-btn {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 9999;
    background: rgba(0,0,0,0.8); color: white; border: 1px solid #444; padding: 8px 20px;
    border-radius: 20px; cursor: pointer; text-transform: uppercase; font-size: 12px;
    letter-spacing: 1px; display: none; backdrop-filter: blur(5px);
}
#cinema-exit-btn:hover { background: var(--accent); border-color: var(--accent); }
body.cinema-mode #cinema-exit-btn { display: block; }
body.cinema-mode #top-nav, body.cinema-mode #sidebar { display: none; }

@media (max-width: 900px) {
    #sidebar { position: fixed; top: var(--header-height); bottom: 0; left:0; width:100%; transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #mobile-menu-btn { display: flex !important; }
}