/* ==================== CSS CUSTOM PROPERTIES ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme */
    --bg-primary: #faf9f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f1ee;
    --bg-header: rgba(255, 255, 255, 0.85);

    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #8a8a9a;

    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --accent-light: rgba(108, 92, 231, 0.08);
    --accent-glow: rgba(108, 92, 231, 0.25);

    --star: #f59e0b;
    --star-empty: #e2e0dd;

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.08);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;

    --border: #e8e6e3;
    --border-focus: rgba(108, 92, 231, 0.4);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.1), 0 8px 20px rgba(0, 0, 0, 0.06);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-header: rgba(15, 15, 26, 0.9);

    --text-primary: #e8e6f0;
    --text-secondary: #b0aec0;
    --text-muted: #6b6980;

    --accent: #8b7cf7;
    --accent-hover: #9d93ff;
    --accent-light: rgba(139, 124, 247, 0.1);
    --accent-glow: rgba(139, 124, 247, 0.3);

    --star: #fbbf24;
    --star-empty: #2d2d4a;

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);

    --border: #2d2d4a;
    --border-focus: rgba(139, 124, 247, 0.5);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ==================== BASE ==================== */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-base), color var(--transition-base);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ==================== HEADER ==================== */
.header {
    background: var(--bg-header);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 0;
    transition: background var(--transition-base), border-color var(--transition-base);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.nav {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    align-items: center;
}

.nav-btn {
    background: transparent;
    border: 1.5px solid transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
}

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

.nav-icon {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.theme-icon-light, .theme-icon-dark {
    position: absolute;
    font-size: 1rem;
    transition: var(--transition-base);
}

[data-theme="light"] .theme-icon-light { opacity: 1; }
[data-theme="light"] .theme-icon-dark { opacity: 0; }
[data-theme="dark"] .theme-icon-light { opacity: 0; }
[data-theme="dark"] .theme-icon-dark { opacity: 1; }

/* ==================== MAIN ==================== */
.main {
    flex: 1;
    padding: 2.5rem 0 4rem;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

.page-header {
    margin-bottom: 2.5rem;
    text-align: center;
}

.page-title {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 400;
}

/* ==================== CATALOG CONTROLS ==================== */
.catalog-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.search-box {
    flex: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

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

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

.sort-box select {
    padding: 0.75rem 2rem 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8a9a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: var(--transition-fast);
}

.sort-box select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.books-count-bar {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.count-badge {
    background: var(--accent);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

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

/* ==================== CATALOG GRID ==================== */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    position: relative;
}

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

.book-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    opacity: 0;
    background: linear-gradient(135deg, var(--accent-glow), transparent);
    transition: opacity var(--transition-base);
    pointer-events: none;
    z-index: 1;
}

.book-card:hover::after {
    opacity: 0.3;
}

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

.card-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-slow);
}

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

.card-empty-cover {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--border));
    font-size: 3.5rem;
    position: relative;
    overflow: hidden;
}

.card-empty-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, var(--accent-light));
}

.card-body {
    padding: 1.15rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    z-index: 2;
}

.card-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.card-rating {
    margin-top: auto;
    padding-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.star {
    font-size: 1.15rem;
    color: var(--star);
    line-height: 1;
}

.star.empty {
    color: var(--star-empty);
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    background: var(--bg-secondary);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-xl);
}

.empty-illustration {
    margin-bottom: 1.5rem;
}

.empty-icon {
    font-size: 4rem;
    display: block;
}

