:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent: #8B0000;
    --accent-hover: #A50000;
    --accent-glow: rgba(139, 0, 0, 0.4);
    --gold: #D4AF37;
    --gold-dark: #B8860B;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --red-bright: #DC143C;
    --gradient-brand: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    --gradient-gold: linear-gradient(135deg, #D4AF37 0%, #B8860B 100%);
    --gradient-royal: linear-gradient(135deg, #D4AF37 0%, #8B0000 100%);
    --border-color: rgba(212, 175, 55, 0.12);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1rem 2rem;
    background: transparent;
    transition: background 0.3s;
}

.navbar.scrolled {
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

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

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

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(145deg, #8B0000 0%, #6B0000 50%, #4A0000 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 12px rgba(139, 0, 0, 0.4), inset 0 1px 0 rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.25);
    overflow: hidden;
}

.logo-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, #8B0000 0%, #6B0000 50%, #4A0000 100%);
    border-radius: 10px;
    z-index: 0;
}

.logo-f-img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.logo-icon.small {
    width: 36px;
    height: 36px;
}

.logo-text {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

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

.nav-actions {
    display: flex;
    gap: 1rem;
}

.btn-upload {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--accent);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 4px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-upload:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
    border-color: var(--gold);
}

.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.book-mosaic {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    transform: rotateZ(-8deg);
}

.cover-row {
    display: flex;
    gap: 12px;
    will-change: transform;
}

.cover-tile {
    flex-shrink: 0;
    width: 140px;
    height: 200px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.cover-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: blur(1.5px) brightness(0.8);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(10,10,10,0.5) 0%, rgba(10,10,10,0.7) 50%, rgba(10,10,10,0.95) 100%),
        linear-gradient(to top, #0a0a0a 0%, transparent 35%),
        linear-gradient(to bottom, rgba(10,10,10,0.7) 0%, transparent 25%);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 800px;
    padding: 0 2rem;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-size: 5rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 1.5rem;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #D4AF37 0%, #FFD700 40%, #D4AF37 60%, #B8860B 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #D4AF37 0%, #FFD700 50%, #B8860B 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-cta-text {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.hero-cta {
    display: flex;
    gap: 0;
    max-width: 640px;
    margin: 0 auto;
}

.hero-search-wrapper {
    flex: 1;
    position: relative;
}

#heroSearch {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(15, 15, 15, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-right: none;
    border-radius: 4px 0 0 4px;
    font-size: 1rem;
    color: white;
    outline: none;
    transition: all 0.3s;
    height: 56px;
}

#heroSearch::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#heroSearch:focus {
    background: rgba(15, 15, 15, 0.95);
    border-color: var(--gold);
}

.btn-get-started {
    padding: 0 1.5rem;
    background: var(--accent);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-left: none;
    border-radius: 0 4px 4px 0;
    color: var(--gold);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.btn-get-started:hover {
    background: var(--accent-hover);
    color: #FFD700;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    margin-top: 0;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-lg);
    z-index: 20;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: background 0.2s;
}

.autocomplete-item:hover {
    background: rgba(139, 0, 0, 0.15);
}

.autocomplete-item .book-mini {
    width: 36px;
    height: 50px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.autocomplete-item .book-info {
    flex: 1;
    min-width: 0;
}

.autocomplete-item .book-info h4 {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item .book-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.uploaded-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold);
    border-radius: 100px;
    font-weight: 600;
    flex-shrink: 0;
}

.hero-divider {
    height: 4px;
    background: linear-gradient(to right, var(--accent), var(--red-bright), var(--gold), var(--gold-dark));
    position: relative;
    z-index: 1;
}

.library-section {
    padding: 3rem 0 0;
    background: var(--bg-secondary);
}

.library-header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.library-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gold);
}

.book-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.category-row {
    margin-bottom: 2.5rem;
}

.category-header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.category-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.category-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold);
    border-radius: 100px;
    font-weight: 600;
}

.shelf-wrapper {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 3rem;
}

.scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-60%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 15, 15, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
}

.shelf-wrapper:hover .scroll-arrow {
    opacity: 1;
}

.scroll-arrow:hover {
    background: var(--accent);
    border-color: var(--gold);
    transform: translateY(-60%) scale(1.1);
}

.scroll-arrow.left {
    left: 0.5rem;
}

.scroll-arrow.right {
    right: 0.5rem;
}

.book-shelf {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 0.5rem 0 1rem;
    scrollbar-width: none;
}

.book-shelf::-webkit-scrollbar {
    display: none;
}

.book-card {
    flex: 0 0 155px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.book-card:hover {
    transform: scale(1.08) translateY(-10px);
}

.book-cover {
    width: 155px;
    height: 215px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    transition: box-shadow 0.3s;
}

.book-card:hover .book-cover {
    box-shadow: 0 12px 40px rgba(139, 0, 0, 0.4);
}

.book-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.7) 100%);
}

.book-initial {
    font-size: 3.5rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.25);
    z-index: 1;
}

