/* ============================================================================
   The GRACE Bible — Web Viewer Styles
   ============================================================================
   A refined grayscale design for viewing Biblical stories reimagined with art
   ============================================================================ */

/* CSS Custom Properties */
:root {
    /* Color Palette - Light Theme (Grayscale with accent) */
    --color-cream: #FFFFFF;
    --color-parchment: #F8F8F8;
    --color-sepia-light: #E5E5E5;
    --color-sepia: #CCCCCC;
    --color-charcoal: #1A1A1A;
    --color-charcoal-light: #555555;
    --color-burgundy: #333333;
    --color-gold: #888888;
    --color-gold-muted: #666666;
    
    /* Accent color for links/navigation only */
    --color-accent: #4A90D9;
    
    /* Background colors */
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-header: rgba(255, 255, 255, 0.95);
    --bg-overlay: rgba(255, 255, 255, 0.9);
    
    /* Text colors */
    --text-primary: #1A1A1A;
    --text-secondary: #555555;
    --text-muted: #888888;
    
    /* Border colors */
    --border-color: #E5E5E5;
    --border-light: #F0F0F0;
    
    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* Typography */
    --font-title: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', Georgia, serif;
    --font-verse: 'IM Fell English', 'Times New Roman', serif;
    --font-accent: 'Cormorant Garamond', Georgia, serif;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
    
    /* Layout */
    --max-width: 1400px;
    --book-max-width: 1600px;
    --nav-height: 44px;  /* Reduced for more image space */
}

/* Dark Theme */
[data-theme="dark"] {
    --color-cream: #1A1A1A;
    --color-parchment: #242424;
    --color-sepia-light: #333333;
    --color-sepia: #444444;
    --color-charcoal: #F5F5F5;
    --color-charcoal-light: #BBBBBB;
    --color-burgundy: #CCCCCC;
    --color-gold: #C9A227;
    --color-gold-muted: #A68B1F;
    
    --color-accent: #6BA8E5;
    
    --bg-primary: #121212;
    --bg-secondary: #1A1A1A;
    --bg-card: #242424;
    --bg-header: rgba(18, 18, 18, 0.95);
    --bg-overlay: rgba(18, 18, 18, 0.9);
    
    --text-primary: #F5F5F5;
    --text-secondary: #BBBBBB;
    --text-muted: #888888;
    
    --border-color: #333333;
    --border-light: #2A2A2A;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Dark mode - Story page specific overrides */
[data-theme="dark"] .right-page {
    background: #1A1A1A;
}

[data-theme="dark"] .story-title {
    color: #F5F5F5;
}

[data-theme="dark"] .verse-text {
    color: #E0E0E0;
}

[data-theme="dark"] .summary-text {
    color: #D0D0D0;
}

[data-theme="dark"] .summary-text .kjv-quote {
    color: #F0F0F0;
}

[data-theme="dark"] .verse-ref {
    color: #999999;
}

[data-theme="dark"] .verse-range {
    color: #888888;
}

[data-theme="dark"] .key-verse {
    border-color: #333333; /* Lighter border in dark mode */
}

[data-theme="dark"] .story-footer {
    border-color: #444444;
    color: #888888;
}

/* Theme Toggle Button - iOS Style */
.theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    min-width: 44px; /* iOS touch target minimum */
    min-height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 1rem;
    transition: all 0.15s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.theme-toggle:active {
    transform: scale(0.92);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* Light mode: show moon (to switch to dark) */
.theme-toggle .icon-moon {
    display: block;
}

.theme-toggle .icon-sun {
    display: none;
}

/* Dark mode: show sun (to switch to light) */
[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: calc(1rem * var(--font-size-scale, 1));
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================================================
   Index Page Styles
   ============================================================================ */

.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.index-page {
    background: var(--bg-primary);
}

/* Compact Header */
.compact-header {
    display: flex;
    flex-direction: column;
    background: #000000;
    position: -webkit-sticky; /* iOS Safari */
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
    padding-top: env(safe-area-inset-top); /* iPhone notch */
}

/* Extend header background upward to prevent scroll bleed-through in PWA */
.compact-header::before {
    content: '';
    position: absolute;
    top: -100vh;
    left: 0;
    right: 0;
    height: 100vh;
    background: #000000;
    z-index: -1;
}

/* Primary header row */
.header-row.header-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xs) var(--spacing-xl);
}

/* Breadcrumb row - hidden by default, slides in on scroll */
.header-row.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 var(--spacing-xl);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Breadcrumb visible state */
.header-row.header-breadcrumb.visible {
    max-height: 40px;
    opacity: 1;
    padding: 8px var(--spacing-xl);
}

/* Breadcrumb segments */
.header-breadcrumb .breadcrumb-testament {
    color: #FFFFFF;
    font-weight: 600;
}

.header-breadcrumb .breadcrumb-grouping {
    color: rgba(255, 255, 255, 0.7);
}

.header-breadcrumb .breadcrumb-book {
    color: rgba(255, 255, 255, 0.5);
}

.header-breadcrumb .breadcrumb-sep {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
}

.header-breadcrumb .breadcrumb-count {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.6875rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    min-width: 0; /* Allow text to truncate */
}

.header-divider {
    color: var(--text-muted);
    font-weight: 300;
    opacity: 0.5;
    flex-shrink: 0;
}

.header-tagline {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hide tagline on smaller screens */
@media (max-width: 900px) {
    .header-tagline,
    .header-divider {
        display: none;
    }
}

/* Brand link - no underline */
.brand-link {
    text-decoration: none;
    color: inherit;
}

.brand-link:hover {
    opacity: 0.9;
}

.brand-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    color: #FFFFFF;
    letter-spacing: -0.01em;
    display: flex;
    align-items: baseline;
    gap: 0.3em;
    margin: 0;
}

/* Standard font for "The" and "Bible" */
.brand-prefix,
.brand-suffix {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 500;
}

.brand-suffix {
    margin-left: 0.25em;
}

/* Brand text (The, Bible) - standard font */
.brand-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 400;
}

/* GRACE Toggle Container - old-timey font */
.grace-toggle {
    display: inline-flex;
    cursor: pointer;
    position: relative;
    font-family: 'IM Fell English', 'Times New Roman', serif;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Collapsed state: "GRACE" */
.grace-collapsed {
    display: inline-block;
    opacity: 1;
    transition: opacity 0.3s ease;
    font-weight: 400;
}

/* Expanded state: Full words */
.grace-expanded {
    display: none;
    opacity: 0;
    align-items: baseline;
    gap: 0.25em;
    transition: opacity 0.3s ease;
}

.grace-toggle.expanded .grace-collapsed {
    display: none;
    opacity: 0;
}

.grace-toggle.expanded .grace-expanded {
    display: inline-flex;
    opacity: 1;
}

/* Individual words in expanded state */
.grace-expanded .grace-word {
    display: inline-block;
    white-space: nowrap;
    animation: wordFadeIn 0.4s ease forwards;
    opacity: 0;
    font-family: 'IM Fell English', 'Times New Roman', serif;
}

.grace-toggle.expanded .grace-word:nth-child(1) { animation-delay: 0ms; }
.grace-toggle.expanded .grace-word:nth-child(2) { animation-delay: 50ms; }
.grace-toggle.expanded .grace-word:nth-child(3) { animation-delay: 100ms; }
.grace-toggle.expanded .grace-word:nth-child(4) { animation-delay: 150ms; }
.grace-toggle.expanded .grace-word:nth-child(5) { animation-delay: 200ms; }

@keyframes wordFadeIn {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-stats {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Admin-only wrapper inside header stats - maintains flex layout when visible */
.header-stats .admin-only {
    display: none;
    gap: 6px;
    align-items: center;
}

/* Show admin-only elements when body has is-admin class */
body.is-admin .admin-only {
    display: flex;
}

/* Card status badges should display inline when visible */
.card-status.admin-only {
    display: none;
}

body.is-admin .card-status.admin-only {
    display: flex;
}

/* Status Filter Buttons in Header */
.stat-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 100px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.25);
}

.stat-btn.active {
    background: rgba(201, 162, 39, 0.15);
    color: var(--color-gold);
    border-color: rgba(201, 162, 39, 0.4);
    font-weight: 600;
}

.stat-btn.active:hover {
    background: rgba(201, 162, 39, 0.25);
}

.stat-btn span {
    font-weight: 700;
}

/* ============================================================================
   Introduction Section - Two Equal Columns
   ============================================================================ */

/* Tagline */
.tagline {
    text-align: center;
    font-family: var(--font-body);
    font-size: 1rem;
    font-style: italic;
    color: var(--text-secondary);
    margin: 0;
    padding: var(--spacing-sm) var(--spacing-xl);
    letter-spacing: 0.01em;
}

/* GRACE accent styling */
.grace-accent {
    font-family: 'IM Fell English', 'Times New Roman', serif;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Tagline responsive */
@media (max-width: 768px) {
    .tagline {
        font-size: 0.875rem;
        padding: var(--spacing-xs) var(--spacing-md);
    }
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-sm) var(--spacing-xl);
    width: 100%;
    animation: contentFadeIn 0.4s ease;
}

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

/* Filter Section */
.filter-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
}

