:root {
    --paper-color: #fdfbf7;
    --ink-color: #2c2c2c;
    --highlight-color: rgba(255, 235, 59, 0.4);
    --accent-color: #8b4513;
    --toolbar-bg: #e8e4dc;
    --bg-color: #dcd8d0;
    --bg-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23b8b4aa' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-book: 0 10px 20px rgba(0, 0, 0, 0.15), 0 6px 6px rgba(0, 0, 0, 0.1);
    --empty-state-color: #666;
}

body.dark-theme {
    --ink-color: #e0e0e0;
    --highlight-color: rgba(255, 193, 7, 0.3);
    --accent-color: #d4a574;
    --toolbar-bg: #363636;
    --bg-color: #292626;
    --bg-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23333333' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-book: 0 10px 20px rgba(0, 0, 0, 0.5), 0 6px 6px rgba(0, 0, 0, 0.3);
    --empty-state-color: #999;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Crimson Text', serif;
    background-color: var(--bg-color);
    background-image: var(--bg-pattern);
    color: var(--ink-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.toolbar {
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid #d4d0c8;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
    z-index: 999;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
}

.controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.button {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.button:hover {
    background-color: rgba(139, 69, 19, 0.1);
    transform: translateY(-1px);
}

.button.primary-btn {
    background-color: var(--accent-color);
    color: #fff;
}

.button.primary-btn:hover {
    background-color: #6d360f;
}

.button.toggle-btn.active {
    background-color: var(--accent-color);
    color: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.icon-btn {
    padding: 0.5rem;
    font-size: 1.2rem;
    line-height: 1;
}

#page-info {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.color-picker-wrapper label {
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.5rem;
    transition: all 0.2s ease;
}

.color-picker-wrapper label:hover {
    background-color: rgba(139, 69, 19, 0.1);
    transform: translateY(-1px);
}

#bg-color-picker {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.book-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    padding: 2rem;
    perspective: 1500px;
    position: relative;
}

.book-page {
    background-color: var(--paper-color);
    box-shadow: var(--shadow-book);
    height: 650px;
    width: 550px;
    padding: 0;
    position: relative;
    transition: background-color 0.3s ease;
    border-radius: 10px;
    overflow-y: auto;
}

.text-content {
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 3rem;
    text-align: justify;
    max-width: 800px;
    margin: 0 auto;
}

.text-content p {
    margin-bottom: 1.5rem;
}

.highlighted-text {
    background-color: var(--highlight-color);
    border-radius: 2px;
    box-shadow: 0 0 2px var(--highlight-color);
}

.loading,
.error {
    text-align: center;
    padding: 2rem;
    font-style: italic;
    color: #666;
}

.view-section {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: 60px;
    /* Offset for fixed toolbar */
}

.app-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--accent-color);
}

.search-container {
    padding: 0.75rem 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
}

.search-field {
    position: relative;
    width: 100%;
}

.search-field input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid rgba(139, 69, 19, 0.3);
    border-radius: 20px;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--ink-color);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-field input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.15);
    background-color: #fff;
}

.search-field input::placeholder {
    color: #999;
    font-size: 0.85rem;
}

.clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    line-height: 1;
}

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

.search-field input:not(:placeholder-shown)~.clear-btn {
    display: flex;
}

.autocomplete-suggestions {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.autocomplete-suggestions.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    color: var(--ink-color);
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(139, 69, 19, 0.1);
}

.autocomplete-item:hover {
    background-color: rgba(139, 69, 19, 0.08);
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 10px 10px;
}

.autocomplete-item:first-child {
    border-radius: 10px 10px 0 0;
}

body.dark-theme .search-field input {
    background-color: rgba(45, 45, 45, 0.9);
    border-color: rgba(212, 165, 116, 0.3);
    color: #e0e0e0;
}

body.dark-theme .search-field input:focus {
    background-color: #2d2d2d;
    border-color: var(--accent-color);
}

body.dark-theme .autocomplete-suggestions {
    background-color: #2d2d2d;
    border-color: var(--accent-color);
}