.uploaded-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    background: rgba(212, 175, 55, 0.9);
    color: #0a0a0a;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

.book-title {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.book-author {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-section {
    padding: 3rem 2rem;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-secondary);
}

.chat-container {
    background: #141414;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.chat-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gold);
}

.book-selector select {
    padding: 0.5rem 1rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.chat-transcript {
    height: 400px;
    overflow-y: auto;
    padding: 1.5rem;
}

.welcome-message,
.message-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.message-row.user {
    flex-direction: row-reverse;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(145deg, #8B0000 0%, #6B0000 50%, #4A0000 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(212, 175, 55, 0.25);
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    padding: 0;
}

.ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-glass);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    line-height: 1.6;
}

.message-bubble.assistant {
    background: var(--bg-glass);
    border-radius: 16px 16px 16px 4px;
}

.message-bubble.user {
    background: var(--accent);
    border-radius: 16px 16px 4px 16px;
}

.message-bubble p {
    margin: 0;
}

.loading-bubble {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    min-width: 180px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-gold);
    opacity: 0.4;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.2); }
}

.loading-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    animation: loadingFade 2s infinite ease-in-out;
}

@keyframes loadingFade {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.mic-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mic-btn:hover {
    background: var(--accent);
    border-color: var(--gold);
    color: white;
}

.mic-btn.recording {
    background: var(--red-bright);
    border-color: var(--red-bright);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 20, 60, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(220, 20, 60, 0); }
}

#queryInput,
#bookPageQueryInput {
    flex: 1;
    padding: 0.875rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

#queryInput:focus,
#bookPageQueryInput:focus {
    border-color: var(--gold);
}

#queryInput::placeholder,
#bookPageQueryInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent);
    border: none;
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.voice-status {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.upload-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.upload-modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 480px;
    width: 90%;
    text-align: center;
    position: relative;
    border: 1px solid var(--border-color);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--accent);
    color: white;
}

.modal-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--gold);
}

.modal-content > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed rgba(212, 175, 55, 0.25);
    border-radius: 16px;
    padding: 3rem 2rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1.5rem;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--gold);
    background: rgba(139, 0, 0, 0.1);
}

.upload-area svg {
    color: var(--gold-dark);
    margin-bottom: 1rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.upload-area span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.upload-area input {
    display: none;
}

.btn-ingest {
    width: 100%;
    padding: 1rem;
    background: var(--accent);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: var(--gold);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ingest:hover {
    background: var(--accent-hover);
}

.btn-ingest:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ingest-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

.ingest-status.success {
    display: block;
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.ingest-status.error {
    display: block;
    background: rgba(220, 20, 60, 0.1);
    color: var(--red-bright);
    border: 1px solid rgba(220, 20, 60, 0.2);
}

.ingest-status.loading {
    display: block;
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.speak-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: all 0.2s;
    z-index: 50;
}

.speak-btn:hover {
    transform: scale(1.1);
    border-color: var(--gold);
}

.speak-btn.hidden {
    display: none;
}

.footer {
    padding: 3rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--gold);
}

.footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.book-page {
    display: none;
    padding-top: 80px;
    min-height: 100vh;
    background: var(--bg-primary);
}

.book-page.active {
    display: block;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--gold);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 auto;
    max-width: 1200px;
    margin-left: 2rem;
    margin-bottom: 2rem;
}

.back-btn:hover {
    background: var(--accent);
    border-color: var(--gold);
    color: white;
}

.book-page-hero-content {
    display: flex;
    align-items: flex-end;
    gap: 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.book-page-cover {
    width: 220px;
    height: 320px;
    border-radius: 8px;
    flex-shrink: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px var(--accent-glow);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-page-cover .book-initial {
    font-size: 5rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.25);
}

.book-page-meta {
    flex: 1;
    padding-bottom: 0.5rem;
}

.book-page-category {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.book-page-title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #D4AF37 0%, #FFD700 40%, #D4AF37 60%, #B8860B 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.book-page-author {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.book-info-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
}

.book-info-heading {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 1.5rem;
}

.book-info-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.book-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.book-info-card:hover {
    border-color: rgba(212, 175, 55, 0.3);
}

.book-info-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-info-card p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
}

.book-info-card ul {
    list-style: none;
    padding: 0;
}

.book-info-card ul li {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
    padding: 0.4rem 0;
    padding-left: 1.25rem;
    position: relative;
}

.book-info-card ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.85rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
}

