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

body {
    font-family: 'Almarai', sans-serif;
    background: #f5f7fa;
    overflow-y: auto;
    --primary-color: #0066CC;
    --primary-color-light: #e6f0fa;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-bg: white;
}

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

.view {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

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

.view.active {
    display: block;
}

/* Header */
.app-header {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 1rem 2rem;
    z-index: 100;
    position: sticky;
    top: 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

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

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.logo-text p {
    font-size: 0.875rem;
    color: #64748b;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 500px;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.search-container input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.search-container svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

/* Main Navigation */
.main-nav {
    display: flex;
    justify-content: center;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    position: sticky;
    top: 72px; /* Adjusted for standard header height */
    z-index: 101; /* Higher than header to ensure tabs are always clickable */
}

.nav-tab {
    padding: 1rem 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-tab:hover {
    color: var(--primary-color);
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.nav-tab svg {
    width: 20px;
    height: 20px;
}

/* Filter Section */
.filter-section {
    padding: 1.5rem 2rem;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-section::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 0.625rem 1.5rem;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 24px;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.1);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Library Content */
.library-content {
    padding: 2rem;
}

.books-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
}

/* Links View */
#links-view {
    padding: 0;
    background: #f1f5f9; /* Match viewer background */
}

.links-header {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 1rem 2rem;
    z-index: 80;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row-reverse; /* Put back button on the right in RTL context but logic-wise "leading" */
}

.links-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 700;
}

.sticky-sub-header {
    position: sticky;
    top: 132px; /* Below header and nav (72 + ~60) */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 102;
}

.links-header .btn-back {
    background: transparent;
    border: 2px solid var(--border-color);
}

.links-container {
    display: flex;
    max-width: 1600px;
    margin: 2rem auto;
    width: calc(100% - 2rem);
    gap: 1.5rem;
    padding: 0 1rem;
}

.links-sidebar {
    background: white;
    border-radius: 16px;
    padding: 1.25rem;
    width: 300px;
    flex-shrink: 0;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.links-sidebar-btn {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: right;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.5rem;
}

.links-sidebar-btn img {
    width: 24px;
    height: 24px;
    transition: filter 0.2s ease;
}

.links-sidebar-btn.active img {
    filter: brightness(0) invert(1);
}

.links-sidebar-btn:hover {
    background: var(--primary-color-light);
    color: var(--primary-color);
}

.links-sidebar-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.links-main-content {
    flex: 1;
    padding-right: 1rem;
}

.links-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.links-category {
    margin-bottom: 3rem;
}

.links-category h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    display: none; /* Hide individual category titles in new layout */
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.link-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 1.25rem;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

.link-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border-color: var(--primary-color);
}

.link-card-icon {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.link-card-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.link-card-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}


.book-card {
    background: var(--card-bg);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.book-card-hero {
    color: white;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    border-bottom: 4px solid rgba(0, 0, 0, 0.1);
}

.book-card-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.book-icon {
    width: 80px;
    height: 80px;
    color: white;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

.book-card:hover .book-icon {
    transform: scale(1.1) rotate(-5deg);
}

.book-card-content {
    padding: 1.5rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.book-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    min-height: 45px; /* Ensures consistent height for 2 lines of text */
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}

.book-meta .subject-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 600;
}

/* --- Enhanced Instructions View Styles --- */
#instructions-view {
    padding: 0;
    background: #f8fafc;
}

.instructions-content {
    padding: 3rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.instructions-grid {
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.instruction-section {
    background: white;
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
}

.instruction-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--primary-color-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
}

.icon-circle img {
    width: 36px;
    height: 36px;
}

.icon-circle i {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.instruction-section h3 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

@media (max-width: 600px) {
    .instruction-section h3 {
        font-size: 1.4rem;
    }
}

.tip-card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.tip-card {
    background: #ffffff;
    padding: 2.5rem 2rem;
    border-radius: 28px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    border-bottom: 6px solid var(--border-color);
}

.tip-card:hover {
    transform: translateY(-12px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1);
    border-bottom-color: var(--primary-color);
}

.tip-card h4 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: block;
    width: 100%;
}

.tip-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.tip-card li {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    position: relative;
    line-height: 1.6;
    padding: 0.75rem 1rem;
    background: #fcfdfe;
    border-radius: 12px;
    transition: background 0.3s ease;
}

.tip-card li:hover {
    background: var(--primary-color-light);
    color: var(--text-primary);
}

.tip-card li::before {
    display: none;
}

/* Theme Colors */
.maintenance-theme .icon-circle { background: #e0f2fe; }
.maintenance-theme .icon-circle i { color: #0369a1; }
.maintenance-theme::after { background: #0ea5e9; }
.maintenance-theme .tip-card h4 { color: #0369a1; }
.maintenance-theme .tip-card { border-bottom-color: #0ea5e9; }
.maintenance-theme li::before { background: #e0f2fe; color: #0369a1; }

.safety-theme .icon-circle { background: #fef2f2; }
.safety-theme .icon-circle i { color: #b91c1c; }
.safety-theme::after { background: #ef4444; }
.safety-theme .tip-card h4 { color: #b91c1c; }
.safety-theme .tip-card { border-bottom-color: #ef4444; }
.safety-theme li::before { background: #fef2f2; color: #b91c1c; content: '🛡️'; background: none; font-size: 1rem; }

.ai-theme .icon-circle { background: #f5f3ff; }
.ai-theme .icon-circle i { color: #6d28d9; }
.ai-theme::after { background: #8b5cf6; }
.ai-theme .tip-card h4 { color: #6d28d9; }
.ai-theme .tip-card { border-bottom-color: #8b5cf6; }
.ai-theme li::before { background: #f5f3ff; color: #6d28d9; content: '✨'; background: none; font-size: 1rem; }

.health-theme .icon-circle { background: #ecfdf5; }
.health-theme .icon-circle i { color: #047857; }
.health-theme::after { background: #10b981; }
.health-theme .tip-card h4 { color: #047857; }
.health-theme .tip-card { border-bottom-color: #10b981; }
.health-theme li::before { background: #ecfdf5; color: #047857; content: '🧘'; background: none; font-size: 1rem; }

/* Viewer */
#viewer-view {
    display: none; /* Hide by default */
}

#viewer-view.active {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f1f5f9;
    z-index: 2000; /* On top of everything */
}

.viewer-header-toolbar {
    background: white;
    height: 64px;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    z-index: 10;
}

.viewer-toolbar-left { display: flex; justify-content: flex-start; }
.viewer-toolbar-center { display: flex; justify-content: center; overflow: hidden; }
.viewer-toolbar-right { display: flex; justify-content: flex-end; }

.viewer-back-button {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6rem 1.2rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.viewer-back-button:hover {
    background: #e2e8f0;
    color: var(--primary-color);
    transform: translateX(4px);
}

.viewer-toolbar-center h2 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.external-link-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 800;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 102, 204, 0.2);
}

.external-link-btn:hover {
    background: #0052a3;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 102, 204, 0.3);
}

.viewer-header {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: #e2e8f0;
}

.book-title {
    flex: 1;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.viewer-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #e2e8f0;
}

#zoom-level {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #64748b;
    min-width: 50px;
    text-align: center;
}

/* Viewer Body */
.viewer-body {
    flex: 1;
    display: flex;
    background: transparent;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.pdf-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 0;
    width: 100%;
    height: 100%;
}

#pdf-canvas {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    background: white;
    max-width: 100%;
    height: auto;
}

.pdf-spread {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px; /* The space between pages */
    transition: opacity 0.3s ease-in-out;
}

.pdf-spread.loading {
    opacity: 0.5;
}

.pdf-spread canvas {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    background: white;
    max-width: 50%;
    height: auto;
    display: block;
}

#pdf-canvas-left.hidden, #pdf-canvas-right.hidden {
    display: none;
}


.html-viewer {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.html-viewer.hidden {
    display: none !important;
}


.page-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

#prev-page-nav {
    left: 0;
}

#next-page-nav {
    right: 0;
}

.nav-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

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

/* Viewer Footer (Internal for PDF viewer) */
.viewer-footer {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.page-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.page-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

#page-input {
    width: 60px;
    padding: 0.375rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    text-align: center;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
}

#page-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* App Footer */
.app-footer {
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    z-index: 5;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 4rem; /* Added spacing from content */
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: center;
}

.footer-section.branding {
    text-align: right;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.footer-logo h4 {
    font-size: 1.1rem;
    font-weight: 800;
}

.footer-section p {
    font-size: 0.8rem;
    opacity: 0.8;
}

.footer-section.links {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.footer-section.links a {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.footer-section.links a:hover {
    opacity: 1;
}

.footer-bottom {
    grid-column: span 2;
    text-align: center;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Hide footer in viewer mode to maximize space */
#viewer-view.active ~ #main-footer {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .viewer-header-toolbar {
        grid-template-columns: auto 1fr auto;
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .viewer-back-button span, .external-link-btn span {
        display: none; /* Hide text on small mobile, keep icons */
    }
    
    .viewer-back-button, .external-link-btn {
        padding: 0.6rem;
        border-radius: 8px;
    }

    .viewer-toolbar-center h2 {
        font-size: 1rem;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .main-nav {
        top: 140px; /* Increased to avoid overlap with stacked mobile header */
        padding: 0 0.5rem;
    }

    .sticky-sub-header {
        top: 200px; /* Increased to avoid overlap with stacked mobile header + nav */
    }

    .links-container {
        flex-direction: column;
        width: 100%;
        margin: 1rem 0;
    }

    .links-sidebar {
        width: 100%;
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .links-sidebar-btn {
        white-space: nowrap;
        width: auto;
        margin-bottom: 0;
    }
    
    .search-container {
        max-width: 100%;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
    
    .viewer-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer-section.branding, .footer-section.links {
        text-align: center;
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-logo {
        justify-content: center;
    }

    .footer-bottom {
        grid-column: 1;
    }
    
    .book-title {
        order: -1;
        width: 100%;
        text-align: right;
    }
}

.viewer-controls.hidden,
.viewer-footer.hidden,
.page-nav.hidden {
    display: none;
}