/* ============================================================
   STORIES - Kids & Family Storytelling Experience
   Colorful, playful, warm design for children
   ============================================================ */

:root {
    --stories-sunshine: #FFD93D;
    --stories-orange: #FF8C42;
    --stories-pink: #FF6B9D;
    --stories-purple: #9B5DE5;
    --stories-blue: #00BBF9;
    --stories-teal: #00F5D4;
    --stories-green: #8AC926;
    --stories-red: #FF595E;
    --stories-cream: #FFF8E7;
    --stories-warm-brown: #8B5E3C;
    --stories-dark: #2D2A32;
    --gradient-rainbow: linear-gradient(135deg, #FF6B9D 0%, #FF8C42 25%, #FFD93D 50%, #8AC926 75%, #00BBF9 100%);
    --gradient-sunset: linear-gradient(135deg, #FF8C42 0%, #FF6B9D 50%, #9B5DE5 100%);
    --gradient-krishna: linear-gradient(135deg, #00BBF9 0%, #9B5DE5 100%);
    --gradient-ganesha: linear-gradient(135deg, #FF8C42 0%, #FFD93D 100%);
    --gradient-hanuman: linear-gradient(135deg, #FF595E 0%, #FF8C42 100%);
    --gradient-ramayana: linear-gradient(135deg, #8AC926 0%, #00F5D4 100%);
    --gradient-moral: linear-gradient(135deg, #9B5DE5 0%, #FF6B9D 100%);
    --shadow-playful: 0 8px 30px rgba(155, 93, 229, 0.15);
    --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.08);
    --radius-bubbly: 24px;
    --radius-round: 50px;
}

/* ===== HERO SECTION ===== */
.stories-hero {
    background: linear-gradient(180deg, #FFF8E7 0%, #FFE8D6 100%);
    padding: 50px 0 80px;
    margin-top: -1rem;
    position: relative;
    overflow: hidden;
}

.stories-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 107, 157, 0.15) 0%, transparent 30%),
        radial-gradient(circle at 90% 80%, rgba(0, 187, 249, 0.15) 0%, transparent 30%),
        radial-gradient(circle at 50% 50%, rgba(255, 217, 61, 0.1) 0%, transparent 40%);
    pointer-events: none;
}

/* Floating decorative elements */
.stories-hero::after {
    content: '✨🌟⭐';
    position: absolute;
    font-size: 3rem;
    opacity: 0.15;
    right: 5%;
    top: 20%;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.stories-hero .container {
    position: relative;
    z-index: 2;
    text-align: center;
}

.stories-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--gradient-sunset);
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 20px;
    padding: 10px 24px;
    border-radius: var(--radius-round);
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(255, 140, 66, 0.3);
}

.stories-hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    color: var(--stories-dark);
    margin-bottom: 16px;
    line-height: 1.2;
}

.stories-hero h1 span {
    background: var(--gradient-rainbow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stories-hero p {
    font-size: 1.15rem;
    color: #5a4b38;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ===== SERIES ICONS ===== */
.series-icons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.series-icon {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: var(--shadow-playful);
}

.series-icon:hover {
    transform: translateY(-5px) scale(1.1);
}

.series-icon.krishna { background: var(--gradient-krishna); }
.series-icon.ganesha { background: var(--gradient-ganesha); }
.series-icon.hanuman { background: var(--gradient-hanuman); }
.series-icon.ramayana { background: var(--gradient-ramayana); }
.series-icon.moral { background: var(--gradient-moral); }

/* ===== FILTER SECTION ===== */
.stories-filters {
    background: white;
    padding: 28px 0;
    border-bottom: 3px solid #FFE8D6;
    position: sticky;
    top: 60px;
    z-index: 100;
}

.stories-filter-form {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.stories-filter-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}

.stories-filter-form label span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--stories-warm-brown);
}

.stories-filter-form select,
.stories-filter-form input[type="search"] {
    border: 2px solid #FFE0C4;
    border-radius: 14px;
    min-height: 48px;
    padding: 10px 16px;
    font-size: 0.95rem;
    background: #FFFBF5;
    color: var(--stories-dark);
    transition: all 0.2s ease;
}

.stories-filter-form select:focus,
.stories-filter-form input:focus {
    outline: none;
    border-color: var(--stories-orange);
    box-shadow: 0 0 0 4px rgba(255, 140, 66, 0.15);
}

.stories-checkbox {
    display: flex;
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
    min-width: auto;
    padding: 12px 18px;
    background: #FFF5E6;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stories-checkbox:hover {
    background: #FFE8D6;
}

.stories-checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--stories-orange);
}

.stories-filter-form button {
    background: var(--gradient-sunset);
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    min-height: 48px;
    padding: 12px 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.25);
}

