/* 
 * Premium Book Reader - CSS Design System
 * Features: Light, Sepia, and Dark Themes, responsive layout, glassmorphic UI, high-quality reading typography.
 */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&family=Outfit:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap');

:root {
    /* Barevná paleta - Útulná tmavá knihovna (Výchozí motiv šetrný pro oči) */
    --bg-primary: #150f0c;
    /* Hluboké teplé mahagonové dřevo */
    --bg-secondary: #1d1511;
    /* Bohatý vlašský ořech */
    --text-primary: #f6efe6;
    /* Teplý krémový papír / pergamen */
    --text-secondary: #b09e90;
    /* Jemný béžový dřevěný popel */
    --accent: #d97706;
    /* Teplé knihovní zlato / jantar */
    --accent-hover: #b45309;
    --border-color: rgba(217, 119, 6, 0.15);
    --glass-bg: rgba(29, 21, 17, 0.85);
    --glass-border: rgba(217, 119, 6, 0.08);
    --shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.5), 0 1px 5px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 25px 45px -15px rgba(217, 119, 6, 0.25);

    /* Typografie a velikosti */
    --font-ui: 'Outfit', sans-serif;
    --font-reading: 'Lora', serif;
    --font-title: 'Playfair Display', serif;

    /* Poloměry */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    /* Tranzice */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Motiv útulné tmavé knihovny (Mahagon) */
[data-theme="mahogany"] {
    --bg-primary: #150f0c;
    --bg-secondary: #1d1511;
    --text-primary: #f6efe6;
    --text-secondary: #b09e90;
    --accent: #d97706;
    --accent-hover: #b45309;
    --border-color: rgba(217, 119, 6, 0.15);
    --glass-bg: rgba(29, 21, 17, 0.85);
    --glass-border: rgba(217, 119, 6, 0.08);
    --shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.5), 0 1px 5px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 25px 45px -15px rgba(217, 119, 6, 0.25);
}

/* Světlé téma (Na čtení - teplý papír bez vypalování očí) */
[data-theme="light"] {
    --bg-primary: #FAF9F5;
    --bg-secondary: #FFFFFF;
    --text-primary: #1C2329;
    --text-secondary: #5C656E;
    --accent: #d97706;
    /* Kožená hněď / jantar */
    --accent-hover: #b45309;
    --border-color: rgba(0, 0, 0, 0.06);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 40px -15px rgba(217, 119, 6, 0.15);
}

/* Sépiové téma */
[data-theme="sepia"] {
    --bg-primary: #f3ecd0;
    --bg-secondary: #fdf6e2;
    --text-primary: #4a3c2d;
    --text-secondary: #857461;
    --accent: #b45309;
    --accent-hover: #92400e;
    --border-color: rgba(74, 60, 45, 0.08);
    --glass-bg: rgba(253, 246, 226, 0.85);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow: 0 10px 30px -10px rgba(74, 60, 45, 0.08);
    --shadow-hover: 0 20px 40px -15px rgba(180, 83, 9, 0.15);
}

/* Tmavé téma čtečky (Břidlicové) */
[data-theme="dark"] {
    --bg-primary: #0e1218;
    --bg-secondary: #161c24;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(22, 28, 36, 0.8);
    --glass-border: rgba(255, 255, 255, 0.05);
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 20px 40px -15px rgba(129, 140, 248, 0.25);
}

/* Reset a globální styly */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

input,
button,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

/* Tlačítka */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--accent);
    color: #ffffff !important;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color);
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: var(--border-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Navigace / Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-family: var(--font-title);
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-accent {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-weight: 500;
    color: var(--text-secondary);
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent);
}

/* Hlavní obsah - Knihovna */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* Sekce Rozčtené */
.currently-reading {
    margin-bottom: 48px;
    padding: 32px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 32px;
    align-items: center;
}

@media (max-width: 600px) {
    .currently-reading {
        grid-template-columns: 1fr;
        text-align: center;
        justify-items: center;
    }
}

.currently-reading img {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.currently-reading:hover img {
    transform: scale(1.03);
}

.currently-reading-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tag {
    align-self: flex-start;
    padding: 4px 12px;
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 600px) {
    .tag {
        align-self: center;
    }
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    margin: 12px 0 20px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent);
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

/* Vyhledávání a Filtry */
.search-filter-row {
    display: flex;
    gap: 16px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .search-filter-row {
        flex-direction: column;
    }
}

.search-wrapper {
    flex: 1;
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.search-input {
    width: 100%;
    padding: 16px 8px;
    background: transparent;
}

.filter-select {
    padding: 0 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    cursor: pointer;
    font-weight: 500;
}

/* Katalog Knih */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 32px;
}

.book-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(99, 102, 241, 0.2);
}

