/* ============================================================================
   BIBLIOTHEK - Professionelle Bibliothek-Seite (Clean Version v2)
   ============================================================================ */

/* Variables */
:root {
    --bibliothek-primary: #667eea;
    --bibliothek-secondary: #764ba2;
    --bibliothek-accent: #f093fb;
    --bibliothek-bg: #f5f5f7;
    --bibliothek-card-bg: #ffffff;
    --bibliothek-text: #1d1d1f;
    --bibliothek-text-secondary: #86868b;
    --bibliothek-border: #d2d2d7;
    --bibliothek-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --bibliothek-shadow-hover: 0 10px 20px rgba(0, 0, 0, 0.1);
    --bibliothek-radius: 12px;
    --rating-star-color: #ffa41c;
    --rating-star-empty: #ddd;
}

html.dark-mode,
body.dark-mode {
    --bibliothek-bg: #000000;
    --bibliothek-card-bg: #2a2a2a;
    --bibliothek-text: #f5f5f7;
    --bibliothek-text-secondary: #a1a1a6;
    --bibliothek-border: #424245;
    --bibliothek-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --bibliothek-shadow-hover: 0 10px 20px rgba(0, 0, 0, 0.5);
    --rating-star-empty: #555;
}

/* Mobil: bis unter fixe Leisten; Hintergrund wie Hauptfläche (sonst Global-Gradient von reset.css als „Streifen“ unten) */
body.bibliothek-page {
    --bibliothek-mobile-chrome-top: 0px;
    /* Filter-Overlay unter Header/Credits (Desktop wie Mobil) */
    --bibliothek-drawer-top: calc(56px + max(12px, env(safe-area-inset-top, 0px)) + 52px);
    /* Panels (Hero, Filter, Karten): weicher Bibliotheks-/Violett-Stil wie SI/Arena-Infoflächen */
    --bib-panel-bg: radial-gradient(115% 78% at 50% -20%, rgba(102, 126, 234, 0.14) 0%, transparent 55%), linear-gradient(168deg, #faf9ff 0%, #f2effa 28%, #e9e3f6 52%, #f3f0fc 100%);
    --bib-panel-border: rgba(102, 126, 234, 0.32);
    --bib-panel-shadow: 0 4px 24px rgba(102, 126, 234, 0.13);
    --bib-filter-field-bg: rgba(255, 255, 255, 0.78);
    --bib-cover-matte: linear-gradient(145deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.08) 100%);
    background: var(--bibliothek-bg) !important;
    min-height: 100vh;
}
html.dark-mode body.bibliothek-page,
body.dark-mode.bibliothek-page {
    --bib-panel-bg: radial-gradient(95% 55% at 50% 0%, rgba(102, 126, 234, 0.11) 0%, transparent 52%), radial-gradient(52% 42% at 100% 100%, rgba(118, 75, 162, 0.09) 0%, transparent 48%), linear-gradient(168deg, #06050f 0%, #090818 24%, #0c0a1e 48%, #080716 72%, #03030a 100%);
    --bib-panel-border: rgba(255, 255, 255, 0.12);
    --bib-panel-shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
    --bib-filter-field-bg: rgba(0, 0, 0, 0.28);
    --bib-cover-matte: linear-gradient(145deg, rgba(40, 35, 65, 0.5) 0%, rgba(20, 18, 35, 0.65) 100%);
    --bibliothek-bg: #000000;
    background: var(--bibliothek-bg) !important;
}

/* Base Layout */
.bibliothek-main {
    display: flex;
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
    background: var(--bibliothek-bg);
    padding-top: 80px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Touch-Scrolling für mobile Geräte aktivieren */
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: auto !important;
    /* Scrollbar Styles */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(102, 126, 234, 0.5) rgba(0, 0, 0, 0.05); /* Firefox */
}

/* Scrollbar Styles für Webkit-Browser (Chrome, Safari, Edge) */
.bibliothek-main::-webkit-scrollbar {
    width: 12px;
}

.bibliothek-main::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.bibliothek-main::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 6px;
}

.bibliothek-main::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* Dark Mode: Scrollbar Styles für bibliothek-main */
body.dark-mode .bibliothek-main,
html.dark-mode .bibliothek-main {
    scrollbar-color: rgba(102, 126, 234, 0.6) rgba(0, 0, 0, 0.3); /* Firefox - dunklerer Track */
}