.stories-filter-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
}

.stories-filter-loading {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--stories-purple);
    font-weight: 600;
}

.htmx-request .stories-filter-loading.htmx-indicator,
.stories-filter-loading.htmx-request {
    display: flex;
}

/* ===== STORIES GRID ===== */
.stories-grid-section {
    background: linear-gradient(180deg, #FFFBF5 0%, #FFF8E7 100%);
    padding: 48px 0 60px;
    min-height: 50vh;
}

.stories-grid {
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ===== STORY CARDS ===== */
.story-card {
    background: white;
    border-radius: var(--radius-bubbly);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid transparent;
    position: relative;
}

.story-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--gradient-rainbow);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-card:hover {
    transform: translateY(-10px) rotate(-1deg);
    box-shadow: 0 20px 50px rgba(155, 93, 229, 0.2);
    border-color: #FFE0C4;
}

.story-card:hover::before {
    opacity: 1;
}

/* Series-specific card accents */
.story-card[data-series="BAL_KRISHNA"] { --card-accent: var(--gradient-krishna); }
.story-card[data-series="GANESHA"] { --card-accent: var(--gradient-ganesha); }
.story-card[data-series="HANUMAN"] { --card-accent: var(--gradient-hanuman); }
.story-card[data-series="RAMAYANA"] { --card-accent: var(--gradient-ramayana); }
.story-card[data-series="MORAL_TALES"] { --card-accent: var(--gradient-moral); }

.story-card-image-link {
    display: block;
    position: relative;
    overflow: hidden;
}

.story-card-image {
    aspect-ratio: 16 / 10;
    display: block;
    object-fit: cover;
    width: 100%;
    height: 100%;
    transition: transform 0.4s ease;
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE8D6 100%);
}

/* SVG images in cards need special handling */
.story-card-image[src$=".svg"] {
    object-fit: contain;
    padding: 10px;
    background: linear-gradient(135deg, #FFF8E7 0%, #FFE8D6 100%);
}

.story-card:hover .story-card-image {
    transform: scale(1.08);
}

/* Image placeholder when no cover */
.story-card-placeholder {
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-sunset);
    font-size: 4rem;
    position: relative;
    overflow: hidden;
}

/* Series-specific placeholder backgrounds */
.story-card[data-series="BAL_KRISHNA"] .story-card-placeholder {
    background: var(--gradient-krishna);
}
.story-card[data-series="GANESHA"] .story-card-placeholder {
    background: var(--gradient-ganesha);
}
.story-card[data-series="HANUMAN"] .story-card-placeholder {
    background: var(--gradient-hanuman);
}
.story-card[data-series="RAMAYANA"] .story-card-placeholder {
    background: var(--gradient-ramayana);
}
.story-card[data-series="MORAL_TALES"] .story-card-placeholder {
    background: var(--gradient-moral);
}

.story-card-body {
    padding: 24px;
}

.story-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.story-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 16px;
    background: #FFF5E6;
    color: var(--stories-warm-brown);
    white-space: nowrap;
}

.story-card-meta .series-badge {
    background: var(--gradient-sunset);
    color: white;
}