.book-card-cover {
    position: relative;
    aspect-ratio: 2/3;
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

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

.book-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.book-card-title {
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.book-card-author {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.book-card-genre {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    margin-top: auto;
}

/* Detail Knihy - book.php */
.book-detail-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 48px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .book-detail-container {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
}

.book-detail-cover {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 2/3;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.book-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-detail-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.book-detail-title {
    font-family: var(--font-title);
    font-size: 40px;
    font-weight: 800;
    line-height: 1.2;
}

.book-detail-author {
    font-size: 20px;
    color: var(--text-secondary);
    margin-top: -8px;
}

.book-detail-description {
    line-height: 1.7;
    color: var(--text-secondary);
    margin: 16px 0;
}

.chapters-section {
    margin-top: 40px;
}

.chapters-title {
    font-family: var(--font-title);
    font-size: 24px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.chapters-list {
    display: grid;
    gap: 12px;
}

.chapter-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.chapter-item:hover {
    border-color: var(--accent);
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.chapter-item-title {
    font-weight: 500;
}

/* Imersivní Čtečka - reader.php */
.reader-body {
    background-color: var(--bg-primary);
    overflow-y: scroll;
}

.reader-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.reader-header.hidden {
    transform: translateY(-64px);
}

.reader-back {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.reader-settings-panel {
    display: flex;
    align-items: center;
    gap: 16px;
}

.setting-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.setting-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Přepínače témat */
.theme-picker {
    display: flex;
    gap: 8px;
}

.theme-opt {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
}

.theme-opt.active {
    border-color: var(--accent);
}

.theme-opt-light {
    background-color: #fbfaf7;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.theme-opt-sepia {
    background-color: #f4edd9;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.theme-opt-mahogany {
    background-color: #150f0c;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.theme-opt-dark {
    background-color: #0b0f17;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Kontejner na text čtečky */
.reader-container {
    max-width: 680px;
    margin: 100px auto 120px auto;
    padding: 0 24px;
}

.reader-chapter-title {
    font-family: var(--font-title);
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 40px;
    text-align: center;
}

.reader-text {
    font-family: var(--font-reading);
    font-size: 20px;
    /* Možnost dynamické změny pomocí JS */
    line-height: 1.8;
    letter-spacing: 0.1px;
    color: var(--text-primary);
}

.reader-text p {
    margin-bottom: 1.2em;
    text-align: justify;
}

.reader-text img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
/* Navigační řádek dole ve čtečce */
.reader-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    transition: transform 0.3s ease;
}

.reader-footer.hidden {
    transform: translateY(64px);
}

/* Boční panel s kapitolami */
.drawer {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100vh;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    z-index: 200;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    left: 0;
}

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-family: var(--font-title);
    font-size: 20px;
    font-weight: 700;
}

.drawer-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
}

.drawer-chapter-link {
    display: block;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-weight: 500;
    transition: var(--transition);
}

.drawer-chapter-link:hover,
.drawer-chapter-link.active {
    background-color: rgba(99, 102, 241, 0.08);
    color: var(--accent);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Administrace - admin.php */
.admin-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* Upozornění / Notifikace */
.alert {
    padding: 16px 24px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-weight: 500;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* PWA offline banner */
.offline-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #ef4444;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
}

.offline-banner.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Skládané karty pro knižní série (3D stacked cover effect) */
.series-card-stack {
    position: relative;
    aspect-ratio: 2/3;
    width: 100%;
    margin-bottom: 16px;
}

.series-card-cover-1 {
    position: absolute;
    top: 14px;
    left: 14px;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
    z-index: 1;
    transform: rotate(-5deg);
    box-shadow: var(--shadow);
    border-radius: var(--radius-md);
    overflow: hidden;
    opacity: 0.4;
    transition: var(--transition);
}

.series-card-cover-2 {
    position: absolute;
    top: 7px;
    left: 7px;
    width: calc(100% - 14px);
    height: calc(100% - 14px);
    z-index: 2;
    transform: rotate(3deg);
    box-shadow: var(--shadow);
    border-radius: var(--radius-md);
    overflow: hidden;
    opacity: 0.7;
    transition: var(--transition);
}

.series-card-cover-main {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    box-shadow: var(--shadow);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.book-card:hover .series-card-cover-main {
    transform: scale(1.03) translateY(-4px);
}

.book-card:hover .series-card-cover-1 {
    transform: rotate(-8deg) translateX(-6px) translateY(2px);
    opacity: 0.5;
}

.book-card:hover .series-card-cover-2 {
    transform: rotate(5deg) translateX(4px) translateY(-2px);
    opacity: 0.8;
}

/* Horizontální záložky pro čtenářské seznamy */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    overflow-x: auto;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 10px 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.tab-btn.active {
    background-color: var(--accent);
    color: #ffffff !important;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.2);
}

/* Responzivní hlavička a navigace na mobilních zařízeních */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
        text-align: center;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        width: 100%;
    }

    .nav-links span {
        display: none;
        /* Skryje jméno uživatele na mobilu pro více místa */
    }
}

/* Svislá časová osa (Timeline) pro knižní série */
.timeline-item {
    display: flex;
    gap: 24px;
    position: relative;
    z-index: 2;
    align-items: start;
    width: 100%;
}

.timeline-node {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-top: 10px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    transition: var(--transition);
}

.timeline-cover {
    display: block;
    aspect-ratio: 2/3;
    width: 100px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.timeline-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.timeline-cover-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1d1511, #d97706);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 8px;
    text-align: center;
    font-family: var(--font-title);
    font-size: 11px;
    font-weight: 800;
}

.timeline-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 24px;
    align-items: start;
    transition: var(--transition);
    width: 100%;
}

.timeline-card:hover {
    border-color: rgba(217, 119, 6, 0.25);
    box-shadow: var(--shadow-hover);
}

.timeline-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 150px;
    height: 100%;
}

/* Mobilní responzivita časové osy */
@media (max-width: 600px) {
    .timeline-item {
        gap: 12px;
    }

    .timeline-card {
        grid-template-columns: 70px 1fr;
        gap: 16px;
        padding: 12px;
        min-height: 110px;
    }

    .timeline-cover {
        width: 70px;
    }

    .timeline-card h3 {
        font-size: 15px !important;
    }

    .timeline-card .tag {
        font-size: 10px !important;
        padding: 2px 8px !important;
    }

    .timeline-details p {
        font-size: 12px !important;
        margin-bottom: 6px !important;
    }

    .timeline-details .btn {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
}

/* Mobilní responzivita obsahu kapitol */
.chapter-item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chapter-item-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

@media (max-width: 600px) {
    .chapter-item {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }

    .chapter-item-right {
        justify-content: space-between;
        width: 100%;
        border-top: 1px solid var(--border-color);
        padding-top: 12px;
    }
}

/* Rozbalovací panel nastavení vzhledu ve čtečce (Popover) */
.reader-settings-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: dropdownFadeIn 0.2s ease-out;
}

.dropdown-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.dropdown-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .reader-settings-dropdown {
        position: fixed;
        top: 64px;
        left: 16px;
        right: 16px;
        width: auto;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    }
}

/* Mobilní 2-sloupcový katalog knih na index.php */
@media (max-width: 600px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .book-card {
        padding: 10px;
        border-radius: var(--radius-md);
    }

    .book-card-title {
        font-size: 14px !important;
    }

    .book-card-author {
        font-size: 12px !important;
    }

    .book-card-genre {
        font-size: 10px !important;
    }

    .series-card-stack {
        margin-bottom: 12px;
    }

    /* Snížit mezery v katalogu na mobilu */
    main {
        padding: 24px 16px;
    }
}

/* Skrytí kapitoly v hlavičce čtečky na tabletech a mobilech */
@media (max-width: 768px) {
    .reader-header-title {
        display: none;
    }
}

/* Paged Reading Mode (Stránkování) */
body.paged-mode {
    overflow: hidden;
}

body.paged-mode .reader-container {
    max-width: 680px;
    height: calc(100vh - 128px); /* Mezi hlavičkou (64px) a patičkou (64px) */
    margin: 64px auto 0 auto;
    padding: 0; /* Padding odebrán, řeší se přímo v odstavcích pro 100% spolehlivý scroll */
    overflow-y: hidden;
    overflow-x: hidden; /* Skryjeme posuvník, scrollování řeší JS přes scrollLeft */
}

body.paged-mode .reader-text {
    column-count: 1; /* Vynutíme přesně jeden sloupec na viditelnou obrazovku */
    column-gap: 0; /* Odstraníme mezeru, posun bude přesně o šířku obrazovky */
    height: 100%;
    margin-bottom: 0;
}

body.paged-mode .reader-text > * {
    /* Okraje se přidávají všem prvkům uvnitř sloupce */
    padding-left: 24px;
    padding-right: 24px;
}

body.paged-mode .reader-text > ul,
body.paged-mode .reader-text > ol {
    /* Udržíme odsazení seznamů */
    padding-left: 48px;
}

body.paged-mode .reader-text p {
    margin-bottom: 1.2em;
}

/* Zvýraznění aktivního režimu v nastavení */
.mode-opt.active {
    background-color: var(--accent);
    color: #ffffff !important;
    border-color: var(--accent);
}

/* Optimalizace stránkování a rozložení pro mobilní zařízení */
@media (max-width: 600px) {
    /* Obecný padding pro scroll-mode na mobilu */
    .reader-container {
        padding: 24px 16px;
        margin: 80px auto 80px auto;
    }

    /* Stránkovaný režim na mobilu - přidat horní/dolní padding */
    body.paged-mode .reader-container {
        padding: 16px 0;
        box-sizing: border-box;
    }

    body.paged-mode .reader-text > * {
        padding-left: 16px;
        padding-right: 16px;
    }
    body.paged-mode .reader-text > ul,
    body.paged-mode .reader-text > ol {
        padding-left: 40px;
    }
}

/* Globální přepínač témat v záhlaví */
.theme-btn {
    border: none;
    outline: none;
    background: none;
}
.theme-btn:hover {
    transform: scale(1.1);
}
.theme-btn.active {
    background-color: var(--accent);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
    transform: scale(1.1);
}

/* Animace spinneru a styly drag-and-drop zóny */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent) !important;
    background-color: rgba(217, 119, 6, 0.04) !important;
    box-shadow: var(--shadow-hover);
}

.dropzone:hover .dropzone-icon, .dropzone.dragover .dropzone-icon {
    transform: scale(1.15) translateY(-4px);
}

/* Statistiky čtení na domovské stránce */
.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-hover) !important;
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}