:root {
    /* Light Mode */
    --gold: #d4af37;
    --gold-dark: #b8960f;
    --bg-primary: #f5f0e8;
    --bg-secondary: #ffffff;
    --bg-book: #fdfbf7;
    --text-primary: #2c3e50;
    --text-secondary: #4a3728;
    --text-muted: #999;
    --border-color: #e8e0d0;
    --shadow: 0 10px 40px rgba(0,0,0,0.15);
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #ddd;
    --red: #c0392b;
    --green: #27ae60;
    --green-hover: #2ecc71;
    --purple: #8e44ad;
    --purple-hover: #9b59b6;
    --dark: #2c3e50;
    --dark-hover: #34495e;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-book: #1a1a2e;
    --text-primary: #e8e0d0;
    --text-secondary: #d4af37;
    --text-muted: #888;
    --border-color: #2a2a4a;
    --shadow: 0 10px 40px rgba(0,0,0,0.5);
    --card-bg: #1e2a4a;
    --input-bg: #2a2a4a;
    --input-border: #3a3a5a;
    --dark: #4a4a6a;
    --dark-hover: #5a5a7a;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    font-family: 'Crimson Pro', 'Segoe UI', serif;
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    color: var(--text-primary);
}

.app-container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================ */
/* HEADER */
/* ============================================================ */
.app-header {
    padding: 6px 15px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.app-header h1 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 4px 0 2px 0;
    font-family: 'Playfair Display', serif;
    text-align: center;
}

.app-header .subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin: 0 0 4px 0;
    text-align: center;
}

/* ============================================================ */
/* CONTROLS - KOMPAKT & MODERN */
/* ============================================================ */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.controls select,
.controls button {
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', sans-serif;
    white-space: nowrap;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.controls select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 5px 8px;
    min-width: 70px;
}

.controls select:focus {
    outline: none;
    border-color: var(--gold);
}

.btn-secondary {
    background: var(--gold);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--gold-dark);
    transform: translateY(-1px);
}

.btn-audio {
    background: var(--green);
    color: #fff;
}

.btn-audio:hover {
    background: var(--green-hover);
    transform: translateY(-1px);
}

.btn-audio-stop {
    background: #e74c3c;
    color: #fff;
}

.btn-audio-stop:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

#auto-page {
    background: var(--purple);
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

#auto-page:hover {
    background: var(--purple-hover);
    transform: translateY(-1px);
}

.btn-darkmode {
    background: var(--dark);
    color: #fff;
    font-size: 13px;
    padding: 5px 9px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-darkmode:hover {
    background: var(--dark-hover);
    transform: translateY(-1px);
}

/* ============================================================ */
/* SEARCH - KOMPAKT */
/* ============================================================ */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 3px;
}

#search-input {
    padding: 5px 28px 5px 10px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 11px;
    width: 80%;
    transition: all 0.3s ease;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: 'Crimson Pro', serif;
}

