/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: clamp(87.5%, 2.5vw, 100%); /* Fluid base: 14px-16px */
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

body {
    background-color: #f5f0e8;
    background-image: url('../assets/images/bg-parchment.png');
    background-repeat: repeat;
    background-size: 512px; /* Adjust based on texture size */
    background-attachment: fixed;
    color: var(--digital-text);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm);
}

/* ... existing styles ... */

.scroll-card-icon {
    height: 80px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.scroll-card-icon img {
    max-height: 100%;
    width: auto;
    filter: drop-shadow(0 4px 6px rgba(139, 115, 85, 0.3));
    /* Blend mode to remove white background from icons if needed */
    mix-blend-mode: multiply; 
    opacity: 0.9;
    transition: all 0.3s ease;
}

.scroll-card:hover .scroll-card-icon img {
    transform: scale(1.1) translateY(-5px);
    opacity: 1;
    filter: drop-shadow(0 8px 12px rgba(139, 115, 85, 0.5));
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--digital-accent);
    color: #000;
    padding: 1rem 2rem;
    z-index: 9999;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}
.skip-link:focus {
    top: 0;
    outline: var(--focus-outline-width) solid #fff;
}

/* Focus Styles */
:focus-visible {
    outline: var(--focus-outline-width) solid var(--focus-outline-color-dark);
    outline-offset: 4px;
}

