@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #f0f2f8;
    --surface: #ffffff;
    --card: #ffffff;
    --primary: #5b6ef7;
    --primary-light: #818cf8;
    --primary-soft: #eef0ff;
    --primary-dark: #4338ca;
    --accent: #8b5cf6;
    --text: #1a1a2e;
    --text-sec: #4a4a6a;
    --text-dim: #8e8ea0;
    --border: #e8e8f0;
    --input-bg: #f5f5fa;
    --danger: #ef4444;
    --reading-bg: #fff8e1; --reading-text: #b8860b;
    --want-bg: #f3edff; --want-text: #6d28d9;
    --done-bg: #e8f5e9; --done-text: #2e7d32;
    --lent-bg: #fce4ec; --lent-text: #c62828;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.04);
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
    --grad: linear-gradient(135deg, #5b6ef7 0%, #8b5cf6 50%, #a78bfa 100%);
    --grad-text: linear-gradient(135deg, #5b6ef7 0%, #8b5cf6 50%, #a78bfa 100%);
}

[data-theme="dark"] {
    --bg: #0e0e18;
    --surface: #1a1a2e;
    --card: #222240;
    --primary: #818cf8;
    --primary-light: #a5b4fc;
    --primary-soft: #2a2850;
    --primary-dark: #6366f1;
    --text: #eaeaf4;
    --text-sec: #b0b0cc;
    --text-dim: #6e6e90;
    --border: #30304a;
    --input-bg: #161628;
    --reading-bg: #3d2e00; --reading-text: #fbbf24;
    --want-bg: #2e1065; --want-text: #c4b5fd;
    --done-bg: #0a3d1a; --done-text: #6ee7b7;
    --lent-bg: #4c0519; --lent-text: #fda4af;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.35);
    --grad: linear-gradient(135deg, #2d2a5e 0%, #3b2d6b 50%, #4a3578 100%);
    --grad-text: linear-gradient(135deg, #a5b4fc 0%, #c4b5fd 50%, #e0aaff 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 5rem;
    transition: background 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */
header {
    background: var(--grad);
    padding: 0.8rem 1rem 0.7rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 20px rgba(91,110,247,0.25);
}
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}
header h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.3px;
}
.header-right { display: flex; gap: 0.3rem; }
.icon-btn {
    background: rgba(255,255,255,0.18);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    backdrop-filter: blur(8px);
    transition: background 0.15s, transform 0.15s;
}
.icon-btn:active { background: rgba(255,255,255,0.35); transform: scale(0.92); }

.header-actions { display: flex; gap: 0.5rem; }
#search {
    flex: 1;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 50px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 0.88rem;
    font-weight: 500;
    outline: none;
    font-family: inherit;
}
#search::placeholder { color: rgba(255,255,255,0.55); }
#search:focus { background: rgba(255,255,255,0.3); box-shadow: 0 0 0 3px rgba(255,255,255,0.12); }

.btn-add {
    background: white;
    color: var(--primary);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    transition: transform 0.15s;
    flex-shrink: 0;
}
.btn-add:active { transform: scale(0.9); }

/* ===== TOOLBAR ===== */
.toolbar { padding: 0 1rem; }
.tabs {
    display: flex;
    gap: 0.4rem;
    padding: 0.7rem 0 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: 0.5rem 1.1rem;
    border: none;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 50px;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    font-family: inherit;
}
.tab:active { transform: scale(0.95); }
.tab.active {
    background: var(--grad);
    color: white;
    box-shadow: 0 3px 12px rgba(91,110,247,0.3);
}

.toolbar-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    padding-bottom: 0.4rem;
}
.toolbar-row select {
    flex: 1;
    padding: 0.45rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.random-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
    flex-shrink: 0;
}
.random-btn:active { transform: scale(0.88) rotate(180deg); }