.filter-section.compact {
    gap: var(--spacing-sm);
}

/* Search Row */
.filter-search-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-search-row .search-wrapper {
    flex: 1;
    max-width: 300px;
}

.filter-search-row .surprise-btn {
    padding: 8px 12px;
    font-size: 1rem;
    min-width: auto;
}

/* Testament Row */
.filter-testament-row {
    display: flex;
    align-items: center;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/* Segment Control (Testament Toggle) - iOS Style */
.segment-control {
    display: inline-flex;
    background: var(--border-color);
    border-radius: 10px;
    padding: 3px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: background-color 0.3s ease;
}

.segment {
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
}

.segment:hover {
    color: var(--text-primary);
}

.segment:active {
    transform: scale(0.97);
}

/* Scrollable Segment Control for cascading filters */
.segment-control.scrollable {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    position: relative;
}

.segment-control.scrollable::-webkit-scrollbar {
    display: none;
}

/* Fade indicators for scrollable content */
.filter-row.grouping-row,
.filter-row.book-row {
    position: relative;
}

.filter-row.grouping-row::before,
.filter-row.grouping-row::after,
.filter-row.book-row::before,
.filter-row.book-row::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.filter-row.grouping-row::before,
.filter-row.book-row::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-primary), transparent);
}

.filter-row.grouping-row::after,
.filter-row.book-row::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-primary), transparent);
}

.filter-row.grouping-row.can-scroll-left::before,
.filter-row.book-row.can-scroll-left::before,
.filter-row.grouping-row.can-scroll-right::after,
.filter-row.book-row.can-scroll-right::after {
    opacity: 1;
}

/* Cascading filter rows - hidden by default with slide animation */
.filter-row.grouping-row,
.filter-row.book-row {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    margin-top: 0;
}

.filter-row.grouping-row.visible,
.filter-row.book-row.visible {
    max-height: 60px;
    opacity: 1;
    margin-top: var(--spacing-sm);
}

/* Smaller segments for cascading filters */
.filter-row.grouping-row .segment,
.filter-row.book-row .segment {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.segment.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Book Select - iOS Style */
/* Book select dropdown replaced with cascading segment controls */

/* Status Pills - iOS Style */
/* Status filter moved to header as .stat-btn */

/* Search Wrapper - iOS Style */
.search-wrapper {
    flex: 1;
    min-width: 240px;
    max-width: 400px;
    position: relative;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s ease;
}

.search-wrapper input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 12px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.search-wrapper input:hover {
    box-shadow: var(--shadow-md);
}

.search-wrapper input:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .search-wrapper input:focus {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.search-wrapper input:focus + .search-icon,
.search-wrapper:focus-within .search-icon {
    color: var(--text-secondary);
}

.search-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    background: var(--border-color);
    border-radius: 6px;
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Surprise Me Button - iOS Style */
.surprise-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(128, 128, 128, 0.12);
    border: none;
    border-radius: 18px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.surprise-btn:hover {
    background: rgba(128, 128, 128, 0.2);
}

.surprise-btn:active {
    transform: scale(0.96);
}

/* Filter Top Row - User filters + Results count */
.filter-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    min-height: 28px;
}

.filter-top-row .user-filters {
    flex-shrink: 0;
}

.filter-top-row .results-count {
    flex-shrink: 0;
    margin-left: auto;
}

/* Hide results count on mobile when user filters are shown - too cramped */
@media (max-width: 480px) {
    .filter-top-row {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .filter-top-row .results-count {
        order: -1;
        width: 100%;
        margin-left: 0;
        margin-bottom: var(--spacing-xs);
        text-align: left;
    }
}

/* Active Filters Row */
.active-filters-row {
    display: none; /* Hidden when no active filters */
}

.active-filters-row:has(.filter-tag) {
    display: block;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #F0F0F0;
    border-radius: 100px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: #555;
    animation: tagFadeIn 0.2s ease;
}

@keyframes tagFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.filter-tag button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 50%;
    font-size: 10px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: 2px;
}

.filter-tag button:hover {
    background: rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
}

.results-count {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8125rem;
    color: #888;
    font-variant-numeric: tabular-nums;
}

/* Stories Grid - iOS Style */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    animation: gridFadeIn 0.5s ease;
}

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

/* Unified Section Breadcrumb - Full Width Sticky Header */
/* Unified Section Breadcrumb - Full width sticky header */
.section-breadcrumb {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: none; /* Hidden until visible class added */
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.section-breadcrumb.visible {
    display: block;
}

.section-breadcrumb .breadcrumb-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 8px var(--spacing-xl);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
}

.section-breadcrumb .breadcrumb-segment {
    background: none;
    border: none;
    padding: 4px 8px;
    margin: -4px -4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    font: inherit;
}

.section-breadcrumb .breadcrumb-segment:hover {
    background: rgba(128, 128, 128, 0.15);
}

.section-breadcrumb .breadcrumb-testament {
    color: var(--text-primary);
    font-weight: 600;
}

.section-breadcrumb .breadcrumb-grouping {
    color: var(--text-secondary);
}

.section-breadcrumb .breadcrumb-book {
    color: var(--text-muted);
}

.section-breadcrumb .breadcrumb-sep {
    color: var(--text-muted);
    opacity: 0.5;
    font-size: 0.75rem;
}

.section-breadcrumb .breadcrumb-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 400;
}

/* Section Headers in Grid - Compact Visual Dividers */
.section-header {
    grid-column: 1 / -1;
    padding: 0;
}

/* Testament Header (OT/NT) - Compact visual divider */
.testament-header {
    padding: 12px 0 6px;
    margin-top: 20px;
    border-bottom: 1px solid var(--border-color);
}

.testament-header:first-child {
    margin-top: 0;
    padding-top: 4px;
}

.testament-header h2 {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin: 0;
}

/* Grouping Header (Torah, History, etc.) - Compact visual divider */
.grouping-header {
    padding: 8px 0 4px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grouping-header h3 {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.grouping-description {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Book Header (Genesis, Exodus, etc.) - Minimal divider */
.book-header {
    padding: 6px 0 2px;
    margin-top: 8px;
}

.book-header h4 {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.5625rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

/* Mobile adjustments for section headers */
@media (max-width: 768px) {
    .section-breadcrumb .breadcrumb-inner {
        padding: 6px var(--spacing-md);
        font-size: 0.75rem;
    }
    
    .testament-header {
        padding: 10px 0 4px;
        margin-top: 16px;
    }
    
    .testament-header h2 {
        font-size: 0.75rem;
    }
    
    .grouping-header {
        margin-top: 10px;
        padding: 6px 0 3px;
        flex-wrap: wrap;
    }
    
    .grouping-header h3 {
        font-size: 0.6875rem;
    }
    
    .grouping-description {
        font-size: 0.625rem;
    }
    
    .book-header {
        padding: 4px 0 2px;
        margin-top: 6px;
    }
    
    .book-header h4 {
        font-size: 0.5rem;
    }
}

.story-card {
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.08);
    will-change: transform, box-shadow;
}

.story-card:hover {
    transform: scale(1.02) translateY(-4px);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.1),
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 16px 48px rgba(0, 0, 0, 0.12);
}

.story-card:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

.card-image {
    aspect-ratio: 3 / 4;
    width: 100%;
    padding: 0;
    position: relative;
    overflow: hidden;
    background: #000;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Fill card, crop minimally */
    border-radius: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-image img.loaded {
    opacity: 1;
}

.card-image .placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #555;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.875rem;
    text-align: center;
    padding: var(--spacing-md);
}

.card-status {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-status.complete {
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
}

.card-status.pending {
    background: rgba(255, 255, 255, 0.1);
    color: #888;
}

.card-content {
    padding: 14px 16px 16px;
    background: var(--bg-card);
    transition: background-color 0.3s ease;
}

.card-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
}

.card-reference {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: color 0.3s ease;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-xl);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
}

.footer-about {
    max-width: 500px;
}

.footer-brand {
    font-family: 'IM Fell English', 'Times New Roman', serif;
    font-size: 1.125rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
    display: block;
    margin-bottom: var(--spacing-sm);
}

.footer-description {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--accent-primary);
}

.footer-link .external-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.footer-divider {
    color: var(--text-muted);
    opacity: 0.5;
}

.footer-copyright {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* Loading & Empty States */
.loading-state,
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-xl);
    color: var(--text-secondary);
    font-family: 'Inter', -apple-system, sans-serif;
    max-width: 400px;
    margin: 2rem auto;
}

.empty-state .empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.empty-state h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
}

.empty-state p {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0 0 1.5rem 0;
}

.empty-state p strong {
    color: var(--text-secondary);
}