.empty-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-text {
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.hidden {
    display: none !important;
}

/* ==================== FORM ==================== */
.add-form {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    max-width: 640px;
    margin: 0 auto;
    transition: var(--transition-base);
}

.form-group {
    margin-bottom: 1.75rem;
}

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

.required {
    color: var(--danger);
    font-weight: 400;
    margin-left: 0.15rem;
}

.form-error {
    display: block;
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.35rem;
    min-height: 1.2em;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.form-group input[type="text"]::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group input.error,
.form-group textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

/* File Upload */
.file-upload {
    width: 100%;
}

.file-upload input[type="file"] {
    display: none;
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    background: var(--bg-primary);
    text-align: center;
    justify-content: center;
}

.file-input-wrapper:hover,
.file-input-wrapper:focus-visible {
    border-color: var(--accent);
    background: var(--accent-light);
}

.file-input-icon {
    font-size: 1.5rem;
}

.file-input-label {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.file-name {
    margin-left: 0.5rem;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.file-upload small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

.cover-preview {
    margin-top: 1rem;
    text-align: center;
    position: relative;
    display: inline-block;
}

.cover-preview img {
    max-width: 200px;
    max-height: 280px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: block;
    margin: 0 auto;
}

.preview-remove {
    position: absolute;
    top: -8px;
    right: calc(50% - 108px);
    background: var(--danger);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.preview-remove:hover {
    transform: scale(1.15);
}

/* Rating Stars (Form) */
.rating {
    display: flex;
    gap: 0.25rem;
    direction: rtl;
}

.rating input[type="radio"] {
    display: none;
}

.star-label {
    font-size: 2.5rem;
    color: var(--star-empty);
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
    user-select: none;
    line-height: 1;
}

.star-label:hover,
.star-label:hover ~ label {
    color: var(--star);
    transform: scale(1.1);
}

.rating input[type="radio"]:checked ~ label {
    color: var(--star);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: 1.5px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}

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

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

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

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}

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

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-back {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 0;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.btn-back:hover {
    color: var(--accent);
}

.btn-submit .btn-loader {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* ==================== BOOK DETAIL ==================== */
.detail-content {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 3rem;
    align-items: start;
    transition: var(--transition-base);
}

.detail-cover {
    text-align: center;
    position: sticky;
    top: 100px;
}

.detail-cover img {
    max-width: 100%;
    max-height: 420px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    object-fit: cover;
}

.detail-meta-top {
    margin-bottom: 1rem;
}

.detail-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.detail-rating {
    display: flex;
    gap: 0.15rem;
}

.detail-rating .star {
    font-size: 1.5rem;
}

.detail-divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

.detail-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-date::before {
    content: '📅';
    font-size: 0.9rem;
}

.detail-description {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    white-space: pre-wrap;
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
}

.detail-loading {
    text-align: center;
    padding: 4rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.detail-not-found {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.detail-not-found h3 {
    font-family: var(--font-serif);
    margin: 1rem 0 1.5rem;
    font-size: 1.25rem;
}

.detail-not-found .empty-icon {
    font-size: 3rem;
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 420px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: modalIn 0.25s ease;
    border: 1.5px solid var(--border);
}

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

.modal-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.modal-content h3 {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-content p em {
    font-size: 0.85rem;
    opacity: 0.8;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-success {
    border-left: 3px solid var(--success);
    color: var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
    color: var(--danger);
}

.toast-info {
    border-left: 3px solid var(--accent);
    color: var(--accent);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ==================== FOOTER ==================== */
.footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
    transition: var(--transition-base);
}

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

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav {
        margin-left: 0;
        order: 3;
        width: 100%;
        justify-content: center;
        gap: 0.25rem;
    }

    .nav-btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
    }

    .page-title {
        font-size: 1.75rem;
    }

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

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

    .add-form {
        padding: 1.5rem;
    }

    .detail-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1.5rem;
    }

    .detail-cover {
        position: static;
        text-align: center;
    }

    .detail-cover img {
        max-height: 300px;
    }

    .detail-title {
        font-size: 1.5rem;
        text-align: center;
    }

    .detail-rating {
        justify-content: center;
    }

    .detail-date {
        justify-content: center;
    }

    .detail-description {
        text-align: left;
    }

    .detail-actions {
        justify-content: center;
    }

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

    .form-actions .btn {
        width: 100%;
    }

    .modal-content {
        padding: 2rem 1.5rem;
    }
}

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

    .page-title {
        font-size: 1.5rem;
    }

    .catalog-grid {
        grid-template-columns: 1fr;
    }

    .book-card {
        max-width: 100%;
    }

    .card-cover,
    .card-empty-cover {
        height: 180px;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ==================== ACCESSIBILITY ==================== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