body.dark-mode .bibliothek-main::-webkit-scrollbar-track,
html.dark-mode .bibliothek-main::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3); /* Dunklerer Track im Dark Mode */
    border-radius: 6px;
}

body.dark-mode .bibliothek-main::-webkit-scrollbar-thumb,
html.dark-mode .bibliothek-main::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.6); /* Hellerer Thumb im Dark Mode */
    border-radius: 6px;
}

body.dark-mode .bibliothek-main::-webkit-scrollbar-thumb:hover,
html.dark-mode .bibliothek-main::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8); /* Hellerer Thumb beim Hover im Dark Mode */
}

.bibliothek-content {
    flex: 1;
    padding: 20px 40px;
    width: 100%;
    max-width: 1600px; /* Begrenzung für sehr große Bildschirme */
    margin: 0 auto;
}

/* Willkommens-Banner: oben im Inhaltsbereich, breit, niedrig (≥769px); Mobil überschreibt unten */
.bibliothek-hero {
    width: 100%;
    margin: 0 0 14px 0;
    padding: 8px 16px 10px;
    box-sizing: border-box;
    background: var(--bib-panel-bg, var(--bibliothek-card-bg));
    border: 1px solid var(--bib-panel-border, var(--bibliothek-border));
    border-radius: 12px;
    box-shadow: var(--bib-panel-shadow, var(--bibliothek-shadow));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    text-align: left;
}

.bibliothek-hero h1 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.02em;
    color: var(--bibliothek-text);
    line-height: 1.25;
}

.bibliothek-hero h1 .hero-title-icon {
    margin-right: 0.28em;
    font-size: 1.08em;
    vertical-align: -0.05em;
}

.bibliothek-hero p {
    font-size: 0.88rem;
    line-height: 1.32;
    color: var(--bibliothek-text-secondary);
    margin: 0;
    flex: 1 1 200px;
}

/* Sidebar: Schublade wie Mobil – öffnen mit „🔍 Filter“, schließen mit „✕“ */
.bibliothek-sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: var(--bibliothek-drawer-top);
    z-index: 100;
    width: min(250px, 92vw);
    max-width: min(250px, 92vw);
    height: calc(100vh - var(--bibliothek-drawer-top));
    max-height: calc(100vh - var(--bibliothek-drawer-top));
    box-sizing: border-box;
    background: var(--bib-panel-bg, var(--bibliothek-card-bg));
    border-right: none;
    border-bottom: 1px solid var(--bib-panel-border, var(--bibliothek-border));
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
    /* Scrollbar Styles */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(102, 126, 234, 0.5) rgba(0, 0, 0, 0.05); /* Firefox */
}

body.bibliothek-page .bibliothek-sidebar.open {
    display: block;
}

/* Desktop: abgerundete Kante rechts (Breite kommt aus Basisregel) */
@media (min-width: 769px) {
    .bibliothek-sidebar {
        border-radius: 0 12px 12px 0;
        border-bottom: none;
        border-right: 1px solid var(--bib-panel-border, var(--bibliothek-border));
        box-shadow: var(--bib-panel-shadow, var(--bibliothek-shadow));
        background: var(--bib-panel-bg, var(--bibliothek-card-bg));
    }
}

/* Scrollbar Styles für Webkit-Browser (Chrome, Safari, Edge) */
.bibliothek-sidebar::-webkit-scrollbar {
    width: 12px;
}

.bibliothek-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.bibliothek-sidebar::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 6px;
}

.bibliothek-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* Dark Mode: Scrollbar Styles für Sidebar */
body.dark-mode .bibliothek-sidebar,
html.dark-mode .bibliothek-sidebar {
    scrollbar-color: rgba(102, 126, 234, 0.6) rgba(0, 0, 0, 0.3); /* Firefox - dunklerer Track */
}

body.dark-mode .bibliothek-sidebar::-webkit-scrollbar-track,
html.dark-mode .bibliothek-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3); /* Dunklerer Track im Dark Mode */
    border-radius: 6px;
}

body.dark-mode .bibliothek-sidebar::-webkit-scrollbar-thumb,
html.dark-mode .bibliothek-sidebar::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.6); /* Hellerer Thumb im Dark Mode */
    border-radius: 6px;
}

body.dark-mode .bibliothek-sidebar::-webkit-scrollbar-thumb:hover,
html.dark-mode .bibliothek-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8); /* Hellerer Thumb beim Hover im Dark Mode */
}