.empty-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: var(--color-gold);
    color: #1a1a1a;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.empty-action-btn:hover {
    background: #e5c158;
    transform: translateY(-1px);
}

.empty-action-btn:active {
    transform: translateY(0);
}

/* Specific empty state themes */
.empty-state-favorites .empty-icon {
    color: #e53e3e;
}

.empty-state-celebration .empty-icon {
    animation: celebrateBounce 0.6s ease infinite alternate;
}

@keyframes celebrateBounce {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

/* Skeleton Loading Cards */
.story-card.skeleton {
    pointer-events: none;
}

.story-card.skeleton .card-image {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        var(--bg-secondary) 50%,
        var(--bg-hover) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.story-card.skeleton .card-content {
    background: var(--bg-secondary);
}

.skeleton-shimmer {
    background: linear-gradient(90deg, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0.1) 50%, 
        rgba(255,255,255,0) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.story-card.skeleton .skeleton-title {
    height: 16px;
    width: 80%;
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        var(--bg-secondary) 50%,
        var(--bg-hover) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.story-card.skeleton .skeleton-meta {
    height: 12px;
    width: 50%;
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        var(--bg-secondary) 50%,
        var(--bg-hover) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 3px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Page Transitions */
.story-layout {
    transition: opacity 0.2s ease-out;
}

.story-layout.fade-out {
    opacity: 0;
}

.story-layout.fade-in {
    opacity: 1;
}

/* ============================================================================
   Story Page Styles
   ============================================================================ */

.story-page {
    background: var(--bg-primary);
}

/* Navigation */
.story-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top); /* iPhone notch */
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: var(--spacing-xl);
    padding-right: var(--spacing-xl);
    z-index: 100;
}

/* Extend story nav background upward for PWA scroll bleed-through */
.story-nav::before {
    content: '';
    position: absolute;
    top: -100vh;
    left: 0;
    right: 0;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: -1;
}

.nav-back {
    font-family: var(--font-body);
    color: #FFFFFF;
    text-decoration: none;
    font-size: 0.875rem;
    transition: opacity 0.2s;
    letter-spacing: 0.02em;
}

.nav-back:hover {
    opacity: 0.7;
}

.nav-controls {
    display: none; /* Using floating nav instead */
}

.nav-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.nav-position {
    font-family: var(--font-body);
    color: #888888;
    font-size: 0.8125rem;
    min-width: 80px;
    text-align: center;
    letter-spacing: 0.05em;
}

/* Book Story Layout - Fixed Images + Scrolling Text */
.book-story {
    min-height: 100vh;
    padding-top: var(--nav-height);
    background: var(--bg-primary);
}

.story-layout {
    display: flex;
    min-height: calc(100vh - var(--nav-height));
}

/* Left Page - Fixed Image Panel */
/* Width calculated from height to fit 3:4 images perfectly */
.left-page {
    position: fixed;
    left: 0;
    top: var(--nav-height);
    /* Width = height * 0.75 for 3:4 ratio (width/height = 3/4) */
    width: calc((100vh - var(--nav-height)) * 0.75);
    height: calc(100vh - var(--nav-height));
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-right: none;  /* Clean edge */
}

.image-container {
    width: 100%;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Single Image Display - Fill entire container */
.single-image {
    width: 100%;
    height: 100%;
    position: relative;
}

.single-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Fill completely, crop minimally */
}

/* 2x2 Image Grid - Minimal gaps, fill each cell */
.image-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    width: 100%;
    height: 100%;
    gap: 2px;  /* iOS-style minimal gap */
    background: #000;
    padding: 0;
    box-sizing: border-box;
}

.grid-image {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #000;
}

.grid-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Fill cell, crop minimally */
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.grid-image img.loaded {
    opacity: 1;
}

.grid-image:hover img {
    transform: scale(1.03);
    filter: brightness(1.05);
}

.grid-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    transition: background 0.3s ease;
    pointer-events: none;
}

.grid-image:hover::after {
    background: rgba(255, 255, 255, 0.05);
    z-index: 1;
}

/* ============================================================================
   Image Selection UI
   ============================================================================ */

/* Primary Image Container */
.primary-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.primary-image-container .single-image {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.primary-image-container .single-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Fill completely */
}

.primary-badge {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    background: #FFFFFF;
    color: #1A1A1A;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
}

.primary-badge.user-selection {
    background: #4CAF50;
    color: #FFFFFF;
}

.expand-options-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    background: linear-gradient(to bottom, #333, #1A1A1A);
    border: none;
    border-top: 2px solid #444;
    color: #FFFFFF;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
    flex-shrink: 0; /* Don't shrink the button */
    min-height: 60px; /* Ensure minimum height */
    width: 100%;
    z-index: 20;
}

.expand-options-btn:hover {
    background: linear-gradient(to bottom, #3A3A3A, #2A2A2A);
    color: #FFFFFF;
}

.expand-icon {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.expand-options-btn:hover .expand-icon {
    transform: translateY(2px);
}

.expand-icon {
    font-size: 0.625rem;
    transition: transform 0.2s ease;
}

/* Selection Grid */
.image-selection-grid {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(to bottom, #1A1A1A, #111);
    border-bottom: 1px solid #333;
}

.selection-title {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: #FFFFFF;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.collapse-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 8px 16px;
    background: #FFFFFF;
    border: none;
    border-radius: 20px;
    color: #1A1A1A;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.collapse-btn:hover {
    background: #F0F0F0;
    transform: scale(1.02);
}

.collapse-icon {
    font-size: 0.625rem;
}

.image-selection-grid .image-grid {
    flex: 1;
}

/* Selectable Image States */
.grid-image.selectable {
    cursor: pointer;
}

.grid-image.selectable .image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 3;
}

.grid-image.selectable:hover .image-overlay,
.grid-image.selectable:focus .image-overlay,
.grid-image.selectable:active .image-overlay {
    opacity: 1;
}

/* Touch devices: always show overlay so users know they can tap */
@media (hover: none) and (pointer: coarse) {
    .grid-image.selectable .image-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.5);
    }
}

.select-label {
    color: white;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    transition: all 0.2s ease;
}

.grid-image.selectable:hover .select-label {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Current Primary Indicator */
.grid-image.is-primary {
    outline: 4px solid #FFFFFF;
    outline-offset: -4px;
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.3);
}

/* User's personal selection - green outline */
.grid-image.is-user-primary {
    outline: 4px solid #4CAF50;
    outline-offset: -4px;
    box-shadow: inset 0 0 0 4px rgba(76, 175, 80, 0.3);
}

/* Global admin default - gold outline */
.grid-image.is-global-primary:not(.is-user-primary) {
    outline: 4px solid var(--color-gold);
    outline-offset: -4px;
    box-shadow: inset 0 0 0 4px rgba(201, 162, 39, 0.3);
}

.grid-image.is-primary::after {
    background: rgba(255, 255, 255, 0.1) !important;
    opacity: 1 !important;
}

.grid-image.is-primary .image-overlay {
    background: rgba(0, 0, 0, 0.4);
    opacity: 1;
}

.grid-image.is-primary .select-label {
    display: none;
}

.grid-image.is-primary:hover .select-label {
    display: block;
    opacity: 0.7;
}

.grid-image.is-primary:hover .image-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.grid-image.is-primary:hover .current-primary-badge::after {
    content: ' (current)';
}

.current-primary-badge {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    background: #FFFFFF;
    color: #1A1A1A;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: none;
}

.grid-image.is-primary .current-primary-badge {
    display: flex !important;
    align-items: center;
    gap: 4px;
}

/* ============================================================================
   Offline Banner
   ============================================================================ */

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: linear-gradient(135deg, #2D3748 0%, #1A202C 100%);
    color: #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.875rem;
    font-family: var(--font-body);
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-banner.visible {
    transform: translateY(0);
}

.offline-banner .offline-icon {
    font-size: 1rem;
}

.offline-banner .offline-text {
    font-weight: 500;
}

.offline-banner .offline-count {
    color: var(--color-gold);
    font-weight: 600;
}

/* Push content down when offline banner is visible */
body.is-offline {
    padding-top: 40px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: var(--spacing-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: #1A1A1A;
    color: #FFFFFF;
    border-radius: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 24px;
    height: 24px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.toast-message {
    font-family: var(--font-body);
    font-size: 0.9375rem;
}

/* Image number badge with gradient overlay for visibility */
.grid-image::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-image:hover::before {
    opacity: 1;
}

.grid-image .image-number {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.95);
    color: #1A1A1A;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Right Page - Scrolling Text Panel */
.right-page {
    /* Margin matches left-page width */
    margin-left: calc((100vh - var(--nav-height)) * 0.75);
    /* Width fills remaining space */
    width: calc(100vw - (100vh - var(--nav-height)) * 0.75);
    min-height: calc(100vh - var(--nav-height));
    padding: var(--spacing-3xl);
    padding-bottom: calc(var(--spacing-3xl) + 60px);
    display: flex;
    flex-direction: column;
    align-items: center;  /* Center the text wrapper */
    background: var(--bg-secondary);
    position: relative;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

/* Inner wrapper for readable text width */
.text-content-wrapper {
    max-width: 680px;  /* Optimal reading width */
    width: 100%;
}

/* Scroll shadow at top when scrolled */
.right-page::before {
    content: '';
    position: fixed;
    top: var(--nav-height);
    /* Match left-page width */
    left: calc((100vh - var(--nav-height)) * 0.75);
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, var(--bg-secondary) 0%, transparent 100%);
    pointer-events: none;
    z-index: 5;
    transition: background 0.3s ease;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.right-page.scrolled::before {
    opacity: 1;
}

/* Scroll indicator at bottom */
.scroll-indicator {
    position: fixed;
    bottom: var(--spacing-lg);
    left: calc(50vw + 50%);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    color: #999999;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-indicator::after {
    content: '↓';
    font-size: 1rem;
    animation: bounce 1.5s ease infinite;
}

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

/* Story Header with Audio Controls */
.story-header-row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.story-header-row .story-title {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.story-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    order: -1; /* Move above title */
    margin-bottom: 4px;
    flex-shrink: 0;
}

.verse-range-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.audio-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px; /* iOS touch target minimum */
    min-height: 44px;
    background: rgba(128, 128, 128, 0.12);
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.audio-btn:hover {
    background: rgba(128, 128, 128, 0.2);
}

.audio-btn:active {
    transform: scale(0.92);
}

.audio-btn.active {
    background: var(--color-gold);
    animation: audioPulse 1.5s ease-in-out infinite;
}

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

/* Audio Controls Panel - iOS Style */
.audio-controls {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(128, 128, 128, 0.1);
    border: none;
    border-radius: 20px;
    margin-top: 8px;
    animation: slideDown 0.15s ease;
}

.audio-controls.visible {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.audio-control-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: var(--text-primary);
}

.audio-control-btn:hover {
    background: rgba(128, 128, 128, 0.15);
}

.audio-control-btn:active {
    transform: scale(0.9);
}

.audio-control-btn .play-icon,
.audio-control-btn .pause-icon {
    display: none;
}

.audio-control-btn.play-pause .play-icon {
    display: block;
}

.audio-control-btn.play-pause.playing .play-icon {
    display: none;
}

.audio-control-btn.play-pause.playing .pause-icon {
    display: block;
}

.speed-btn {
    padding: 4px 10px;
    background: transparent;
    border: none;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.speed-btn:hover {
    background: rgba(128, 128, 128, 0.15);
}

.audio-status {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.audio-status.speaking {
    color: var(--color-gold);
}

/* Audio Segment Highlighting */
.audio-segment {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    border-radius: 2px;
    padding: 0 2px;
    margin: 0 -2px;
}

.audio-segment.audio-active {
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.18), rgba(201, 162, 39, 0.08));
    box-shadow: inset 0 -2px 0 var(--color-gold);
    animation: audioReadingPulse 1.5s ease-in-out infinite;
}

@keyframes audioReadingPulse {
    0%, 100% { 
        background: linear-gradient(135deg, rgba(201, 162, 39, 0.18), rgba(201, 162, 39, 0.08));
    }
    50% { 
        background: linear-gradient(135deg, rgba(201, 162, 39, 0.28), rgba(201, 162, 39, 0.15));
    }
}

.audio-segment.audio-complete {
    opacity: 0.6;
}

/* Sticky Audio Bar - Slides down during playback */
.audio-sticky-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: max(env(safe-area-inset-top), 8px) 16px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), 
                opacity 0.25s ease;
    pointer-events: none;
}

.audio-sticky-bar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

[data-theme="dark"] .audio-sticky-bar {
    background: rgba(26, 26, 26, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* Sticky bar controls */
.audio-sticky-bar .sticky-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--color-gold);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.audio-sticky-bar .sticky-control-btn:hover {
    transform: scale(1.05);
}

.audio-sticky-bar .sticky-control-btn:active {
    transform: scale(0.95);
}

.audio-sticky-bar .sticky-control-btn.secondary {
    background: rgba(128, 128, 128, 0.12);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
}

/* Progress Dots */
.audio-progress-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
    overflow: hidden;
}

.audio-progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(128, 128, 128, 0.3);
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.audio-progress-dot:hover {
    transform: scale(1.2);
    background: rgba(128, 128, 128, 0.5);
}

.audio-progress-dot:active {
    transform: scale(0.9);
}

.audio-progress-dot.active {
    background: var(--color-gold);
    transform: scale(1.3);
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.6);
}

.audio-progress-dot.complete {
    background: var(--color-gold);
}

/* Section Skip Buttons */
.audio-sticky-bar .skip-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.audio-sticky-bar .skip-btn:hover {
    background: rgba(128, 128, 128, 0.2);
}

.audio-sticky-bar .skip-btn:active {
    transform: scale(0.95);
    background: rgba(128, 128, 128, 0.3);
}

.audio-sticky-bar .skip-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Speed indicator in sticky bar */
.audio-sticky-bar .speed-indicator {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: rgba(128, 128, 128, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.audio-sticky-bar .speed-indicator:hover {
    background: rgba(128, 128, 128, 0.2);
}

/* Sticky bar play button states */
.audio-sticky-bar .sticky-control-btn .play-icon,
.audio-sticky-bar .sticky-control-btn .pause-icon {
    display: none;
}

.audio-sticky-bar .sticky-control-btn .play-icon {
    display: block;
}

.audio-sticky-bar .sticky-control-btn.playing .play-icon {
    display: none;
}

.audio-sticky-bar .sticky-control-btn.playing .pause-icon {
    display: block;
}

/* Mobile adjustments for sticky bar */
@media (max-width: 768px) {
    .audio-sticky-bar {
        padding: max(env(safe-area-inset-top), 6px) 12px 6px;
        gap: 8px;
    }
    
    .audio-sticky-bar .sticky-control-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .audio-sticky-bar .sticky-control-btn.secondary {
        width: 28px;
        height: 28px;
    }
    
    .audio-progress-dot {
        width: 8px;
        height: 8px;
    }
    
    .audio-sticky-bar .skip-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 12px;
    }
    
    .audio-sticky-bar .speed-indicator {
        font-size: 0.625rem;
        padding: 3px 6px;
    }
}

.story-header {
    margin-bottom: var(--spacing-lg); /* Tighter - iOS style */
}

.story-title {
    font-family: var(--font-title);
    font-size: clamp(1.5rem, 4vw, 2.5rem); /* Responsive sizing */
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: var(--spacing-xs); /* Tighter gap to verse range */
    letter-spacing: -0.02em;
    transition: color 0.3s ease;
    word-wrap: break-word;
}

.verse-range {
    font-family: var(--font-body);
    font-size: 0.75rem; /* Smaller */
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    transition: color 0.2s ease;
}

.verse-range:hover {
    color: var(--color-gold);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.verse-range::after {
    content: '↗';
    font-size: 0.75em;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.verse-range:hover::after {
    opacity: 0.8;
    transform: translateX(0);
}

/* Key Verse */
.key-verse {
    margin-bottom: var(--spacing-lg); /* Tighter spacing */
    padding: var(--spacing-md) 0;     /* Reduced padding */
    border-top: none;                  /* Remove top border */
    border-bottom: 1px solid var(--border-light); /* Single lighter border */
    position: relative;
    transition: border-color 0.3s ease;
}

.verse-text {
    font-family: var(--font-verse);
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.7;
    color: var(--text-primary);
    font-style: italic;
    margin-bottom: var(--spacing-md);
    transition: color 0.3s ease;
}

.verse-ref {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: normal;
    display: block;
    text-align: right;
    letter-spacing: 0.05em;
    transition: color 0.3s ease;
}

/* Divider */
.divider {
    display: none; /* Removed - redundant with key-verse border */
}

/* Summary Text */
.summary-text {
    flex: 1;
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.9;
    color: var(--color-charcoal);
    text-align: left;
    letter-spacing: 0.01em;
}

.summary-text p {
    margin-bottom: var(--spacing-lg);
}

.summary-text p:last-child {
    margin-bottom: 0;
}

/* KJV Quotes in Summary - styled like key verse */
.summary-text .kjv-quote {
    font-family: var(--font-verse);
    font-size: 1.125rem;
    font-weight: 500;
    font-style: italic;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

/* Story Footer */
.story-footer {
    display: flex;
    justify-content: space-between;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-sepia);
    font-family: var(--font-accent);
    font-size: 0.75rem;
    color: var(--color-charcoal-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Error State */
.error-state {
    text-align: center;
    padding: var(--spacing-3xl);
    color: var(--color-cream);
}

.error-state h2 {
    font-family: var(--font-title);
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

.error-state p {
    margin-bottom: var(--spacing-xl);
    opacity: 0.8;
}

.btn {
    display: inline-block;
    padding: var(--spacing-md) var(--spacing-xl);
    background: #000000;
    color: white;
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    border-radius: 100px;
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.btn:hover {
    background: #333333;
    transform: scale(1.02);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 1024px) {
    /* Revert to stacked layout on tablets/mobile */
    .story-layout {
        display: block;
    }
    
    .left-page {
        position: relative;
        width: 100%;
        /* Auto height - show full image without cropping */
        height: auto;
        top: 0;
        border: none;  /* Clean edges */
    }
    
    /* Full height images on mobile - no cropping */
    .left-page .image-container {
        height: auto;
    }
    
    .left-page .single-image {
        height: auto;
        aspect-ratio: 3 / 4;
    }
    
    .left-page .single-image img {
        height: auto;
        width: 100%;
        object-fit: contain;
        background: #000;
    }
    
    /* Grid view on mobile - 2x2 with full images */
    .left-page .image-grid {
        height: auto;
        aspect-ratio: 3 / 4; /* Match single image ratio - 2x2 grid of 3:4 images */
    }
    
    .left-page .grid-image img {
        object-fit: cover; /* Fill cell, crop minimally */
        background: #000;
    }
    
    /* Primary image container */
    .left-page .primary-image-container {
        height: auto;
    }
    
    .left-page .primary-image-container .single-image {
        height: auto;
        aspect-ratio: 3 / 4;
    }
    
    .left-page .primary-image-container .single-image img {
        object-fit: contain;
    }
    
    /* Image selection grid on mobile */
    .left-page .image-selection-grid {
        height: auto;
    }
    
    .left-page .image-selection-grid .image-grid {
        aspect-ratio: 3 / 4; /* Match single image ratio for full-width 2x2 grid */
    }
    
    .right-page {
        margin-left: 0;
        width: 100%;
        padding: var(--spacing-xl);
        padding-bottom: calc(var(--spacing-xl) + 80px); /* Space for floating nav */
        min-height: auto;
    }
    
    .right-page::before {
        left: 0;
    }
    
    .scroll-indicator {
        left: 50%;
    }
    
    .hero-features {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .text-content-wrapper {
        max-width: 100%;  /* Full width on mobile */
    }
    
    /* Floating nav already visible - no change needed */
}

@media (max-width: 768px) {
    .header-row.header-primary {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .header-row.header-breadcrumb {
        padding: 0 var(--spacing-md);
        font-size: 0.75rem;
    }
    
    .header-row.header-breadcrumb.visible {
        padding: 6px var(--spacing-md);
    }
    
    .header-left {
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-xs);
        flex: 1;
        min-width: 0; /* Allow shrinking */
    }
    
    .brand-title {
        font-size: 1.125rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-divider,
    .header-tagline {
        display: none; /* Hide on mobile to save space */
    }
    
    .header-stats {
        flex-shrink: 0;
        display: flex;
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
    }
    
    /* Hide admin stats on mobile, keep auth controls */
    .header-stats .admin-only {
        display: none;
    }
    
    .auth-controls {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }
    
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* Keep search and testament rows horizontal on mobile */
    .filter-row.filter-search-row {
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-sm);
    }
    
    .filter-row.filter-testament-row {
        flex-direction: row;
        align-items: center;
    }
    
    .segment-control {
        width: 100%;
        justify-content: center;
    }
    
    .segment {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
        font-size: 0.75rem;
    }
    
    /* Cascading filter sliders on mobile - allow horizontal scroll */
    .segment-control.scrollable {
        justify-content: flex-start;
        padding: 3px;
    }
    
    .segment-control.scrollable .segment {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 8px 14px;
    }
    
    .filter-row.grouping-row.visible,
    .filter-row.book-row.visible {
        margin-top: var(--spacing-xs);
    }
    
    .search-wrapper {
        max-width: none;
        width: 100%;
    }
    
    .search-shortcut {
        display: none;
    }
    
    .stories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    .card-title {
        font-size: 0.8125rem;
    }
    
    .card-reference {
        font-size: 0.625rem;
    }
}

@media (max-width: 480px) {
    .brand-title {
        font-size: 1.125rem;
    }
    
    .stat-btn {
        font-size: 0.5625rem;
        padding: 4px 8px;
        gap: 2px;
    }
    
    .segment {
        font-size: 0.6875rem;
        padding: 8px 6px;
    }
    
    .stories-grid {
        gap: var(--spacing-sm);
    }
    
    .card-content {
        padding: var(--spacing-sm);
    }
    
    .card-title {
        font-size: 0.75rem;
    }
}

/* ============================================================================
   Image Regeneration UI
   ============================================================================ */

/* Regenerate Button in Grid */
.regen-btn,
.regenerate-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #FFFFFF;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

.grid-image:hover .regen-btn,
.grid-image:hover .regenerate-btn {
    opacity: 1;
}

.regen-btn:hover,
.regenerate-btn:hover {
    background: rgba(255, 100, 100, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1) rotate(180deg);
}

/* Touch devices: always show regen button */
@media (hover: none) and (pointer: coarse) {
    .regen-btn,
    .regenerate-btn {
        opacity: 0.85;
    }
}

/* Regeneration Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: var(--spacing-xl);
    animation: modalFadeIn 0.3s ease;
}

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

/* Modal Content */
.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: var(--spacing-2xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: modalSlideUp 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

.modal-content h2 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 500;
    color: #1A1A1A;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.02em;
}

.modal-content p {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: #666;
    margin-bottom: var(--spacing-xl);
    line-height: 1.6;
}

/* Progress Ring & Countdown Timer */
.countdown-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-xl) 0;
}

.progress-ring-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: #F0F0F0;
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: #1A1A1A;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283; /* 2 * PI * 45 */
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1s ease;
}

.countdown-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 500;
    color: #1A1A1A;
    letter-spacing: -0.03em;
}

.stage-text {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: #888;
    text-align: center;
    min-height: 1.2em;
    transition: opacity 0.3s ease;
}

.stage-text.overtime {
    color: #4CAF50;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* New Image Options Grid */
.new-image-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.new-image-option {
    aspect-ratio: 3 / 4;
    background: #F0F0F0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.new-image-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.new-image-option:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.new-image-option.selected {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

.new-image-option .option-number {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    color: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
}

/* Skeleton Loader for New Images */
.skeleton-image-option {
    aspect-ratio: 3 / 4;
    background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.modal-actions .btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.modal-actions .btn.secondary {
    background: #F0F0F0;
    color: #666;
}

.modal-actions .btn.secondary:hover {
    background: #E5E5E5;
}

.modal-actions .btn.primary {
    background: #4CAF50;
    color: #FFFFFF;
}

.modal-actions .btn.primary:hover {
    background: #43A047;
    transform: scale(1.02);
}

/* Mobile Responsive Regeneration */
@media (max-width: 768px) {
    .modal-content {
        padding: var(--spacing-lg);
        border-radius: 16px;
        max-height: 85vh;
    }
    
    .new-image-options-grid {
        gap: var(--spacing-sm);
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .regen-btn,
    .regenerate-btn {
        opacity: 0.8;
    }
}

/* ============================================================================
   Floating Story Navigation (Mobile)
   ============================================================================ */

.floating-story-nav {
    display: flex; /* Always visible for easy navigation */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-lg);
    padding-bottom: max(var(--spacing-lg), calc(env(safe-area-inset-bottom) + var(--spacing-md)));
    justify-content: space-between;
    align-items: center;
    z-index: 1000; /* Above everything */
    pointer-events: none;
}

.floating-nav-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.floating-nav-btn:hover {
    background: rgba(40, 40, 40, 0.95);
    transform: scale(1.05);
}

.floating-nav-btn:active {
    transform: scale(0.95);
}

.floating-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.floating-nav-btn:disabled:hover {
    background: rgba(26, 26, 26, 0.9);
    transform: none;
}

.floating-nav-btn span {
    line-height: 1;
}

/* Larger touch targets on small screens */
@media (max-width: 480px) {
    .floating-nav-btn {
        width: 60px;
        height: 60px;
        font-size: 1.75rem;
    }
    
    /* Larger summary text for readability */
    .summary-text {
        font-size: 1.0625rem;
        line-height: 1.85;
    }
    
    .summary-text p {
        margin-bottom: 1.25em;
    }
    
    /* Larger key verse for readability */
    .key-verse .verse-text {
        font-size: 1.125rem;
    }
}

/* ============================================================================
   PWA Install Banner
   ============================================================================ */

.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1A1A1A;
    border-top: 1px solid rgba(201, 162, 39, 0.3);
    padding: 0;
    z-index: 9999;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

.install-banner.visible {
    transform: translateY(0);
    opacity: 1;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.install-banner-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.install-banner-text {
    flex: 1;
    min-width: 0;
}

.install-banner-text strong {
    display: block;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #F5F5F5;
    margin-bottom: 2px;
}

.install-banner-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.8125rem;
    color: #888;
}

.install-banner-btn {
    background: #C9A227;
    color: #1A1A1A;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.install-banner-btn:hover {
    background: #D4AF37;
}

.install-banner-btn:active {
    transform: scale(0.98);
}

.install-banner-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.2s;
}

.install-banner-close:hover {
    color: #FFF;
}

/* iOS Installation Steps */
.install-ios-steps {
    max-height: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.install-ios-steps.visible {
    max-height: 200px;
    padding: 16px;
}

.ios-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.875rem;
    color: #CCC;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ios-step:last-child {
    border-bottom: none;
}

.ios-step-num {
    width: 24px;
    height: 24px;
    background: #C9A227;
    color: #1A1A1A;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.ios-step strong {
    color: #FFF;
}

.ios-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #4A90D9;
    margin-left: auto;
    flex-shrink: 0;
}

/* Dark mode adjustments for install banner */
[data-theme="dark"] .install-banner {
    background: #0D0D0D;
}

/* ============================================================================
   Authentication UI
   ============================================================================ */

/* Auth Controls in Header */
.auth-controls {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.auth-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
}

.auth-btn:active {
    transform: scale(0.96);
}

.auth-btn.signed-in {
    background: rgba(201, 162, 39, 0.15);
    border-color: rgba(201, 162, 39, 0.3);
    color: var(--color-gold);
}

.auth-btn.signed-in:hover {
    background: rgba(201, 162, 39, 0.25);
    border-color: rgba(201, 162, 39, 0.5);
}

/* Auth Modal */
.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 20px;
}

.auth-modal.visible {
    opacity: 1;
    visibility: visible;
}

.auth-modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    position: relative;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: translateY(20px) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.auth-modal.visible .auth-modal-content {
    transform: translateY(0) scale(1);
}

.auth-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.auth-close:hover {
    background: rgba(128, 128, 128, 0.25);
    color: var(--text-primary);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h2 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.auth-header p {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.auth-form input::placeholder {
    color: var(--text-muted);
}

.auth-submit {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    background: var(--color-gold);
    color: #1A1A1A;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-submit:hover:not(:disabled) {
    background: #D4AF37;
    transform: translateY(-1px);
}

.auth-submit:active:not(:disabled) {
    transform: translateY(0);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-legal {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
    line-height: 1.4;
}

.auth-legal a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.3);
    transition: color 0.2s;
}

.auth-legal a:hover {
    color: var(--color-gold);
}

.auth-status {
    text-align: center;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.875rem;
    min-height: 1.25em;
    margin: 0;
}

.auth-status.success {
    color: #4CAF50;
}

.auth-status.error {
    color: #F44336;
}

.pwa-hint {
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: var(--spacing-md) 0 0 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
    line-height: 1.5;
}

.pwa-hint p {
    margin: 0 0 var(--spacing-xs) 0;
}

.pwa-hint p:last-child {
    margin-bottom: 0;
}

.pwa-hint strong {
    color: var(--color-accent);
}

.pwa-hint-alt {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.auth-check-status {
    width: 100%;
    padding: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: var(--spacing-sm);
    transition: all 0.2s ease;
}

.auth-check-status:hover:not(:disabled) {
    background: var(--color-accent);
    color: var(--bg-primary);
    border-color: var(--color-accent);
}

.auth-check-status:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-footer {
    text-align: center;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 16px 0 0 0;
}

/* ============================================================================
   Auth Modal - OTP Code Entry (PWA Users)
   ============================================================================ */

/* View container for smooth transitions */
.auth-view {
    animation: authViewFadeIn 0.25s ease;
}

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

/* Success icon for link sent view */
.auth-success-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

/* OTP Input Container */
.otp-container {
    display: flex;
    justify-content: center;
    margin: 8px 0 16px 0;
}

/* Single input styled for 8-digit code */
.otp-input {
    width: 100%;
    max-width: 320px;
    padding: 16px 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.8em;
    text-align: center;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    caret-color: var(--color-gold);
    transition: all 0.2s ease;
}

.otp-input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.otp-input::placeholder {
    color: var(--text-muted);
    opacity: 0.3;
    letter-spacing: 1.2em;
}

.otp-input:disabled {
    opacity: 0.6;
    background: var(--bg-hover);
}

/* Auth action buttons row */
.auth-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.auth-back,
.auth-resend {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.auth-back:hover {
    color: var(--text-primary);
    background: rgba(128, 128, 128, 0.1);
}

.auth-resend:hover:not(:disabled) {
    color: var(--color-gold);
    background: rgba(201, 162, 39, 0.1);
}

.auth-resend:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Back to email link (link sent view) */
.auth-back-link {
    width: 100%;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    cursor: pointer;
    margin-top: 8px;
    transition: color 0.15s ease;
}

.auth-back-link:hover {
    color: var(--text-secondary);
}

/* Hint text */
.auth-hint {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

/* Error message */
.auth-error {
    text-align: center;
    font-size: 0.875rem;
    color: #F44336;
    margin: 12px 0 0 0;
    padding: 8px 12px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 8px;
}

/* Shake animation for invalid code */
@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

#authCodeView.shake {
    animation: authShake 0.5s ease;
}

#authCodeView.shake .otp-input {
    border-color: #F44336;
}

/* Success state */
#authCodeView.success .otp-input {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

#authCodeView.success .auth-header h2 {
    color: #4CAF50;
}

#authCodeView.success .auth-header h2::before {
    content: '✓ ';
}

#authCodeView.success .auth-actions {
    opacity: 0;
    pointer-events: none;
}

/* Mobile adjustments for auth modal */
@media (max-width: 768px) {
    .auth-modal-content {
        padding: 24px;
        border-radius: 16px;
    }
    
    .auth-header h2 {
        font-size: 1.25rem;
    }
    
    .auth-form input,
    .auth-submit {
        padding: 12px 14px;
        font-size: 0.9375rem;
    }
    
    .otp-input {
        font-size: 1.25rem;
        padding: 14px 10px;
        letter-spacing: 0.6em;
    }
    
    .auth-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .auth-back,
    .auth-resend {
        width: 100%;
    }
}

/* ============================================================================
   Settings Button
   ============================================================================ */

.settings-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.settings-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: stroke 0.15s ease, transform 0.3s ease;
}

.settings-btn:hover {
    background: rgba(128, 128, 128, 0.25);
}

.settings-btn:hover svg {
    stroke: var(--text-primary);
    transform: rotate(45deg);
}

/* Admin glow effect for settings button */
.settings-btn.is-admin {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.4), 0 0 24px rgba(212, 175, 55, 0.2);
    animation: adminGlow 2s ease-in-out infinite alternate;
}

.settings-btn.is-admin svg {
    stroke: var(--color-accent);
}

@keyframes adminGlow {
    from {
        box-shadow: 0 0 8px rgba(212, 175, 55, 0.3), 0 0 16px rgba(212, 175, 55, 0.15);
    }
    to {
        box-shadow: 0 0 16px rgba(212, 175, 55, 0.5), 0 0 32px rgba(212, 175, 55, 0.25);
    }
}

/* Admin Button */
.admin-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(212, 175, 55, 0.15);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    text-decoration: none;
}

.admin-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-accent);
    transition: stroke 0.15s ease, transform 0.2s ease;
}