#search-input:focus {
    border-color: var(--gold);
    outline: none;
    width: 80%;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.btn-search {
    background: var(--gold);
    color: #fff;
    border: none;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.btn-search:hover {
    background: var(--gold-dark);
    transform: translateY(-1px);
}

.btn-search-clear {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 5px 7px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    position: absolute;
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
}

.btn-search-clear:hover {
    background: #c0392b;
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 12px;
    color: var(--text-primary);
}

.search-result-item:hover {
    background: rgba(212, 175, 55, 0.1);
}

.search-result-item .result-surah {
    font-weight: bold;
    color: var(--gold);
    font-size: 11px;
    display: block;
}

.search-result-item .result-verse {
    font-size: 12px;
    line-height: 1.3;
}

.search-result-item .result-verse b {
    background: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
    color: #000;
}

.search-no-results {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================================ */
/* BOOK */
/* ============================================================ */
.book-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    touch-action: pan-y;
}

.book {
    display: flex;
    height: 100%;
    background: var(--bg-book);
    box-shadow: var(--shadow);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.3s ease;
    will-change: transform;
    cursor: grab;
    position: relative;
}

.book:active {
    cursor: grabbing;
}

.page {
    flex: 1;
    padding: 25px 35px;
    overflow-y: auto;
    background: var(--bg-book);
    border-right: 1px solid var(--border-color);
    position: relative;
    transition: background 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.page.right {
    border-right: none;
}

/* Scrollbar Styling */
.page::-webkit-scrollbar {
    width: 4px;
}

.page::-webkit-scrollbar-track {
    background: transparent;
}

.page::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

/* ============================================================ */
/* SWIPE INDICATOR - SICHTBAR */
/* ============================================================ */
.swipe-indicator {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    font-family: 'Playfair Display', serif;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    color: var(--gold);
    text-shadow: 0 2px 20px rgba(212, 175, 55, 0.2);
}

.swipe-indicator.left {
    left: 12px;
}

.swipe-indicator.right {
    right: 12px;
}

.swipe-indicator.visible {
    opacity: 0.5;
    transform: translateY(-50%) scale(1);
}

.swipe-indicator.active {
    opacity: 0.9;
    transform: translateY(-50%) scale(1.3);
    color: var(--gold);
}

/* Swipe-Hinweis unten */
.swipe-hint {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
    font-family: 'Segoe UI', sans-serif;
    letter-spacing: 0.5px;
    background: rgba(0,0,0,0.05);
    padding: 3px 12px;
    border-radius: 12px;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.5s ease;
}

.swipe-hint .arrow {
    font-size: 13px;
}

[data-theme="dark"] .swipe-hint {
    background: rgba(255,255,255,0.05);
}

/* ============================================================ */
/* NAVIGATION - KOMPAKT */
/* ============================================================ */
.navigation {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.btn-main {
    background: var(--dark);
    color: white;
    border: none;
    padding: 6px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', sans-serif;
}

.btn-main:hover {
    background: var(--dark-hover);
    transform: translateY(-1px);
}

.btn-main:active {
    transform: scale(0.97);
}

/* ============================================================ */
/* RED MARKER */
/* ============================================================ */
.red-marker {
    position: absolute;
    top: 0;
    right: 30px;
    background: var(--red);
    color: white;
    padding: 5px 12px 14px 12px;
    font-size: 0.55rem;
    font-weight: bold;
    text-transform: uppercase;
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 85%, 0% 100%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
    letter-spacing: 0.5px;
}

/* ============================================================ */
/* SURAH TITLE */
/* ============================================================ */
.surah-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--gold);
    padding-bottom: 10px;
    transition: color 0.3s ease;
}

/* ============================================================ */
/* VERSES */
/* ============================================================ */
.verse {
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 14px;
    text-align: justify;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.v-num {
    color: var(--gold);
    font-weight: bold;
    margin-right: 8px;
    font-size: 0.85rem;
}

.verse-highlight {
    background-color: rgba(212, 175, 55, 0.15);
    border-left: 3px solid var(--gold);
    padding-left: 12px;
    margin-left: -12px;
    transition: background-color 0.3s ease;
    border-radius: 0 4px 4px 0;
}

/* ============================================================ */
/* PAGE FOOTER */
/* ============================================================ */
.page-footer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 12px 0 4px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 15px;
}

/* ============================================================ */
/* INSTALL BANNER */
/* ============================================================ */
#install-banner {
    display: none;
    text-align: center;
    padding: 6px 15px;
    background: var(--gold);
    color: white;
    cursor: pointer;
    border-radius: 8px;
    margin: 5px 20px;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s ease;
}

#install-banner:hover {
    background: var(--gold-dark);
    transform: scale(1.02);
}

/* ============================================================ */
/* AUDIO PLAYING PULSE */
/* ============================================================ */
.audio-playing {
    animation: pulse 1.5s infinite;
}

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

