/* Dev self-test banner (opt-in) */
.dev-check-banner{position:fixed;left:16px;right:16px;bottom:16px;z-index:9999;display:flex;align-items:center;justify-content:space-between;background:rgba(20,20,30,0.9);color:#fff;border:1px solid rgba(255,255,255,0.15);border-radius:10px;padding:8px 12px;backdrop-filter:blur(6px);box-shadow:0 8px 24px rgba(0,0,0,0.25)}
.dev-check-banner.dcb-ok{background:linear-gradient(135deg, rgba(17,95,45,0.92), rgba(14,74,35,0.92))}
.dev-check-banner.dcb-bad{background:linear-gradient(135deg, rgba(125,30,30,0.92), rgba(95,18,18,0.92))}
.dev-check-banner .dcb-left{font-weight:600}
.dev-check-banner .dcb-center{opacity:0.9}
.dev-check-banner .dcb-right{display:flex;gap:6px}
.dev-check-banner .dcb-btn{background:rgba(255,255,255,0.12);color:#fff;border:1px solid rgba(255,255,255,0.2);border-radius:6px;padding:4px 8px;cursor:pointer}
.dev-check-banner .dcb-btn:hover{background:rgba(255,255,255,0.18)}
.dev-check-panel{position:fixed;left:16px;right:16px;bottom:72px;max-height:40vh;overflow:auto;background:rgba(0,0,0,0.75);color:#fff;padding:10px;border-radius:10px;border:1px solid rgba(255,255,255,0.15);display:none;z-index:9998}
.dev-check-panel.show{display:block}
.dev-check-panel .dcr{padding:4px 6px;border-radius:6px;margin:2px 0}
.dev-check-panel .dcr.ok{background:rgba(0,160,80,0.15)}
.dev-check-panel .dcr.bad{background:rgba(200,0,0,0.18)}
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Header */
header {
    margin-bottom: 30px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-text {
    text-align: center;
    flex: 1;
}

.header-text h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.header-text p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Controls */
.controls {
    background: white;
    padding: 20px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.filter-groups {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-group {
    border-left: 4px solid #667eea;
    padding-left: 16px;
}

.filter-group-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* Section separator */
.section-separator {
    height: 2px;
    background: linear-gradient(to right, #667eea, #764ba2);
    margin: 20px 0;
    border-radius: 1px;
}

/* Stats (now within controls container) */
.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    flex-wrap: nowrap;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
    flex: 1;
    min-width: 120px;
}

.filter-section label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.filter-section select {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
    width: 100%;
    min-width: 120px;
}

.filter-section .search-input {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: text;
    transition: border-color 0.2s;
    width: 100%;
    min-width: 200px;
}

.filter-section select:focus,
.filter-section .search-input:focus {
    outline: none;
    border-color: #667eea;
}

.filter-section input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    padding: 8px;
    border: 2px solid #e1e5e9;
    border-radius: 4px;
    background: white;
    transition: border-color 0.2s;
}

.checkbox-filter {
    display: flex;
    flex-direction: column !important;
    align-items: flex-start;
    gap: 5px;
    white-space: nowrap;
    flex: 0 0 auto;
    min-width: 120px;
}

.checkbox-filter .checkbox-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 38px; /* Match select element total height (padding + border + font) */
}

.checkbox-filter input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    border: 2px solid #e1e5e9;
    border-radius: 4px;
    background: white;
    transition: border-color 0.2s;
}

.checkbox-filter label {
    cursor: pointer;
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .filter-groups {
        gap: 16px;
    }
    
    .filter-row {
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .filter-section {
        min-width: 140px;
        flex: 1;
    }
    
    .filter-section .search-input {
        min-width: 180px;
    }
    
    .filter-section select {
        min-width: 120px;
        min-height: 44px; /* Better touch target */
        font-size: 1rem;
    }
    
    .checkbox-filter .checkbox-wrapper {
        min-height: 44px; /* Better touch target */
    }
    
    .checkbox-filter input[type="checkbox"] {
        width: 20px;
        height: 20px; /* Larger touch target */
    }
}

@media (max-width: 480px) {
    .filter-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .filter-section {
        min-width: auto;
        width: 100%;
    }
    
    .filter-section .search-input,
    .filter-section select {
        width: 100%;
        min-width: auto;
        min-height: 48px; /* Even larger on very small screens */
        font-size: 1.1rem; /* Slightly larger text */
    }
}

.action-section {
    display: flex;
    gap: 15px;
    flex-wrap: nowrap;
    align-items: flex-end;
}

.primary-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* Random Pick Dropdown specific styles */
.random-pick-dropdown .dropdown-menu {
    min-width: 200px;
}

.random-pick-dropdown .dropdown-item.primary-action {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    margin-top: 4px;
}

.random-pick-dropdown .dropdown-item.primary-action:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
}

/* Responsive adjustments for primary actions */
@media (max-width: 1200px) {
    .primary-actions {
        gap: 10px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

@media (max-width: 992px) {
    .primary-actions {
        gap: 8px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* Mobile-first responsive design for stats and actions */
@media (max-width: 768px) {
    .stats {
        flex-direction: column;
        gap: 20px;
        align-items: stretch;
    }
    
    .stats-numbers {
        justify-content: space-around;
        gap: 15px;
        flex-wrap: wrap;
    }
    
    .action-section {
        width: 100%;
    }
    
    .primary-actions {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: stretch;
        width: 100%;
    }
    
    .primary-actions .btn,
    .primary-actions .dropdown {
        flex: 1;
        min-width: calc(50% - 6px);
        min-height: 44px; /* Minimum touch target size */
    }
    
    .primary-actions .dropdown .dropdown-toggle {
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-numbers {
        gap: 10px;
    }
    
    .stat-item {
        flex: 1;
        min-width: calc(25% - 8px);
    }
    
    .stat-item span:last-child {
        font-size: 1.2rem; /* Slightly smaller on very small screens */
    }
    
    .primary-actions {
        gap: 8px;
    }
    
    .primary-actions .btn,
    .primary-actions .dropdown {
        min-height: 48px; /* Larger touch targets on very small screens */
        font-size: 0.9rem;
    }
}

.sync-status {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border: 1px solid;
    min-width: 70px;
    text-align: center;
}

.sync-status.connected {
    color: white;
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    border-color: #4caf50;
    box-shadow: 0 1px 4px rgba(76, 175, 80, 0.3);
}

.sync-status.syncing {
    color: white;
    background: linear-gradient(135deg, #ff9800, #ffb74d);
    border-color: #ff9800;
    box-shadow: 0 1px 4px rgba(255, 152, 0, 0.3);
    animation: pulse 2s infinite;
}

.sync-status:not(.connected):not(.syncing) {
    color: white;
    background: linear-gradient(135deg, #f44336, #ef5350);
    border-color: #f44336;
    box-shadow: 0 1px 4px rgba(244, 67, 54, 0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Generic inline search/loading button state */
.chip-action.loading, .loading-btn {
    position: relative;
    opacity: 0.75;
    pointer-events: none;
    animation: pulse 1.6s ease-in-out infinite;
}
.chip-action.loading::after, .loading-btn::after {
    content: '⏳';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.05);
    backdrop-filter: blur(1px);
}

/* Compact action buttons (icon + text); hide text on very small screens to prevent overflow */
.compact-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compact-btn .btn-icon { font-size: 1.05rem; line-height: 1; }
.compact-btn .btn-text { display: inline-block; }

@media (max-width: 560px) {
    .compact-btn .btn-text { display: none; }
    .compact-btn { min-width: 48px; padding: 8px 10px; }
}
@media (max-width: 560px) {
    .stats-numbers {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        justify-items: center;
        align-items: start;
    }
    .stat-item { flex: unset; width: 100%; }
    .stat-label { font-size: 0.75rem; text-align: center; }
    .stat-item span:last-child { font-size: 1.3rem; }
}
/* Utility to hide full-size button on very small screens when an overflow duplicate exists */
.visually-hidden-mobile { display: inline-flex; }
@media (max-width: 560px) { .visually-hidden-mobile { display: none !important; } }

/* SVG icon baseline styling */
.icon { width: 18px; height: 18px; display: inline-block; }
.icon-gear path, .icon-add path, .icon-broom path, .icon-dice rect, .icon-dice circle { stroke: none; fill: currentColor; }
.icon-dice rect { fill: none; stroke: currentColor; stroke-width: 2; }

@media (max-width: 400px) {
    .primary-actions { gap: 6px; }
    .compact-btn { min-width: 44px; }
}

/* Dropdown Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown-toggle:after {
    content: "▼";
    font-size: 0.7em !important;
    margin-left: 4px !important;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.dropdown.active .dropdown-toggle:after {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 200px;
    overflow: hidden;
}

@media (max-width: 560px) {
    .dropdown-menu {
        max-width: calc(100vw - 16px);
    }
    .random-pick-dropdown .dropdown-menu {
        left: 0;
        right: auto;
    }
}

.dropdown.active .dropdown-menu,
.dropdown-menu.show {
    display: block;
    animation: dropdownSlide 0.2s ease-out;
}

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

.dropdown-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item.danger {
    color: #dc3545;
}

.dropdown-item.danger:hover {
    background-color: #fff5f5;
}

.dropdown-divider {
    height: 1px;
    background-color: #e9ecef;
    margin: 4px 0;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    white-space: nowrap;
    min-height: 40px; /* Ensure minimum touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none; /* In case used as link */
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.stats-numbers {
    display: flex;
    gap: 30px;
    flex-wrap: nowrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label { font-size: 0.8rem; font-weight: 600; color: #555; letter-spacing: .5px; text-transform: uppercase; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: #667eea; line-height: 1; }

@media (max-width: 560px) {
    .stats-numbers { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
    .stat-item { background: transparent; padding: 4px 0; }
    .stat-label { font-size: .65rem; letter-spacing: .75px; }
    .stat-value { font-size: 1.15rem; }
}

.stat-item span:last-child {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

/* Table */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* Responsive column hiding */
/* marker class used only for responsive hiding; intentionally no base styles */
@media (max-width: 680px) {
        th.hide-mobile, td.hide-mobile { display: none !important; }
}

/* Format icons always visible under title */
.format-icons { 
    display: flex; 
    margin-top: 4px; 
    gap: 4px; 
    align-items: center; 
}
.format-icons .format-icon { 
    font-size: 0.9rem; 
    line-height: 1;
}

/* Mobile meta badges inside title cell */
.mobile-meta { display: none; margin-top: 4px; gap: 6px; flex-wrap: wrap; }
.mobile-meta .mm { background: #eef1f8; color: #445; padding: 2px 6px; border-radius: 12px; font-size: .6rem; font-weight:600; letter-spacing:.5px; }
@media (max-width: 680px) {
    .mobile-meta { display: flex; }
    td.title-cell { padding-bottom: 10px; }
}

/* Mobile card view */
@media (max-width: 680px) {
    .table-container { display: none; }
    .mobile-card-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
}
@media (min-width: 681px) {
    .mobile-card-list { display: none; }
}

.book-card { background:#fff; border:1px solid #e4e7ee; border-radius:14px; padding:12px 14px; box-shadow:0 2px 6px rgba(0,0,0,0.04); display:flex; gap:12px; position:relative; }
.book-card .cover { width:46px; height:70px; flex-shrink:0; border-radius:6px; object-fit:cover; background:#f2f4f8; display:flex; align-items:center; justify-content:center; font-weight:600; color:#667; }
.book-card .main { flex:1; display:flex; flex-direction:column; gap:4px; }
.book-card .title-row { display:flex; align-items:flex-start; gap:6px; }
.book-card .title { font-weight:600; font-size:.95rem; line-height:1.15; flex:1; }
.book-card .badges { display:flex; flex-wrap:wrap; gap:4px; }
.book-card .badge { background:#eef1f8; color:#445; padding:2px 6px; border-radius:10px; font-size:.55rem; font-weight:600; letter-spacing:.5px; }
.book-card .meta-line { font-size:.65rem; color:#556; display:flex; gap:10px; flex-wrap:wrap; }
.book-card .actions { margin-top:6px; display:flex; gap:6px; }
.book-card button.btn-xs { padding:4px 6px; font-size:.6rem; border-radius:6px; }
.book-card .select-checkbox { position:absolute; top:6px; left:6px; }
.book-card .status-dot { width:10px; height:10px; border-radius:50%; background:#bbb; margin-right:4px; }
.status-queued .status-dot { background:#667eea; }
.status-reading .status-dot { background:#ff9800; }
.status-read .status-dot { background:#43a047; }

/* Mobile detail panel */
@media (max-width: 700px){
    #bookDetailModal { display:none !important; }
    .mobile-detail-panel { position:fixed; left:0; right:0; bottom:0; top:28%; background:#fff; border-top-left-radius:22px; border-top-right-radius:22px; box-shadow:0 -4px 24px -4px rgba(0,0,0,0.35); transform:translateY(100%); transition:transform .35s cubic-bezier(.4,.8,.4,1); z-index:250; display:flex; flex-direction:column; }
    .mobile-detail-panel.open { transform:translateY(0); }
    .mobile-detail-panel.dragging { transition:none !important; }
    .mdp-handle { width:54px; height:5px; border-radius:3px; background:#d0d5dd; margin:10px auto 4px; cursor:pointer; }
    .mdp-header { display:flex; align-items:flex-start; gap:12px; padding:4px 16px 8px; }
    .mdp-close { background:#eef1f8; border:none; border-radius:50%; width:34px; height:34px; font-size:16px; cursor:pointer; display:flex; align-items:center; justify-content:center; }
    .mdp-title-wrap { flex:1; }
    .mdp-title { font-size:1.05rem; margin:4px 0 2px; line-height:1.15; }
    .mdp-author { margin:0; font-size:.7rem; letter-spacing:.5px; text-transform:uppercase; color:#5a6372; font-weight:600; }
    .mdp-scroll { flex:1; overflow-y:auto; padding:0 16px 28px; }
        .mdp-scroll-bottom-spacer { height:88px; }
    .mdp-cover img, .mdp-cover-placeholder { width:120px; height:180px; border-radius:12px; object-fit:cover; box-shadow:0 4px 14px -4px rgba(0,0,0,0.25); }
    .mdp-cover { display:flex; gap:14px; margin:4px 0 14px; }
    .mdp-meta { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:8px; margin-bottom:14px; }
    .mdp-meta .meta-chip { background:#eef1f8; padding:8px 10px; border-radius:10px; font-size:.65rem; display:flex; flex-direction:column; gap:4px; }
        .mdp-meta .meta-chip .chip-action { border:none; background:#667db6; color:#fff; padding:6px 8px; border-radius:8px; font-size:.62rem; font-weight:600; letter-spacing:.4px; cursor:pointer; box-shadow:0 2px 4px rgba(0,0,0,0.15); }
        .mdp-meta .meta-chip .chip-action:active { transform:translateY(1px); }
    .mdp-meta .meta-chip span { font-size:.62rem; opacity:.7; text-transform:uppercase; letter-spacing:.6px; font-weight:600; }
        .mdp-sticky-actions { position:absolute; left:0; right:0; bottom:0; padding:10px 14px calc(10px + env(safe-area-inset-bottom)); background:linear-gradient(180deg,rgba(255,255,255,0) 0%, #ffffff 50%); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); box-shadow:0 -2px 10px -4px rgba(0,0,0,0.15); }
        .mdp-action-buttons { display:flex; gap:10px; }
        .mdp-action-buttons button { flex:1; border:none; border-radius:14px; padding:14px 12px; font-size:.78rem; font-weight:600; letter-spacing:.4px; cursor:pointer; background:linear-gradient(135deg,#667db6,#0082c8); color:#fff; box-shadow:0 2px 6px rgba(0,0,0,0.15); }
        .mdp-action-buttons button.secondary { background:#eef1f8; color:#364152; box-shadow:none; }
        .mdp-action-buttons button:active { transform:translateY(1px); }
    .mdp-description { font-size:.72rem; line-height:1.35; margin-bottom:16px; }
    .mdp-description h4 { margin:0 0 6px; font-size:.8rem; }
    .mdp-history h4, .mdp-notes h4 { margin:0 0 6px; font-size:.8rem; }
    .mdp-history { font-size:.66rem; line-height:1.3; margin-bottom:18px; }
    .mdp-history .session { background:#f5f7fa; padding:6px 8px; border-radius:8px; margin-bottom:6px; }
    .mdp-notes { font-size:.68rem; line-height:1.3; margin-bottom:12px; }
    body.mobile-detail-open { overflow:hidden; }
}

    /* Desktop detail modal upgraded layout */
    @media (min-width: 701px){
        #bookDetailModal .modal-content{ max-width:900px; }
        .desktop-detail-wrapper{ position:relative; padding:8px 4px 90px; }
    .dd-top{ display:flex; gap:24px; align-items:flex-start; margin-bottom:18px; }
    /* Fine-tune cover + chips alignment when meta grid is inline */
    .dd-top-with-meta{ gap:20px; }
    .dd-top-with-meta .dd-cover-block{ margin-top:6px; }
        .dd-top-with-meta{ align-items:stretch; }
        .dd-top-with-meta .dd-top-main{ flex:1; display:flex; flex-direction:column; }
        .dd-meta-grid.inline{ margin:6px 0 0; }
    /* Inline chips revert to adaptive sizing similar to original meta grid */
    .dd-meta-grid.inline{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:6px 8px; }
    @media (max-width: 880px){ .dd-meta-grid.inline{ grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); } }
    @media (max-width: 640px){ .dd-meta-grid.inline{ grid-template-columns:repeat(auto-fill,minmax(130px,1fr)); } }
        .dd-meta-grid.inline .meta-chip{ margin:0; padding:8px 10px; } /* Slightly tighter internal padding */
            .dd-meta-grid.inline .meta-chip span{ font-size:.6rem; }
            .dd-meta-grid.inline .meta-chip .mc-val{ font-size:.7rem; line-height:1.3; overflow:visible; -webkit-line-clamp:unset; line-clamp:unset; }
        /* Enlarge cover in meta-inline layout */
    /* Revert cover to original size & style */
    .dd-top-with-meta .dd-cover-block .book-detail-cover img, .dd-top-with-meta .dd-cover-block .book-detail-cover-placeholder{ width:140px; height:210px; object-fit:cover; padding:0; background:none; }
        /* Pull description upward slightly to reclaim whitespace */
        .dd-top-with-meta + .dd-description{ margin-top:-6px; }
        @media (max-width: 880px){
            .dd-top-with-meta{ flex-direction:column; }
            .dd-meta-grid.inline{ grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); }
            .dd-top-with-meta .dd-cover-block .book-detail-cover img, .dd-top-with-meta .dd-cover-block .book-detail-cover-placeholder{ width:140px; height:210px; }
        }
    .dd-top.dd-top-with-desc{ align-items:stretch; }
    .dd-main-top{ flex:1; display:flex; flex-direction:column; }
    .dd-inline-description{ margin-top:8px; background:#f8faff; border:1px solid #e2e8f3; padding:12px 14px; border-radius:12px; box-shadow:0 2px 6px -2px rgba(0,0,0,0.06); }
    .dd-inline-description .dd-description{ margin:0; }
    .dd-inline-description .dd-description h4{ margin:0 0 6px; font-size:.7rem; letter-spacing:.5px; text-transform:uppercase; color:#4f5d6b; }
    .dd-inline-description .dd-description p{ font-size:.7rem; line-height:1.35; max-height:240px; overflow:auto; padding-right:6px; }
        /* Float variant (description wraps under title and beside cover, reducing blank space) */
        .dd-top-float-desc{ position:relative; flex-wrap:wrap; }
        .dd-top-float-desc .dd-cover-block{ flex:0 0 auto; }
        .dd-inline-description-float{ flex:1 1 100%; margin-left:164px; margin-top:-6px; }
        .dd-inline-description-float .dd-description p{ max-height:none; }
        @media (max-width: 900px){
            .dd-inline-description-float{ margin-left:0; margin-top:8px; }
        }
    .dd-cover-block .book-detail-cover img, .dd-cover-block .book-detail-cover-placeholder{ width:140px; height:210px; border-radius:12px; object-fit:cover; box-shadow:0 4px 14px -4px rgba(0,0,0,0.25); }
        .dd-title-block{ flex:1; }
        .dd-title{ margin:4px 0 6px; font-size:1.4rem; line-height:1.15; }
        .dd-author{ margin:0; font-size:.8rem; letter-spacing:.6px; text-transform:uppercase; color:#546170; font-weight:600; }
        .dd-meta-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; margin:8px 0 22px; }
        .dd-meta-grid .meta-chip{ background:#f1f4fa; padding:10px 12px; border-radius:12px; font-size:.7rem; display:flex; flex-direction:column; gap:6px; position:relative; }
        .dd-meta-grid .meta-chip span{ font-size:.6rem; opacity:.65; letter-spacing:.55px; font-weight:600; text-transform:uppercase; }
        .dd-meta-grid .meta-chip .mc-val code{ background:#e7ebf2; padding:2px 4px; border-radius:4px; font-size:.65rem; }
        .dd-meta-grid .meta-chip .chip-action.inline{ position:absolute; top:8px; right:8px; background:#667db6; border:none; color:#fff; padding:4px 6px; font-size:.6rem; border-radius:6px; cursor:pointer; box-shadow:0 2px 4px rgba(0,0,0,0.15); }
        .dd-meta-grid .meta-chip .chip-action.inline:active{ transform:translateY(1px); }
        .dd-section{ margin:0 0 26px; }
        .dd-section h4{ margin:0 0 10px; font-size:.85rem; letter-spacing:.5px; text-transform:uppercase; color:#44505c; }
        .dd-section p{ margin:0; font-size:.75rem; line-height:1.4; }
        .dd-history .session-row{ background:#f5f7fa; padding:8px 10px; border-radius:10px; font-size:.7rem; margin-bottom:6px; display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
        .dd-history .session-row .mini-link{ border:none; background:#e2e8f3; padding:4px 6px; border-radius:6px; font-size:.6rem; cursor:pointer; }
        .dd-history .session-row .mini-link:hover{ background:#d6deea; }
        .dd-history .empty{ text-align:center; background:#f5f7fa; padding:18px 14px; border-radius:12px; font-size:.7rem; }
        .dd-notes p{ white-space:pre-wrap; }
        .dd-sticky-actions{ position:absolute; left:0; right:0; bottom:0; padding:14px 18px 18px; background:linear-gradient(180deg,rgba(255,255,255,0) 0%, #ffffff 55%); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); box-shadow:0 -2px 14px -4px rgba(0,0,0,0.18); }
        .dd-action-buttons{ display:flex; gap:10px; flex-wrap:wrap; }
        .dd-action-buttons .dd-btn{ flex:1; min-width:130px; background:#eef1f8; color:#364152; border:none; border-radius:14px; padding:12px 14px; font-size:.75rem; font-weight:600; letter-spacing:.4px; cursor:pointer; transition:background .18s, transform .15s; }
        .dd-action-buttons .dd-btn.primary{ background:linear-gradient(135deg,#667db6,#0082c8); color:#fff; }
        .dd-action-buttons .dd-btn.secondary{ background:#ffecec; color:#b84a4a; }
        .dd-action-buttons .dd-btn:hover{ background:#e2e7f0; }
        .dd-action-buttons .dd-btn.primary:hover{ filter:brightness(1.05); }
        .dd-action-buttons .dd-btn:active{ transform:translateY(1px); }
            .dd-description .desc-loading{ font-size:.7rem; color:#556; display:flex; align-items:center; gap:6px; }
    }

/* New mobile card split action styles */
.card-inline-actions { display:flex; gap:8px; }
.card-inline-actions .card-btn { flex:1; border:none; border-radius:10px; padding:10px 12px; font-size:.72rem; font-weight:600; display:flex; align-items:center; justify-content:center; gap:6px; letter-spacing:.4px; cursor:pointer; transition:background .18s, transform .15s; }
.card-inline-actions .card-btn.primary { background:linear-gradient(135deg,#667db6,#0082c8); color:#fff; }
.card-inline-actions .card-btn.secondary { background:#eef1f8; color:#364152; }
.card-inline-actions .card-btn.primary:hover { filter:brightness(1.05); }
.card-inline-actions .card-btn.secondary:hover { background:#e2e7f0; }
.card-inline-actions .card-btn:active { transform:translateY(1px); }
@media (max-width:480px){ .card-inline-actions .card-btn { padding:9px 10px; font-size:.68rem; } }

th {
    background: #f8f9fa;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
}

/* Cover column styling */
.cover-column {
    width: 60px;
    text-align: center;
    padding: 8px !important;
}

.book-cover {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

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

.book-cover.loading {
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 10px;
}

.book-cover.error {
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 16px;
}

.cover-placeholder {
    width: 40px;
    height: 60px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
}

th.sortable:hover {
    background: #e9ecef;
}

.sort-indicator {
    margin-left: 8px;
    font-size: 0.8rem;
    opacity: 0.6;
}

.sort-indicator::after {
    content: '↕️';
}

th.sort-asc .sort-indicator::after {
    content: '↑';
    opacity: 1;
}

th.sort-desc .sort-indicator::after {
    content: '↓';
    opacity: 1;
}

td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.cover-cell {
    padding: 8px !important;
    text-align: center;
    width: 60px;
}

tr:hover {
    background: #f8f9fa;
}

.title-cell {
    font-weight: 600;
    color: #495057;
    cursor: pointer;
}

.title-cell:hover {
    color: #667eea;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-queued {
    background: #e3f2fd;
    color: #1976d2;
}

.status-reading {
    background: #e8f5e8;
    color: #2e7d32;
}

.status-read {
    background: #fce4ec;
    color: #c2185b;
}

/* Format badges */
.format-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    background: none;
    cursor: default;
}

.format-badge.clickable-format {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.format-badge.clickable-format:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.1);
}

.format-badge.clickable-format:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Clickable Author Styles */
.clickable-author {
    cursor: pointer;
    color: #1976d2;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
}

.clickable-author:hover {
    background-color: rgba(25, 118, 210, 0.1);
    color: #0d47a1;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clickable-author:active {
    transform: translateY(0);
    background-color: rgba(25, 118, 210, 0.2);
}

/* Clickable Category Styles */
.clickable-category {
    cursor: pointer;
    color: #7b1fa2;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
}

.clickable-category:hover {
    background-color: rgba(123, 31, 162, 0.1);
    color: #4a148c;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clickable-category:active {
    transform: translateY(0);
    background-color: rgba(123, 31, 162, 0.2);
}

/* Clickable Narrator Styles */
.clickable-narrator {
    cursor: pointer;
    color: #f57c00;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
}

.clickable-narrator:hover {
    background-color: rgba(245, 124, 0, 0.1);
    color: #e65100;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clickable-narrator:active {
    transform: translateY(0);
    background-color: rgba(245, 124, 0, 0.2);
}

/* Clickable Status Styles */
.status-badge.clickable-status {
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-badge.clickable-status:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
}

.status-badge.clickable-status:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Clickable Series Styles */
.clickable-series {
    color: #1976d2;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 1px 3px;
}

.clickable-series:hover {
    color: #0d47a1;
    background-color: rgba(25, 118, 210, 0.1);
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.clickable-series:active {
    transform: translateY(0);
    background-color: rgba(25, 118, 210, 0.2);
}

.clickable-series.standalone {
    color: #555;
    font-style: italic;
}

.clickable-series.standalone:hover {
    color: #333;
    background-color: rgba(85, 85, 85, 0.1);
}

/* Series cell styling to prevent wrapping */
.series-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clickable-series {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}

.format-book {
    background: #f3e5f5;
    color: #7b1fa2;
}

.format-audiobook {
    background: #e1f5fe;
    color: #0277bd;
}

.format-both {
    background: #e8f5e8;
    color: #2e7d32;
}

.format-none {
    background: #ffebee;
    color: #c62828;
}

.format-unknown {
    background: #f5f5f5;
    color: #757575;
}

.format-cell {
    text-align: center;
}

.date-added-cell {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
}

.series-info {
    font-size: 0.9rem;
    color: #666;
}

.action-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

/* Split action button */
.action-split { position: relative; display: inline-flex; border-radius: 6px; overflow: visible; }
.action-split .primary-action-btn { background: linear-gradient(135deg,#667eea,#764ba2); color:#fff; border:none; padding:6px 14px; font-size:.8rem; font-weight:600; border-radius:6px; cursor:pointer; display:inline-flex; align-items:center; gap:6px; min-width:110px; justify-content:center; }
.action-split .primary-action-btn:hover { filter:brightness(1.05); }
.action-split .secondary-toggle { background:#4a4f57; color:#fff; border:none; padding:6px 10px; font-size:.75rem; border-radius:6px; margin-left:4px; cursor:pointer; }
.action-split .secondary-toggle:hover { filter:brightness(1.1); }
.action-split .action-menu { position:absolute; top:100%; right:0; background:#fff; border:1px solid #d3d8e2; border-radius:8px; box-shadow:0 6px 18px rgba(0,0,0,.15); display:none; min-width:140px; padding:6px; z-index:20; }
.action-split.open .action-menu { display:block; animation: dropdownSlide .18s ease-out; }
.action-split .action-menu button { width:100%; background:#f4f6fa; border:none; padding:6px 8px; margin:2px 0; font-size:.7rem; border-radius:5px; text-align:left; cursor:pointer; display:flex; gap:6px; align-items:center; }
.action-split .action-menu button:hover { background:#e3e8f1; }
@media (max-width:680px){ .action-split { display:none; } }

.action-buttons .btn-small {
    padding: 6px 8px !important;
    font-size: 0.8rem !important;
    height: 32px !important;
    line-height: 1.2 !important;
    min-width: 90px !important;
    width: auto !important;
    border: none !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    font-weight: 600 !important;
}

.btn-start {
    background: #28a745;
    color: white;
}

.btn-start:hover {
    background: #218838;
}

.btn-finish {
    background: #6f42c1;
    color: white;
}

.btn-finish:hover {
    background: #5a2d8c;
}

.btn-read {
    background: #17a2b8;
    color: white;
}

.btn-read:hover {
    background: #138496;
}

.btn-reread {
    background: #fd7e14;
    color: white;
}

.btn-reread:hover {
    background: #e66b02;
}

.btn-queue {
    background: #6c757d;
    color: white;
}

.btn-queue:hover {
    background: #5a6268;
}

.btn-status {
    background: #667eea;
    color: white;
}

.btn-status:hover {
    background: #5a6fd8;
}

.btn-edit-format {
    background: #fd7e14;
    color: white;
}

.btn-edit-format:hover {
    background: #e96900;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

/* Format Editor Modal */
.format-edit-section {
    text-align: center;
    padding: 20px 0;
}

.format-edit-section h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1.3rem;
}

.format-edit-section p {
    margin-bottom: 25px;
    color: #666;
    font-size: 1rem;
}

.format-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    align-items: center;
}

.format-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
    min-width: 200px;
    justify-content: flex-start;
}

.format-option:hover {
    border-color: #667eea;
    background-color: #f8f9fa;
}

.format-option input[type="radio"] {
    margin: 0;
    transform: scale(1.2);
}

.format-option input[type="radio"]:checked + .format-badge {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.format-option .format-badge {
    transition: all 0.2s;
    font-size: 0.9rem;
    padding: 6px 14px;
}

.format-edit-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: nowrap;
}

.format-edit-buttons .btn {
    min-width: 120px;
}

/* Modal improvements */
.modal-content {
    max-width: 800px;
    max-height: 85vh;
    margin: 5% auto;
    overflow-y: auto;
    padding-bottom: 20px;
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    padding: 15px 20px 10px 20px;
    border-bottom: 1px solid #eee;
}

.modal-body {
    padding: 20px;
}

/* Ensure action buttons have proper spacing and are never cut off */
.modal-content .rating-management,
.modal-content .date-edit-buttons,
.modal-content .add-books-buttons,
.modal-content .format-edit-buttons,
.modal-content .rating-buttons,
.modal-content .book-info-edit-buttons {
    margin-top: 20px;
    margin-bottom: 5px;
    padding-top: 20px;
    padding-bottom: 5px;
    border-top: 1px solid #eee;
    background: white;
}

/* Ensure book detail modals have adequate bottom spacing */
#bookDetailModal .modal-content {
    padding-bottom: 20px;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

/* Enhanced Add Books Modal Styling */
#addBooksModal .modal-content{max-width:900px;padding:36px 42px 40px 42px;border-radius:18px;box-shadow:0 14px 40px -8px rgba(32,44,70,.35);background:linear-gradient(180deg,#ffffff 0%,#f7f9fc 100%);} 
#addBooksModal .modal-content h2{font-size:1.85rem;font-weight:650;letter-spacing:.5px;color:#1f2733;display:flex;align-items:center;gap:14px;justify-content:flex-start;margin:0;padding:0 0 24px 0;border-bottom:1px solid #e1e7ef;} 
#addBooksModal .modal-content h2:before{content:"";display:inline-block;width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,#667eea,#764ba2);box-shadow:0 4px 10px -2px rgba(102,126,234,.5);mask: url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22white%22><path d=%22M4 5h16v2H4zm0 6h16v2H4zm0 6h16v2H4z%22/></svg>') center / 60% 60% no-repeat;-webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22white%22><path d=%22M4 5h16v2H4zm0 6h16v2H4zm0 6h16v2H4z%22/></svg>') center/60% 60% no-repeat;} 
#addBooksModal .add-book-tabs{display:flex;gap:14px;margin:30px 0 20px 0;padding:4px 6px;background:#f1f4f9;border:1px solid #dde3ec;border-radius:14px;position:relative;} 
#addBooksModal .add-book-tabs:before{content:"";position:absolute;inset:0;border-radius:14px;background:radial-gradient(circle at 85% 25%,rgba(102,126,234,.18),transparent 70%);pointer-events:none;} 
#addBooksModal .add-book-tabs .tab-button{flex:1;padding:14px 14px;background:transparent;border:none;font-weight:600;font-size:.83rem;letter-spacing:.6px;color:#4a5662;cursor:pointer;position:relative;border-radius:12px;transition:background .25s,color .25s,box-shadow .25s;} 
#addBooksModal .add-book-tabs .tab-button.active{background:linear-gradient(135deg,#ffffff,#f8faff);color:#1f2733;box-shadow:0 3px 10px -4px rgba(55,65,90,.35),0 0 0 1px #fff,inset 0 0 0 1px #e2e8f3;} 
#addBooksModal .add-book-tabs .tab-button:not(.active):hover{background:#e6ebf3;color:#2a3442;} 
#addBooksModal .add-book-tabs .tab-button.active:after{content:"";position:absolute;left:14px;right:14px;bottom:-6px;height:4px;background:linear-gradient(90deg,#667eea,#764ba2);border-radius:4px;} 
#addBooksModal .add-books-form-panel{background:linear-gradient(140deg,#ffffff 0%,#f5f7fb 45%,#f2f5fa 100%);border:1px solid #dbe2eb;border-radius:22px;padding:34px 40px 40px 40px;position:relative;overflow:hidden;box-shadow:0 10px 32px -10px rgba(40,55,90,.25);} 
#addBooksModal .add-books-form-panel:before{content:"";position:absolute;inset:0;background:radial-gradient(circle at 92% 12%,rgba(118,75,162,.18),transparent 70%),radial-gradient(circle at 4% 88%,rgba(102,126,234,.15),transparent 65%);pointer-events:none;mix-blend-mode:normal;} 
#addBooksModal .add-books-form-panel label{font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.9px;color:#5b6677;margin-bottom:6px;display:block;}
#addBooksModal .add-books-form-panel input[type=text]{width:100%;padding:15px 18px;border:1px solid #cfd8e3;border-radius:14px;background:linear-gradient(145deg,#ffffff,#f4f7fb);font-size:.92rem;color:#243041;transition:border-color .18s, box-shadow .18s, background .25s;box-shadow:0 2px 4px -2px rgba(60,72,90,.15);} 
#addBooksModal .add-books-form-panel input[type=text]:focus{border-color:#667eea;box-shadow:0 0 0 3px rgba(102,126,234,.25),0 6px 18px -6px rgba(55,65,90,.3);outline:none;background:#ffffff;} 
#addBooksModal .add-books-buttons{display:flex;gap:18px;justify-content:flex-end;margin-top:38px;padding-top:26px;border-top:1px solid #d4dde8;background:linear-gradient(180deg,#f5f7fa 0%,#e9edf2 100%);border-bottom-left-radius:18px;border-bottom-right-radius:18px;} 
#addBooksModal .add-books-buttons .btn{min-width:160px;font-weight:600;letter-spacing:.4px;padding:14px 18px;border-radius:10px;font-size:.85rem;}
#addBooksModal .add-books-buttons .btn.btn-secondary{background:#4b5662;color:#fff;}
#addBooksModal .add-books-buttons .btn.btn-secondary:hover{background:#3a444e;}
#addBooksModal .add-books-buttons .btn.btn-primary{background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;box-shadow:0 4px 14px -2px rgba(102,126,234,.55);} 
#addBooksModal .add-books-buttons .btn.btn-primary:hover{filter:brightness(1.05);} 
#addBooksModal .add-books-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:26px 34px;margin-bottom:8px;}
#addBooksModal .add-books-form-grid .full-row{grid-column:1 / -1;}
/* Intro / results summary bar */
#addBooksModal #searchResults > div:first-child{background:linear-gradient(120deg,#f6f8fb,#eef2f7);border:0;border-bottom:1px solid #e0e6ef;border-top-left-radius:18px;border-top-right-radius:18px;box-shadow:inset 0 -1px 0 #d8e0ea;font-family:inherit;padding:18px 24px;} 
#addBooksModal #searchResults h4{font-size:1rem;font-weight:650;letter-spacing:.5px;color:#1e2530;} 
#addBooksModal #searchResults .search-result-actions{display:flex;gap:14px;justify-content:flex-end;padding:16px 22px;border-top:1px solid #e1e8f1;background:linear-gradient(180deg,#f5f8fb,#eef2f6);border-bottom-left-radius:16px;border-bottom-right-radius:16px;} 
#addBooksModal #searchResults{border:1px solid #d0d9e3;border-radius:20px;background:#fff;box-shadow:0 10px 30px -12px rgba(40,55,90,.28),0 2px 6px -2px rgba(55,65,85,.18);margin-top:34px;} 
#addBooksModal #searchResults .search-result-item{border:0;border-bottom:1px solid #eef1f5;padding:22px 24px 22px 24px;}
#addBooksModal #searchResults .search-result-item:last-child{border-bottom:0;}
#addBooksModal #searchResults .search-result-item.selected{background:linear-gradient(100deg,rgba(102,126,234,.14),rgba(118,75,162,.14));border-left:5px solid #6d79e8;box-shadow:0 4px 14px -10px rgba(55,65,90,.45);} 
#addBooksModal #searchResults .search-result-item-abs{background:linear-gradient(95deg,#f4f1ff,#fafbfe);} 
#addBooksModal #searchResults .search-result-item-abs:hover{background:linear-gradient(95deg,#eee8ff,#f2f6ff);} 
#addBooksModal #searchResults .search-result-meta span{background:#f1f3f8;padding:5px 11px;border-radius:30px;font-size:.58rem;font-weight:700;text-transform:uppercase;letter-spacing:.7px;color:#4a5662;display:inline-flex;align-items:center;gap:4px;box-shadow:0 1px 2px rgba(30,45,70,.15);} 
#addBooksModal #searchResults .search-result-meta span + span{margin-left:6px;}
#addBooksModal #searchResults .search-result-description{margin-top:12px;line-height:1.5;font-size:.75rem;color:#2f3945;background:#f7f9fc;padding:14px 16px;border-radius:14px;border:1px solid #e5ebf2;} 
#addBooksModal #searchResults .badge-source{background:#e7ecf5;color:#3f4a57;font-weight:700;font-size:.55rem;padding:5px 9px;border-radius:40px;text-transform:uppercase;letter-spacing:.7px;box-shadow:0 1px 2px rgba(40,50,70,.25);} 
#addBooksModal #searchResults .badge-source.source-audiobookshelf{background:#5c3fa4;color:#fff;box-shadow:0 2px 6px -2px rgba(92,63,164,.6);} 
#addBooksModal #searchResults .badge-source.source-abs{background:#5d3fa2;color:#fff;} 
#addBooksModal #searchResults .badge-source.source-google{background:#1a73e8;color:#fff;} 
#addBooksModal #searchResults .badge-source.source-ol{background:#333;color:#fff;} 
#addBooksModal #searchResults::-webkit-scrollbar{width:10px;} 
#addBooksModal #searchResults::-webkit-scrollbar-track{background:transparent;border-radius:10px;} 
#addBooksModal #searchResults::-webkit-scrollbar-thumb{background:linear-gradient(180deg,#cbd3de,#b9c2cf);border-radius:10px;border:2px solid #f5f7fa;} 
#addBooksModal #searchResults::-webkit-scrollbar-thumb:hover{background:linear-gradient(180deg,#c2ccd9,#b2bdcb);} 
@media (max-width:820px){#addBooksModal .add-books-form-grid{grid-template-columns:1fr;}#addBooksModal .add-books-buttons{flex-direction:column;align-items:stretch;}#addBooksModal .add-books-buttons .btn{width:100%;}}

/* Book Info Edit Modal */
.input-with-action{display:flex;align-items:center;gap:8px;}
.input-with-action .inline-icon-btn{flex:0 0 auto;background:#eef2f7;border:1px solid #cfd6e0;color:#445064;padding:10px 12px;border-radius:10px;cursor:pointer;font-size:.9rem;line-height:1;transition:background .18s,border-color .18s,transform .18s;box-shadow:0 2px 4px -2px rgba(50,60,80,.2);}
.input-with-action .inline-icon-btn:hover{background:#e2e8f1;border-color:#b5c0cc;transform:translateY(-2px);} 
.input-with-action .inline-icon-btn:active{transform:translateY(0);background:#d9e0ea;} 

/* ISBN Search Styles */
.btn-small.btn-secondary {
    background: #6c757d;
    color: white;
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.btn-small.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-small.btn-secondary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.book-detail-value code { background:#f8f9fa; padding:2px 6px; border-radius:4px; font-family:'Courier New', monospace; font-size:0.9em; color:#495057; }

.book-info-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.book-info-row .book-info-field {
    flex: 1;
    margin-bottom: 0;
}

.book-info-field {
    margin-bottom: 20px;
}

/* Shared Category / Series / Narrator Suggestion Modal Styles */
#categorySearchModal .modal-content.category-modal-panel,
#isbnSearchModal .modal-content.category-modal-panel,
#descriptionSearchModal .modal-content.category-modal-panel,
#seriesSearchModal .modal-content.category-modal-panel,
#narratorSearchModal .modal-content.category-modal-panel,
#lengthSearchModal .modal-content.category-modal-panel,
#descriptionSearchModal .modal-content.category-modal-panel,
#formatEditModal .modal-content.category-modal-panel{max-width:880px;width:92%;padding:34px 38px 42px 38px;position:relative;}
#lengthSearchModal .modal-close-btn,
#narratorSearchModal .modal-close-btn,
#seriesSearchModal .modal-close-btn,
#categorySearchModal .modal-close-btn,
#isbnSearchModal .modal-close-btn,
#pageSearchModal .modal-close-btn,
#descriptionSearchModal .modal-close-btn,
#descriptionSearchModal .modal-close-btn,
#formatEditModal .modal-close-btn{position:absolute;top:10px;right:12px;background:transparent;border:none;font-size:20px;cursor:pointer;color:#667;}
#lengthSearchModal .category-modal-header,
#narratorSearchModal .category-modal-header,
#seriesSearchModal .category-modal-header,
#categorySearchModal .category-modal-header,
#isbnSearchModal .category-modal-header,
#pageSearchModal .category-modal-header,
#descriptionSearchModal .category-modal-header,
#descriptionSearchModal .category-modal-header,
#formatEditModal .category-modal-header{margin-bottom:18px;}
#lengthSearchModal .category-modal-title,
#narratorSearchModal .category-modal-title,
#seriesSearchModal .category-modal-title,
#categorySearchModal .category-modal-title,
#isbnSearchModal .category-modal-title,
#pageSearchModal .category-modal-title,
#descriptionSearchModal .category-modal-title,
#descriptionSearchModal .category-modal-title,
#formatEditModal .category-modal-title{font-size:1.55rem;font-weight:600;color:#1f2733;letter-spacing:.5px;}
#lengthSearchModal .category-modal-title .cm-book-title,
#narratorSearchModal .category-modal-title .cm-book-title,
#seriesSearchModal .category-modal-title .cm-book-title,
#categorySearchModal .category-modal-title .cm-book-title,
#isbnSearchModal .category-modal-title .cm-book-title,
#pageSearchModal .category-modal-title .cm-book-title,
#descriptionSearchModal .category-modal-title .cm-book-title,
#descriptionSearchModal .category-modal-title .cm-book-title,
#formatEditModal .category-modal-title .cm-book-title{color:#364b8a;}
#lengthSearchModal .category-modal-sub,
#narratorSearchModal .category-modal-sub,
#seriesSearchModal .category-modal-sub,
#categorySearchModal .category-modal-sub,
#isbnSearchModal .category-modal-sub,
#pageSearchModal .category-modal-sub,
#descriptionSearchModal .category-modal-sub,
#descriptionSearchModal .category-modal-sub,
#formatEditModal .category-modal-sub{color:#6b7480;font-size:.85rem;margin-top:4px;}
#lengthSearchModal .category-current-bar,
#narratorSearchModal .category-current-bar,
#seriesSearchModal .category-current-bar,
#categorySearchModal .category-current-bar,
#isbnSearchModal .category-current-bar,
#pageSearchModal .category-current-bar,
#descriptionSearchModal .category-current-bar,
#descriptionSearchModal .category-current-bar,
#formatEditModal .category-current-bar{display:flex;flex-wrap:wrap;align-items:center;gap:10px;background:#f4f7fb;border:1px solid #e2e8f0;padding:10px 14px;border-radius:10px;margin-bottom:20px;}
#lengthSearchModal .category-current-bar .label,
#narratorSearchModal .category-current-bar .label,
#seriesSearchModal .category-current-bar .label,
#categorySearchModal .category-current-bar .label,
#isbnSearchModal .category-current-bar .label,
#pageSearchModal .category-current-bar .label,
#descriptionSearchModal .category-current-bar .label,
#descriptionSearchModal .category-current-bar .label,
#formatEditModal .category-current-bar .label{font-size:.65rem;font-weight:700;text-transform:uppercase;letter-spacing:.7px;color:#556070;background:#dde3ec;padding:4px 8px;border-radius:6px;}
#lengthSearchModal .category-current-bar .value-pill,
#narratorSearchModal .category-current-bar .value-pill,
#seriesSearchModal .category-current-bar .value-pill,
#categorySearchModal .category-current-bar .value-pill,
#isbnSearchModal .category-current-bar .value-pill,
#pageSearchModal .category-current-bar .value-pill,
#descriptionSearchModal .category-current-bar .value-pill,
#formatEditModal .category-current-bar .value-pill{background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;padding:6px 14px;border-radius:20px;font-size:.8rem;font-weight:600;}
#lengthSearchModal .legend-pill,
#narratorSearchModal .legend-pill,
#seriesSearchModal .legend-pill,
#categorySearchModal .legend-pill,
#isbnSearchModal .legend-pill,
#pageSearchModal .legend-pill,
#descriptionSearchModal .legend-pill,
#formatEditModal .legend-pill{display:flex;align-items:center;gap:4px;font-size:.62rem;font-weight:600;letter-spacing:.6px;padding:4px 8px;border-radius:30px;background:#e2e8f0;color:#384253;text-transform:uppercase;}
#lengthSearchModal .legend-pill.existing,
#narratorSearchModal .legend-pill.existing,
#seriesSearchModal .legend-pill.existing,
#categorySearchModal .legend-pill.existing,
#isbnSearchModal .legend-pill.existing,
#pageSearchModal .legend-pill.existing,
#descriptionSearchModal .legend-pill.existing,
#formatEditModal .legend-pill.existing{background:#daf5e5;color:#1e6a3d;}
#lengthSearchModal .legend-pill.new,
#narratorSearchModal .legend-pill.new,
#seriesSearchModal .legend-pill.new,
#categorySearchModal .legend-pill.new,
#isbnSearchModal .legend-pill.new,
#pageSearchModal .legend-pill.new,
#descriptionSearchModal .legend-pill.new,
#formatEditModal .legend-pill.new{background:#e2dcf8;color:#4b2f73;}
#lengthSearchModal .legend-spacer,
#narratorSearchModal .legend-spacer,
#seriesSearchModal .legend-spacer,
#categorySearchModal .legend-spacer,
#isbnSearchModal .legend-spacer,
#pageSearchModal .legend-spacer,
#descriptionSearchModal .legend-spacer,
#formatEditModal .legend-spacer{flex:1;}
#lengthSearchModal .category-results-grid,
#narratorSearchModal .category-results-grid,
#seriesSearchModal .category-results-grid,
#categorySearchModal .category-results-grid,
#isbnSearchModal .category-results-grid,
#pageSearchModal .category-results-grid,
#descriptionSearchModal .category-results-grid,
#formatEditModal .category-results-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:18px;max-height:360px;overflow-y:auto;padding:4px;}
#lengthSearchModal .category-card,
#narratorSearchModal .category-card,
#seriesSearchModal .category-card,
#categorySearchModal .category-card,
#isbnSearchModal .category-card,
#pageSearchModal .category-card,
#descriptionSearchModal .category-card,
#formatEditModal .category-card{border:1px solid #e1e6ef;background:#fafbfc;border-radius:14px;padding:14px 16px;display:flex;flex-direction:column;gap:10px;cursor:pointer;transition:box-shadow .18s, transform .18s, border-color .2s;position:relative;}
#lengthSearchModal .category-card.selected,
#narratorSearchModal .category-card.selected,
#seriesSearchModal .category-card.selected,
#categorySearchModal .category-card.selected,
#isbnSearchModal .category-card.selected,
#pageSearchModal .category-card.selected,
#descriptionSearchModal .category-card.selected,
#formatEditModal .category-card.selected{border-color:#667eea;box-shadow:0 4px 14px -2px rgba(102,126,234,.38);background:#f3f7ff;}
#lengthSearchModal .category-card:hover,
#narratorSearchModal .category-card:hover,
#seriesSearchModal .category-card:hover,
#categorySearchModal .category-card:hover,
#isbnSearchModal .category-card:hover,
#pageSearchModal .category-card:hover,
#descriptionSearchModal .category-card:hover,
#formatEditModal .category-card:hover{box-shadow:0 6px 18px -4px rgba(40,51,80,.25);transform:translateY(-3px);}
#lengthSearchModal .category-card .card-top,
#narratorSearchModal .category-card .card-top,
#seriesSearchModal .category-card .card-top,
#categorySearchModal .category-card .card-top,
#isbnSearchModal .category-card .card-top,
#pageSearchModal .category-card .card-top,
#descriptionSearchModal .category-card .card-top,
#formatEditModal .category-card .card-top{display:flex;justify-content:space-between;align-items:flex-start;gap:8px;}
#lengthSearchModal .cat-pill,
#narratorSearchModal .cat-pill,
#seriesSearchModal .cat-pill,
#categorySearchModal .cat-pill,
#isbnSearchModal .cat-pill,
#pageSearchModal .cat-pill,
#descriptionSearchModal .cat-pill,
#formatEditModal .cat-pill{font-size:.75rem;font-weight:600;padding:6px 12px;border-radius:18px;color:#fff;white-space:nowrap;box-shadow:0 2px 4px rgba(0,0,0,0.08);}
#lengthSearchModal .cat-pill.existing,
#narratorSearchModal .cat-pill.existing,
#seriesSearchModal .cat-pill.existing,
#categorySearchModal .cat-pill.existing,
#isbnSearchModal .cat-pill.existing,
#pageSearchModal .cat-pill.existing,
#descriptionSearchModal .cat-pill.existing,
#formatEditModal .cat-pill.existing{background:linear-gradient(135deg,#28a745,#20c997);} 
#lengthSearchModal .cat-pill.new,
#narratorSearchModal .cat-pill.new,
#seriesSearchModal .cat-pill.new,
#categorySearchModal .cat-pill.new,
#isbnSearchModal .cat-pill.new,
#pageSearchModal .cat-pill.new,
#descriptionSearchModal .cat-pill.new,
#formatEditModal .cat-pill.new{background:linear-gradient(135deg,#667eea,#764ba2);} 
#lengthSearchModal .source-pill,
#narratorSearchModal .source-pill,
#seriesSearchModal .source-pill,
#categorySearchModal .source-pill,
#isbnSearchModal .source-pill,
#pageSearchModal .source-pill,
#descriptionSearchModal .source-pill,
#formatEditModal .source-pill{background:#eef1f6;color:#445064;font-size:.55rem;font-weight:700;padding:5px 8px;border-radius:14px;letter-spacing:.8px;text-transform:uppercase;}
#lengthSearchModal .category-card .reason,
#narratorSearchModal .category-card .reason,
#seriesSearchModal .category-card .reason,
#categorySearchModal .category-card .reason,
#isbnSearchModal .category-card .reason,
#pageSearchModal .category-card .reason,
#descriptionSearchModal .category-card .reason,
#formatEditModal .category-card .reason{font-size:.68rem;line-height:1.25;color:#4a5662;background:#fff;border:1px solid #e3e8ef;padding:8px 9px;border-radius:8px;box-shadow:inset 0 0 0 1px rgba(255,255,255,.6);}
#lengthSearchModal .category-modal-actions,
#narratorSearchModal .category-modal-actions,
#seriesSearchModal .category-modal-actions,
#categorySearchModal .category-modal-actions,
#isbnSearchModal .category-modal-actions,
#pageSearchModal .category-modal-actions,
#descriptionSearchModal .category-modal-actions,
#formatEditModal .category-modal-actions{display:flex;gap:14px;margin-top:28px;}
@media (max-width:620px){#lengthSearchModal .category-results-grid,#narratorSearchModal .category-results-grid,#seriesSearchModal .category-results-grid,#categorySearchModal .category-results-grid,#pageSearchModal .category-results-grid,#descriptionSearchModal .category-results-grid,#formatEditModal .category-results-grid{grid-template-columns:1fr 1fr;}}
@media (max-width:520px){#lengthSearchModal .category-results-grid,#narratorSearchModal .category-results-grid,#seriesSearchModal .category-results-grid,#categorySearchModal .category-results-grid,#pageSearchModal .category-results-grid,#descriptionSearchModal .category-results-grid,#formatEditModal .category-results-grid{grid-template-columns:1fr;}#lengthSearchModal .category-modal-title,#narratorSearchModal .category-modal-title,#seriesSearchModal .category-modal-title,#categorySearchModal .category-modal-title,#pageSearchModal .category-modal-title,#descriptionSearchModal .category-modal-title,#formatEditModal .category-modal-title{font-size:1.3rem;}}

/* Description Search Specific Styles */
.description-search-btn {
    background: transparent;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 8px;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s, transform 0.1s;
}

.description-search-btn:hover {
    background-color: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.search-status {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.search-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #6c757d;
}

.search-icon {
    animation: spin 1s linear infinite;
}

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

.description-card .description-preview {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #495057;
    background: #fff;
    border: 1px solid #e9ecef;
    padding: 12px;
    border-radius: 8px;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.description-card .description-meta {
    font-size: 0.7rem;
    color: #6c757d;
    text-align: right;
    font-style: italic;
}

.legend-pill.searching {
    background: #fff3cd;
    color: #856404;
}

.value-pill.empty {
    background: #f8d7da;
    color: #721c24;
}

.category-modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* Mobile responsiveness for description cards */
@media (max-width: 520px) {
    .description-card .description-preview {
        font-size: 0.8rem;
        padding: 10px;
    }
    
    .description-search-btn {
        font-size: 0.8rem;
        margin-left: 6px;
    }
}

.book-info-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

/* Clickable format chip */
.meta-chip .format-chip-edit{cursor:pointer;position:relative;}
.meta-chip .format-chip-edit:hover{color:#364b8a;text-decoration:underline;}
.meta-chip .chip-action.inline{margin-left:4px;}

.book-info-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.book-info-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.book-info-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.book-info-input:invalid {
    border-color: #e74c3c;
}

.isbn-validation {
    margin-top: 5px;
    font-size: 14px;
    min-height: 20px;
}

.isbn-validation.valid {
    color: #27ae60;
}

.isbn-validation.invalid {
    color: #e74c3c;
}

.isbn-validation.warning {
    color: #f39c12;
}

.book-info-help {
    margin: 20px 0;
    padding: 12px;
    background-color: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 4px;
}

.book-info-help p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Responsive layout for book info edit */
@media (max-width: 768px) {
    .book-info-row {
        flex-direction: column;
        gap: 0;
    }
    
    .book-info-row .book-info-field {
        margin-bottom: 20px;
    }
}

.book-info-edit-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.book-info-edit-buttons .btn {
    min-width: 120px;
}

.book-info-edit-book-info {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.book-info-edit-book-info h3 {
    margin-bottom: 5px;
    color: #333;
}

.book-info-edit-book-info p {
    color: #666;
    font-style: italic;
}

/* Responsive adjustments for format editor */
@media (max-width: 768px) {
    .format-options {
        width: 100%;
    }
    
    .format-option {
        min-width: auto;
        width: 100%;
    }
    
    .format-edit-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .format-edit-buttons .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 15px;
}

.close:hover {
    color: #333;
}

.random-book-card {
    text-align: center;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid #667eea;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0ff 100%);
}

.random-book-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.random-book-author {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 15px;
}

/* Multi-pick random selection additions */
.random-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 10px;
}
.random-book-card.option {
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .2s, box-shadow .2s;
    position: relative;
}
.random-book-card.option:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102,126,234,.3);
}
.random-book-card.option.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,.2);
}
.random-book-card.option .selection-ring {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 14px;
    height: 14px;
    border: 2px solid #b3c2ff;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 2px #fff;
    transition: background .2s, border-color .2s;
}
.random-book-card.option.selected .selection-ring {
    background: #667eea;
    border-color: #667eea;
}
.multi-pick-instructions {
    font-size: .8rem;
    color: #556;
    margin-top: 4px;
    text-align: center;
}
.random-pick-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    justify-content: center;
    flex-wrap: wrap;
}
.random-pick-actions .btn {
    flex: 1 1 auto;
    min-width: 140px;
}
.multi-pick-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #667eea;
    color: #fff;
    padding: 2px 8px;
    font-size: .7rem;
    border-radius: 12px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.random-book-details {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.random-book-detail {
    text-align: center;
}

.random-book-detail strong {
    display: block;
    color: #667eea;
    font-size: 0.9rem;
}

.book-detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
    margin: 20px 0;
}

.book-detail-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.book-detail-label {
    font-weight: 600;
    color: #495057;
    min-width: 120px;
}

.book-detail-value {
    color: #666;
}

/* Book Detail Cover Styles */
.book-detail-header {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: flex-start;
}

.book-detail-cover {
    flex-shrink: 0;
}

.book-detail-cover-image {
    width: 130px;
    height: auto;
    max-height: 200px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    object-fit: contain; /* show full cover without cropping top */
    background: #fff;
    padding: 4px;
}

/* If a dominant color background is desired for transparency, fallback */
.book-detail-cover-image[data-fallback-cover='1'] { object-fit: cover; }

.book-detail-cover-placeholder {
    width: 120px;
    height: 180px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Cover overlay search/change button */
.book-detail-cover { position: relative; }
.cover-search-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    backdrop-filter: blur(2px);
    transition: background 0.2s, transform 0.2s;
}
.cover-search-btn:hover { background: rgba(102,126,234,0.9); transform: scale(1.05); }
.cover-search-btn:active { transform: scale(0.95); }

/* Cover card unified styling */
.category-card.cover-card { position:relative; padding:8px 8px 10px; display:flex; flex-direction:column; align-items:center; }
.cover-card-thumb-wrapper { position:relative; width:100%; display:flex; justify-content:center; }
.cover-card-thumb { width:100%; max-width:120px; height:auto; border-radius:6px; box-shadow:0 4px 10px -2px rgba(0,0,0,0.3); background:#fff; }
.cover-card-overlay { position:absolute; left:6px; top:6px; background:rgba(0,0,0,0.55); color:#fff; padding:2px 6px; font-size:11px; border-radius:4px; backdrop-filter:blur(2px); }
.cover-card-qual { position:absolute; right:6px; top:6px; background:#667eea; color:#fff; padding:2px 6px; font-size:11px; border-radius:4px; }
.cover-card-qual.medium-quality { background:#6c757d; }
.cover-card-qual.low-quality { background:#b85; }
.cover-card-meta { margin-top:6px; font-size:12px; color:#555; text-align:center; }
.category-card.cover-card.selected { outline:3px solid #667eea; }

.book-detail-title-section {
    flex: 1;
    min-width: 0; /* Allows text to wrap properly */
}

.book-detail-title-section h3 {
    margin: 0 0 10px 0;
    font-size: 1.8rem;
    color: #333;
    line-height: 1.2;
}

.book-detail-author {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #666;
    font-style: italic;
}

.book-description {
    margin: 15px 0 0 0;
    padding: 15px 0;
    border-top: 1px solid #eee;
}

.book-description p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
    text-align: justify;
    max-height: 120px;
    overflow-y: auto;
}

.book-description-full {
    margin: 20px 0 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.book-description-full h4 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

.book-description-full p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: #555;
    text-align: justify;
}

.notes-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.notes-section h4 {
    color: #495057;
    margin-bottom: 10px;
}

.reading-sessions {
    margin-top: 15px;
}

.session-item {
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #dee2e6;
    background: #ffffff;
}

.session-item.current-session {
    border-left-color: #28a745;
    background: #f8fff9;
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
    gap: 10px;
}

.session-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.session-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.session-header strong {
    color: #495057;
}

.session-header em {
    color: #666;
    font-size: 0.9rem;
}

.session-edit-btn {
    padding: 4px 8px;
    font-size: 12px;
    min-width: auto;
    height: auto;
    flex-shrink: 0;
}

.session-delete-btn {
    padding: 4px 8px;
    font-size: 12px;
    min-width: auto;
    height: auto;
    flex-shrink: 0;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.session-dates {
    font-size: 0.9rem;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
    }

    .header-text {
        text-align: center;
    }
    
    .header-text h1 {
        font-size: 2rem; /* Slightly smaller on mobile */
        margin-bottom: 8px;
    }
    
    .header-text p {
        font-size: 1rem;
    }

    .user-profile {
        min-width: auto;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .user-profile-toggle {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 16px;
    }

    .user-info {
        align-items: center;
    }

    .profile-dropdown-arrow {
        margin-top: 4px;
    }

    .user-profile-menu {
        right: auto;
        left: 0;
        width: 100%;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-sections {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .stats-numbers {
        gap: 20px;
    }

    .action-section {
        justify-content: center;
    }

    .modal-content {
        margin: 2% auto;
        width: 95%;
        padding: 20px;
        max-height: 95vh;
    }

    .book-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }

    .book-detail-cover-image,
    .book-detail-cover-placeholder {
        width: 100px;
        height: 150px;
    }

    .book-detail-cover-placeholder {
        font-size: 2.5rem;
    }

    .book-detail-title-section h3 {
        font-size: 1.5rem;
    }

    .book-description p {
        font-size: 0.9rem;
        text-align: left;
        max-height: 100px;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 8px 6px;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .header-text h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .header-text p {
        font-size: 0.9rem;
        padding: 0 10px;
    }
    
    .controls {
        padding: 15px 16px;
        margin: 0 -5px 15px -5px;
    }
    
    .filter-group-title {
        font-size: 0.9rem;
    }
    
    /* Force single column layout for filter groups */
    .filter-row {
        flex-direction: column;
        gap: 14px;
    }
}

/* Loading and empty states */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #666;
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* Add Books Modal Styles */
#booksJsonInput {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    background: #f9f9f9;
    line-height: 1.4;
}

#booksJsonInput:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.add-books-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#jsonValidationMessage {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 500;
    display: none;
}

#jsonValidationMessage.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

#jsonValidationMessage.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Authentication Styles */
/* Initial Loading Screen */
.initial-loader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.initial-loader.show {
    display: flex;
}

.loader-content {
    text-align: center;
    color: white;
}

.loader-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 2s ease-in-out infinite;
}

.loader-content h2 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    font-weight: 300;
    letter-spacing: 1px;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

.loader-content p {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Authentication Screen */
.auth-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.auth-container.show {
    display: flex;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: authSlideIn 0.5s ease-out;
}

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

.auth-logo {
    font-size: 3rem;
    margin-bottom: 20px;
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.auth-subtitle {
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
}

.auth-button {
    background: #0078d4;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}

.auth-button:hover {
    background: #106ebe;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 120, 212, 0.3);
}

.auth-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-error {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    border-left: 4px solid #c62828;
    display: none;
}

.auth-error.show {
    display: block;
}

.auth-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #666;
    margin-top: 15px;
}

.auth-loading.show {
    display: flex;
}

.auth-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0078d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Remember Me Checkbox */
.auth-remember {
    margin-top: 20px;
    margin-bottom: 20px;
}

.remember-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #666;
    font-size: 0.95rem;
    user-select: none;
}

.remember-checkbox input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.remember-checkbox input[type="checkbox"]:checked {
    background: #0078d4;
    border-color: #0078d4;
}

.remember-checkbox input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
}

.remember-checkbox:hover input[type="checkbox"] {
    border-color: #0078d4;
}

/* Auto-login Status */
.auth-auto-login {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: #666;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.auth-auto-login.show {
    display: flex;
}

.auth-cancel-auto {
    background: transparent;
    border: 1px solid #6c757d;
    color: #6c757d;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-cancel-auto:hover {
    background: #6c757d;
    color: white;
}

/* User Profile Display */
.user-profile {
    display: none;
    position: relative;
    color: white;
    min-width: 250px;
}

.user-profile.show {
    display: block;
}

.user-profile-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

/* Override the default dropdown arrow for user profile */
.user-profile .dropdown-toggle:after {
    display: none;
}

.user-profile-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.user-email {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-bottom: 4px;
}

.user-sync-status {
    margin-top: 2px;
}

.user-sync-status .sync-status {
    font-size: 0.75rem !important;
    padding: 2px 6px !important;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-dropdown-arrow {
    font-size: 0.8rem;
    opacity: 0.8;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.user-profile.active .profile-dropdown-arrow {
    transform: rotate(180deg);
}

.user-profile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 200px;
    overflow: hidden;
    display: none;
}

.user-profile.active .user-profile-menu {
    display: block;
    animation: dropdownSlide 0.2s ease-out;
}

.user-profile-menu .dropdown-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    font-weight: 500;
}

.user-profile-menu .dropdown-item:hover {
    background-color: #f8f9fa;
}

.user-profile-menu .onedrive-login-btn {
    color: #0078d4;
    display: none;
}

.user-profile-menu .onedrive-logout-btn {
    color: #dc3545;
    display: none;
}

.user-profile-menu .auth-logout-btn {
    color: #dc3545;
}

.user-profile-menu .auth-logout-btn:hover {
    background-color: #fff5f5;
}

/* When used in stats section - no longer applicable */

/* Main app container - hidden by default */
.main-app {
    display: none;
}

.main-app.show {
    display: block;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Book Rating Modal Styles */
.rating-book-info {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

.rating-book-info h3 {
    margin: 0 0 8px 0;
    color: var(--primary-color);
    font-size: 1.3em;
}

.rating-book-info p {
    margin: 0;
    color: #666;
    font-style: italic;
}

.rating-section {
    text-align: center;
    margin-bottom: 25px;
}

.rating-section p {
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #333;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}

.star {
    font-size: 2.5em;
    cursor: pointer;
    transition: all 0.2s ease;
    filter: grayscale(100%);
    opacity: 0.4;
    user-select: none;
}

.star:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.star.active {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.05);
}

.star.hover-preview {
    filter: grayscale(0%);
    opacity: 0.7;
    transform: scale(1.05);
}

.rating-text {
    height: 24px;
    margin-bottom: 20px;
}

.rating-text span {
    font-weight: 500;
    color: #667eea;
    font-size: 1.1em;
}

.rating-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.rating-buttons .btn {
    min-width: 140px;
}

/* Rating display in table and details */
.book-rating {
    font-size: 0.9em;
    color: #f39c12;
}

.book-rating .stars {
    letter-spacing: 1px;
}

.book-rating .no-rating {
    color: #999;
    font-style: italic;
}

.book-rating.clickable-rating {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.book-rating.clickable-rating:hover {
    opacity: 0.7;
}

.book-rating.clickable-rating .no-rating {
    color: #667eea;
    text-decoration: underline;
}

.book-rating.clickable-rating .no-rating:hover {
    color: #5a6fd8;
}

/* Update book detail grid for rating */
.book-detail-item .rating-stars {
    color: #f39c12;
    font-size: 1.1em;
    letter-spacing: 2px;
}

/* Date Editing Modal Styles */
.date-edit-book-info {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.date-edit-book-info h3 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 1.3em;
}

.date-edit-book-info p {
    margin: 0;
    color: #666;
    font-style: italic;
}

.date-edit-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.date-field {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    background: #f8f9fa;
}

.date-field label {
    font-weight: 600;
    color: #333;
    min-width: 100px;
    margin: 0;
}

.date-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s ease;
}

.date-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.date-help {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
}

.date-help p {
    margin: 0;
    font-size: 13px;
    color: #1565c0;
    line-height: 1.4;
}

.date-edit-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.date-edit-buttons .btn {
    min-width: 120px;
}

/* Cover Selection Modal Styles */
.cover-selection-book-info {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.cover-selection-book-info h3 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 1.3em;
}

.cover-selection-book-info p {
    margin: 0;
    color: #666;
    font-style: italic;
}

.cover-search-section {
    margin-bottom: 25px;
}

.cover-search-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.cover-search-results {
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 20px;
    background: #f8f9fa;
}

.cover-search-loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cover-search-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.cover-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.cover-option {
    background: white;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cover-option:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.cover-option.selected {
    border-color: #667eea;
    background: #f8f9ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.cover-option-image {
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cover-option-source {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
    margin-bottom: 5px;
}

.cover-option-quality {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cover-option-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

.cover-option-badge.high-quality {
    background: #e8f5e8;
    color: #2e7d32;
}

.cover-option-badge.medium-quality {
    background: #fff3e0;
    color: #f57c00;
}

.cover-option-badge.low-quality {
    background: #ffebee;
    color: #c62828;
}

.cover-selection-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding-top: 20px;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

.cover-selection-buttons .btn {
    min-width: 140px;
}

.cover-upload-option {
    background: white;
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
}

.cover-upload-option:hover {
    background: #f8f9ff;
    border-color: #5a6fd8;
}

.cover-upload-option .upload-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 10px;
    display: block;
}

.cover-upload-option .upload-text {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.cover-upload-option .upload-hint {
    color: #999;
    font-size: 0.9rem;
}

.cover-preview {
    margin-top: 15px;
    text-align: center;
}

.cover-preview-image {
    max-width: 200px;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cover-preview-info {
    margin-top: 10px;
    color: #666;
    font-size: 0.9rem;
}

.no-covers-found {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.no-covers-found .icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
    opacity: 0.5;
}

.no-covers-found p {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}

.no-covers-found .suggestion {
    font-size: 0.9rem;
    color: #999;
}

/* Responsive adjustments for cover selection */
@media (max-width: 768px) {
    .cover-search-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .cover-search-controls .btn {
        width: 100%;
        max-width: 250px;
    }
    
    .cover-options-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .cover-option-image {
        width: 100px;
        height: 150px;
    }
    
    .cover-selection-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .cover-selection-buttons .btn {
        width: 100%;
        max-width: 250px;
    }
}

/* Responsive adjustments for date editing */
@media (max-width: 768px) {
    .date-field {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .date-field label {
        min-width: auto;
    }
    
    .date-edit-buttons {
        flex-direction: column;
    }
    
    .date-edit-buttons .btn {
        width: 100%;
    }
}

/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-top: 20px;
    gap: 20px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-controls .btn {
    min-width: 80px;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.pagination-controls .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
    color: #999;
}

.page-info {
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin: 0 8px;
}

.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #666;
}

.items-per-page label {
    font-weight: 500;
}

.items-per-page select {
    padding: 6px 10px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.items-per-page select:focus {
    outline: none;
    border-color: #667eea;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .pagination-controls .btn {
        min-width: 70px;
        font-size: 0.8rem;
    }
    
    .page-info {
        margin: 0;
        text-align: center;
        width: 100%;
    }
    
    .items-per-page {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .pagination-controls {
        gap: 4px;
    }
    
    .pagination-controls .btn {
        min-width: 60px;
        padding: 6px 8px;
        font-size: 0.75rem;
    }
}

/* Add Books Modal Tabs and Search */
.add-book-tabs {
    display: flex;
    border-bottom: 2px solid #e1e5e9;
    margin-bottom: 20px;
}

.tab-button {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.tab-button:hover {
    color: #667eea;
    background: #f8f9ff;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f8f9ff;
}

.add-book-section {
    display: none;
}

.add-book-section.active {
    display: block;
}

.search-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.search-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.search-field {
    display: flex;
    flex-direction: column;
}

.search-field label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #333;
}

.search-input {
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

.search-result-item {
    border-bottom: 1px solid #eee;
    padding: 15px 15px 18px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: block;
    position: relative;
}

/* Ensure nested items never appear indented (reset potential inherited margins) */
.search-result-item > .search-result-header > div > .search-result-title,
.search-result-item > .search-result-header > div > .search-result-author { margin-left:0 !important; }

.search-result-separator { height:10px; display:block; background:linear-gradient(to right, rgba(102,126,234,.25), transparent); margin:0; padding:0; border:0; }
.search-result-item * { margin-left:0; }
.search-result-item-abs + .search-result-item { margin-left:0; }

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

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

.search-result-item.selected {
    background: #e6f3ff;
    border-left: 4px solid #667eea;
}

/* Audiobookshelf specific styling */
.search-result-item-abs {
    background: #f7f3ff;
}
.search-result-item-abs:hover { background:#f0eaff; }

/* Visual separator between ABS block and others */
.search-result-separator { height:12px; background:linear-gradient(to right, #ddd 10%, transparent 40%); opacity:0.6; }

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

/* Source badges for search results */
.search-result-sources { display:flex; gap:4px; flex-wrap:wrap; max-width:160px; justify-content:flex-end; }
.badge-source { background: #eef2f7; color:#334; padding:2px 6px; border-radius:12px; font-size:0.65rem; font-weight:600; letter-spacing:.5px; text-transform:uppercase; white-space:nowrap; box-shadow:0 0 0 1px rgba(0,0,0,0.05); }
.badge-source.source-google { background:#e3f2fd; color:#0d47a1; }
.badge-source.source-open-library { background:#e8f5e9; color:#1b5e20; }
.badge-source.source-audiobookshelf { background:#f3e5f5; color:#6a1b9a; }
.badge-source:not(:hover){ transition:background .2s, color .2s; }
.badge-source:hover { filter:brightness(0.9); }

.search-result-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.search-result-author {
    color: #666;
    font-size: 0.9rem;
}

.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 8px 0 4px 0;
    font-size: 0.75rem;
    color: #555;
    line-height: 1.2;
}

.search-result-meta span {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.search-result-description {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.4;
    margin-top: 8px;
}

.search-result-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Search Result Loading States */
.search-result-item.loading {
    background: #f0f7ff;
    border-left: 4px solid #667eea;
    cursor: not-allowed;
    opacity: 0.8;
    position: relative;
}

.search-result-item.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.1);
    z-index: 1;
}

.search-result-item.loading .search-result-loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 500;
}

.search-result-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.search-results.processing {
    pointer-events: none;
}

.search-results.processing .search-result-item:not(.loading) {
    opacity: 0.5;
}

@media (max-width: 768px) {
    .search-fields {
        grid-template-columns: 1fr;
    }
    
    .search-actions {
        flex-direction: column;
    }
    
    .search-result-header {
        flex-direction: column;
    }
    
    .search-result-meta {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* Last Read column styling */
.last-read-dates {
    font-size: 0.85em;
    text-align: center;
}

.last-read-dates .start-date {
    color: #2196F3;
    margin-bottom: 2px;
    font-weight: 500;
}

.last-read-dates .finish-date {
    color: #4CAF50;
    font-weight: 500;
}

.last-read-dates .duration {
    color: #9C27B0;
    font-size: 0.8em;
    margin-top: 2px;
    font-style: italic;
}

.last-read-dates .no-reads {
    color: #9E9E9E;
    font-style: italic;
}

/* Times Read column styling */
.times-read-display {
    font-size: 0.9em;
    text-align: center;
}

.times-read-display .read-count {
    font-size: 1.2em;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 2px;
}

.times-read-display .read-label {
    font-size: 0.8em;
    color: #666;
}

.times-read-display .in-progress {
    color: #FF9800;
    font-style: italic;
    font-weight: 500;
}

.times-read-display .never-read {
    color: #9E9E9E;
    font-style: italic;
}

/* Column Selector Styles */

.column-selector-modal {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.column-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.column-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.column-checkbox:hover {
    background: #e3f2fd;
}

.column-checkbox.required {
    background: #fff3e0;
    border: 1px solid #ffcc80;
}

.column-checkbox.required:hover {
    background: #ffe0b2;
}

.column-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-label {
    font-weight: 500;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.column-checkbox.required .checkbox-label {
    color: #e65100;
}

.column-checkbox.required .checkbox-label em {
    font-size: 0.8rem;
    opacity: 0.8;
}

.column-presets {
    margin: 20px 0;
    padding: 20px;
    background: #f0f4f8;
    border-radius: 8px;
    border: 1px solid #b0bec5;
}

.column-presets h4 {
    margin-bottom: 15px;
    color: #37474f;
    font-size: 1rem;
}

.preset-btn {
    margin-right: 10px;
    margin-bottom: 10px;
    padding: 6px 12px;
    font-size: 0.85rem;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.preset-btn:hover {
    background: #1976D2;
}

.preset-btn:last-child {
    margin-right: 0;
}

/* Responsive column selector */
@media (max-width: 768px) {
    .column-selector-modal {
        width: 95%;
        max-height: 90vh;
    }
    
    .column-checkboxes {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .preset-btn {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}

/* Enhanced table responsiveness for custom columns */
@media (max-width: 1200px) {
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 800px;
    }
}

/* Mobile table improvements */
@media (max-width: 768px) {
    .table-container {
        margin: 0 -10px; /* Allow table to use full container width */
        border-radius: 8px;
    }
    
    table {
        min-width: 600px; /* Reduced from 800px for better mobile experience */
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 8px 6px; /* Reduced padding for mobile */
        font-size: 0.85rem;
    }
    
    th {
        white-space: nowrap;
        font-size: 0.8rem;
    }
    
    /* Hide less important columns on mobile */
    .table-container table th:nth-child(n+9), /* Hide series column and beyond */
    .table-container table td:nth-child(n+9) {
        display: none;
    }
    
    /* Ensure important columns remain visible */
    .cover-column,
    th[data-column="title"], td:nth-child(3), /* Title */
    th[data-column="author"], td:nth-child(4), /* Author */
    th[data-column="read_status"], td:nth-child(6), /* Status */
    .table-container table th:last-child, /* Actions */
    .table-container table td:last-child {
        display: table-cell !important;
    }
}

@media (max-width: 480px) {
    table {
        min-width: 500px;
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 6px 4px;
        font-size: 0.75rem;
    }
    
    /* Hide even more columns on very small screens */
    .table-container table th:nth-child(n+7), /* Hide rating column and beyond */
    .table-container table td:nth-child(n+7) {
        display: none;
    }
    
    /* Keep only essential columns visible */
    .cover-column,
    th[data-column="title"], td:nth-child(3), /* Title */
    th[data-column="author"], td:nth-child(4), /* Author */
    th[data-column="read_status"], td:nth-child(6), /* Status */
    .table-container table th:last-child, /* Actions */
    .table-container table td:last-child {
        display: table-cell !important;
    }
    
    .book-cover {
        width: 30px;
        height: 45px; /* Smaller covers on very small screens */
    }
    
    .cover-placeholder {
        width: 30px;
        height: 45px;
        font-size: 14px;
    }
}

/* Column visibility animations */
th, td {
    transition: opacity 0.3s ease;
}

th[style*="display: none"], 
td[style*="display: none"] {
    display: none !important;
}

/* Enhanced Statistics Modal Styles */
.enhanced-stats-modal {
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
}

.enhanced-stats-modal .modal-body {
    max-height: calc(90vh - 120px);
    overflow-y: auto;
    padding: 0;
}

/* Stats Navigation Tabs */
.stats-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    margin: 0;
    padding: 0;
}

.stats-tab-button {
    flex: 1;
    background: none;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.stats-tab-button:hover {
    color: #667eea;
    background: #ffffff;
}

.stats-tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #ffffff;
}

/* Tab Content */
.stats-tab-content {
    display: none;
    padding: 25px;
}

.stats-tab-content.active {
    display: block;
}

/* Overview Tab */
.stats-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 20px;
}

.stats-summary h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3em;
}

.overview-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.overview-stat-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.overview-stat-item:hover {
    transform: translateY(-2px);
}

.overview-stat-item .stat-number {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.overview-stat-item .stat-label {
    color: #666;
    font-size: 0.9em;
    font-weight: 500;
}

/* Charts Container */
.stats-charts {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-container h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
}

.chart-container canvas {
    max-height: 250px;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Reading Progress Tab */
.progress-controls {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.progress-controls label {
    font-weight: 500;
    margin-right: 10px;
    color: #333;
}

.progress-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.progress-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

/* Analytics Tab */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.analytics-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.analytics-section h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.analytics-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.speed-stat, .completion-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.speed-stat:last-child, .completion-stat:last-child {
    border-bottom: none;
}

.speed-label, .completion-label {
    font-weight: 500;
    color: #555;
}

.speed-value, .completion-value {
    font-weight: bold;
    color: #667eea;
}

.speed-detail {
    font-size: 0.9em;
    color: #888;
    margin-left: 10px;
}

.completion-breakdown {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.completion-item {
    text-align: center;
    padding: 15px;
    background: #f8f9ff;
    border-radius: 8px;
}

.completion-count {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.completion-type {
    color: #666;
    font-size: 0.9em;
}

/* Export Tab */
.export-section h4 {
    margin-bottom: 15px;
    color: #333;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.export-option {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.export-option h5 {
    margin-bottom: 8px;
    color: #333;
    font-size: 1.1em;
}

.export-option p {
    margin-bottom: 15px;
    color: #666;
}

.export-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sharing-section {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.sharing-section h4 {
    margin-bottom: 15px;
    color: #333;
}

.sharing-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.shareable-stats {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-top: 15px;
}

.shareable-stats pre {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

/* Responsive Design for Enhanced Stats */
@media (max-width: 768px) {
    .enhanced-stats-modal {
        width: 98%;
        margin: 1%;
    }
    
    .stats-tabs {
        flex-direction: column;
    }
    
    .stats-tab-button {
        border-bottom: none;
        border-right: 3px solid transparent;
    }
    
    .stats-tab-button.active {
        border-bottom: none;
        border-right-color: #667eea;
    }
    
    .stats-overview-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .overview-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .progress-charts {
        gap: 20px;
    }
    
    .completion-breakdown {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .export-buttons, .sharing-buttons {
        flex-direction: column;
    }
    
    .export-buttons .btn, .sharing-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .overview-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-tab-content {
        padding: 15px;
    }
    
    .overview-stat-item .stat-number {
        font-size: 1.5em;
    }
}

/* Fallback Chart Styles (when Chart.js is not available) */
.fallback-chart {
    padding: 20px;
}

.fallback-bar-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.fallback-bar-label {
    min-width: 120px;
    font-weight: 500;
    color: #333;
}

.fallback-bar {
    flex: 1;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.fallback-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.fallback-bar-value {
    min-width: 30px;
    text-align: right;
    font-weight: bold;
    color: #667eea;
}

.fallback-line-chart {
    padding: 20px;
    position: relative;
    height: 200px;
}

.fallback-chart-title {
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.fallback-line-data {
    position: relative;
    height: 150px;
    border-left: 2px solid #ddd;
    border-bottom: 2px solid #ddd;
    display: flex;
    align-items: end;
    justify-content: space-around;
    padding: 10px;
}

.fallback-line-point {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fallback-point {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    margin-bottom: 5px;
}

.fallback-point-label {
    font-size: 0.8em;
    color: #666;
}

/* Selection Controls Styling */
.selection-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    padding: 10px 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.selection-info {
    flex: 1;
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
}

.selection-buttons {
    display: flex;
    gap: 8px;
}

/* Selection Column Styling */
.selection-column {
    width: 40px;
    text-align: center;
    font-size: 0.9rem;
}

.selection-cell {
    text-align: center;
    padding: 8px 4px;
}

.book-selection-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    border: 2px solid #e1e5e9;
    border-radius: 3px;
    background: white;
    transition: all 0.2s;
}

.book-selection-checkbox:checked {
    background: #667eea;
    border-color: #667eea;
    position: relative;
}

.book-selection-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.book-selection-checkbox:hover {
    border-color: #667eea;
    transform: scale(1.1);
}

.selection-disabled {
    color: #ccc;
    font-size: 0.8rem;
}

/* Selected row styling */
tr.selected-for-random {
    background-color: rgba(102, 126, 234, 0.05);
    border-left: 3px solid #667eea;
}

/* Pick source styling in random pick modal */
.pick-source {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 500;
    text-align: center;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 4px;
}

/* Additional responsive improvements */
@media (max-width: 768px) {
    .selection-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .selection-buttons {
        justify-content: center;
    }
    
    .selection-column {
        width: 35px;
    }
}

/* Narrator display limitations */
.narrator-cell-limited {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    line-height: 1.4;
    max-height: calc(1.4em * 3); /* 3 lines */
    cursor: help;
}

.narrator-chip-limited {
    display: inline-block;
    max-width: 300px;
    max-height: 2.8em; /* Fixed height for consistency */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: help;
}

/* Enhanced tooltips for narrator display */
.narrator-cell-limited:hover,
.narrator-chip-limited:hover {
    position: relative;
}

/* Ensure narrator cells in table have consistent width */
td:has(.narrator-cell-limited) {
    max-width: 200px;
    word-wrap: break-word;
}

/* Modal chip specific narrator styling */
.dd-meta-grid .meta-chip:has(.narrator-chip-limited) {
    min-height: auto;
    height: auto;
    max-height: 60px; /* Fixed maximum height */
    overflow: hidden;
}