.admin-btn:hover {
    background: rgba(212, 175, 55, 0.25);
    transform: scale(1.05);
}

.admin-btn:hover svg {
    stroke: var(--color-accent);
}

/* ============================================================================
   Settings Modal
   ============================================================================ */

.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 20px;
    overflow-y: auto;
}

.settings-modal.visible {
    opacity: 1;
    visibility: visible;
}

.settings-modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    position: relative;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: translateY(20px) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.settings-modal.visible .settings-modal-content {
    transform: translateY(0) scale(1);
}

.settings-modal-content h2 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    text-align: center;
}

.settings-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.settings-close:hover {
    background: rgba(128, 128, 128, 0.25);
    color: var(--text-primary);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.setting-row:first-of-type {
    padding-top: 0;
}

.setting-row:last-of-type {
    border-bottom: none;
}

.setting-label {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--text-primary);
}

/* iOS-style Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(128, 128, 128, 0.3);
    border-radius: 31px;
    transition: background 0.25s ease;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: #D4AF37;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Settings Select */
.setting-select {
    font-family: var(--font-body);
    font-size: 0.875rem;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 140px;
    transition: border-color 0.15s ease;
}

.setting-select:hover {
    border-color: var(--text-muted);
}

.setting-select:focus {
    outline: none;
    border-color: #D4AF37;
}