/* ============================================================ */
/* RESPONSIVE */
/* ============================================================ */
@media (max-width: 768px) {
    .page {
        padding: 18px;
    }
    
    .page.right {
        display: none;
    }
    
    .surah-title {
        font-size: 1.4rem;
        margin-bottom: 18px;
    }
    
    .verse {
        font-size: 0.88rem;
        line-height: 1.7;
    }
    
    .controls {
        padding: 4px 6px;
        gap: 4px;
    }
    
    .controls select,
    .controls button {
        padding: 4px 7px;
        font-size: 10px;
    }
    
    #search-input {
        width: 80%;
        font-size: 10px;
        padding: 4px 22px 4px 7px;
    }
    
    #search-input:focus {
        width: 80%;
    }
    
    .btn-search {
        padding: 4px 6px;
        font-size: 10px;
    }
    
    .btn-search-clear {
        padding: 4px 5px;
        font-size: 10px;
        right: 30px;
    }
    
    .swipe-indicator {
        font-size: 26px;
    }
    
    .swipe-indicator.left {
        left: 6px;
    }
    
    .swipe-indicator.right {
        right: 6px;
    }
    
    .swipe-hint {
        font-size: 9px;
        padding: 2px 10px;
        bottom: 10px;
    }
    
    .swipe-hint .arrow {
        font-size: 11px;
    }
    
    .red-marker {
        right: 18px;
        padding: 4px 8px 10px 8px;
        font-size: 0.45rem;
    }
    
    .btn-main {
        padding: 5px 14px;
        font-size: 11px;
    }
    
    .app-header h1 {
        font-size: 0.9rem;
    }
    
    .app-header .subtitle {
        font-size: 0.55rem;
    }
    
/* Suchcontainer in die nächste Zeile zwingen */
.controls .search-container {
    order: 2;
    flex-basis: 100%;  /* Nimmt die ganze Breite ein */
    margin-top: 3px;
}

/* Suchfeld innerhalb des Containers */
.controls .search-container #search-input {
    flex: 1;
    width: 100%;
    min-width: 100px;
}
}

@media (max-width: 480px) {
    .page {
        padding: 12px;
    }
    
    .controls select,
    .controls button {
        font-size: 9px;
        padding: 3px 5px;
    }
    
    #search-input {
        width: 80%;
        font-size: 9px;
        padding: 3px 18px 3px 6px;
    }
    
    #search-input:focus {
        width: 80%;
    }
    
    .btn-search {
        padding: 3px 5px;
        font-size: 9px;
    }
    
    .swipe-indicator {
        font-size: 20px;
    }
    
    .surah-title {
        font-size: 1.2rem;
    }
    
    .verse {
        font-size: 0.82rem;
    }
    
    /* Suchcontainer in die nächste Zeile zwingen */
.controls .search-container {
    order: 2;
    flex-basis: 100%;  /* Nimmt die ganze Breite ein */
    margin-top: 3px;
}

/* Suchfeld innerhalb des Containers */
.controls .search-container #search-input {
    flex: 1;
    width: 100%;
    min-width: 100px;
}
}


/* ============================================================ */
/* SUREN-BUTTON                                                  */
/* ============================================================ */
.btn-surah {
    background: var(--gold);
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', sans-serif;
}

.btn-surah:hover {
    background: var(--gold-dark);
    transform: translateY(-1px);
}

/* Suren-Liste Einträge */
.surah-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 4px;
}

.surah-list-item:hover {
    background: rgba(212, 175, 55, 0.1);
}