/* ===== ISBN ===== */
.isbn-search { display: flex; gap: 0.4rem; margin-top: 0.3rem; margin-bottom: 0.3rem; }
.isbn-search input {
    flex: 1; padding: 0.7rem 0.9rem; border: 2px solid var(--border); border-radius: var(--radius-sm);
    background: var(--input-bg); color: var(--text); font-size: 0.92rem; font-weight: 500;
    outline: none; font-family: inherit;
}
.isbn-search input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(91,110,247,0.08); }
.isbn-btn, .isbn-scan-btn {
    width: 44px; height: 44px; border-radius: var(--radius-sm); border: none;
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.isbn-btn { background: var(--grad); color: white; box-shadow: 0 2px 8px rgba(91,110,247,0.25); }
.isbn-btn:active { transform: scale(0.92); }
.isbn-scan-btn { background: var(--input-bg); color: var(--text-dim); border: 2px solid var(--border); }
.isbn-scan-btn:active { transform: scale(0.92); }
#isbn-status { font-size: 0.78rem; font-weight: 600; margin-bottom: 0.3rem; min-height: 1.1em; }
#isbn-status.loading { color: var(--primary); }
#isbn-status.success { color: var(--done-text); }
#isbn-status.error { color: var(--danger); }

/* ===== FAB ===== */
.fab {
    position: fixed;
    bottom: 5rem;
    right: 1rem;
    width: 54px; height: 54px;
    border-radius: 16px;
    background: var(--grad);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(91,110,247,0.35);
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }

/* ===== BOTTOM NAV ===== */
.nav-bar {
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.4rem 0 env(safe-area-inset-bottom, 0.35rem);
    z-index: 20;
    backdrop-filter: blur(20px);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
    padding: 0.25rem 1.2rem;
    border: none; background: none; color: var(--text-dim);
    font-size: 0.65rem; font-weight: 700; cursor: pointer;
    text-decoration: none; text-transform: uppercase; letter-spacing: 0.3px;
    transition: color 0.2s;
}
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 22px; height: 22px; stroke-linecap: round; stroke-linejoin: round; }

/* ===== BOOK GRID ===== */
main#books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
    padding: 0.5rem 1rem 1rem;
}

/* Shelf view */
main#books-grid.shelf-view {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 1rem;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0, transparent 230px,
            #8B6914 230px, #8B6914 240px,
            #a07818 240px, #a07818 244px
        );
    align-items: flex-end;
}
[data-theme="dark"] main#books-grid.shelf-view {
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0, transparent 230px,
            #4a3510 230px, #4a3510 240px,
            #5a4218 240px, #5a4218 244px
        );
}
.shelf-view .book-card {
    width: 60px;
    border-radius: 3px;
    margin: 0 2px;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
    height: 220px;
    align-self: flex-end;
}
.shelf-view .book-card .book-cover { aspect-ratio: auto; height: 100%; }
.shelf-view .book-card .book-cover-placeholder { aspect-ratio: auto; height: 100%; font-size: 1.5rem; }
.shelf-view .book-card .book-info,
.shelf-view .book-card .book-badge,
.shelf-view .book-card .book-lent-badge { display: none; }

.book-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s;
    position: relative;
    box-shadow: var(--shadow);
}
.book-card:active { transform: scale(0.97); }