/* Settings Admin Link */
.settings-admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 24px;
    padding: 14px 20px;
    border: 1px solid var(--color-accent);
    border-radius: 12px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--color-accent);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-admin-link svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.settings-admin-link:hover {
    background: var(--color-accent);
    color: var(--bg-primary);
}

/* ============================================================================
   Offline Storage Section
   ============================================================================ */

.settings-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.settings-section-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.storage-subsection {
    background: var(--bg-hover);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.storage-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.storage-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.storage-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding: 6px 8px;
    background: var(--bg-card);
    border-radius: 6px;
}

.storage-count {
    font-weight: 500;
}

.storage-size {
    color: var(--text-muted);
}

.storage-action-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.storage-action-btn:hover {
    background: var(--bg-primary);
}

.storage-action-btn:active {
    transform: scale(0.98);
}

.storage-action-btn.danger {
    color: #E53E3E;
}

.storage-action-btn.danger:hover {
    background: rgba(229, 62, 62, 0.1);
}

.storage-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.storage-signin-prompt {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
}

/* Settings User Info */
.settings-user-info {
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 20px;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
}

.settings-user-info span {
    color: var(--text-primary);
    font-weight: 500;
}

/* Settings Legal Links */
.settings-legal-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.75rem;
}

.settings-legal-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.settings-legal-links a:hover {
    color: var(--color-gold);
}