/* Main Scroll Container (The Palimpsest) */
.scroll-container {
    background-color: var(--parchment-bg);
    color: var(--parchment-text);
    width: 100%;
    max-width: 900px;
    margin: var(--spacing-lg) 0;
    border: 1px solid var(--parchment-border);
    box-shadow: 0 0 50px var(--shadow-color), 0 0 20px rgba(0, 246, 255, 0.1);
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.scroll-container :focus-visible {
    outline-color: var(--focus-outline-color);
}

/* Decorative Edges */
.scroll-top, .scroll-bottom {
    height: 12px;
    background: repeating-linear-gradient(
        45deg,
        var(--parchment-border),
        var(--parchment-border) 2px,
        transparent 2px,
        transparent 8px
    );
    opacity: 0.5;
}

.scroll-content {
    padding: var(--spacing-lg) var(--spacing-md);
}

@media (min-width: 768px) {
    .scroll-content {
        padding: var(--spacing-xl) var(--spacing-lg);
    }
}

/* Typography */
h1, h2, h3, h4 {
    margin-bottom: var(--spacing-md);
    color: #1a1a1a;
}

p {
    margin-bottom: var(--spacing-md);
    max-width: var(--max-width-text);
}

/* Header */
.logo-container {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    border-bottom: 2px solid var(--parchment-border);
    padding-bottom: var(--spacing-lg);
}

.logo-img {
    max-width: 150px;
    height: auto;
    margin-bottom: var(--spacing-sm);
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.main-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2em;
}

.title-handwritten {
    font-family: var(--font-handwritten);
    color: #8b4513;
    transform: rotate(-2deg);
}

.title-futuristic {
    font-family: var(--font-futuristic);
    font-size: 0.6em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #333;
    border-bottom: 2px solid var(--digital-glow);
}

.subtitle {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.2rem;
    color: #555;
    margin-top: var(--spacing-sm);
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Specific styling for translation sub-subtitles */
h3 .subtitle {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    font-style: normal;
    opacity: 0.7;
    margin-top: 4px;
    font-family: var(--font-sans);
}


/* Text Block (Bilingual) */
.text-block {
    background: rgba(255, 255, 255, 0.5);
    border-left: 4px solid var(--parchment-border);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.original-text {
    font-size: 1.1rem; /* Reduced from 1.4rem */
    margin-bottom: var(--spacing-xs);
    line-height: 1.6;
}

.original-text[lang="grc"] { font-family: var(--font-greek); }
.original-text[lang="he"] { font-family: var(--font-hebrew); direction: rtl; }

.translation-text {
    font-family: var(--font-mono);
    font-size: 0.95rem; /* Slightly reduced for balance */
    color: #444;
    background-color: #f9f9f7;
    padding: 0.8rem;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Menu / Navigation */
.app-nav {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.nav-button {
    background: transparent;
    border: 1px solid var(--parchment-border);
    color: var(--parchment-text);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-button:hover {
    background: rgba(0,0,0,0.05);
    border-color: #8b4513;
}

.nav-button:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
}

/* Podcast Section */
.podcast-section {
    background: #f4f4f4;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    border: 1px dashed var(--parchment-border);
    text-align: center;
}

audio {
    width: 100%;
    margin: var(--spacing-sm) 0;
    height: 44px;
}

/* Carousel (Digital Window) */
.analysis-carousel {
    position: relative;
    margin: var(--spacing-xl) 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: inset 0 0 10px rgba(0, 246, 255, 0.05); 
}

.analysis-carousel h4 {
    font-family: var(--font-futuristic);
    color: #333;
    border-bottom: 1px solid var(--digital-grid);
    padding-bottom: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.carousel-viewport {
    overflow: hidden;
    width: 100%;
    /* Smooth height transition */
    transition: height 0.4s ease-out;
}

.carousel-track {
    display: flex;
    width: 100%;
    transition: transform var(--transition-speed) ease-out;
    /* Allow cards to have their natural height, don't stretch */
    align-items: flex-start; 
}

.carousel-card {
    flex: 0 0 100%;
    width: 100%;
    padding: 0 var(--spacing-xs);
    /* Ensure card doesn't collapse */
    height: auto;
}

/* Narrow Screen Support (Galaxy Fold 4 cover ~320px-375px) */
@media (max-width: 380px) {
    .scroll-container {
        padding: 0;
        border: none;
        box-shadow: none;
    }

    .scroll-content {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    /* Smaller fonts for narrow screens */
    h1, h2 { font-size: 1.5rem; }
    h3 { font-size: 1.2rem; }
    h4 { font-size: 1rem; }
    p, li { font-size: 0.9rem; }

    /* Adjust Carousel Buttons to not overlap text */
    .carousel-button {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        background: rgba(255, 255, 255, 0.9);
    }
    .carousel-button.prev { left: -5px; }
    .carousel-button.next { right: -5px; }

    .card-content {
        padding: var(--spacing-sm);
    }
}

.card-content {
    padding: var(--spacing-md);
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 4px;
}

.card-content h5 {
    font-size: 1.2rem;
    color: #008b8b;
    margin-bottom: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 700;
}

.carousel-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border: 2px solid var(--parchment-border);
    color: #333;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 10;
    transition: all 0.2s;
}

.carousel-button:hover {
    background: var(--parchment-bg);
    border-color: #8b4513;
}

.carousel-button.prev { left: -22px; }
.carousel-button.next { right: -22px; }

.carousel-button.is-hidden {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 600px) {
    .carousel-button.prev { left: -10px; }
    .carousel-button.next { right: -10px; }
}

.carousel-nav-container {
    margin-top: var(--spacing-md);
    text-align: center;
}

.carousel-instruction {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: var(--spacing-xs);
}

.carousel-nav {
    display: inline-flex;
    gap: var(--spacing-xs);
    background: #f0f0f0;
    padding: 4px;
    border-radius: 20px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.carousel-indicator {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    color: #666;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.carousel-indicator[aria-selected="true"] {
    background: #fff;
    color: #000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.carousel-indicator:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: -2px;
}

/* Responsive carousel indicators */
@media (max-width: 500px) {
    .carousel-nav {
        padding: 2px;
        gap: 2px;
    }
    
    .carousel-indicator {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }
}

@media (max-width: 380px) {
    .carousel-indicator {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
}

/* Reference List */
.reference-list {
    font-family: var(--font-serif);
    font-size: 0.95rem;
}

.reference-list ul {
    list-style: none;
    padding-left: 0;
}

.reference-list li {
    margin-bottom: var(--spacing-sm);
    padding-left: 1.5em;
    text-indent: -1.5em;
}

.reference-list li::before {
    content: "❧";
    color: #8b4513;
    margin-right: 0.5em;
}

.separator {
    border: 0;
    height: 1px;
    background: var(--parchment-border);
    margin: var(--spacing-xl) 0;
}

/* Scroll Cards Navigation - Centered Grid with Logo */
.scroll-cards-wrapper {
    position: relative;
    margin: 4rem auto;
    max-width: 900px;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2rem;
    width: 100%;
    position: relative;
}

/* Center logo overlapping cards */
.center-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.center-logo img {
    width: 140px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    pointer-events: auto;
}

.scroll-card {
    position: relative;
    background: linear-gradient(135deg, rgba(255,249,237,0.95) 0%, rgba(245,238,216,0.9) 100%);
    backdrop-filter: blur(2px);
    border: 2px solid var(--parchment-border);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.scroll-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-color: #c4a874;
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(255,249,237,0.95) 100%);
    z-index: 10;
}

.scroll-card.active {
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(255,249,237,0.95) 100%);
    border-color: #8b7355;
    border-width: 3px;
    box-shadow: 0 12px 32px rgba(139, 115, 85, 0.25);
    transform: scale(1.03);
    z-index: 11;
}

/* Legacy icon styles removed - see top of file for new image-based styles */

/* Divider Style */
.separator-graphic {
    display: block;
    width: auto;
    max-width: 300px; /* 50% of original 600px */
    height: auto;
    margin: 2rem 0 2rem 0; /* Top Right Bottom Left - no left margin */
    margin-left: 0 !important; /* Force left alignment */
    float: none;
    clear: both;
    opacity: 0.8;
    mix-blend-mode: multiply;
}

.scroll-card-title {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    text-align: center;
    margin: 0;
}

.scroll-card-ref {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    margin: 0;
}

.scroll-card-summary {
    font-family: var(--font-serif);
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--parchment-text);
    text-align: center;
    margin: 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}

.scroll-card-badge {
    position: absolute;
    top: -8px; /* Overlap top edge */
    left: -8px; /* Overlap left edge */
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b7355 0%, #6d5a44 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    z-index: 10;
    /* No border/outline on badge */
}

/* Reading Content */
.reading-content {
    display: none;
}

.reading-content.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .scroll-cards-wrapper {
        margin: 2rem auto;
        min-height: auto;
    }
    
    .scroll-cards {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 1.5rem; /* Normal gap - no need for extra space */
    }
    
    /* Hide center logo on mobile */
    .center-logo {
        display: none;
    }
    
    .scroll-card {
        min-height: 180px; /* Slightly smaller on mobile */
    }
}

/* Sticky Header */
.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--parchment-bg) 0%, #f5f0e8 100%);
    border-bottom: 2px solid var(--parchment-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000; /* Restored for visibility */
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
    padding: 0.5rem 1rem;
}

.sticky-header.visible {
    transform: translateY(0);
}

/* Auto-hide on mobile scroll down */
@media (max-width: 768px) {
    .sticky-header.visible.hidden-mobile {
        transform: translateY(-100%);
    }
}

.sticky-header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Sticky ref - prevent logo overlap on medium screens */
@media (min-width: 450px) and (max-width: 764px) {
    .sticky-reading-ref {
        max-width: 50%; /* Narrower to avoid logo */
        margin: 0 auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.7rem;
    }
}

/* Desktop: More room for sticky ref */
@media (min-width: 765px) {
    .sticky-reading-ref {
        max-width: 40%; /* More space available */
        margin: 0 auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Mobile Sticky Header Layout & Global Mobile Tweaks */
@media (max-width: 600px) {
    /* Restore minimal padding for better aesthetics (< 470px request) */
    body {
        padding: 0.25rem; 
    }

    .sticky-header {
        padding: 0.5rem 0.5rem;
    }

    .sticky-header-content {
        flex-direction: column;
        gap: 0.1rem;
        align-items: center;
        position: relative;
    }

    .sticky-date-selector {
        width: 100%;
        justify-content: center;
        order: -1; /* Date on top */
        padding-bottom: 0.25rem;
        margin-bottom: 0.25rem;
        border-bottom: 1px solid rgba(139, 115, 85, 0.2);
        z-index: 2; /* Ensure on top */
    }

    .sticky-header-left {
        width: 100%;
        text-align: center;
        align-items: center;
        padding-top: 0px;
        padding-bottom: 45px; /* Space for logo below */
        position: relative;
    }
    
    .sticky-reading-title { font-size: 0.9rem; margin-bottom: 0.1rem; }
    .sticky-reading-ref { 
        font-size: 0.75rem; 
        display: block; 
        color: #666;
    } 
    
    /* Scroll Cards Scaling */
    .scroll-cards {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.5rem;
    }

    /* Logo positioned in middle of bottom padding - half inside header, half extending below */
    .sticky-logo {
        position: absolute;
        left: 50%;
        bottom: 0; /* Align to bottom of sticky-header-left */
        transform: translate(-50%, 50%); /* Center horizontally, move down by half its height */
        width: 70px;
        height: auto;
        z-index: 500; /* Below calendar */
        transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    }
    
    /* Logo follows header when hidden */
    .sticky-header.hidden-mobile .sticky-logo {
        opacity: 0;
        pointer-events: none;
    }
}

/* Narrow Screen Refinements (< 470px) */
@media (max-width: 470px) {
    .scroll-container {
        /* Restore minimal sidebar presence or just small framing */
        margin: 0.5rem 0; 
        width: 100%;
        border-radius: 4px; /* Slight rounded again */
    }

    .scroll-content {
        padding: 1rem 0.5rem; /* Restore internal breathing room */
    }

    /* Cards should have small gaps, not full flush */
    .scroll-card, .text-block, .analysis-carousel, .podcast-section {
        border-radius: 8px; /* Restore curvature */
        margin-bottom: 1rem;
        width: 100%;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Restore subtle depth */
        
        /* Stronger outline as requested */
        border: 1px solid #8b7355; 
    }
    
    .scroll-card {
        border: 2px solid #8b7355; /* Even clearer contour for navigation cards */
    }
    
    .text-block { 
        padding: 1.5rem 1rem;
    }
}

/* Edge-to-Edge Logic for Narrow Aspect Ratios (Mobile Phones) */
@media (max-aspect-ratio: 1/2), (max-width: 450px) {
    .scroll-container {
        margin: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .scroll-content {
        padding: 1rem 0; /* Zero side padding inside content */
    }

    /* Scroll cards MUST have visible outline on narrow screens */
    .scroll-card {
        border: 2px solid #8b7355 !important; /* Force outline */
        border-radius: 8px !important;
        margin-bottom: 1rem;
        width: 100%;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Other content blocks */
    .text-block, .analysis-carousel, .podcast-section {
        border-radius: 0; 
        border: none;
        margin: 0;
        width: 100%;
        box-shadow: none;
        border-bottom: 1px solid var(--parchment-border);
    }

    .analysis-carousel {
        border-bottom: none; 
    }
    
    .text-block { 
        padding: 1.5rem 1rem;
        border-left: 4px solid var(--parchment-border); 
    }
    
    .scroll-cards-wrapper {
        padding: 0 0.5rem;
    }
    
    /* Carousel Scaling/Hints */
    .carousel-button { display: none !important; }
    
    .carousel-viewport {
        margin: 0;
        border-radius: 0;
        /* Scroll Hints (Gradient Overlays) */
        mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    }
}

/* Extra Small Screens (<380px) */
@media (max-width: 380px) {
    .scroll-cards {
            grid-template-columns: repeat(2, 1fr); /* Force 2 columns */
            gap: 0.25rem;
    }
    .scroll-card {
        font-size: 0.8rem;
    }
    .scroll-card-title { font-size: 0.9rem; }
    .scroll-card-ref { font-size: 0.7rem; }
    .scroll-card-icon { height: 60px; }
}

.sticky-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* When study mode toggle is inside sticky-header-left */
.sticky-header-left .study-mode-toggle {
    margin-top: 0.25rem;
    align-self: flex-start;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.sticky-reading-title {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--parchment-text);
    margin: 0;
}

.sticky-reading-ref {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #666;
    margin: 0;
}

.sticky-date-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--parchment-text);
}

.date-nav-btn {
    background: transparent;
    border: 1px solid var(--parchment-border);
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--parchment-text);
    font-size: 1.2rem;
    line-height: 1;
}

.date-nav-btn:hover {
    background: rgba(0,0,0,0.05);
    border-color: #8b7355;
}

.date-display {
    position: relative;
    /* Removed min-width to allow flexibility on mobile */
    text-align: center;
}

.date-display-btn {
    background: transparent;
    border: 1px solid var(--parchment-border);
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--parchment-text);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.date-display-btn:hover {
    background: rgba(0,0,0,0.05);
    border-color: #8b7355;
}

/* Calendar Portal - Rendered outside header for proper stacking */
.date-calendar {
    position: fixed; /* Fixed to viewport, not parent */
    transform: translateX(-50%); /* Center on button */
    background: white;
    border: 2px solid var(--parchment-border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 10000; /* Above everything */
    display: none;
    min-width: 320px;
}

.date-calendar.open {
    display: block;
}

/* Calendar Styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: bold;
    color: #333;
}

.calendar-header button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.5rem;
    color: #666;
}

.calendar-header button:hover {
    color: #000;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.cal-day-name {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.cal-day {
    padding: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    background-color: white; /* Default background */
    color: #333; /* Dark text for contrast */
}

.cal-day:hover:not(.disabled):not(.empty) {
    background-color: #f0f0f0;
}

.cal-day.selected {
    background-color: #8b7355;
    color: white;
}

.cal-day.disabled {
    color: #ccc;
    cursor: not-allowed;
    background: none;
}

.cal-day.empty {
    cursor: default;
}

.sticky-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -40px;
    width: 90px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    z-index: 500; /* Below calendar (2000) */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.sticky-header.visible .sticky-logo {
    opacity: 1;
}

/* Hide logo when header is auto-hidden on mobile */
@media (max-width: 768px) {
    .sticky-header.visible.hidden-mobile .sticky-logo {
        opacity: 0;
    }
}

/* Center Logo Hide State */
.center-logo {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.center-logo.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
    pointer-events: none;
}

/* Sticky Audio Player */
.sticky-audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #f5f0e8 0%, var(--parchment-bg) 100%);
    border-top: 2px solid var(--parchment-border);;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 1rem 2rem;
    transition: transform 0.3s ease-in-out;
    transform: translateY(0);
}

/* Auto-hide on mobile when scrolling down */
@media (max-width: 768px) {
    .sticky-audio-player {
        padding: 0.75rem 1rem;
    }
    
    .sticky-audio-player.hidden-mobile {
        transform: translateY(100%);
    }
    
}

/* Collapsed state (Universal) */
.sticky-audio-player.collapsed {
    padding-bottom: 0;
}

.sticky-audio-player.collapsed .audio-player-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.sticky-audio-player:not(.collapsed) .audio-player-content {
    max-height: 300px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease 0.1s;
}

/* Toggle tab/wstążka */
.audio-toggle-tab {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #f5f0e8 0%, var(--parchment-bg) 100%);
    border: 2px solid var(--parchment-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--parchment-text);
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
    display: block;
}

.audio-toggle-tab:hover {
    background: var(--parchment-bg);
    transform: translateX(-50%) translateY(-2px);
}

.audio-toggle-tab::before {
    content: '🎧 ';
    margin-right: 0.25rem;
}

.sticky-audio-player.collapsed .audio-toggle-tab::after {
    content: ' ▼';
}

.sticky-audio-player:not(.collapsed) .audio-toggle-tab::after {
    content: ' ▲';
}


.audio-player-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.audio-info {
    text-align: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--parchment-border);
}

.audio-controls-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.5rem;
}

.audio-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.audio-btn {
    background: transparent; /* Removed background */
    border: none; /* Removed border */
    border-radius: 50%;
    width: 52px; /* Reduced from 70px (-25%) */
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--parchment-text);
    padding: 0; /* Ensure no padding affects size */
}