/* Filter Styles */
.filter-section {
    margin-bottom: 24px;
}

.filter-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--bibliothek-text-secondary);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.filter-input, .filter-select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--bibliothek-border);
    border-radius: 8px;
    background: var(--bibliothek-bg);
    color: var(--bibliothek-text);
    font-family: inherit;
    box-sizing: border-box;
}

body.bibliothek-page .filter-input,
body.bibliothek-page .filter-select {
    background: var(--bib-filter-field-bg, var(--bibliothek-bg));
    border-color: var(--bib-panel-border, var(--bibliothek-border));
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 14px;
    color: var(--bibliothek-text);
}

.filter-checkbox input[type="checkbox"] {
    accent-color: var(--bibliothek-primary);
    width: 16px;
    height: 16px;
}

.filter-reset {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--bibliothek-border);
    border-radius: 8px;
    color: var(--bibliothek-text);
    cursor: pointer;
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 50px;
}

.filter-reset:hover {
    background: var(--bibliothek-bg);
    border-color: var(--bibliothek-text-secondary);
}

.filter-more-btn {
    background: none;
    border: none;
    color: var(--bibliothek-primary);
    font-size: 13px;
    cursor: pointer;
    padding: 5px 0;
    margin-top: 5px;
}

/* Toolbar Elements */
.filter-toggle {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: transparent;
    color: var(--bibliothek-text);
    border: 1px solid var(--bibliothek-border);
    border-radius: 8px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

.filter-toggle:hover {
    background: var(--bibliothek-bg);
}

/* Filter-Button wie Hero/Filter-Sidebar (Panel-Stil) */
body.bibliothek-page .filter-toggle {
    background: var(--bib-panel-bg, var(--bibliothek-card-bg));
    border-color: var(--bib-panel-border, var(--bibliothek-border));
    color: var(--bibliothek-text);
    box-shadow: var(--bib-panel-shadow, var(--bibliothek-shadow));
}

body.bibliothek-page .filter-toggle:hover {
    filter: brightness(0.97);
    border-color: var(--bibliothek-primary);
}

.toolbar-info {
    font-size: 14px;
    color: var(--bibliothek-text-secondary);
    font-weight: 600;
}

.view-toggle {
    display: flex;
    gap: 8px;
}

.view-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--bibliothek-border);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bibliothek-text);
}

.view-btn:hover {
    background: var(--bibliothek-bg);
}

.view-btn.active {
    background: var(--bibliothek-text);
    color: var(--bibliothek-card-bg);
    border-color: var(--bibliothek-text);
}

/* Sidebar Close (sichtbar wenn Filter-Schublade offen) */
.sidebar-close {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--bibliothek-text);
    position: absolute;
    top: 15px;
    right: 15px;
}

/* GRID LAYOUT - Kompakt & 3 Spalten auf Mobile */
.bibliothek-grid {
    display: grid;
    /* 30% kleiner auf Desktop (140px Basis) */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
    padding: 10px 0 40px 0;
}

/* BOOK CARD - Grid View */
.bibliothek-book-card {
    background: var(--bib-panel-bg, var(--bibliothek-card-bg));
    border-radius: var(--bibliothek-radius);
    box-shadow: var(--bib-panel-shadow, var(--bibliothek-shadow));
    border: 1px solid var(--bib-panel-border, var(--bibliothek-border));
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
    max-width: 240px; /* Kompakter */
    margin: 0 auto;
    width: 100%;
}

.bibliothek-book-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--bibliothek-shadow-hover);
}

/* 1. Das Bild (3:4 Format) */
.book-cover-container {
    position: relative;
    width: 100%;
    padding-top: 133.33%; /* 3:4 Aspect Ratio (4/3 = 1.333) */
    overflow: hidden;
    background: var(--bib-cover-matte, #eee);
}

.book-cover-container img,
.book-cover-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.bibliothek-book-card:hover .book-cover-container img {
    transform: scale(1.05);
}

/* Overlay Titel (oben im Bild) - Optimierte Lesbarkeit */
.book-title-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 6px 30px 6px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 50%, rgba(0,0,0,0) 100%);
    color: white !important; /* Erzwinge Weiß */
    text-align: center;
    z-index: 2;
    pointer-events: none;
}