.settings-legal-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Settings Sign Out Button */
.settings-signout {
    width: 100%;
    margin-top: 12px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    background: rgba(229, 62, 62, 0.15);
    color: #E53E3E;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.settings-signout:hover {
    background: rgba(229, 62, 62, 0.25);
}

/* ============================================================================
   iOS-style Settings Sections
   ============================================================================ */

.settings-section-group {
    margin-bottom: 20px;
}

.settings-section-header {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 12px 6px;
}

.settings-section-card {
    background: var(--bg-hover);
    border-radius: 12px;
    overflow: hidden;
}

.settings-section-card .setting-row {
    padding: 14px 16px;
    margin: 0;
    border-bottom: 1px solid var(--border-light);
}

.settings-section-card .setting-row:last-child {
    border-bottom: none;
}

/* Compact Storage Rows */
.storage-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.storage-row:last-child {
    border-bottom: none;
}

.storage-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.storage-info .storage-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.storage-info .storage-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    padding: 0;
    margin: 0;
}

.storage-action-btn.compact {
    width: auto;
    padding: 6px 14px;
    font-size: 0.75rem;
    border-radius: 6px;
    background: var(--bg-card);
}

/* Download Buttons Section */
.download-section {
    padding: 12px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.download-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

.download-btn:hover {
    background: var(--bg-primary);
    border-color: var(--text-muted);
}

.download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.download-btn.primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--bg-primary);
}