/* Series-specific badge colors */
.story-card[data-series="BAL_KRISHNA"] .series-badge {
    background: var(--gradient-krishna);
}
.story-card[data-series="GANESHA"] .series-badge {
    background: var(--gradient-ganesha);
}
.story-card[data-series="HANUMAN"] .series-badge {
    background: var(--gradient-hanuman);
}
.story-card[data-series="RAMAYANA"] .series-badge {
    background: var(--gradient-ramayana);
}
.story-card[data-series="MORAL_TALES"] .series-badge {
    background: var(--gradient-moral);
}

.story-card-meta .age-badge {
    background: #E8F5FF;
    color: var(--stories-blue);
}

.story-card-meta .time-badge {
    background: #F0FFF0;
    color: var(--stories-green);
}

.story-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.4;
}

.story-card h2 a {
    color: var(--stories-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

.story-card h2 a:hover {
    color: var(--stories-purple);
}

.story-theme {
    font-size: 0.9rem;
    color: var(--stories-purple);
    margin-bottom: 10px;
    font-style: italic;
}

.story-card p {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 16px;
}

.story-card-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gradient-sunset);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-round);
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.story-card-link:hover {
    transform: translateX(5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    color: white;
}

/* Series-specific button colors */
.story-card[data-series="BAL_KRISHNA"] .story-card-link {
    background: var(--gradient-krishna);
}
.story-card[data-series="GANESHA"] .story-card-link {
    background: var(--gradient-ganesha);
}
.story-card[data-series="HANUMAN"] .story-card-link {
    background: var(--gradient-hanuman);
}
.story-card[data-series="RAMAYANA"] .story-card-link {
    background: var(--gradient-ramayana);
}
.story-card[data-series="MORAL_TALES"] .story-card-link {
    background: var(--gradient-moral);
}

.story-card-link::after {
    content: '→';
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.story-card:hover .story-card-link::after {
    transform: translateX(5px);
}

/* ===== EMPTY STATE ===== */
.story-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 40px;
    background: white;
    border-radius: var(--radius-bubbly);
    box-shadow: var(--shadow-card);
}

.story-empty::before {
    content: '📚';
    font-size: 5rem;
    display: block;
    margin-bottom: 24px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.story-empty h2 {
    font-size: 1.5rem;
    color: var(--stories-dark);
    margin-bottom: 12px;
}

.story-empty p {
    color: #666;
    font-size: 1.05rem;
}

/* ===== STORY DETAIL PAGE ===== */
.story-detail-hero {
    background: linear-gradient(180deg, #FFF8E7 0%, #FFE8D6 100%);
    padding: 40px 0 60px;
    margin-top: -1rem;
    position: relative;
}

.story-detail-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 5% 30%, rgba(255, 140, 66, 0.15) 0%, transparent 25%),
        radial-gradient(circle at 95% 70%, rgba(155, 93, 229, 0.15) 0%, transparent 25%);
    pointer-events: none;
}

.story-detail-header {
    position: relative;
    z-index: 2;
    max-width: 900px;
}

.story-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: var(--stories-warm-brown);
    padding: 10px 20px;
    border-radius: var(--radius-round);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.story-back:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    color: var(--stories-warm-brown);
}

.story-back::before {
    content: '←';
    font-size: 1.1rem;
}

.story-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.story-detail-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 8px 16px;
    border-radius: var(--radius-round);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--stories-warm-brown);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.story-detail-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--stories-dark);
    margin-bottom: 16px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.story-detail-summary {
    font-size: 1.1rem;
    color: #5a4b38;
    line-height: 1.7;
    max-width: 700px;
}