.audio-btn:hover {
    background: rgba(0,0,0,0.05); /* Subtle hover effect instead of solid color */
    transform: scale(1.1); /* Add scale effect since border is gone */
}

.audio-btn img {
    width: 45px; /* Reduced from 60px (-25%) */
    height: 45px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); /* Stronger shadow for better contrast */
}

.audio-btn.play-pause img {
    width: 54px; /* Reduced from 72px (-25%) */
    height: 54px;
}

.audio-btn.play-pause {
    width: 68px; /* Reduced from 90px (-25%) */
    height: 68px;
    font-size: 1.2rem;
}

/* Rewind button labels */
.audio-btn {
    position: relative;
}

.audio-btn::after {
    content: attr(data-label);
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

@media (max-width: 768px) {
    .audio-btn::after {
        opacity: 1; /* Always show on mobile */
    }
}

.audio-btn:hover::after {
    opacity: 1;
}


.audio-progress {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.audio-timeline {
    width: 100%;
    height: 6px;
    background: #e0d5c4;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.audio-timeline-fill {
    height: 100%;
    background: linear-gradient(90deg, #c4a874 0%, #8b7355 100%);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.audio-time {
    display: flex;
    justify-content: space-between;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.volume-fill {
    height: 100%;
    background: #8b7355;
    border-radius: 2px;
    width: 100%;
}

/* Footer */
.site-footer {
    margin-top: auto;
    padding: var(--spacing-md);
    text-align: center;
    font-size: 0.875rem;
    color: var(--digital-text);
    opacity: 0.7;
}

.site-footer a {
    color: var(--digital-accent);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   MODAL KOMPILACJI ON-DEMAND
   ============================================ */

.compilation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.compilation-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.compilation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.compilation-card {
    position: relative;
    background: linear-gradient(135deg, #fdf5e6 0%, #f5eedd 100%);
    border: 3px solid var(--parchment-border);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.compilation-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1); 
    }
    50% { 
        transform: scale(1.1); 
    }
}

.reading-content h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: #8b7355; /* Brown to match parchment theme */
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.reading-content h4 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: #666;
    margin: 1.5rem 0 0.5rem;
    font-weight: 600;
    padding-left: 0.5rem;
}

/* Footnotes and Bibliography */
.reading-content sup {
    font-size: 0.7em;
    vertical-align: super;
    line-height: 0;
}

.reading-content sup a {
    text-decoration: none;
    color: #8b7355;
    font-weight: 600;
    padding: 0 2px;
}

.reading-content sup a:hover {
    text-decoration: underline;
    color: #6d5a44;
}

.footnotes {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--parchment-border);
    font-size: 0.9rem;
}

.footnotes ol {
    padding-left: 2rem;
    line-height: 1.8;
}

.footnotes li {
    margin-bottom: 0.8rem;
    color: #666;
}

.footnotes li::marker {
    color: #8b7355;
    font-weight: 600;
}

.footnotes a {
    color: #8b7355;
    text-decoration: none;
    word-break: break-word;
}

.footnotes a:hover {
    text-decoration: underline;
    color: #6d5a44;
}

.footnote-backref {
    font-size: 0.8em;
    margin-left: 0.5rem;
    text-decoration: none;
}

.footnote-backref:hover {
    text-decoration: underline;
}

/* Lists */
.reading-content ul, 
.reading-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
    color: #444;
}

.reading-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    padding-left: 0.5rem;
}