.download-btn.primary:hover {
    background: #c9a030;
    border-color: #c9a030;
}

.download-btn .download-size {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: auto;
}

/* Download Progress */
.download-progress {
    padding: 12px 0;
}

.progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Storage Quota Display */
.storage-quota-card {
    padding: 12px 16px;
}

.storage-quota-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.storage-quota-header .storage-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.storage-quota-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.storage-quota-track {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
}

.storage-quota-bar {
    height: 100%;
    width: 0%;
    background: var(--color-accent);
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* Storage Limit Slider */
.storage-limit-control {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.storage-limit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.storage-limit-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.storage-limit-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-accent);
}

.storage-slider-container {
    position: relative;
}

.storage-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.storage-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-main);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.storage-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(212, 175, 55, 0.4);
}

.storage-slider::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

.storage-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-main);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.storage-slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 2px;
}

.storage-slider-labels span {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    width: 28px;
}

.storage-limit-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 10px;
    text-align: center;
    font-style: italic;
}

/* Setting Row with Description */
.setting-label-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-description {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Redesigned Admin Link */
.settings-section-card .settings-admin-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.settings-section-card .settings-admin-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.settings-section-card .settings-admin-link svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-accent);
}

.settings-section-card .settings-admin-link .chevron {
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    margin-left: auto;
}

/* Compact Account Section */
.settings-section-card .settings-user-info {
    margin: 0;
    padding: 14px 16px;
    background: transparent;
    border-radius: 0;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.settings-section-card .settings-signout {
    margin: 0;
    padding: 14px 16px;
    border-radius: 0;
    background: transparent;
    color: #E53E3E;
    text-align: left;
}

.settings-section-card .settings-signout:hover {
    background: rgba(229, 62, 62, 0.05);
}

/* Legal Links in Card */
.settings-section-card .settings-legal-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
}

.settings-section-card .settings-legal-links a {
    display: block;
    padding: 14px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

.settings-section-card .settings-legal-links a:last-child {
    border-bottom: none;
}

.settings-section-card .settings-legal-links a:hover {
    background: var(--bg-card);
    color: var(--color-accent);
}

/* ============================================================================
   Admin Curation Mode
   ============================================================================ */

.curation-bar {
    background: var(--color-accent);
    color: var(--bg-primary);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.curation-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.curation-count {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.curation-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.curation-progress-fill {
    height: 100%;
    background: var(--bg-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.curation-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.curation-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.15);
    color: inherit;
    transition: background 0.15s ease;
}

.curation-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.25);
}

.curation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.curation-btn.primary {
    background: var(--bg-primary);
    color: var(--color-accent);
}

.curation-btn.primary:hover {
    background: var(--bg-secondary);
}

.curation-btn.exit {
    background: rgba(229, 62, 62, 0.8);
    color: white;
}

.curation-btn.exit:hover {
    background: rgba(229, 62, 62, 1);
}

.curation-shortcuts {
    font-size: 0.7rem;
    opacity: 0.8;
    font-family: var(--font-body);
}

/* ============================================================================
   Full Curation View (replaces story page in curation mode)
   ============================================================================ */

.curation-view {
    padding: var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
}

/* Curation Header with progress and navigation */
.curation-header {
    background: var(--color-accent);
    color: var(--bg-primary);
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.curation-header .curation-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.curation-remaining {
    font-size: 0.75rem;
    opacity: 0.8;
    white-space: nowrap;
}

.curation-nav-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Main curation content - two columns */
.curation-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    align-items: start;
}

/* Left side: Image grid */
.curation-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.curation-image-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.curation-image-card:hover {
    border-color: var(--text-muted);
}

.curation-image-card.is-default {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.curation-image-wrapper {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-hover);
}

.curation-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.curation-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.875rem;
}

.curation-default-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--color-accent);
    color: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.curation-image-actions {
    display: flex;
    gap: 6px;
    padding: 10px;
    background: var(--bg-secondary);
}

.curation-set-default,
.curation-regenerate {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.curation-set-default {
    background: var(--color-accent);
    color: var(--bg-primary);
}

.curation-set-default:hover:not(:disabled) {
    background: #c9a030;
}

.curation-set-default:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.curation-regenerate {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.curation-regenerate:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* Right side: Story info and abstract */
.curation-info {
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.curation-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.curation-ref {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* Scene details for curation - clean field display */
.curation-scene-details {
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.scene-field {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: var(--spacing-md);
}

.scene-field label {
    display: block;
    font-family: var(--font-body);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent);
    margin-bottom: 6px;
}

.scene-value {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.scene-value.title-value {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 600;
}

.scene-value.focal-value {
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--color-accent);
}

.scene-value.approach-value {
    font-size: 0.9375rem;
    line-height: 1.7;
}

.scene-value.prompt-value {
    font-size: 0.875rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.6;
}

.curation-keyboard-help {
    background: var(--bg-hover);
    border-radius: 8px;
    padding: var(--spacing-md);
}

.curation-keyboard-help h4 {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.shortcut-row:last-child {
    margin-bottom: 0;
}

.shortcut-row kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Empty state - no images placeholder */
.curation-images.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
}

.curation-no-images-placeholder {
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    max-width: 400px;
}

.no-images-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-md);
    color: var(--text-muted);
}

.no-images-icon svg {
    width: 100%;
    height: 100%;
}

.curation-no-images-placeholder h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-sm) 0;
}

.curation-no-images-placeholder p {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 var(--spacing-lg) 0;
    line-height: 1.5;
}

.curation-generate-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--color-accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.curation-generate-all svg {
    width: 20px;
    height: 20px;
}

.curation-generate-all:hover:not(:disabled) {
    background: #c9a030;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.curation-generate-all:disabled {
    opacity: 0.8;
    cursor: wait;
}

.curation-generate-all .spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.generate-estimate {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-sm);
}

/* Mobile adjustments for curation view */
@media (max-width: 900px) {
    .curation-content {
        grid-template-columns: 1fr;
    }
    
    .curation-images {
        order: 2;
    }
    
    .curation-info {
        order: 1;
    }
}

@media (max-width: 600px) {
    .curation-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .curation-header .curation-progress {
        width: 100%;
    }
    
    .curation-nav-actions {
        justify-content: center;
    }
    
    .curation-images {
        grid-template-columns: 1fr;
    }
    
    .curation-title {
        font-size: 1.25rem;
    }
}

/* Mobile adjustments for curation bar */
@media (max-width: 480px) {
    .curation-bar {
        padding: 10px 12px;
    }
    
    .curation-actions {
        justify-content: center;
    }
    
    .curation-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .curation-shortcuts {
        text-align: center;
    }
}