/* ===== STORY DETAIL MAIN ===== */
.story-detail-main {
    background: linear-gradient(180deg, #FFFBF5 0%, #FFF8E7 100%);
    padding: 48px 0 60px;
}

.story-detail-grid {
    display: grid;
    gap: 32px;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

.story-detail-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

/* Ensure all images/SVGs in content area are constrained */
.story-detail-content img,
.story-detail-content svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Cover Image Wrapper - prevents SVG overflow */
.story-cover-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius-bubbly);
    box-shadow: var(--shadow-card);
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE8D6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.story-cover {
    border-radius: 16px;
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 450px;
    object-fit: contain;
}

/* SVG cover images - extra constraints */
.story-cover[src$=".svg"],
.story-cover-wrapper svg {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
}

.story-panel {
    background: white;
    border-radius: var(--radius-bubbly);
    padding: 32px;
    box-shadow: var(--shadow-card);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
}

.story-panel:hover {
    border-color: #FFE0C4;
    transform: translateY(-3px);
}

.story-panel h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--stories-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.story-panel h2::before {
    font-size: 1.5rem;
}

.story-panel.story-theme-panel h2::before { content: '🌟'; }
.story-panel.story-body-panel h2::before { content: '📖'; }
.story-panel.story-moral-panel h2::before { content: '💡'; }
.story-panel.story-note h2::before { content: '💝'; }
.story-panel.story-audio-panel h2::before { content: '🎧'; }
.story-panel.story-attribution h2::before { content: 'ℹ️'; }

.story-body {
    font-size: 1.1rem;
    color: #2f2418;
    line-height: 2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    max-width: 100%;
}

.story-body p {
    margin-bottom: 1.25rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.story-body img,
.story-body svg,
.story-panel img,
.story-panel svg {
    max-width: 100%;
    height: auto;
}

.story-panel.story-moral-panel {
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE8D6 100%);
    border: 2px solid #FFD9B8;
}

.story-panel.story-note {
    background: linear-gradient(135deg, #F5F0FF 0%, #EDE4FF 100%);
    border: 2px solid #D4C4F5;
}

.story-panel.story-attribution {
    background: #F8F8F8;
    font-size: 0.9rem;
}

.story-audio-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--gradient-sunset);
    color: white;
    padding: 16px 28px;
    border-radius: var(--radius-round);
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.25);
}

.story-audio-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
    color: white;
}

.story-audio-link i {
    font-size: 1.5rem;
}

/* ===== SIDEBAR ===== */
.story-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.story-detail-sidebar .story-panel {
    position: sticky;
    top: 120px;
}

.story-facts {
    list-style: none;
    padding: 0;
    margin: 0;
}

.story-facts li {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 2px dashed #FFE8D6;
    font-size: 0.95rem;
}

.story-facts li:last-child {
    border-bottom: none;
}

.story-facts li strong {
    color: var(--stories-warm-brown);
}

.story-related-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.story-related-list li {
    margin-bottom: 12px;
}

.story-related-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #FFF5E6;
    border-radius: 12px;
    color: var(--stories-dark);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.story-related-list a::before {
    content: '📚';
}

.story-related-list a:hover {
    background: var(--gradient-sunset);
    color: white;
    transform: translateX(5px);
}

.story-related-list a:hover::before {
    content: '→';
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
    .stories-hero {
        padding: 40px 0 60px;
    }
    
    .story-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .story-detail-sidebar .story-panel {
        position: relative;
        top: 0;
    }
}

@media (max-width: 768px) {
    .stories-hero h1 {
        font-size: 1.75rem;
    }
    
    .stories-filter-form {
        flex-direction: column;
    }
    
    .stories-filter-form label {
        width: 100%;
    }
    
    .stories-grid {
        grid-template-columns: 1fr;
    }
    
    .story-card:hover {
        transform: translateY(-5px) rotate(0deg);
    }
    
    .story-panel {
        padding: 24px;
    }
    
    .story-body {
        font-size: 1rem;
        line-height: 1.8;
    }
}

@media (max-width: 480px) {
    .series-icons {
        gap: 12px;
    }
    
    .series-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }
    
    .story-card-body {
        padding: 20px;
    }
}

/* ============================================================
   READER MODE - Kindle-like Reading Experience
   Eye-friendly, distraction-free reading for kids & families
   ============================================================ */

/* Reader Mode Variables */
:root {
    /* Light theme (default) */
    --reader-bg: #FFFFFF;
    --reader-text: #2D2A32;
    --reader-text-secondary: #666666;
    --reader-accent: #FF8C42;
    --reader-border: #E8E8E8;
    --reader-panel-bg: #F8F8F8;
    
    /* Font sizes */
    --reader-font-sm: 1rem;
    --reader-font-md: 1.15rem;
    --reader-font-lg: 1.35rem;
    --reader-font-xl: 1.55rem;
}

