html, body { 
    background-color: #fcfcfc; color: #1d1d1f;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    margin: 0; padding: 0; overflow-x: hidden;
    -webkit-tap-highlight-color: transparent; /* Removes mobile tap flash */
}

/* --- NAVIGATION --- */
.top-nav {
    display: flex;
    justify-content: flex-end;
    padding: 1.5rem 2rem;
    position: absolute; 
    top: 0;
    right: 0;
    width: 100%;
    z-index: 100;
}
.nav-links a {
    margin-left: 1.5rem;
    text-decoration: none;
    color: #86868b;
    font-size: 0.95rem;
    transition: color 0.2s;
}
.nav-links a.active, .nav-links a:hover {
    color: #1d1d1f;
    font-weight: 600;
}

/* --- MAIN CONTAINER --- */
.container { max-width: 1200px; margin: 0 auto; padding: 5rem 1.5rem 3rem 1.5rem; }
@media (min-width: 768px) { .container { padding-top: 3rem; } }

h1 { text-align: center; margin-bottom: 2.5rem; font-weight: 700; font-size: 2.2rem; }

/* --- STABILIZED MINIMALIST CONTROLS --- */
.controls { 
    display: flex; gap: 12px; justify-content: center; margin-bottom: 3rem; align-items: center; 
    min-height: 48px;
}
.search-input { 
    width: 44px; height: 44px; padding: 0; border: none; border-radius: 22px; outline: none !important;
    background-color: #f5f5f7;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='8'/%3e%3cline x1='21' y1='21' x2='16.65' y2='16.65'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: center;
    font-size: 0; color: transparent; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}
.search-input:focus, .search-input:not(:placeholder-shown) { 
    width: 220px; padding: 0 16px 0 40px; background-position: 14px center;
    font-size: 1rem; color: #1d1d1f; cursor: text; background-color: #e8e8ed;
}
.search-input::placeholder { color: transparent; }
.search-input:focus::placeholder { color: #86868b; }

.sort-select { 
    width: 44px; height: 44px; min-width: 44px; flex-shrink: 0; padding: 0; border: none; border-radius: 22px; outline: none !important;
    background-color: #f5f5f7;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M7 15l5 5 5-5M7 9l5-5 5 5'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: center;
    color: transparent; cursor: pointer; transition: 0.2s;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    box-sizing: border-box;
}

/* --- GRID --- */
.bookshelf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
@media (min-width: 768px) { .bookshelf { grid-template-columns: repeat(3, 1fr); gap: 2rem; } }
@media (min-width: 1024px) { .bookshelf { grid-template-columns: repeat(4, 1fr); gap: 2rem; } }

/* --- CARDS --- */
.book-card { 
    border: none !important; outline: none !important; box-shadow: 0 4px 15px rgba(0,0,0,0.04); border-radius: 12px; 
    transition: 0.3s ease; display: flex; flex-direction: column; background: #fff; overflow: hidden; height: 100%; cursor: pointer; 
} 
.book-card:hover, .book-card.is-active { box-shadow: 0 12px 28px rgba(0,0,0,0.1); transform: translateY(-4px); }

.img-container { position: relative; aspect-ratio: 2 / 3; overflow: hidden;
background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite linear;
}
.img-container.stop-shimmer { animation: none; background: transparent; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.cover-img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.6s ease; position: absolute; top: 0; left: 0; z-index: 3; }
.cover-img.loaded { opacity: 1; }

.card-body { padding: 1rem; display: flex; flex-direction: column; flex-grow: 1; }
.book-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card.is-active .book-title { white-space: normal; overflow: visible; } /* Dynamic Title Expansion */
.book-author { font-size: 0.85rem; color: #666; margin: 0 0 1rem 0; }

.btn-amazon { background-color: #f5f5f7; color: #1d1d1f; border: none; border-radius: 8px; outline: none;
padding: 10px 16px; font-size: 0.85rem; font-weight: 600; text-decoration: none; transition: 0.2s; display: block; text-align: center; margin-top: auto; }

/* --- SUMMARY OVERLAY --- */
.summary-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; 
    background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease; display: flex; flex-direction: column;
}
.book-card.is-active .summary-overlay { opacity: 1; pointer-events: auto; }
.summary-content { flex-grow: 1; padding: 1.5rem; overflow-y: auto; text-align: center; display: flex; flex-direction: column; }
.summary-text { margin: auto 0; font-size: 0.95rem; line-height: 1.6; color: #1d1d1f; }

/* --- AI LINK --- */
.ai-link { 
    position: absolute; bottom: 8px; right: 8px; display: flex; align-items: center; z-index: 25; 
    text-decoration: none; padding: 5px;
    pointer-events: none; opacity: 0; 
    transition: opacity 0.3s ease, pointer-events 0s linear 0.4s;
}
.book-card.is-active .ai-link { pointer-events: auto; opacity: 1; }
.ai-icon { width: 18px; height: 18px; fill: #666; opacity: 0.5; transition: opacity 0.2s; }
.ai-link:hover .ai-icon { opacity: 1; fill: #1d1d1f; }

.ai-tooltip {
    position: absolute; right: 28px; background: rgba(29, 29, 31, 0.95); color: #ffffff; 
    font-size: 0.55rem; font-weight: 500; padding: 6px 10px; border-radius: 6px; white-space: nowrap; 
    opacity: 0; transform: translateX(5px); transition: all 0.2s ease; pointer-events: none;
}
.ai-link:hover .ai-tooltip, .ai-link:active .ai-tooltip { opacity: 1; transform: translateX(0); }