.reading-content li::marker {
    color: #8b7355;
    font-weight: 600;
}

/* Bibliography section */
.bibliography {
    margin-top: 2.5rem;
    padding: 1.5rem;
    background: rgba(253, 245, 230, 0.4); /* Subtle parchment tint */
    border: 1px solid var(--parchment-border);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.bibliography p {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 1.6;
    color: #444;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.bibliography p strong {
    font-family: var(--font-sans);
    background-color: #e8dec8;
    color: #5c4b37;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 2.2rem;
    text-align: center;
    border: 1px solid #d4c5b0;
    flex-shrink: 0;
    margin-top: 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.bibliography p a {
    color: #8b7355;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    word-break: break-word; /* Prevent long URLs from overflowing */
}

.bibliography p a:hover {
    color: #5c4b37;
    text-decoration: underline;
}

/* Anchor spacing correction */
.bibliography a[id^="ref"] {
    position: absolute; /* Take out of flow */
    margin-top: -120px; /* Offset for sticky header */
}

/* Markdown Content Elements */
.reading-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem; /* Increased slightly */
    font-family: var(--font-serif); /* Fix: Use consistent font */
    background: rgba(255,255,255,0.4);
    border-radius: 4px;
    overflow: hidden;
}

.reading-content th {
    background: rgba(139, 115, 85, 0.1);
    color: #5c4b37;
    font-weight: 600;
    text-align: left;
    padding: 0.8rem;
    border-bottom: 2px solid #d4c5b0;
    font-family: var(--font-serif); /* Explicitly set */
}

.reading-content td {
    padding: 0.8rem;
    border-bottom: 1px solid #e8dec8;
    color: #444; /* Fix: Softer gray, matching text */
    vertical-align: top;
    font-family: var(--font-serif); /* Explicitly set */
}

.reading-content tr:last-child td {
    border-bottom: none;
}

.reading-content blockquote {
    border-left: 4px solid #c4a874;
    margin: 1.5rem 0;
    padding: 0.8rem 1rem 0.8rem 1.5rem;
    font-style: italic;
    color: #5c4b37;
    background: rgba(253, 245, 230, 0.5);
    border-radius: 0 4px 4px 0;
    font-family: var(--font-serif); /* Ensure consistent serif */
}

.reading-content blockquote p {
    margin: 0;
}

.reading-content pre {
    background: rgba(255,255,255,0.6);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid #e0d5c4;
    margin: 1rem 0;
}

/* Synthesis Grid Layout */
.synthesis-container {
    padding: 1rem 0;
}

.synthesis-title-main {
    text-align: center;
    font-family: var(--font-serif);
    color: #8b7355;
    margin-bottom: 2rem;
    font-size: 1.8rem;
    border-bottom: 1px solid #d4c5b0;
    padding-bottom: 1rem;
}

.synthesis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.synthesis-card {
    background: #fffdf5;
    border: 1px solid #e0d5c4;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.synthesis-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(139, 115, 85, 0.1);
    border-color: #c4a874;
}

.synthesis-card-header {
    background: rgba(139, 115, 85, 0.1);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0d5c4;
}

.synthesis-card-header h4 {
    margin: 0;
    color: #5c4b37;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    padding: 0;
}

.synthesis-card-content {
    padding: 1.5rem;
    color: #444;
    font-family: var(--font-serif);
    line-height: 1.6;
    flex-grow: 1;
}

.synthesis-card-content p:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .synthesis-grid {
        grid-template-columns: 1fr;
    }
    
    .synthesis-card {
        margin-bottom: 1rem;
    }
}