.surah-list-item .surah-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.surah-list-item .surah-id {
    color: var(--gold);
    font-weight: bold;
    font-size: 12px;
    background: rgba(212, 175, 55, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.surah-list-item .surah-verses {
    color: var(--text-muted);
    font-size: 11px;
}

/* Filter-Input Fokus */
#surah-filter:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

/* Popup Overlay Animation */
#surah-popup-overlay {
    animation: fadeIn 0.25s ease;
}

#surah-popup {
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

/* Mobile Anpassungen */
@media (max-width: 768px) {
    .btn-surah {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    #surah-popup {
        width: 95%;
        max-height: 85vh;
    }
    
    .surah-list-item {
        padding: 6px 10px;
    }
    
    .surah-list-item .surah-name {
        font-size: 13px;
    }
}

/* ============================================================ */
/* TOAST-NACHRICHTEN                                            */
/* ============================================================ */
.toast-message {
    font-family: 'Segoe UI', sans-serif;
}

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

/* ============================================================ */
/* VERBESSERTE SUREN-LISTE                                      */
/* ============================================================ */
.surah-list-item .surah-verses {
    color: var(--text-muted);
    font-size: 11px;
    background: rgba(0,0,0,0.05);
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

[data-theme="dark"] .surah-list-item .surah-verses {
    background: rgba(255,255,255,0.05);
}

.surah-list-item .surah-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
}

/* Filter-Eingaben im Popup */
#surah-filter, #verse-filter {
    transition: all 0.3s ease;
}

#surah-filter:focus, #verse-filter:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

#goto-verse-btn:hover {
    background: var(--gold-dark);
    transform: translateY(-1px);
}

/* Vers-Nummer Anzeige in der Liste */
.surah-list-item .verse-indicator {
    color: var(--gold);
    font-size: 11px;
    font-weight: bold;
}

/* Mobile Anpassungen */
@media (max-width: 480px) {
    #surah-filter, #verse-filter {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    #goto-verse-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .surah-list-item .surah-verses {
        font-size: 10px;
        padding: 1px 8px;
    }
}

/* ============================================================ */
/* SCHRIFTGRÖSSE-CONTROLS                                      */
/* ============================================================ */
.font-size-controls {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 2px 4px;
    border: 1px solid var(--border-color);
}

.btn-font {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', sans-serif;
    line-height: 1;
}

.btn-font:hover {
    background: rgba(212, 175, 55, 0.2);
    transform: scale(1.1);
}

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

.font-size-display {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 36px;
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
}

/* Schriftgrößen-Klassen für Verse */
.font-size-xs .verse { font-size: 0.75rem; }
.font-size-sm .verse { font-size: 0.85rem; }
.font-size-md .verse { font-size: 0.95rem; }
.font-size-lg .verse { font-size: 1.1rem; }
.font-size-xl .verse { font-size: 1.25rem; }
.font-size-xxl .verse { font-size: 1.4rem; }

/* Auch die Suren-Titel anpassen */
.font-size-xs .surah-title { font-size: 1.4rem; }
.font-size-sm .surah-title { font-size: 1.6rem; }
.font-size-md .surah-title { font-size: 1.8rem; }
.font-size-lg .surah-title { font-size: 2.0rem; }
.font-size-xl .surah-title { font-size: 2.2rem; }
.font-size-xxl .surah-title { font-size: 2.5rem; }

/* Responsive Anpassungen */
@media (max-width: 768px) {
    .font-size-controls {
        padding: 1px 3px;
    }
    .btn-font {
        font-size: 11px;
        padding: 1px 4px;
    }
    .font-size-display {
        font-size: 9px;
        min-width: 28px;
    }
    
    .font-size-xs .verse { font-size: 0.7rem; }
    .font-size-sm .verse { font-size: 0.78rem; }
    .font-size-md .verse { font-size: 0.88rem; }
    .font-size-lg .verse { font-size: 1.0rem; }
    .font-size-xl .verse { font-size: 1.1rem; }
    .font-size-xxl .verse { font-size: 1.2rem; }
    
    .font-size-xs .surah-title { font-size: 1.1rem; }
    .font-size-sm .surah-title { font-size: 1.3rem; }
    .font-size-md .surah-title { font-size: 1.4rem; }
    .font-size-lg .surah-title { font-size: 1.6rem; }
    .font-size-xl .surah-title { font-size: 1.8rem; }
    .font-size-xxl .surah-title { font-size: 2.0rem; }
}