/* Sepia theme */
.reader-mode[data-theme="sepia"] {
    --reader-bg: #F8F1E3;
    --reader-text: #5B4636;
    --reader-text-secondary: #7D6B5D;
    --reader-accent: #A0522D;
    --reader-border: #E0D5C1;
    --reader-panel-bg: #EFE6D5;
}

/* Dark theme */
.reader-mode[data-theme="dark"] {
    --reader-bg: #1A1A2E;
    --reader-text: #E8E8E8;
    --reader-text-secondary: #A0A0A0;
    --reader-accent: #FFD93D;
    --reader-border: #2D2D44;
    --reader-panel-bg: #252538;
}

/* Reader Mode Container */
.reader-mode {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: var(--reader-bg);
    overflow-y: auto;
    display: none;
    flex-direction: column;
}

.reader-mode.active {
    display: flex;
}

/* Reader Toolbar */
.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--reader-bg);
    border-bottom: 2px solid var(--reader-border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.reader-toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.reader-toolbar-center {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.reader-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reader-close-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--reader-panel-bg);
    border: 2px solid var(--reader-border);
    border-radius: 12px;
    padding: 10px 18px;
    color: var(--reader-text);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reader-close-btn:hover {
    background: var(--reader-accent);
    color: white;
    border-color: var(--reader-accent);
}

.reader-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--reader-text);
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Theme Switcher */
.reader-theme-group {
    display: flex;
    gap: 6px;
    background: var(--reader-panel-bg);
    padding: 4px;
    border-radius: 12px;
}

.reader-theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-theme-btn[data-theme="light"] {
    background: #FFFFFF;
    color: #333;
    border-color: #E0E0E0;
}

.reader-theme-btn[data-theme="sepia"] {
    background: #F8F1E3;
    color: #5B4636;
    border-color: #E0D5C1;
}

.reader-theme-btn[data-theme="dark"] {
    background: #1A1A2E;
    color: #E8E8E8;
    border-color: #2D2D44;
}

.reader-theme-btn.active {
    border-color: var(--reader-accent);
    box-shadow: 0 0 0 2px rgba(255, 140, 66, 0.3);
}

/* Font Size Controls */
.reader-font-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--reader-panel-bg);
    padding: 6px 12px;
    border-radius: 12px;
}

.reader-font-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--reader-bg);
    color: var(--reader-text);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-font-btn:hover {
    background: var(--reader-accent);
    color: white;
}

.reader-font-label {
    font-size: 0.85rem;
    color: var(--reader-text-secondary);
    min-width: 24px;
    text-align: center;
}

/* Progress Bar */
.reader-progress-container {
    position: sticky;
    top: 70px;
    z-index: 99;
    height: 4px;
    background: var(--reader-border);
}

.reader-progress-bar {
    height: 100%;
    background: var(--gradient-rainbow);
    width: 0%;
    transition: width 0.1s ease;
}

/* Reader Content */
.reader-content {
    flex: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.reader-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 2px dashed var(--reader-border);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.reader-series-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gradient-sunset);
    color: white;
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.reader-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--reader-text);
    margin-bottom: 12px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.reader-header .reader-meta {
    display: flex;
    justify-content: center;
    gap: 20px;
    color: var(--reader-text-secondary);
    font-size: 0.9rem;
}