body.dark-theme .autocomplete-item {
    border-bottom-color: rgba(212, 165, 116, 0.1);
    color: #e0e0e0;
}

body.dark-theme .autocomplete-item:hover {
    background-color: rgba(212, 165, 116, 0.1);
}

.library-grid {
    flex: 1;
    padding: 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    column-gap: 0.2rem;
    row-gap: 2rem;
    overflow-y: auto;
    align-content: start;
}

.empty-library-state {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 5rem;
    color: var(--empty-state-color);
    font-size: 1.2rem;
}

.book-card {
    width: 170px;
    height: 200px;
    background-color: #8b4513;
    border-radius: 4px 8px 8px 4px;
    box-shadow:
        inset 4px 0 10px rgba(0, 0, 0, 0.3),
        inset -1px 0 2px rgba(255, 255, 255, 0.1),
        5px 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1.5rem;
    color: #e8e4dc;
    text-align: center;
    border-left: 12px solid #5e2f0d;
}

.book-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow:
        inset 4px 0 10px rgba(0, 0, 0, 0.3),
        8px 12px 25px rgba(0, 0, 0, 0.4);
}

.book-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    word-wrap: break-word;
}

.book-author {
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    font-style: italic;
    opacity: 0.9;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(232, 228, 220, 0.3);
}

.book-title-display {
    font-weight: 600;
    margin-left: 1rem;
    color: #555;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-theme .book-card {
    background-color: #5a3825;
    border-left-color: #3d2417;
}

body.dark-theme .book-title-display {
    color: #ccc;
}

.keyboard-help {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: rgba(232, 228, 220, 0.95);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-soft);
    z-index: 100;
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
}

.help-content {
    display: flex;
    gap: 1.5rem;
}

#toggle-help-btn {
    position: absolute;
    top: -0.8rem;
    left: -0.8rem;
    background: var(--toolbar-bg);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--accent-color);
    transition: background-color 0.3s ease-in-out;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    line-height: 1;
    color: white;
    cursor: pointer;
}

#toggle-help-btn:hover {
    background-color: rgb(205, 134, 83);
}

.help-collapsed-icon {
    display: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    cursor: pointer;
}

.keyboard-help.collapsed {
    padding: 0;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.keyboard-help.collapsed .help-content,
.keyboard-help.collapsed #toggle-help-btn {
    display: none;
}

.keyboard-help.collapsed .help-collapsed-icon {
    display: block;
}

.keyboard-help.collapsed:hover {
    background-color: rgba(139, 69, 19, 0.1);
    transform: translateY(-1px);
}

body.dark-theme .keyboard-help {
    background-color: rgb(41, 38, 38);
}

.help-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.arrow-icon {
    font-size: 1.5rem;
    color: var(--accent-color);
    font-weight: bold;
    display: block;
}

.help-text {
    font-size: 0.75rem;
    color: #555;
    white-space: nowrap;
}

body.dark-theme .help-text {
    color: #aaa;
}

#share-btn {
    position: fixed;
    bottom: 8rem;
    right: 2rem;
    z-index: 101;
    transition: bottom 0.3s ease-in-out;
    font-size: 1rem;
    width: 2.4rem;
    height: 2.4rem;
    justify-content: center;
    border-radius: 7px;
}

#share-btn.help-collapsed {
    bottom: 5rem;
}

#share-btn.copied::after {
    content: 'Kopyalandı!';
    position: absolute;
    top: -2.5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: 12px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.app-footer {
    background-color: var(--toolbar-bg);
    padding: 1rem 1.5rem;
    border-top: 1px solid #d4d0c8;
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem;
    color: var(--ink-color);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

.copyright-info {
    grid-column: 2;
    text-align: center;
}

.contact-info {
    grid-column: 3;
    text-align: right;
}

.app-footer a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.app-footer a:hover {
    color: var(--accent-color);
}

.app-footer strong {
    color: var(--accent-color);
}

#library-container {
    flex: 1;
    /* Take up all available vertical space */
    overflow-y: auto;
    /* Enable vertical scrolling */
    padding: 3rem;
}

.library-section {
    margin-bottom: 3rem;
}