.book-cover { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.book-cover-placeholder {
    width: 100%; aspect-ratio: 2/3;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem;
}
.book-cover-placeholder svg { width: 40px; height: 40px; opacity: 0.2; }

.book-info { padding: 0.5rem 0.6rem 0.6rem; }
.book-title { font-size: 0.78rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.1rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { font-size: 0.7rem; color: var(--text-dim); font-weight: 500; margin-bottom: 0.1rem; }
.book-meta { font-size: 0.62rem; color: var(--text-dim); font-weight: 500; margin-top: 0.1rem; }
.book-series { font-size: 0.62rem; color: var(--accent); font-weight: 700; margin-top: 0.1rem; }
.book-tags { display: flex; flex-wrap: wrap; gap: 0.12rem; margin-top: 0.15rem; }
.book-tag { font-size: 0.58rem; padding: 0.08rem 0.4rem; border-radius: 50px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.book-badge {
    position: absolute; top: 0.4rem; right: 0.4rem;
    padding: 0.15rem 0.5rem; border-radius: 50px;
    font-size: 0.58rem; font-weight: 800; backdrop-filter: blur(8px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.badge-reading { background: var(--reading-bg); color: var(--reading-text); }
.badge-done { background: var(--done-bg); color: var(--done-text); }
.badge-want { background: var(--want-bg); color: var(--want-text); }
.book-lent-badge {
    position: absolute; top: 0.4rem; left: 0.4rem;
    padding: 0.15rem 0.4rem; border-radius: 50px;
    font-size: 0.56rem; font-weight: 800;
    background: var(--lent-bg); color: var(--lent-text);
    backdrop-filter: blur(8px);
}
.book-priority { position: absolute; bottom: 0.4rem; right: 0.4rem; font-size: 0.6rem; }

/* ===== VIEW MODAL ===== */
.view-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.6rem; }
.view-header h2 { margin-bottom: 0; flex: 1; padding-right: 0.5rem; }
.view-edit-btn {
    background: var(--primary-soft); border: none; border-radius: 50%;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--primary); flex-shrink: 0;
    transition: transform 0.15s;
}
.view-edit-btn:active { transform: scale(0.88); }
.view-cover-wrap { margin: -1.5rem -1.5rem 1rem; position: relative; overflow: hidden; }
.view-cover { width: 100%; max-height: 300px; object-fit: cover; display: block; }
.view-cover-gradient { position: absolute; bottom: 0; left: 0; right: 0; height: 80px; background: linear-gradient(to top, var(--surface), transparent); }
.view-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.55rem 0; border-bottom: 1px solid var(--border); gap: 0.5rem;
}
.view-row:last-child { border-bottom: none; }
.view-row .vr-label { color: var(--text-dim); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0; }
.view-row .vr-value { font-weight: 600; text-align: right; color: var(--text-sec); font-size: 0.85rem; }
.view-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: flex-end; }
.view-tag { font-size: 0.7rem; padding: 0.18rem 0.6rem; border-radius: 50px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.view-status-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 50px; font-size: 0.75rem; font-weight: 800; }
.view-status-group { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.view-status-btn {
    padding: 0.3rem 0.7rem; border-radius: 50px; font-size: 0.72rem; font-weight: 700;
    border: 2px solid var(--border); background: var(--surface); color: var(--text-dim);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.view-status-btn:active { transform: scale(0.95); }
.view-status-btn.active.status-want { background: var(--want-bg); color: var(--want-text); border-color: transparent; }
.view-status-btn.active.status-reading { background: var(--reading-bg); color: var(--reading-text); border-color: transparent; }
.view-status-btn.active.status-done { background: var(--done-bg); color: var(--done-text); border-color: transparent; }
.view-description { margin: 0.7rem 0 0; padding: 0; font-size: 0.84rem; line-height: 1.6; color: var(--text-sec); white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; }
.view-notes { background: var(--input-bg); border-radius: var(--radius-sm); padding: 0.75rem; margin: 0.6rem 0; font-size: 0.85rem; line-height: 1.5; color: var(--text-sec); font-style: italic; white-space: pre-wrap; }
.view-lent-history { margin-top: 0.6rem; }
.view-lent-history h4 { font-size: 0.72rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; margin-bottom: 0.3rem; }
.lent-entry { font-size: 0.8rem; padding: 0.3rem 0; color: var(--text-sec); border-bottom: 1px solid var(--border); }
.lent-entry:last-child { border: none; }
.view-actions { display: flex; gap: 0.6rem; margin-top: 1rem; }
.view-actions .btn-secondary, .view-actions .btn-primary { flex: 1; padding: 0.7rem; font-weight: 700; font-size: 0.88rem; font-family: inherit; }
.view-actions .btn-primary {
    background: var(--grad); color: white; border: none; border-radius: 50px; cursor: pointer;
    box-shadow: 0 3px 12px rgba(91,110,247,0.25);
}
.view-actions .btn-primary:active { transform: scale(0.97); }

/* ===== MODAL ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(6px);
    z-index: 100; justify-content: center; align-items: flex-end;
}
.modal-overlay.open { display: flex; }
body.modal-open { overflow: hidden; }
.modal {
    background: var(--surface); border-radius: 24px 24px 0 0;
    padding: 0.6rem 1.3rem 1.3rem; width: 100%; max-width: 480px; max-height: 92vh;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: none;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.08);
}
.modal::-webkit-scrollbar { display: none; }
.modal::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 4px;
    margin: 0 auto 0.8rem;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }

.modal h2 { margin-bottom: 0.8rem; font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.modal label, .field-label { display: block; margin-bottom: 0.7rem; font-size: 0.7rem; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.modal input[type="text"], .modal input[type="date"], .modal select, .modal textarea {
    display: block; width: 100%; margin-top: 0.25rem; padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--input-bg); color: var(--text);
    font-size: 0.9rem; font-weight: 500; outline: none; font-family: inherit;
    transition: border 0.15s, box-shadow 0.15s;
}
.modal textarea { resize: vertical; min-height: 56px; line-height: 1.5; }
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(91,110,247,0.08); }
.form-row { display: flex; gap: 0.5rem; }
.flex1 { flex: 1; }
.w80 { width: 80px; flex-shrink: 0; }

.cover-upload-area { margin-top: 0.4rem; display: flex; gap: 0.5rem; }
.cover-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    padding: 0.7rem 0.4rem; border: 2px dashed var(--border); border-radius: var(--radius-sm);
    background: var(--input-bg); cursor: pointer;
    font-size: 0.68rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.4px;
    transition: transform 0.15s;
}
.cover-btn:active { transform: scale(0.96); }
.cover-btn svg { width: 24px; height: 24px; opacity: 0.35; }
.cover-btn input { display: none; }

.tags-selector { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; margin-bottom: 0.4rem; }
.tag-chip {
    padding: 0.32rem 0.75rem; border-radius: 50px;
    border: 1.5px solid var(--border); background: var(--input-bg);
    color: var(--text-dim); font-size: 0.75rem; font-weight: 600;
    cursor: pointer; user-select: none; transition: all 0.15s;
}
.tag-chip.selected { background: var(--primary-soft); border-color: var(--primary-light); color: var(--primary); }
.tag-chip:active { transform: scale(0.94); }

.rating-selector, .priority-selector { display: flex; gap: 0.4rem; margin-top: 0.3rem; margin-bottom: 0.4rem; }
.star-btn, .prio-btn { background: none; border: none; font-size: 1.7rem; cursor: pointer; padding: 0.1rem; filter: grayscale(1) opacity(0.2); transition: all 0.12s; }
.star-btn.active, .prio-btn.active { filter: none; }
.star-btn:active, .prio-btn:active { transform: scale(1.2); }

#cover-preview { margin: 0.4rem 0; }
#cover-preview img { max-height: 120px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }

.form-actions-sticky { position: sticky; bottom: -1.3rem; background: var(--surface); padding: 0.6rem 0; z-index: 2; }
.form-actions { display: flex; gap: 0.6rem; }
.btn-secondary {
    flex: 1; padding: 0.7rem; border: 1.5px solid var(--border); border-radius: 50px;
    background: transparent; color: var(--text); font-size: 0.88rem; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: transform 0.15s;
}
.btn-secondary:active { transform: scale(0.97); }
.form-actions .btn-primary {
    flex: 1; padding: 0.7rem; background: var(--grad); color: white;
    border: none; border-radius: 50px; font-weight: 700; font-size: 0.88rem; cursor: pointer;
    box-shadow: 0 3px 12px rgba(91,110,247,0.25); font-family: inherit;
    transition: transform 0.15s;
}
.form-actions .btn-primary:active { transform: scale(0.97); }

.btn-danger {
    width: 100%; margin-top: 0.6rem; padding: 0.65rem;
    border: 1.5px solid var(--danger); border-radius: 50px;
    background: transparent; color: var(--danger);
    font-size: 0.82rem; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.btn-danger:active { background: var(--danger); color: white; }

.section-divider { border: none; border-top: 1px solid var(--border); margin: 0.7rem 0; }

#empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-dim); }
#empty-state svg { width: 56px; height: 56px; opacity: 0.18; margin-bottom: 0.7rem; stroke-linecap: round; stroke-linejoin: round; }
#empty-state p { margin-bottom: 0.3rem; font-weight: 500; }
#empty-state p:first-of-type { font-size: 1.05rem; font-weight: 700; color: var(--text-sec); }

/* Random */
.random-modal { text-align: center; }
.random-modal h2 { text-align: center; font-size: 1.05rem; }
.random-cover { width: 130px; height: 195px; object-fit: cover; border-radius: var(--radius-sm); margin: 0.8rem auto; box-shadow: var(--shadow); }
.random-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 0.15rem; }
.random-author { font-size: 0.82rem; color: var(--text-dim); }

/* Scanner & Camera */
.scanner-overlay { display:none; position:fixed; inset:0; background:black; z-index:200; flex-direction:column; }
.scanner-overlay.open { display:flex; }
.scanner-video { flex:1; object-fit:cover; width:100%; }
.scanner-close { position:absolute; top:1rem; right:1rem; width:44px; height:44px; border-radius:50%; background:rgba(0,0,0,0.5); border:none; color:white; font-size:1.4rem; cursor:pointer; z-index:201; display:flex; align-items:center; justify-content:center; }
.scanner-frame { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:260px; height:160px; border:3px solid rgba(255,255,255,0.6); border-radius:16px; box-shadow:0 0 0 9999px rgba(0,0,0,0.4); }
.scanner-hint { position:absolute; bottom:7rem; left:0; right:0; text-align:center; color:white; font-size:0.88rem; font-weight:600; text-shadow:0 1px 4px rgba(0,0,0,0.5); }
.camera-shutter { position:absolute; bottom:2rem; left:50%; transform:translateX(-50%); width:68px; height:68px; border-radius:50%; background:white; border:5px solid rgba(255,255,255,0.4); cursor:pointer; box-shadow:0 4px 20px rgba(0,0,0,0.3); z-index:201; }
.camera-shutter:active { transform:translateX(-50%) scale(0.88); background:#e0e0e0; }

/* ===== STATS ===== */
.stats-page { padding: 1rem; padding-bottom: 5rem; }
.stats-header {
    background: var(--grad); padding: 1.3rem; border-radius: var(--radius);
    color: white; margin-bottom: 1rem; text-align: center;
    box-shadow: 0 4px 20px rgba(91,110,247,0.25);
    position: relative; overflow: hidden;
}
.stats-header::before { content:''; position:absolute; top:-50%; right:-30%; width:180px; height:180px; border-radius:50%; background:rgba(255,255,255,0.08); }
.stats-header h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 0.15rem; position: relative; }
.stats-header p { opacity: 0.8; font-weight: 500; font-size: 0.82rem; position: relative; }

.stats-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 0.9rem 0.5rem; text-align: center; box-shadow: var(--shadow); transition: transform 0.15s; }
.stat-card:active { transform: scale(0.97); }
.stat-card .number { font-size: 1.8rem; font-weight: 900; background: var(--grad-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-card .label { font-size: 0.62rem; color: var(--text-dim); font-weight: 700; margin-top: 0.15rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* Goal */
.goal-section { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.8rem; box-shadow: var(--shadow); }
.goal-section h3 { font-size: 0.8rem; font-weight: 800; margin-bottom: 0.7rem; color: var(--primary); text-transform: uppercase; }
.goal-bar-wrap { height: 30px; background: var(--input-bg); border-radius: 50px; overflow: hidden; position: relative; margin-bottom: 0.5rem; }
.goal-bar-fill { height: 100%; background: var(--grad); border-radius: 50px; transition: width 0.8s cubic-bezier(0.16,1,0.3,1); display: flex; align-items: center; justify-content: flex-end; padding-right: 0.6rem; font-size: 0.72rem; font-weight: 800; color: white; min-width: 36px; }
.goal-text { font-size: 0.82rem; font-weight: 600; color: var(--text-sec); text-align: center; }
.goal-form { display: flex; gap: 0.4rem; margin-top: 0.7rem; }
.goal-form input { flex: 1; padding: 0.45rem 0.7rem; border: 1.5px solid var(--border); border-radius: 10px; background: var(--input-bg); color: var(--text); font-size: 0.88rem; font-family: inherit; outline: none; }
.goal-form button { padding: 0.45rem 0.9rem; background: var(--grad); color: white; border: none; border-radius: 10px; font-weight: 700; font-size: 0.78rem; cursor: pointer; font-family: inherit; }

.stats-section { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.8rem; box-shadow: var(--shadow); }
.stats-section h3 { font-size: 0.8rem; font-weight: 800; margin-bottom: 0.7rem; color: var(--primary); text-transform: uppercase; }
.genre-bar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
.genre-bar .name { font-size: 0.72rem; font-weight: 600; min-width: 80px; text-align: right; color: var(--text-sec); }
.genre-bar .bar-wrap { flex: 1; height: 22px; background: var(--input-bg); border-radius: 50px; overflow: hidden; }
.genre-bar .bar-fill { height: 100%; border-radius: 50px; min-width: 24px; display: flex; align-items: center; justify-content: flex-end; padding-right: 0.4rem; font-size: 0.68rem; font-weight: 800; color: white; }
.month-row { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; color: var(--text-sec); }
.month-row:last-child { border: none; }
.month-row .count { font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 0.12rem 0.5rem; border-radius: 50px; font-size: 0.72rem; }
.export-btn { display: block; margin: 0.8rem auto 0; padding: 0.65rem 1.4rem; background: var(--grad); color: white; border: none; border-radius: 50px; font-weight: 700; font-size: 0.82rem; cursor: pointer; font-family: inherit; box-shadow: 0 3px 12px rgba(91,110,247,0.25); text-decoration: none; text-align: center; }
.export-btn:active { transform: scale(0.97); }

/* ===== YEARLY ===== */
.yearly-page { padding: 1rem; padding-bottom: 5rem; }
.yearly-hero {
    background: var(--grad); border-radius: var(--radius); padding: 1.8rem 1.3rem;
    text-align: center; color: white; margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(91,110,247,0.25);
}
.yearly-hero .big-num { font-size: 3.5rem; font-weight: 900; line-height: 1; }
.yearly-hero .big-label { font-size: 0.95rem; font-weight: 600; opacity: 0.85; margin-top: 0.25rem; }
.yearly-row { display: flex; gap: 0.7rem; margin-bottom: 0.8rem; overflow-x: auto; justify-content: center; }
.yearly-mini { text-align: center; flex-shrink: 0; }
.yearly-mini .val { font-size: 1.3rem; font-weight: 900; color: var(--primary); }
.yearly-mini .lbl { font-size: 0.62rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }
.yearly-best { background: var(--surface); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 0.8rem; display: flex; gap: 0.8rem; align-items: center; }
.yearly-best img { width: 65px; height: 97px; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow-sm); }
.yearly-best-info .yb-title { font-weight: 800; font-size: 0.92rem; }
.yearly-best-info .yb-author { font-size: 0.78rem; color: var(--text-dim); }
.yearly-best-info .yb-rating { font-size: 0.82rem; margin-top: 0.25rem; }
.yearly-month-chart { background: var(--surface); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 0.8rem; }
.yearly-month-chart h3 { font-size: 0.8rem; font-weight: 800; margin-bottom: 0.7rem; color: var(--primary); text-transform: uppercase; }
.chart-bars { display: flex; align-items: flex-end; gap: 0.25rem; height: 110px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; border-radius: 5px 5px 0 0; min-height: 4px; transition: height 0.5s; }
.chart-bar-label { font-size: 0.55rem; font-weight: 700; color: var(--text-dim); }
.chart-bar-val { font-size: 0.58rem; font-weight: 800; color: var(--primary); }
.year-selector { display: flex; gap: 0.4rem; justify-content: center; margin-bottom: 0.8rem; flex-wrap: wrap; }
.year-btn { padding: 0.4rem 0.9rem; border: 1.5px solid var(--border); border-radius: 50px; background: var(--surface); color: var(--text); font-weight: 700; font-size: 0.82rem; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.year-btn:active { transform: scale(0.95); }
.year-btn.active { background: var(--grad); color: white; border-color: transparent; }

/* Clickable elements */
.clickable { cursor: pointer; transition: transform 0.12s; }
.clickable:active { transform: scale(0.97); }
.stat-card.clickable:active { box-shadow: 0 2px 10px rgba(91,110,247,0.15); }
.genre-bar.clickable:active { background: var(--primary-soft); border-radius: 8px; }
.month-row.clickable:active { background: var(--primary-soft); border-radius: 8px; }
.month-row.clickable, .genre-bar.clickable { padding: 0.3rem 0.5rem; margin: -0.3rem -0.5rem; }

/* Book list modal */
.book-list-content { max-height: 60vh; overflow-y: auto; overflow-x: hidden; margin: 0.4rem 0; scrollbar-width: none; }
.book-list-content::-webkit-scrollbar { display: none; }
.list-book-item { display: flex; gap: 0.7rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s; }
.list-book-item:active { background: var(--primary-soft); border-radius: 8px; }
.list-book-item:last-child { border-bottom: none; }
.list-book-cover { flex-shrink: 0; width: 42px; height: 63px; border-radius: 6px; overflow: hidden; }
.list-book-cover img { width: 100%; height: 100%; object-fit: cover; }
.list-no-cover { width: 42px; height: 63px; background: var(--primary-soft); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.list-book-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.list-book-title { font-weight: 700; font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-book-author { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-book-meta { font-size: 0.65rem; color: var(--text-dim); margin-top: 0.12rem; }

@media (min-width: 600px) {
    main#books-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
    .modal { border-radius: 24px; align-self: center; }
    .modal-overlay { align-items: center; }
    .stats-cards { grid-template-columns: repeat(4, 1fr); }
}