/* Reader Cover Image */
.reader-cover {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 40px;
    display: block;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* Reader Theme Panel */
.reader-theme-intro {
    background: var(--reader-panel-bg);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 32px;
    text-align: center;
    border-left: 4px solid var(--reader-accent);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.reader-theme-intro h3 {
    color: var(--reader-accent);
    font-size: 1rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.reader-theme-intro p {
    color: var(--reader-text);
    font-size: var(--reader-font-md);
    margin: 0;
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Reader Story Text */
.reader-story-text {
    font-size: var(--reader-font-md);
    color: var(--reader-text);
    line-height: 2;
    text-align: justify;
    hyphens: auto;
}

.reader-story-text p {
    margin-bottom: 1.5em;
    text-indent: 2em;
}

.reader-story-text p:first-child {
    text-indent: 0;
}

.reader-story-text p:first-child::first-letter {
    font-size: 3.5em;
    float: left;
    line-height: 0.8;
    padding-right: 12px;
    color: var(--reader-accent);
    font-weight: 700;
}

/* Font size variations */
.reader-mode[data-font="sm"] .reader-story-text,
.reader-mode[data-font="sm"] .reader-theme-intro p,
.reader-mode[data-font="sm"] .reader-moral-box p {
    font-size: var(--reader-font-sm);
}

.reader-mode[data-font="md"] .reader-story-text,
.reader-mode[data-font="md"] .reader-theme-intro p,
.reader-mode[data-font="md"] .reader-moral-box p {
    font-size: var(--reader-font-md);
}

.reader-mode[data-font="lg"] .reader-story-text,
.reader-mode[data-font="lg"] .reader-theme-intro p,
.reader-mode[data-font="lg"] .reader-moral-box p {
    font-size: var(--reader-font-lg);
}

.reader-mode[data-font="xl"] .reader-story-text,
.reader-mode[data-font="xl"] .reader-theme-intro p,
.reader-mode[data-font="xl"] .reader-moral-box p {
    font-size: var(--reader-font-xl);
}

/* Reader Moral Box */
.reader-moral-box {
    background: linear-gradient(135deg, rgba(255, 217, 61, 0.15) 0%, rgba(255, 140, 66, 0.15) 100%);
    border: 2px solid rgba(255, 140, 66, 0.3);
    border-radius: 20px;
    padding: 32px;
    margin-top: 48px;
    text-align: center;
}

.reader-mode[data-theme="dark"] .reader-moral-box {
    background: linear-gradient(135deg, rgba(255, 217, 61, 0.1) 0%, rgba(255, 140, 66, 0.1) 100%);
    border-color: rgba(255, 217, 61, 0.3);
}

.reader-moral-box h3 {
    color: var(--reader-accent);
    font-size: 1.1rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.reader-moral-box p {
    color: var(--reader-text);
    font-size: var(--reader-font-md);
    line-height: 1.8;
    margin: 0;
    font-weight: 500;
}

/* Reader Footer */
.reader-footer {
    border-top: 2px dashed var(--reader-border);
    margin-top: 48px;
    padding-top: 32px;
    text-align: center;
}

.reader-nav-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.reader-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--reader-panel-bg);
    border: 2px solid var(--reader-border);
    color: var(--reader-text);
    padding: 14px 28px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.reader-nav-btn:hover {
    background: var(--gradient-sunset);
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
}

.reader-nav-btn.primary {
    background: var(--gradient-sunset);
    border-color: transparent;
    color: white;
}

.reader-nav-btn.primary:hover {
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
}

/* Reader Enter Button (on story detail page) */
.reader-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 28px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.reader-mode-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.reader-mode-toggle i {
    font-size: 1.2rem;
}

/* Reader Actions Bar */
.reader-actions-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* Responsive Reader Mode */
@media (max-width: 768px) {
    .reader-toolbar {
        padding: 10px 16px;
    }
    
    .reader-title {
        display: none;
    }
    
    .reader-toolbar-center {
        width: 100%;
        justify-content: center;
        order: 3;
        padding-top: 10px;
        border-top: 1px solid var(--reader-border);
        margin-top: 10px;
    }
    
    .reader-content {
        padding: 32px 20px 60px;
    }
    
    .reader-header h1 {
        font-size: 1.5rem;
    }
    
    .reader-story-text p:first-child::first-letter {
        font-size: 2.5em;
    }
}

@media (max-width: 480px) {
    .reader-font-group {
        padding: 4px 8px;
    }
    
    .reader-theme-group {
        padding: 3px;
    }
    
    .reader-theme-btn {
        width: 32px;
        height: 32px;
    }
    
    .reader-close-btn span {
        display: none;
    }
    
    .reader-close-btn {
        padding: 10px;
    }
}
