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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f8fafc;
    color: #0f172a;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Common */
.container {
    width: min(1400px, 95%);
    margin: 0 auto;
}

/* Header */
.header {
    height: 64px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left,
.header-right {
    flex: 1;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.header-center {
    flex: 2;
    display: flex;
    justify-content: center;
}

.logo {
    color: #0f172a;
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-trigger {
    display: flex;
    align-items: center;
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 16px;
    width: 100%;
    max-width: 400px;
    cursor: pointer;
    color: #64748b;
    font-size: 14px;
    transition: background 0.2s, border-color 0.2s;
}

.search-trigger:hover {
    background: rgba(226, 232, 240, 0.9);
    border-color: #cbd5e1;
}

.search-icon {
    margin-right: 8px;
}

.search-text {
    flex-grow: 1;
    text-align: left;
}

.search-shortcut {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.nav {
    display: flex;
    gap: 24px;
}

.nav a {
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s;
}

.nav a:hover {
    color: #0f172a;
}

.nav a.active {
    color: #0f172a;
    border-bottom-color: #0f172a;
}

/* Main */
.main {
    flex: 1;
    padding: 40px 0;
}

/* States */
.state {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    text-align: center;
}

.state[hidden] {
    display: none;
}

.state h2 {
    margin-bottom: 12px;
    font-size: 24px;
}

.state p {
    max-width: 440px;
    margin-bottom: 28px;
    color: #64748b;
    font-size: 15px;
    line-height: 1.6;
}

/* Empty, Error, Loading Icons */
.empty-icon,
.state-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    border-radius: 50%;
    font-size: 32px;
}

.empty-icon {
    background: #f1f5f9;
}

.state-icon {
    background: #fef2f2;
}

.spinner {
    width: 42px;
    height: 42px;
    margin-bottom: 24px;
    border: 4px solid #e2e8f0;
    border-top-color: #0f172a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Button */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    background: #0f172a;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.button:hover {
    background: #1e293b;
}

.button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

/* Card Styling */
.book-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 2px dotted #cbd5e1;
    border-radius: 12px;
    padding: 14px;
    transition: border-color 0.2s;
}

.book-card:hover {
    border-color: #94a3b8;
}

.card-top-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
}

.book-title {
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.book-year {
    color: #64748b;
    flex-shrink: 0;
}

.cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 14px;
    background: #e2e8f0;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

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

.card-bottom-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.book-author {
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
    flex: 1;
}

.card-bottom-info .button {
    font-size: 11px;
    min-height: 28px;
    padding: 0 12px;
    background: transparent;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.card-bottom-info .button:hover:not(:disabled) {
    background: #f1f5f9;
}

/* Footer */
.footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 16px 0;
    margin-top: auto;
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #64748b;
}

.footer a {
    color: #0f172a;
    font-weight: 600;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
}

.modal[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.modal-search-icon {
    font-size: 18px;
    color: #f97316;
    margin-right: 12px;
}

#modal-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #0f172a;
    background: transparent;
}

#modal-search-input::placeholder {
    color: #94a3b8;
}

.modal-close-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 11px;
    cursor: pointer;
}

.close-kbd {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-weight: bold;
    color: #0f172a;
}

.modal-results {
    overflow-y: auto;
    padding: 12px 0;
}

.modal-initial-state {
    padding: 20px;
    text-align: center;
    color: #64748b;
    font-size: 14px;
}

.search-result-item {
    display: flex;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    gap: 16px;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #f8fafc;
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-cover {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    background: #e2e8f0;
}

.result-info {
    flex: 1;
}

.result-title {
    font-weight: 600;
    color: #0f172a;
    font-size: 14px;
    margin-bottom: 4px;
}

.result-author {
    color: #64748b;
    font-size: 12px;
}

/* Mobile */
@media (max-width: 768px) {
    .header-container {
        flex-wrap: wrap;
        padding: 10px 0;
    }

    .header {
        height: auto;
    }

    .header-left,
    .header-right {
        flex: initial;
    }

    .header-center {
        width: 100%;
        order: 3;
        margin-top: 12px;
    }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .modal-content {
        width: 95%;
        margin-top: 5vh;
    }
}