.book-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.book-info-loading {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.shimmer-card {
    height: 120px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.shimmer-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(212, 175, 55, 0.05) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.book-page-chat {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 1rem;
    }

    .nav-links {
        display: none;
    }

    .logo-text {
        font-size: 1.4rem;
    }

    .logo-icon {
        width: 34px;
        height: 34px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .btn-upload {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .hero {
        min-height: 100vh;
        min-height: 100svh;
    }

    .book-mosaic {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(8, 1fr);
        gap: 6px;
        transform: perspective(600px) rotateX(5deg) rotateZ(-15deg) scale(1.5);
    }

    .mosaic-tile {
        font-size: 1.2rem;
        border-radius: 4px;
    }

    .hero-title {
        font-size: 3rem;
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .hero-cta-text {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }

    .hero-cta {
        flex-direction: column;
        gap: 0.75rem;
    }

    #heroSearch {
        border-right: 1px solid rgba(212, 175, 55, 0.3);
        border-radius: 4px;
        height: 50px;
        font-size: 0.95rem;
    }

    .btn-get-started {
        border-radius: 4px;
        border-left: 1px solid rgba(212, 175, 55, 0.3);
        height: 50px;
        justify-content: center;
        font-size: 1rem;
    }

    .autocomplete-dropdown {
        border-radius: 8px;
        margin-top: 4px;
    }

    .hero-divider {
        height: 3px;
    }

    .library-section {
        padding: 1.5rem 0 0;
    }

    .library-header {
        padding: 0 1rem;
        margin-bottom: 0.75rem;
    }

    .library-header h2 {
        font-size: 1.4rem;
    }

    .book-count {
        font-size: 0.8rem;
    }

    .category-row {
        margin-bottom: 1.75rem;
    }

    .category-header {
        padding: 0 1rem;
        gap: 0.5rem;
        margin-bottom: 0.6rem;
    }

    .category-header h3 {
        font-size: 1.1rem;
    }

    .category-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    .shelf-wrapper {
        padding: 0 1rem;
    }

    .book-shelf {
        gap: 0.75rem;
        padding: 0.25rem 0 0.75rem;
        -webkit-overflow-scrolling: touch;
    }

    .book-card {
        flex: 0 0 120px;
    }

    .book-card:hover {
        transform: none;
    }

    .book-cover {
        width: 120px;
        height: 170px;
        border-radius: 4px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    }

    .book-initial {
        font-size: 2.8rem;
    }

    .uploaded-tag {
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
        top: 6px;
        right: 6px;
    }

    .book-title {
        font-size: 0.78rem;
        margin-top: 0.4rem;
    }

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

    .scroll-arrow {
        display: none;
    }

    .book-page {
        padding-top: 60px;
    }

    .back-btn {
        margin-left: 1rem;
        margin-bottom: 1rem;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .book-page-hero-content {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        padding: 0 1rem 2rem;
        text-align: center;
    }

    .book-page-cover {
        width: 160px;
        height: 230px;
    }

    .book-page-title {
        font-size: 2rem;
    }

    .book-page-author {
        font-size: 1rem;
    }

    .book-info-section {
        padding: 1.5rem 1rem 2rem;
    }

    .book-info-heading {
        font-size: 1.4rem;
    }

    .book-info-grid {
        grid-template-columns: 1fr;
    }

    .book-page-chat {
        padding: 0 1rem 2rem;
    }

    .chat-section {
        padding: 2rem 1rem;
    }

    .chat-container {
        border-radius: 12px;
    }

    .chat-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .chat-header h2 {
        font-size: 1.1rem;
    }

    .book-selector {
        width: 100%;
    }

    .book-selector select {
        width: 100%;
        font-size: 0.85rem;
    }

    .chat-transcript {
        height: 300px;
        padding: 1rem;
    }

    .message-bubble {
        max-width: 85%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .ai-avatar,
    .user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        font-size: 0.85rem;
    }

    .welcome-message,
    .message-row {
        gap: 0.6rem;
        margin-bottom: 1rem;
    }

    .chat-input-area {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .mic-btn {
        width: 42px;
        height: 42px;
    }

    .mic-btn svg {
        width: 20px;
        height: 20px;
    }

    #queryInput,
    #bookPageQueryInput {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .send-btn {
        width: 42px;
        height: 42px;
        border-radius: 10px;
    }

    .send-btn svg {
        width: 18px;
        height: 18px;
    }

    .modal-content {
        padding: 1.75rem 1.25rem;
        border-radius: 14px;
        width: 92%;
    }

    .modal-content h2 {
        font-size: 1.25rem;
    }

    .upload-area {
        padding: 2rem 1.25rem;
        border-radius: 12px;
    }

    .upload-area svg {
        width: 36px;
        height: 36px;
    }

    .upload-area p {
        font-size: 0.9rem;
    }

    .speak-btn {
        width: 48px;
        height: 48px;
        bottom: 1.25rem;
        right: 1.25rem;
    }

    .speak-btn svg {
        width: 18px;
        height: 18px;
    }

    .footer {
        padding: 2rem 1rem;
        margin-top: 0;
    }

    .footer p {
        font-size: 0.75rem;
        text-align: center;
    }
}

@media (max-width: 400px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .hero-cta-text {
        font-size: 0.85rem;
    }

    .book-card {
        flex: 0 0 105px;
    }

    .book-cover {
        width: 105px;
        height: 150px;
    }

    .book-initial {
        font-size: 2.4rem;
    }

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

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

    .library-header h2 {
        font-size: 1.2rem;
    }

    .category-header h3 {
        font-size: 1rem;
    }
}