.library-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* padding is now handled by #library-container */
    margin-bottom: .5rem;
}

.library-section-title {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    color: var(--accent-color);
}

.show-all-link,
.show-less-link {
    font-family: 'Crimson Text', serif;
    color: var(--accent-color);
    text-decoration: none;
    font-style: italic;
    cursor: pointer;
}

.favorite-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    opacity: 0;
}

.book-card:hover .favorite-btn {
    opacity: 1;
}

.favorite-btn.favorited {
    opacity: 1;
    color: #ffd700;
    /* Gold color for favorited star */
    text-shadow: 0 0 5px #ffd700;
}


/* --- LAYOUT & FILTERING STYLES --- */

.main-layout {
    display: flex;
    position: relative;
    flex-grow: 1;
    padding-top: 60px;
    /* Offset for fixed toolbar */
}

.content-wrapper {
    flex-grow: 1;
    transition: margin-left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.main-content {
    flex-grow: 1;
}

/* Sidebar */
.filter-sidebar {
    position: fixed;
    top: 60px;
    /* Match toolbar height */
    left: 0;
    width: 280px;
    height: calc(100vh - 60px);
    background-color: var(--toolbar-bg);
    z-index: 998;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.filter-sidebar.open {
    transform: translateX(0);
}

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

body.dark-theme .sidebar-header,
body.dark-theme .filter-sidebar {
    border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
}

.filter-content {
    padding: 1rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-footer-link {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar-footer-link a {
    display: block;
    text-align: center;
    color: var(--ink-color);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.sidebar-footer-link a:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-theme .sidebar-footer-link {
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .sidebar-footer-link a {
    color: var(--ink-color);
}

body.dark-theme .sidebar-footer-link a:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-menu-overlay.open {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    height: 60px;
    /* Match toolbar */
    background: var(--toolbar-bg);
    box-shadow: var(--shadow-soft);
}

.mobile-menu-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--accent-color);
}

#mobile-menu-close-btn {
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Category Filter */
.category-filter h3 {
    font-family: 'Playfair Display', serif;
    margin: 1.5rem 0 1rem 0;
    color: var(--accent-color);
    font-size: 1.1rem;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-list button {
    background: transparent;
    border: 1px solid rgba(139, 69, 19, 0.3);
    color: var(--ink-color);
    padding: 0.6rem;
    text-align: left;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.category-list button:hover {
    background: rgba(139, 69, 19, 0.1);
    border-color: var(--accent-color);
}

.category-list button.active {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
    border-color: var(--accent-color);
}

body.dark-theme .category-list button {
    border-color: rgba(212, 165, 116, 0.3);
}

body.dark-theme .category-list button.active {
    color: #2c2c2c;
}

/* Language Filter */
.language-filter h3 {
    font-family: 'Playfair Display', serif;
    margin: 1.5rem 0 1rem 0;
    color: var(--accent-color);
    font-size: 1.1rem;
}

.language-list {
    display: flex;
    gap: 1rem;
}

.language-list button {
    flex-grow: 1;
    background: transparent;
    border: 1px solid rgba(139, 69, 19, 0.3);
    color: var(--ink-color);
    padding: 0.6rem;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.language-list button:hover {
    background: rgba(139, 69, 19, 0.1);
    border-color: var(--accent-color);
}

.language-list button.active {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
    border-color: var(--accent-color);
}

body.dark-theme .language-list button {
    border-color: rgba(212, 165, 116, 0.3);
}

body.dark-theme .language-list button.active {
    color: #2c2c2c;
}


/* Language Filter */
.language-filter h3 {
    font-family: 'Playfair Display', serif;
    margin: 1.5rem 0 1rem 0;
    color: var(--accent-color);
    font-size: 1.1rem;
}

.language-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.language-list button {
    background: transparent;
    border: 1px solid rgba(139, 69, 19, 0.3);
    color: var(--ink-color);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.language-list button:hover {
    background: rgba(139, 69, 19, 0.1);
    border-color: var(--accent-color);
}

.language-list button.active {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
    border-color: var(--accent-color);
}

body.dark-theme .language-list button {
    border-color: rgba(212, 165, 116, 0.3);
}

body.dark-theme .language-list button.active {
    color: #2c2c2c;
}


/* Button visibility */
#sidebar-close-btn {
    display: none;
}

#mobile-menu-toggle-btn {
    display: none;
}

.mobile-nav-buttons {
    display: none;
    /* Hide by default on desktop */
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    #sidebar-toggle-btn {
        display: none;
    }

    #mobile-menu-toggle-btn {
        display: flex;
    }

    #reader-view .toolbar {
        min-height: 80px;
        align-content: center;
    }

    .toolbar {
        padding: 0.5rem 1rem;
        flex-wrap: wrap;
        /* position: static removed to allow fixed positioning */
    }

    .app-title {
        font-size: 1.2rem;
    }

    .toolbar-group {
        gap: 0.5rem;
    }

    .button {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .icon-btn {
        padding: 0.4rem;
        font-size: 1rem;
    }

    #mobile-menu-toggle-btn,
    #theme-toggle {
        width: 32px;
        height: 32px;
        padding: 0;
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .search-container {
        padding: 0.5rem 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .search-field {
        width: 100%;
    }

    .library-grid {
        padding: 1.5rem 1rem;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .book-card {
        width: 100%;
        height: 180px;
        padding: 1.5rem 1rem;
    }

    .favorite-btn {
        opacity: 1;
        /* Always visible on mobile */
    }

    .book-title {
        font-size: 1rem;
    }

    .book-author {
        font-size: 0.85rem;
    }

    .book-container {
        padding: 0.5rem;
        padding-bottom: 8rem;
        padding-top: 2rem;
        /* Increased padding to make space for both button rows */
    }

    .book-page {
        height: calc(100vh - 250px);
        min-height: 0;
        max-height: none;
        min-width: 95%;
        width: 95%;
        border-radius: 10px;
    }

    .text-content {
        padding: 1.5rem 1rem;
        font-size: 1rem;
        line-height: 1.6;
    }

    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    #page-info {
        font-size: 0.9rem;
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    #theme-toggle-reader {
        display: none;
    }

    .color-picker-wrapper label {
        font-size: 1rem;
        padding: 0.4rem;
    }

    .keyboard-help {
        display: none;
    }

    #share-btn {
        display: none;
        /* Hide desktop button on mobile */
    }

    #share-btn.mobile-share {
        display: flex;
        position: fixed;
        /* Reverted to fixed */
        bottom: 1.5rem;
        /* Positioned at the very bottom */
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 400px;
        justify-content: center;
        z-index: 101;
    }

    .mobile-nav-buttons {
        display: flex;
        justify-content: space-between;
        position: fixed;
        bottom: 5rem;
        /* Positioned above the share button */
        left: 0;
        right: 0;
        padding: 0 1rem;
        z-index: 101;
        pointer-events: none;
        /* Allow clicks to pass through the container */
    }

    .mobile-nav-buttons .button {
        pointer-events: auto;
        /* Make only the buttons clickable */
    }

    #mobile-prev-page-left,
    #mobile-next-page-left {
        margin-right: auto;
    }

    #mobile-prev-page-right,
    #mobile-next-page-right {
        margin-left: auto;
    }

    .book-title-display {
        display: none;
    }

    .app-footer {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .copyright-info,
    .contact-info {
        text-align: center;
    }
}

@media screen and (min-width: 769px) {
    .filter-sidebar.open~.content-wrapper {
        margin-left: 280px;
        /* Same as sidebar width */
    }
}

@media screen and (max-width: 480px) {
    .app-title {
        font-size: 1rem;
    }

    .toolbar {
        padding: 0.5rem;
    }

    .book-page {
        height: calc(100vh - 250px);
    }

    .text-content {
        padding: 1rem 0.75rem;
        font-size: 0.95rem;
    }

    .library-grid {
        padding: 1rem 0.5rem;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .book-card {
        height: 150px;
        padding: 1rem 0.75rem;
    }

    .book-title {
        font-size: 0.9rem;
    }

    .book-author {
        font-size: 0.75rem;
    }

    #page-info {
        font-size: 0.85rem;
    }
}