.book-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 800; /* Extra Fett */
    margin: 0;
    color: white !important; /* Erzwinge Weiß */
    text-shadow: 0 1px 3px rgba(0,0,0,1); /* Harter schwarzer Schatten für Kontrast */
    line-height: 1.2;
    letter-spacing: 0.3px;
    -webkit-font-smoothing: antialiased; /* Schärferes Rendering in Webkit */
    -moz-osx-font-smoothing: grayscale; /* Schärferes Rendering in Firefox Mac */
}

/* Badges */
.book-badges-container {
    position: absolute;
    top: 6px; /* Etwas höher */
    right: 6px;
    z-index: 3;
}

.book-badge {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 3px 6px;
    border-radius: 8px;
    font-size: 10px;
}

/* Favoriten-Button */
.book-favorite-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: transparent;
    border: none;
    border-radius: 0;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 28px;
    z-index: 4;
    transition: transform 0.2s ease;
    box-shadow: none;
    padding: 0;
    line-height: 1;
}

.book-favorite-btn:hover {
    background: transparent;
    transform: scale(1.2);
    box-shadow: none;
}

.book-favorite-btn.favorite {
    background: transparent;
    border: none;
    color: #ffd700;
}

.book-favorite-btn.favorite:hover {
    background: transparent;
    transform: scale(1.3);
}

/* Dark Mode: Favoriten-Button */
body.dark-mode .book-favorite-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .book-favorite-btn:hover {
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
}

body.dark-mode .book-favorite-btn.favorite {
    background: transparent;
    border: none;
    color: #ffd700;
}

body.dark-mode .book-favorite-btn.favorite:hover {
    background: transparent;
    color: #ffed4e;
}