/* Mobile adjustments for settings modal */
@media (max-width: 768px) {
    .settings-modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .settings-modal-content {
        padding: 20px;
        padding-top: 16px;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        width: 100%;
        max-width: 100%;
    }
    
    .settings-modal-content h2 {
        font-size: 1.25rem;
        margin-top: 8px;
    }
    
    .setting-select {
        min-width: 120px;
        font-size: 0.8125rem;
    }
    
    .settings-close {
        top: 12px;
        right: 12px;
    }
}

/* ============================================================================
   User Filters Row
   ============================================================================ */

.user-filters-row {
    /* No border or extra spacing - seamlessly above testament filter */
}

.user-filters-row .segment {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.user-filters-row .filter-icon {
    color: #E53E3E;
    font-size: 0.875rem;
}

.user-filters-row .segment.active .filter-icon {
    color: inherit;
}

/* Large Heart Icon in User Filter - Favorites button */
#userFilter .segment[data-value="favorites"] {
    font-size: 1.5rem; /* 3x bigger heart (0.5rem × 3) */
    line-height: 1;
    padding-top: 4px;
    padding-bottom: 4px;
    color: #E53E3E;
}

#userFilter .segment[data-value="favorites"].active {
    color: var(--text-primary);
}

/* Compact variant for user filters */
.segment-control.compact .segment[data-value="favorites"] {
    font-size: 1.4rem;
}

/* ============================================================================
   Story Card States
   ============================================================================ */

/* Favorited card - golden glow border */
.story-card.favorited {
    box-shadow: 
        0 0 0 2px rgba(218, 165, 32, 0.6),
        0 0 20px rgba(218, 165, 32, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.12);
}

.story-card.favorited:hover {
    box-shadow: 
        0 0 0 2px rgba(218, 165, 32, 0.8),
        0 0 30px rgba(218, 165, 32, 0.35),
        0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Read card indicator - subtle checkmark */
.story-card.read .card-image::before {
    content: '✓';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.75);
    color: #4CAF50;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Both favorited and read */
.story-card.favorited.read .card-image::before {
    left: 10px;
}

/* ============================================================================
   Favorite Button (Story Page)
   ============================================================================ */

.favorite-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.favorite-btn:hover {
    transform: scale(1.1);
}

.favorite-btn:active {
    transform: scale(0.9);
}

/* SVG Heart Icon */
.favorite-btn .heart-icon {
    width: 26px;
    height: 26px;
    stroke: var(--text-secondary);
    stroke-width: 2;
    fill: transparent;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.favorite-btn:hover .heart-icon {
    stroke: #E53E3E;
}

/* Active (favorited) state */
.favorite-btn.active .heart-icon {
    stroke: #E53E3E;
    fill: #E53E3E;
}

/* Pop animation on toggle */
@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.favorite-btn.just-toggled {
    animation: heartPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================================
   Library Button (Save for Offline)
   ============================================================================ */

.library-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.library-btn:hover {
    transform: scale(1.1);
}

.library-btn:active {
    transform: scale(0.9);
}

/* SVG Download Icon */
.library-btn .download-icon {
    width: 24px;
    height: 24px;
    stroke: var(--text-secondary);
    stroke-width: 2;
    fill: transparent;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.library-btn:hover .download-icon {
    stroke: var(--color-gold);
}

/* Active (in library) state */
.library-btn.in-library .download-icon {
    stroke: var(--color-gold);
    fill: rgba(201, 162, 39, 0.15);
}

/* Pop animation on toggle */
.library-btn.just-toggled {
    animation: heartPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tooltip on hover */
.library-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

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

/* Hide tooltip on mobile */
@media (max-width: 768px) {
    .library-btn::after {
        display: none;
    }
}

/* ============================================================================
   Read Status Button (Story Page)
   ============================================================================ */

.read-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    margin-left: auto;
}

.read-btn:hover {
    background: rgba(128, 128, 128, 0.1);
}

.read-btn:active {
    transform: scale(0.92);
}

.read-btn .read-icon {
    width: 22px;
    height: 22px;
    stroke: var(--text-muted);
    fill: none;
    transition: stroke 0.2s ease, fill 0.2s ease;
}

.read-btn .read-icon .check-mark {
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset 0.3s ease;
}

/* Read state */
.read-btn.is-read .read-icon {
    stroke: #4CAF50;
}

.read-btn.is-read .read-icon .check-mark {
    stroke-dashoffset: 0;
}

/* Pop animation when marked as read */
@keyframes readPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.read-btn.pop {
    animation: readPop 0.3s ease;
}

/* ============================================================================
   Share Button
   ============================================================================ */

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.share-btn:hover {
    background: rgba(128, 128, 128, 0.15);
    transform: scale(1.1);
}

.share-btn:active {
    transform: scale(0.92);
}

.share-btn .share-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    fill: none;
    transition: stroke 0.2s ease;
}

.share-btn:hover .share-icon {
    stroke: var(--color-gold);
}

/* ============================================================================
   Admin-Only & User-Only Elements
   ============================================================================ */

.admin-only {
    display: none;
}

.user-only {
    display: none;
}

/* Admin badge for image selection */
.admin-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: rgba(201, 162, 39, 0.9);
    color: #1A1A1A;
    border-radius: 4px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 10;
}

/* User's personal primary badge */
.user-primary-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    background: rgba(76, 175, 80, 0.9);
    color: #FFFFFF;
    border-radius: 4px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 10;
}

/* ============================================================================
   Responsive Auth
   ============================================================================ */

@media (max-width: 768px) {
    .auth-controls {
        margin-left: 4px;
    }
    
    .auth-btn {
        padding: 5px 10px;
        font-size: 0.6875rem;
    }
    
    .user-filters-row .segment {
        padding: 8px 10px;
        font-size: 0.6875rem;
    }
}

@media (max-width: 480px) {
    .auth-btn {
        padding: 4px 8px;
        font-size: 0.625rem;
    }
}

/* ============================================================================
   Loading Skeletons
   ============================================================================ */

/* Skeleton pulse animation */
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-pulse {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        var(--bg-secondary) 50%,
        var(--bg-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Dark mode skeleton */
[data-theme="dark"] .skeleton-pulse {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
}

/* Story Loading Skeleton */
.story-skeleton {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: calc(100vh - 60px);
}

.story-skeleton-image {
    flex: 0 0 50%;
    max-width: 50%;
    aspect-ratio: 3 / 4;
}

.story-skeleton-content {
    flex: 1;
    padding: var(--spacing-2xl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.story-skeleton-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.story-skeleton-title {
    height: 40px;
    width: 70%;
    border-radius: 8px;
}

.story-skeleton-ref {
    height: 20px;
    width: 40%;
    border-radius: 4px;
}

.story-skeleton-verse {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    background: var(--bg-hover);
    border-radius: 12px;
}

.story-skeleton-verse-text {
    height: 24px;
    width: 90%;
    border-radius: 4px;
}

.story-skeleton-verse-ref {
    height: 16px;
    width: 30%;
    border-radius: 4px;
    margin-top: var(--spacing-sm);
}

.story-skeleton-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    flex: 1;
}

.story-skeleton-line {
    height: 18px;
    border-radius: 4px;
}

.story-skeleton-line:nth-child(1) { width: 100%; }
.story-skeleton-line:nth-child(2) { width: 95%; }
.story-skeleton-line:nth-child(3) { width: 98%; }
.story-skeleton-line:nth-child(4) { width: 90%; }
.story-skeleton-line:nth-child(5) { width: 100%; }
.story-skeleton-line:nth-child(6) { width: 85%; }
.story-skeleton-line:nth-child(7) { width: 92%; }
.story-skeleton-line:nth-child(8) { width: 100%; }
.story-skeleton-line:nth-child(9) { width: 88%; }
.story-skeleton-line:nth-child(10) { width: 75%; }

/* Mobile story skeleton */
@media (max-width: 900px) {
    .story-skeleton {
        flex-direction: column;
        min-height: auto;
    }
    
    .story-skeleton-image {
        flex: none;
        max-width: 100%;
        width: 100%;
        aspect-ratio: 4 / 3;
    }
    
    .story-skeleton-content {
        padding: var(--spacing-lg);
    }
}

/* Home Grid Loading Skeleton */
.grid-skeleton {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
}

.grid-skeleton-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.grid-skeleton-image {
    aspect-ratio: 3 / 4;
    width: 100%;
}

.grid-skeleton-info {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.grid-skeleton-title {
    height: 20px;
    width: 80%;
    border-radius: 4px;
}

.grid-skeleton-meta {
    height: 14px;
    width: 60%;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .grid-skeleton {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
        padding: var(--spacing-md);
    }
}

/* Loading overlay for actions */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--bg-primary-rgb), 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progressive loading sentinel */
.load-more-sentinel {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    min-height: 100px;
}

.load-more-sentinel .loading-spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
    opacity: 0.6;
}