.reading-content code {
    font-family: 'Courier Prime', monospace;
    font-size: 0.9em;
    color: #444;
}

.reading-content p code {
    background: rgba(139, 115, 85, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: #8b7355;
    font-weight: 600;
}

.bibliography a[id^="ref"] {
    display: block;
    margin-bottom: 1.5rem;
    scroll-margin-top: 120px;
    line-height: 1.6;
    color: #666;
}

.bibliography a[id^="ref"]:hover {
    color: #8b7355;
}

.bibliography a[id^="ref"] a {
    color: #8b7355;
    text-decoration: none;
}

.bibliography a[id^="ref"] a:hover {
    text-decoration: underline;
    color: #6d5a44;
}

.bibliography a[id^="ref"]::before {
    content: "";
    display: block;
    margin-bottom: 0.3rem;
}

.reading-content p {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: #666; /* Softer gray for references */
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.compilation-card h2 {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    color: var(--parchment-text);
    margin-bottom: 0.5rem;
}

.compilation-date {
    font-family: var(--font-sans);
    font-size: 1rem;
    color: #666;
    margin-bottom: 2rem;
}

.compilation-date span {
    font-weight: 600;
    color: var(--parchment-text);
}

.progress-container {
    margin: 2rem 0;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0d5c4;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c4a874 0%, #8b7355 100%);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(196, 168, 116, 0.5);
}

.progress-text {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.5rem;
    min-height: 1.5em;
}

.progress-percent {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--parchment-text);
}

.compilation-note {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: #888;
    margin-top: 2rem;
}

/* Responsywność modalu */
@media (max-width: 600px) {
    .compilation-card {
        padding: 2rem 1.5rem;
    }
    
    .compilation-icon {
        font-size: 3rem;
    }
    
    .compilation-card h2 {
        font-size: 1.4rem;
    }
}

/* ============================================
   CONTENT DISCOVERY UX
   ============================================ */

/* Reading Progress Bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--digital-accent), var(--digital-glow));
    z-index: 10001;
    transition: width 0.1s ease-out;
    box-shadow: 0 0 10px var(--digital-accent);
}

/* Section Navigation Pills */
.section-nav {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.section-nav.visible {
    opacity: 1;
    pointer-events: auto;
}

.section-nav-toggle {
    display: none;
}

.section-nav-pills {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-nav-pill {
    background: rgba(253, 245, 230, 0.95);
    border: 2px solid var(--parchment-border);
    border-radius: 20px;
    padding: 0.6rem 1rem;
    font-family: var(--font-sans);
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--parchment-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    text-align: right;
}

.section-nav-pill:hover {
    background: var(--parchment-bg);
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.section-nav-pill.active {
    background: var(--parchment-text);
    color: var(--parchment-bg);
    border-color: var(--parchment-text);
}

/* Mobile: Vertical Collapsible Navigation */
@media (max-width: 768px) {
    .section-nav {
        right: 15px;
        bottom: 15px;
        top: auto;
        transform: none;
        align-items: flex-end;
    }

    .section-nav-toggle {
        display: block;
        background: var(--parchment-text);
        color: var(--parchment-bg);
        border: none;
        border-radius: 50px;
        padding: 0.8rem 1.2rem;
        font-family: var(--font-sans);
        font-size: 0.85rem;
        font-weight: 800;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        z-index: 1001;
        transition: all 0.3s ease;
    }

    .section-nav-toggle::before {
        content: "🧭";
        margin-right: 8px;
    }

    .section-nav.expanded .section-nav-toggle {
        background: #8b7355;
        transform: rotate(90deg);
    }

    .section-nav.expanded .section-nav-toggle span {
        display: none;
    }

    .section-nav-pills {
        position: absolute;
        bottom: 60px;
        right: 0;
        display: flex;
        flex-direction: column; /* Changed from column-reverse to column */
        gap: 0.6rem;
        opacity: 0;
        transform: translateY(20px) scale(0.9);
        pointer-events: none;
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .section-nav.expanded .section-nav-pills {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }

    .section-nav-pill {
        padding: 0.75rem 1.2rem;
        font-size: 0.8rem;
        text-align: center;
        width: auto;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
}

/* "Więcej poniżej" Continue Reading Hint */
.continue-reading-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.1) 0%, rgba(0, 246, 255, 0.1) 100%);
    border: 2px dashed var(--digital-accent);
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--parchment-text);
    text-align: center;
    animation: pulse-hint 2s ease-in-out infinite;
}

.continue-reading-hint::before {
    content: '↓';
    font-size: 1.2em;
    animation: bounce-arrow 1.5s ease-in-out infinite;
}

@keyframes pulse-hint {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

/* Mobile adjustments */
@media (max-width: 600px) {
    .continue-reading-hint {
        padding: 0.75rem 1rem;
        font-size: var(--font-size-xs);
        margin: 1rem 0.5rem;
    }
}

/* ============================================
   STUDY MODE - Expert Dual-Column Layout
   ============================================ */

/* Study Mode Toggle Button */
.study-mode-toggle {
    display: none; /* Hidden on mobile */
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 2px solid var(--parchment-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--parchment-text);
    transition: all 0.2s;
}

.study-mode-toggle:hover {
    background: rgba(139, 115, 85, 0.1);
    border-color: #8b7355;
}

.study-mode-toggle.active {
    background: var(--parchment-text);
    color: var(--parchment-bg);
    border-color: var(--parchment-text);
}

/* No icon - removed per user request */

@media (min-width: 1024px) {
    .study-mode-toggle {
        display: flex;
    }
}

/* Study Mode Active State (Desktop Only) */
@media (min-width: 1024px) {
    body.study-mode .scroll-container {
        max-width: 100%;
        margin: 0;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    body.study-mode .scroll-content {
        padding: 0;
        display: flex;
        flex-direction: column;
        min-height: calc(100vh - 120px);
    }

    /* Hide scroll cards and center logo in study mode */
    body.study-mode .scroll-cards-wrapper {
        display: none;
    }

    /* Main Study Layout Container */
    body.study-mode .study-layout {
        display: flex;
        flex: 1;
        height: calc(100vh - 120px);
        overflow: hidden;
    }

    /* Left Sidebar */
    body.study-mode .study-sidebar {
        width: 260px;
        min-width: 260px;
        max-width: 260px;
        flex-shrink: 0;
        background: linear-gradient(180deg, #fdf5e6 0%, #f5f0e8 100%);
        border-right: 2px solid var(--parchment-border);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        transition: width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease;
    }

    body.study-mode .study-sidebar.collapsed {
        width: 60px;
        min-width: 60px;
    }

    body.study-mode .study-sidebar.collapsed .sidebar-content {
        display: none;
    }

    body.study-mode .study-sidebar.collapsed .sidebar-collapsed-icons {
        display: flex;
    }

    .sidebar-header {
        padding: 1rem;
        border-bottom: 1px solid var(--parchment-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar-logo {
        width: 40px;
        height: auto;
    }

    .sidebar-collapse-btn {
        background: transparent;
        border: 1px solid var(--parchment-border);
        border-radius: 4px;
        width: 32px;
        height: 32px;
        cursor: pointer;
        font-size: 1rem;
        color: var(--parchment-text);
        transition: all 0.2s;
    }

    .sidebar-collapse-btn:hover {
        background: rgba(0,0,0,0.05);
    }

    .sidebar-content {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
    }

    .sidebar-collapsed-icons {
        display: none;
        flex-direction: column;
        align-items: center;
        padding: 1rem 0.5rem;
        gap: 1rem;
    }

    .sidebar-collapsed-icons button {
        background: transparent;
        border: none;
        cursor: pointer;
        font-size: 1.5rem;
        padding: 0.5rem;
        border-radius: 4px;
        transition: background 0.2s;
    }

    .sidebar-collapsed-icons button:hover {
        background: rgba(0,0,0,0.05);
    }

    /* Reading Selection Tiles */
    .study-reading-tiles {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .study-reading-tile {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        background: rgba(255, 255, 255, 0.6);
        border: 2px solid var(--parchment-border);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .study-reading-tile:hover {
        background: rgba(255, 255, 255, 0.9);
        border-color: #8b7355;
        transform: translateX(4px);
    }

    .study-reading-tile.active {
        background: var(--parchment-text);
        color: var(--parchment-bg);
        border-color: var(--parchment-text);
    }

    .study-reading-tile img {
        width: 32px;
        height: 32px;
        object-fit: contain;
    }

    .study-reading-tile .tile-text {
        flex: 1;
    }

    .study-reading-tile .tile-title {
        font-weight: 700;
        font-size: 0.85rem;
        margin: 0;
    }

    .study-reading-tile .tile-ref {
        font-size: 0.75rem;
        opacity: 0.8;
        margin: 0;
    }

    /* Section Navigation */
    .study-section-nav {
        border-top: 1px solid var(--parchment-border);
        padding-top: 1rem;
    }

    .study-section-nav h4 {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #888;
        margin-bottom: 0.75rem;
    }

    .study-section-list {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .study-section-item {
        padding: 0.5rem 0.75rem;
        border-radius: 4px;
        cursor: pointer;
        font-size: 0.85rem;
        color: var(--parchment-text);
        transition: all 0.2s;
        border: none;
        background: transparent;
        text-align: left;
        width: 100%;
    }

    .study-section-item:hover {
        background: rgba(139, 115, 85, 0.1);
    }

    .study-section-item.active {
        background: rgba(139, 115, 85, 0.2);
        font-weight: 600;
    }

    /* Main Content Area - Dual Columns */
    body.study-mode .study-main {
        flex: 1;
        display: flex;
        overflow: hidden;
    }

    /* Left Column - Source Text */
    body.study-mode .study-column-left {
        flex: 1;
        min-width: 0;
        overflow-y: auto;
        padding: 2rem;
        border-right: 1px solid var(--parchment-border);
        background: rgba(255, 255, 255, 0.3);
    }

    /* Right Column - Analysis */
    body.study-mode .study-column-right {
        flex: 1;
        min-width: 0;
        overflow-y: auto;
        padding: 2rem;
        background: rgba(253, 245, 230, 0.3);
    }

    /* Column Headers */
    .study-column-header {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding-bottom: 1rem;
        border-bottom: 2px solid var(--parchment-border);
        margin-bottom: 1.5rem;
    }

    .study-column-header h3 {
        font-family: var(--font-futuristic);
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #666;
        margin: 0;
    }

    .study-column-header .column-icon {
        font-size: 1.2rem;
    }

    /* Study Mode Content Blocks */
    body.study-mode .study-text-block {
        background: rgba(255, 255, 255, 0.6);
        border: 1px solid var(--parchment-border);
        border-radius: 8px;
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }

    body.study-mode .study-text-block h4 {
        color: #8b7355;
        margin-bottom: 1rem;
        font-size: 1rem;
    }

    /* Resize Handle */
    .study-resize-handle {
        width: 4px;
        background: var(--parchment-border);
        cursor: col-resize;
        transition: background 0.2s;
    }

    .study-resize-handle:hover {
        background: #8b7355;
    }

    /* Exit Study Mode Button - always above player */
    .exit-study-mode {
        position: fixed;
        bottom: 120px; /* Higher to account for audio player */
        right: 20px;
        background: var(--parchment-text);
        color: var(--parchment-bg);
        border: none;
        border-radius: 50px;
        padding: 0.75rem 1.5rem;
        font-family: var(--font-sans);
        font-weight: 600;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        z-index: 1001; /* Above audio player */
        transition: all 0.2s;
    }

    .exit-study-mode:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    }

    .exit-study-mode::before {
        content: '✕ ';
    }

    /* Study Mode inherits reading-content styles for proper formatting */
    body.study-mode .study-column-left,
    body.study-mode .study-column-right {
        overflow-x: hidden;
        display: flex !important; /* Override reading-content display: none */
        flex-direction: column;
    }

    body.study-mode .study-text-block p,
    body.study-mode .study-text-block li,
    body.study-mode .card-content p,
    body.study-mode .card-content li {
        font-family: var(--font-serif);
        font-size: 1.1rem;
        color: #444;
        line-height: 1.6;
    }

    body.study-mode .card-content h5 {
        font-size: 1.2rem;
        color: #008b8b;
        margin-bottom: 0.5rem;
        font-family: var(--font-sans);
        font-weight: 700;
    }

    /* Sticky header should ALWAYS be visible in study mode */
    body.study-mode .sticky-header {
        position: fixed;
        top: 0 !important;
        left: 0;
        right: 0;
        z-index: 1002;
        transform: translateY(0) !important; /* Force visible */
    }

    /* Adjust study layout for sticky header */
    body.study-mode .study-layout {
        margin-top: 60px; /* Account for sticky header */
        height: calc(100vh - 60px); /* Full height minus header */
    }

    /* Audio player aware - exit button positioned above player */
    body.study-mode .exit-study-mode {
        bottom: calc(var(--audio-player-height, 60px) + 20px); /* Dynamic based on player */
    }
}