/* 2. Info Bereich (unter dem Bild) - Kompakt */
.book-info-area {
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.book-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--bibliothek-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.book-rating {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.stars {
    color: var(--rating-star-empty);
    font-size: 11px;
    position: relative;
    display: inline-block;
    letter-spacing: 1px;
}

.stars-fill {
    color: var(--rating-star-color);
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
}

.rating-count {
    font-size: 10px;
    color: var(--bibliothek-text-secondary);
}

/* WICHTIG: Listen-Infos im Grid ausblenden! */
.book-list-details {
    display: none !important;
}

/* ============================================================================
   LISTENANSICHT (TABELLE)
   ============================================================================ */

.bibliothek-grid.list-view {
    display: block; /* Kein Grid mehr */
    grid-template-columns: none;
    gap: 0;
}

.bibliothek-table-container {
    background: var(--bibliothek-card-bg);
    border-radius: var(--bibliothek-radius);
    box-shadow: var(--bibliothek-shadow);
    overflow-x: auto;
    width: 100%;
}

.bibliothek-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.bibliothek-table th {
    text-align: left;
    padding: 16px;
    border-bottom: 1px solid var(--bibliothek-border);
    color: var(--bibliothek-text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    background: var(--bibliothek-bg);
}

.bibliothek-table td {
    padding: 16px;
    border-bottom: 1px solid var(--bibliothek-border);
    color: var(--bibliothek-text);
    font-size: 14px;
    vertical-align: middle;
}

.bibliothek-table tr:last-child td {
    border-bottom: none;
}

.bibliothek-table tr:hover {
    background-color: rgba(0,0,0,0.02);
}

/* Zellen-Styles */
.cell-title { font-weight: 600; }
.cell-author { color: var(--bibliothek-primary); }
.cell-rating { white-space: nowrap; }
.cell-rating .stars { font-size: 12px; letter-spacing: 1px; }

/* ============================================================================
   DESKTOP: Filterspalte, Toggle bündig mit Sidebar, Grid begrenzt & zentriert
   ============================================================================ */
@media (min-width: 769px) {
    body.bibliothek-page {
        --bib-filter-gutter: min(250px, 92vw);
        --bib-filter-inner-pad: 20px;
        --bib-filter-content-pad-left: 40px;
    }

    body.bibliothek-page .bibliothek-content {
        padding: 20px 40px 20px calc(var(--bib-filter-gutter) + var(--bib-filter-content-pad-left));
        box-sizing: border-box;
    }

    body.bibliothek-page .bibliothek-toolbar {
        margin-left: calc(var(--bib-filter-inner-pad) - var(--bib-filter-gutter) - var(--bib-filter-content-pad-left));
        width: calc(100% + var(--bib-filter-gutter) + var(--bib-filter-content-pad-left) - var(--bib-filter-inner-pad));
        max-width: none;
        box-sizing: border-box;
    }

    body.bibliothek-page .bibliothek-grid,
    body.bibliothek-page .bibliothek-pagination {
        max-width: min(1200px, 100%);
        margin-left: auto;
        margin-right: auto;
        width: 100%;
        box-sizing: border-box;
    }

    /* Willkommens-Karte: optisch näher zur Bildschirmmitte (Inhaltsbereich ist durch Filter-Gutter nach rechts versetzt) */
    body.bibliothek-page .bibliothek-hero {
        width: 100%;
        max-width: 520px;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 22px;
        padding: 14px 18px;
        border-radius: 14px;
        border: 1px solid var(--bib-panel-border, var(--bibliothek-border));
        box-shadow: var(--bib-panel-shadow, var(--bibliothek-shadow));
        background: var(--bib-panel-bg, var(--bibliothek-card-bg));
        display: block;
        flex-wrap: unset;
        align-items: unset;
        gap: unset;
        text-align: center;
        box-sizing: border-box;
        transform: translateX(calc(-0.42 * (min(250px, 92vw) + 40px)));
    }

    body.bibliothek-page .bibliothek-hero h1 {
        font-size: 1.4rem;
        font-weight: 800;
        margin-bottom: 4px;
        letter-spacing: 0.02em;
        color: var(--bibliothek-text);
    }

    body.bibliothek-page .bibliothek-hero h1 .hero-title-icon {
        margin-right: 0.3em;
        font-size: 1.15em;
        vertical-align: -0.06em;
    }

    body.bibliothek-page .bibliothek-hero p {
        font-size: 1rem;
        line-height: 1.45;
        color: var(--bibliothek-text-secondary);
        max-width: 100%;
        margin: 0;
        flex: unset;
        min-width: unset;
    }

    html.dark-mode body.bibliothek-page .bibliothek-hero,
    body.dark-mode.bibliothek-page .bibliothek-hero {
        background: var(--bib-panel-bg);
        border-color: var(--bib-panel-border);
        box-shadow: var(--bib-panel-shadow);
    }
}

/* ============================================================================
   MOBILE ANPASSUNGEN
   ============================================================================ */
@media (max-width: 768px) {
    /* Tablet: vertikaler Scroll-Indikator rechts; Abstand bis unter Header + Credits-Zeile (menueband.js) */
    body.bibliothek-page {
        --bibliothek-mobile-chrome-top: calc(56px + max(12px, env(safe-area-inset-top, 0px)) + 52px);
        --bibliothek-drawer-top: var(--bibliothek-mobile-chrome-top);
    }

    .bibliothek-sidebar {
        border-radius: 0;
        border-right: none;
    }

    body.bibliothek-page .bibliothek-toolbar {
        margin-left: 0;
        width: 100%;
        max-width: none;
    }

    body.bibliothek-page .bibliothek-grid,
    body.bibliothek-page .bibliothek-pagination {
        max-width: none;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    body.bibliothek-page .bibliothek-main {
        padding-top: var(--bibliothek-mobile-chrome-top);
        flex-direction: column;
        min-height: 100vh;
        height: 100vh;
        max-height: 100vh;
        box-sizing: border-box;
    }

    .toolbar-info {
        display: none; /* Platz sparen */
    }

    .bibliothek-content {
        padding: 8px 10px 10px;
    }

    .bibliothek-hero {
        display: block;
        width: 100%;
        max-width: 520px;
        margin: 0 auto 12px;
        padding: 12px 14px;
        text-align: center;
        background: var(--bib-panel-bg, var(--bibliothek-card-bg));
        border: 1px solid var(--bib-panel-border, var(--bibliothek-border));
        border-radius: 14px;
        box-shadow: var(--bib-panel-shadow, var(--bibliothek-shadow));
        flex-wrap: unset;
        align-items: unset;
        gap: unset;
    }

    .bibliothek-hero h1 {
        font-size: 1.25rem;
        font-weight: 800;
        margin-bottom: 6px;
        letter-spacing: 0.02em;
        color: var(--bibliothek-text);
    }

    .bibliothek-hero h1 .hero-title-icon {
        margin-right: 0.3em;
        font-size: 1.12em;
        vertical-align: -0.06em;
    }

    .bibliothek-hero p {
        font-size: 0.95rem;
        line-height: 1.45;
        color: var(--bibliothek-text-secondary);
        margin: 0;
        flex: unset;
        min-width: unset;
    }

    .bibliothek-grid {
        /* Mobile: 3 Spalten möglich machen */
        /* minmax 90px erlaubt 3 Spalten auch auf kleinen Screens (320px - Padding) */
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px; /* Enger Gap für mehr Platz */
    }

    .book-title {
        font-size: 12px; /* Kleiner auf Mobile */
        line-height: 1.1;
    }
    
    .book-author {
        font-size: 11px;
    }
    
    .book-info-area {
        padding: 6px 4px;
    }
}

/* Schmale Phones: horizontale Scroll-Leiste wie Arena/Schatzinsel (14px + 56px), keine Doppelzählung */
@media (max-width: 480px) {
    /* Wie Schatzinsel: horizontale Scroll-Leiste + Credits-Zeile darunter (menueband.js); +36px = Höhe Credits-Zeile */
    body.bibliothek-page {
        --bibliothek-mobile-chrome-top: calc(56px + max(12px, env(safe-area-inset-top, 0px)) + 14px + 56px + 36px);
        --bibliothek-drawer-top: var(--bibliothek-mobile-chrome-top);
    }

    .bibliothek-content {
        padding: 6px 8px 10px;
    }

    .bibliothek-hero {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    .bibliothek-hero h1 {
        font-size: 1.1rem;
        margin-bottom: 4px;
    }

    .bibliothek-hero p {
        font-size: 0.88rem;
        line-height: 1.42;
    }
}

/* Toolbar (Filter, Sortierung) */
.bibliothek-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

/* Scroll Indicator Fix */
#scrollIndicatorContainer .scroll-indicator {
    position: fixed;
    right: 32.8px; /* 12.8px + 20px Padding rechts für größere Ansichten */
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
}

/* Kindermodus: Orange Hintergrund mit 50% Transparenz für Scroll-Indikator - NUR Farben ändern, keine Layout-Änderungen */
body.kids-mode-active .scroll-indicator,
html.kids-mode-active .scroll-indicator,
body.kids-mode-active #scrollIndicatorContainer .scroll-indicator,
html.kids-mode-active #scrollIndicatorContainer .scroll-indicator,
body.kids-mode-active.dark-mode .scroll-indicator,
html.kids-mode-active.dark-mode .scroll-indicator,
body.kids-mode-active.dark-mode #scrollIndicatorContainer .scroll-indicator,
html.kids-mode-active.dark-mode #scrollIndicatorContainer .scroll-indicator {
    background: linear-gradient(135deg, rgba(var(--kids-mode-primary-rgb), 0.5) 0%, rgba(var(--kids-mode-secondary-rgb), 0.5) 50%, rgba(var(--kids-mode-primary-rgb), 0.5) 100%) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-color: rgba(var(--kids-mode-primary-rgb), 0.9) !important;
    box-shadow: 0 8px 24px rgba(var(--kids-mode-primary-rgb), 0.5), 0 4px 12px rgba(var(--kids-mode-secondary-rgb), 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 30px rgba(var(--kids-mode-primary-rgb), 0.2) !important;
}

/* Dark Mode: Scroll Indicator */
body.dark-mode .scroll-indicator,
html.dark-mode .scroll-indicator,
body.dark-mode #scrollIndicatorContainer .scroll-indicator,
html.dark-mode #scrollIndicatorContainer .scroll-indicator {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.6) 0%, rgba(102, 126, 234, 0.6) 100%) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1), inset 0 0 100px rgba(0,0,0,0.3) !important;
}

body.dark-mode .scroll-indicator button,
body.dark-mode .scroll-indicator .scroll-indicator-item,
html.dark-mode .scroll-indicator button,
html.dark-mode .scroll-indicator .scroll-indicator-item,
body.dark-mode #scrollIndicatorContainer .scroll-indicator button,
body.dark-mode #scrollIndicatorContainer .scroll-indicator .scroll-indicator-item,
html.dark-mode #scrollIndicatorContainer .scroll-indicator button,
html.dark-mode #scrollIndicatorContainer .scroll-indicator .scroll-indicator-item {
    color: #ffffff !important;
}

/* Seiten-Footer auf der Bibliothek nicht anzeigen (falls vorhanden / nachgeladen) */
body.bibliothek-page > footer,
body.bibliothek-page footer.footer {
    display: none !important;
}
