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

html {
    touch-action: manipulation;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 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: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --reading-color: #6366f1;
    --tbr-color: #8b5cf6;
}

[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: #312e81;
    --secondary-color: #94a3b8;
    --success-color: #34d399;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --background: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 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.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
    --reading-color: #818cf8;
    --tbr-color: #a78bfa;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    touch-action: manipulation;
}

body:not([data-theme="dark"]) {
    background: linear-gradient(to bottom right, #f8fafc 0%, #e0e7ff 100%);
}

[data-theme="dark"] body {
    background: linear-gradient(to bottom right, #0f172a 0%, #1e1b4b 100%);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

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

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: background 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .header {
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid var(--border-color);
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: background 0.3s ease;
}

[data-theme="dark"] .logo {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-1px);
}

[data-theme="dark"] .nav-links a:hover,
[data-theme="dark"] .nav-links a.active {
    background: rgba(129, 140, 248, 0.15);
    color: var(--primary-color);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

[data-theme="dark"] .btn-icon:hover {
    background: rgba(129, 140, 248, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #7c3aed 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--background);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

[data-theme="dark"] .btn-outline {
    border-color: rgba(148, 163, 184, 0.3);
}

[data-theme="dark"] .btn-outline:hover {
    background: rgba(129, 140, 248, 0.1);
    border-color: var(--primary-color);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.625rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    font-family: inherit;
    touch-action: manipulation;
}

[data-theme="dark"] .form-control {
    background: var(--card-bg);
    color: var(--text-primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .auth-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(51, 65, 85, 0.95) 100%);
    border-color: rgba(148, 163, 184, 0.2);
}

@media (max-width: 768px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-card p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.auth-card .btn {
    width: 100%;
    margin-top: 1rem;
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .stat-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(51, 65, 85, 0.6) 100%);
    border-color: rgba(148, 163, 184, 0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), #a855f7, #ec4899);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
    display: inline-block;
    animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary-color) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .value.money {
    background: linear-gradient(135deg, var(--success-color) 0%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Library Controls */
.library-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    margin-top: 2rem;
    align-items: center;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .library-controls {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(51, 65, 85, 0.6) 100%);
    border-color: rgba(148, 163, 184, 0.1);
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box input {
    padding-left: 1rem;
}

.search-box input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .search-box input {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(148, 163, 184, 0.2);
}

.filter-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
}

[data-theme="dark"] .filter-group select {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    border-color: rgba(148, 163, 184, 0.2);
}

.filter-group select:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Book Grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.book-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

[data-theme="dark"] .book-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(51, 65, 85, 0.7) 100%);
    border-color: rgba(148, 163, 184, 0.15);
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border-color);
    transition: background 0.3s;
}

.book-card.status-read::before {
    background: linear-gradient(90deg, var(--success-color), #34d399);
}

.book-card.status-reading::before {
    background: linear-gradient(90deg, var(--reading-color), #818cf8);
}

.book-card.status-unread::before {
    background: linear-gradient(90deg, var(--warning-color), #fbbf24);
}

.book-card.status-tbr::before {
    background: linear-gradient(90deg, var(--tbr-color), #c084fc);
}

.book-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

.book-cover-wrapper {
    position: relative;
    overflow: hidden;
}

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: var(--background);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.book-cover-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    position: relative;
    overflow: hidden;
}

.book-cover-placeholder::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

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

.book-status-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.book-status-badge.read {
    background: rgba(16, 185, 129, 0.95);
    color: white;
}

.book-status-badge.unread {
    background: rgba(245, 158, 11, 0.95);
    color: white;
}

.book-status-badge.reading {
    background: rgba(99, 102, 241, 0.95);
    color: white;
}

.book-status-badge.tbr {
    background: rgba(139, 92, 246, 0.95);
    color: white;
}

.book-info {
    padding: 1.25rem;
    background: linear-gradient(to bottom, transparent 0%, rgba(255,255,255,0.5) 100%);
}

[data-theme="dark"] .book-info {
    background: linear-gradient(to bottom, transparent 0%, rgba(30, 41, 59, 0.5) 100%);
}

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

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

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

.book-rating {
    color: #f59e0b;
    font-size: 0.875rem;
}

.book-genre {
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: var(--background);
    border-radius: 9999px;
}

.book-price {
    color: var(--success-color);
    font-weight: 700;
    font-size: 0.9rem;
}

.book-status {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.book-status.read {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.book-status.unread {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #78350f;
    border: 1px solid #fcd34d;
}

/* Scanner Page */
.scanner-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 768px) {
    .scanner-container {
        padding: 2rem;
    }
}

.scanner-preview {
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xl);
    border: 3px solid var(--primary-color);
    position: relative;
}

.scanner-preview::after {
    content: 'Position barcode in frame';
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    pointer-events: none;
}

#reader {
    width: 100%;
    height: 100%;
}

.scanner-result {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    animation: slideUp 0.3s ease-out;
}

[data-theme="dark"] .scanner-result {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(51, 65, 85, 0.7) 100%);
    border-color: rgba(148, 163, 184, 0.2);
}

.scanner-result .btn {
    width: 100%;
    margin-top: 0.5rem;
}

@media (min-width: 768px) {
    .scanner-result .btn {
        width: auto;
    }
}

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

.book-preview {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-lg);
}

[data-theme="dark"] .book-preview {
    background: rgba(15, 23, 42, 0.5);
}

.book-preview img {
    width: 80px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

@media (min-width: 768px) {
    .book-preview img {
        width: 100px;
        height: 150px;
    }
}

.book-preview-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.book-preview-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

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

/* Modal styles - for library.html structure (modal-overlay > modal) */
.modal-overlay .modal,
.modal {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* For collections.html structure (modal with hidden class) */
.modal:not(.modal-overlay .modal) {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .modal:not(.modal-overlay .modal) {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-overlay .modal,
[data-theme="dark"] .modal-content {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(51, 65, 85, 0.95) 100%);
    border-color: rgba(148, 163, 184, 0.2);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--background);
    transform: rotate(90deg);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Alert */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease-out;
}

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

.alert-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #991b1b;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .alert-error {
    background: linear-gradient(135deg, rgba(254, 226, 226, 0.1) 0%, rgba(254, 202, 202, 0.15) 100%);
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.3);
}

.alert-success {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #166534;
    border: 1px solid #bbf7d0;
}

[data-theme="dark"] .alert-success {
    background: linear-gradient(135deg, rgba(220, 252, 231, 0.1) 0%, rgba(187, 247, 208, 0.15) 100%);
    color: #86efac;
    border-color: rgba(74, 222, 128, 0.3);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem 0;
}

[data-theme="dark"] .empty-state h3 {
    color: var(--text-primary);
}

.empty-state p {
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header-content {
        gap: 1rem;
    }

    .menu-toggle {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--card-bg);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow-lg);
        border-bottom: 1px solid var(--border-color);
        gap: 0;
        display: none;
        z-index: 99;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a,
    .nav-links .btn-icon {
        width: 100%;
        text-align: left;
        padding: 1rem;
        border-radius: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links a:last-child,
    .nav-links .btn-icon {
        border-bottom: none;
    }

    .library-controls {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .filter-group {
        width: 100%;
        flex-wrap: wrap;
    }

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

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem 0.5rem;
    }
    
    .stat-card h3 {
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }
    
    .stat-card .value {
        font-size: 1.25rem;
    }
    
    .stat-card .stat-icon {
        font-size: 1.25rem;
    }
    
    .stat-card.money .value {
        font-size: 1rem;
    }
    
    /* Mobile-specific book card styles */
    .book-card {
        font-size: 0.9rem;
    }
    
    .book-title {
        font-size: 0.95rem;
        line-height: 1.3;
    }
    
    .book-author {
        font-size: 0.8rem;
        margin-top: 0.25rem;
    }
    
    .book-series {
        font-size: 0.75rem !important;
        margin-top: 0.2rem !important;
    }
    
    .book-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
        padding-top: 0.375rem;
        font-size: 0.8rem;
    }
    
    .book-genre {
        font-size: 0.7rem;
        padding: 0.125rem 0.375rem;
    }
    
    .book-rating {
        font-size: 0.8rem;
    }
    
    .book-price {
        font-size: 0.8rem;
    }
    
    /* Mobile quick progress */
    .quick-progress {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.625rem;
        margin-top: 0.5rem;
    }
    
    .progress-input {
        width: 100%;
        padding: 0.5rem;
        font-size: 1rem;
        text-align: left;
    }
    
    .progress-total {
        font-size: 1rem;
        text-align: center;
    }
    
    .btn-progress {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Mobile bulk actions */
    .bulk-actions-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .bulk-actions-bar > div {
        width: 100%;
        justify-content: center;
    }
}

/* Hide class */
.hidden {
    display: none !important;
}

/* Pull to refresh */
.pull-to-refresh {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--card-bg);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 99;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .pull-to-refresh {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.2);
}

.pull-to-refresh.visible {
    transform: translateX(-50%) translateY(0);
}

.pull-to-refresh .spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Bulk Actions */
.bulk-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .bulk-actions-bar {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.bulk-actions-bar.hidden {
    display: none;
}

.book-select-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .book-select-checkbox {
    background: rgba(30, 41, 59, 0.9);
}

.book-select-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* List View */
.book-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.book-list .book-card {
    display: flex;
    flex-direction: row;
    padding: 1rem;
}

.book-list .book-cover-wrapper {
    width: 80px;
    height: 120px;
    flex-shrink: 0;
    margin-right: 1rem;
}

.book-list .book-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Button sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Quick Progress Update */
.quick-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

[data-theme="dark"] .quick-progress {
    background: rgba(51, 65, 85, 0.5);
}

.progress-input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: center;
}

.progress-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.progress-total {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-progress {
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-progress:hover {
    background: var(--primary-hover);
}

.btn-progress:active {
    transform: scale(0.95);
}

/* Account Settings Page */
.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .settings-section {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.settings-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

@media (min-width: 768px) {
    .info-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.info-item label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.info-item p {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 600;
}

.danger-zone {
    border: 2px solid var(--danger-color);
}

.danger-zone h2 {
    color: var(--danger-color);
}

/* Collections Page */
.collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.collection-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.collection-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.collection-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.collection-icon {
    flex-shrink: 0;
}

.collection-info {
    flex: 1;
}

.collection-info h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0 0 0.5rem 0;
}

.collection-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.collection-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
}

.collection-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.icon-btn, .color-btn {
    width: 3rem;
    height: 3rem;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover, .color-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.color-btn {
    border-width: 3px;
}

@media (max-width: 768px) {
    .collections-grid {
        grid-template-columns: 1fr;
    }
    
    .collection-actions {
        flex-direction: column;
    }
    
    .collection-actions .btn {
        width: 100%;
    }
}
