:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #dbeafe;
    --card-bg: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --star-color: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-light: #1e3a5f;
    --card-bg: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    --star-color: #fbbf24;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    min-height: 100vh;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    transform: rotate(15deg);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.main-content {
    padding: 32px 20px;
    min-height: calc(100vh - 64px - 80px);
}

.search-section {
    margin-bottom: 24px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 100%;
}

.search-box svg {
    position: absolute;
    left: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 14px 48px 14px 48px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.clear-btn {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.clear-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 56px;
    padding-top: 8px;
    flex-shrink: 0;
}

.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.tag {
    padding: 7px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tag:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.tag.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.tag.active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #ffffff;
}

.sort-group {
    align-items: center;
}

.sort-select {
    padding: 8px 36px 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.sort-select:hover,
.sort-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.results-info {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-state p {
    font-size: 1rem;
}

.empty-state svg {
    margin-bottom: 16px;
    color: var(--text-tertiary);
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.book-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.book-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: var(--accent);
}

.book-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--accent-light));
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.book-card:hover .book-cover img {
    transform: scale(1.08);
}

.book-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.95);
    color: #ffffff;
    backdrop-filter: blur(4px);
}

.book-badge.lang-en { background: rgba(16, 185, 129, 0.95); }
.book-badge.lang-ja { background: rgba(236, 72, 153, 0.95); }
.book-badge.lang-ko { background: rgba(139, 92, 246, 0.95); }
.book-badge.lang-fr { background: rgba(59, 130, 246, 0.95); }
.book-badge.lang-es { background: rgba(249, 115, 22, 0.95); }
.book-badge.lang-de { background: rgba(245, 158, 11, 0.95); }
.book-badge.lang-ru { background: rgba(239, 68, 68, 0.95); }
.book-badge.lang-zh { background: rgba(6, 182, 212, 0.95); }

.book-rating-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 0.8125rem;
    font-weight: 700;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
}

.book-rating-badge svg {
    color: var(--star-color);
}

.book-info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.book-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.book-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.category-tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    background: var(--accent-light);
    color: var(--accent);
}

.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    transition: var(--transition);
}

.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

.back-to-top.show {
    display: flex;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.25s ease;
}

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

.modal-content {
    position: relative;
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--accent);
    color: #ffffff;
    transform: rotate(90deg);
}

.modal-body {
    overflow-y: auto;
    flex: 1;
}

.book-detail-header {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 32px;
    padding: 32px;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
}

.book-detail-cover {
    width: 200px;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

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

.book-detail-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.book-detail-title {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--text-primary);
}

.book-detail-original {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.book-detail-authors {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.book-detail-authors span strong {
    color: var(--text-primary);
}

.book-detail-rating-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.book-detail-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--star-color);
}

.book-detail-rating svg {
    width: 24px;
    height: 24px;
}

.book-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.book-detail-body {
    padding: 32px;
    border-top: 1px solid var(--border-color);
}

.book-detail-section {
    margin-bottom: 24px;
}

.book-detail-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
}

.book-description {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 0.9375rem;
    white-space: pre-line;
}

.book-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px 20px;
}

.book-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.book-field-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.book-field-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
}

.book-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    height: 80px;
    display: flex;
    align-items: center;
}

@media (max-width: 1024px) {
    .book-detail-header {
        padding: 24px;
        gap: 24px;
    }

    .book-detail-body {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .header-inner {
        height: 56px;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .main-content {
        padding: 20px 16px;
    }

    .search-box input {
        padding: 12px 44px 12px 44px;
        font-size: 0.9375rem;
    }

    .filter-section {
        padding: 16px;
        gap: 16px;
    }

    .filter-group {
        gap: 8px;
    }

    .filter-label {
        min-width: auto;
        padding-top: 6px;
        font-size: 0.8125rem;
    }

    .tag {
        padding: 6px 12px;
        font-size: 0.8125rem;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }

    .book-info {
        padding: 12px;
        gap: 6px;
    }

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

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

    .book-detail-header {
        grid-template-columns: 120px 1fr;
        padding: 20px;
        gap: 16px;
    }

    .book-detail-cover {
        width: 120px;
    }

    .book-detail-title {
        font-size: 1.375rem;
    }

    .book-detail-body {
        padding: 20px;
    }

    .book-fields {
        grid-template-columns: repeat(2, 1fr);
    }

    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 42px;
        height: 42px;
    }

    .modal {
        padding: 0;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        display: none;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .book-cover {
        aspect-ratio: 2 / 3;
    }

    .book-detail-header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .book-detail-cover {
        width: 140px;
        margin: 0 auto;
    }

    .book-detail-info {
        align-items: center;
    }

    .book-detail-authors {
        justify-content: center;
    }

    .book-detail-tags {
        justify-content: center;
    }

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

    .book-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .filter-label {
        width: 100%;
        padding-top: 0;
    }
}
