/* ═══════════════════════════════════════════════════════
   ScholarStore — Mobile-first PWA
   Aesthetic: Editorial Library — warm, scholarly, precise
   ═══════════════════════════════════════════════════════ */

/* ─── Design Tokens ────────────────────────────────────── */

:root {
    /* Light theme: warm ivory + deep ink */
    --bg: #f5f0e8;
    --bg-subtle: #ede7db;
    --surface: #fffdf8;
    --surface-hover: #f9f5ec;
    --text: #1a1916;
    --text-secondary: #6b6660;
    --text-tertiary: #9e9690;
    --accent: #8b4513;
    --accent-hover: #a0522d;
    --accent-subtle: rgba(139, 69, 19, 0.08);
    --accent-light: rgba(139, 69, 19, 0.12);
    --border: #ddd5c8;
    --border-light: #e8e1d4;
    --success: #2d6a4f;
    --success-bg: #d8f3dc;
    --warning: #b08000;
    --warning-bg: #fef3c7;
    --error: #9b2c2c;
    --error-bg: #fee2e2;
    --shadow-sm: 0 1px 3px rgba(26,25,22,0.06);
    --shadow-md: 0 4px 12px rgba(26,25,22,0.08);
    --shadow-lg: 0 8px 24px rgba(26,25,22,0.10);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 100px;
    --font-serif: 'Source Serif 4', 'Georgia', serif;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --header-height: 56px;
    --search-height: 64px;
    --tabs-height: 48px;
    --pdf-color: #b33a2e;
    --pdf-bg: rgba(179, 58, 46, 0.08);
    --key-paper: #92400e;
    --key-paper-bg: #fef3c7;
    --read-color: #065f46;
    --read-bg: #d1fae5;
    --skimmed-color: #4338ca;
    --skimmed-bg: #e0e7ff;
}

.native-offline-notice {
    padding: 8px 16px;
    background: var(--warning-bg);
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
}
.native-reader-select {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 8px 0 16px;
    padding: 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141518;
        --bg-subtle: #1c1d22;
        --surface: #222328;
        --surface-hover: #2a2b31;
        --text: #e8e4dd;
        --text-secondary: #9b958d;
        --text-tertiary: #6b6660;
        --accent: #d4915c;
        --accent-hover: #e0a06e;
        --accent-subtle: rgba(212, 145, 92, 0.08);
        --accent-light: rgba(212, 145, 92, 0.12);
        --border: #2e2f35;
        --border-light: #27282d;
        --success: #6bc98b;
        --success-bg: rgba(45,106,79,0.2);
        --warning: #e0a030;
        --warning-bg: rgba(176,128,0,0.15);
        --error: #f87171;
        --error-bg: rgba(155,44,44,0.2);
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
        --pdf-color: #e8845a;
        --pdf-bg: rgba(232,132,90,0.1);
        --key-paper: #fbbf24;
        --key-paper-bg: rgba(251,191,36,0.12);
        --read-color: #6ee7b7;
        --read-bg: rgba(110,231,183,0.1);
        --skimmed-color: #a5b4fc;
        --skimmed-bg: rgba(165,180,252,0.1);
    }
}

/* ─── Reset & Base ─────────────────────────────────────── */

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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100%;
    overscroll-behavior-y: none;
}

.native-reader body { overscroll-behavior-y: auto; }
.library-refresh-status { color: var(--text-secondary); font-size: 12px; text-align: center; padding: 4px 0; }
#refresh-library[aria-busy="true"] svg { animation: library-refresh-spin 1s linear infinite; }
@keyframes library-refresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #refresh-library[aria-busy="true"] svg { animation: none; } }

/* iOS safe areas */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
    }
}

/* ─── Views / Routing ──────────────────────────────────── */

.view {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.view.active {
    display: flex;
    flex-direction: column;
    animation: viewFadeIn 0.2s ease-out;
}

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

/* ─── Search Header ────────────────────────────────────── */

.search-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    color: var(--accent);
}

.brand h1 {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
    background: var(--accent-subtle);
}

/* ─── Search Bar ───────────────────────────────────────── */

.search-bar {
    padding: 10px 16px 10px;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: color 0.2s;
}

.search-input-wrap:focus-within .search-icon {
    color: var(--accent);
}

#search-input {
    width: 100%;
    padding: 12px 40px 12px 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-sans);
    font-size: 16px; /* prevents iOS zoom */
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    -webkit-appearance: none;
}

#search-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 300;
}

#search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
    background: var(--surface);
}

.search-clear {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-subtle);
    color: var(--text-tertiary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.search-clear:active {
    background: var(--border);
}

/* ─── Semantic Toggle ─────────────────────────────────── */

.semantic-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.semantic-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 34px;
    height: 20px;
    background: var(--border);
    border-radius: var(--radius-pill);
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--surface);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: var(--shadow-sm);
}

.semantic-toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.semantic-toggle input:checked + .toggle-slider::after {
    transform: translateX(14px);
}

.toggle-label {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.semantic-toggle input:checked ~ .toggle-label {
    color: var(--accent);
}

/* ─── Similarity Score Badge ──────────────────────────── */

.similarity-score {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--success);
    background: var(--success-bg);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ─── Filter Tabs ──────────────────────────────────────── */

.filter-tabs {
    display: flex;
    gap: 6px;
    padding: 6px 16px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tab:not(.active):active {
    background: var(--accent-subtle);
}

/* ─── Sort Pills ──────────────────────────────────────── */

.sort-pills {
    display: flex;
    gap: 4px;
    padding: 0 16px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.sort-pills::-webkit-scrollbar {
    display: none;
}

.sort-pill {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sort-pill.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}

.sort-pill:not(.active):active {
    background: var(--bg-subtle);
}

/* ─── Results List ─────────────────────────────────────── */

.results-list {
    flex: 1;
    padding: 8px 12px;
}

/* Empty / Landing State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    color: var(--text-tertiary);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-sub {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Section labels */
.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    padding: 24px 0 8px;
}

/* Home dual sections */
.home-section {
    padding: 0 4px;
}

.home-section .section-label {
    padding: 16px 10px 8px;
}

/* ─── Result Card ──────────────────────────────────────── */

.result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    margin-bottom: 6px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.12s, box-shadow 0.12s;
    -webkit-tap-highlight-color: transparent;
}

.result-item:hover {
    background: var(--surface-hover);
}

.result-item:active {
    background: var(--surface-hover);
    box-shadow: var(--shadow-sm);
}

.result-body {
    flex: 1;
    min-width: 0;
}

.result-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.result-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    flex-shrink: 0;
}

.result-year {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
    flex-shrink: 0;
}

.result-title {
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-meta {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.result-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* PDF quick-open button on result card */
.result-pdf-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--pdf-bg);
    color: var(--pdf-color);
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.result-pdf-btn:active {
    background: rgba(179, 58, 46, 0.16);
}

.result-pdf-btn svg {
    flex-shrink: 0;
}

/* Remove from collection button on cards */
.result-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.result-remove-btn:hover {
    background: var(--error-bg);
    color: var(--error);
}

/* Tag badges */
.tag-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* Reading status badges */
.reading-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.reading-badge.key_paper {
    background: var(--key-paper-bg);
    color: var(--key-paper);
}

.reading-badge.read {
    background: var(--read-bg);
    color: var(--read-color);
}

.reading-badge.skimmed {
    background: var(--skimmed-bg);
    color: var(--skimmed-color);
}

/* Loading state */
.loading {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}

.loading::after {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    margin: 12px auto 0;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Result count */
.results-count {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 4px 4px 8px;
    font-weight: 500;
}

.results-count .engine-label {
    font-weight: 400;
    font-style: italic;
    opacity: 0.75;
    margin-left: 4px;
}

.load-more-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 16px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.load-more-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

/* ─── Detail View ──────────────────────────────────────── */

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: var(--header-height);
}

.header-title {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
}

.library-back {
    width: auto;
    min-height: 44px;
    gap: 4px;
    padding: 8px;
    font-size: 14px;
    text-decoration: none;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Detail card */
.detail-card {
    padding: 20px 16px;
}

.detail-title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    margin-bottom: 8px;
}

.detail-authors {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
}

.detail-journal {
    font-size: 14px;
    color: var(--text-tertiary);
    font-style: italic;
    margin-bottom: 16px;
}

/* Action buttons row */
.detail-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:active {
    transform: scale(0.97);
}

.action-btn.primary {
    background: var(--pdf-color);
    color: #fff;
    flex: 1;
    justify-content: center;
    min-height: 48px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(179, 58, 46, 0.2);
}

@media (prefers-color-scheme: dark) {
    .action-btn.primary {
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
}

.action-btn.primary:active {
    background: #9b3025;
}

.action-btn.secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 14px;
}

.action-btn.secondary:active {
    background: var(--bg-subtle);
}

/* Detail sections */
.detail-section {
    padding: 0 16px 20px;
}

.detail-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
}

.detail-section-header h2 {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
}

.detail-section p {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

.detail-section .abstract-text {
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.65;
}

.detail-section .video-description-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.detail-section ul {
    list-style: none;
    padding: 0;
}

.detail-section ul li {
    position: relative;
    padding-left: 16px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
}

.detail-section ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    background: var(--accent);
    border-radius: 50%;
}

/* Reading status selector */
.status-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.status-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.status-option.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
}

.status-option:active {
    transform: scale(0.96);
}

/* Notes editor */
.notes-area {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.notes-area:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.notes-area::placeholder {
    color: var(--text-tertiary);
}

/* Metadata footer */
.detail-meta-footer {
    padding: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.7;
}

/* Delete button — deliberately quiet, tucked into footer */
.delete-zone {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    color: var(--text-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.delete-btn:hover {
    color: var(--error);
    border-color: var(--error);
    background: var(--error-bg);
}

.delete-btn:active {
    transform: scale(0.96);
}

.delete-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Edit Mode ───────────────────────────────────────── */

.edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 10;
}

.edit-bar-label {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent);
}

.edit-bar-actions {
    display: flex;
    gap: 8px;
}

.edit-cancel-btn {
    padding: 8px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.edit-cancel-btn:hover {
    border-color: var(--text-tertiary);
    color: var(--text);
}

.edit-save-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.edit-save-btn:hover {
    background: var(--accent-hover);
}

.edit-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.edit-field {
    padding: 0 16px 16px;
}

.edit-field-label {
    display: block;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.edit-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

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

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

.edit-input--title {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
}

.edit-input--abstract {
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.6;
    min-height: 120px;
    resize: vertical;
}

.edit-input--notes {
    min-height: 80px;
    resize: vertical;
}

.edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 16px;
}

.edit-row .edit-field {
    padding: 0;
}

.edit-select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%239e9690' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.edit-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.edit-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 16px 16px;
}

/* ─── Add View ─────────────────────────────────────────── */

.add-form {
    padding: 20px 16px;
}

.add-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.type-btn.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
}

.type-btn:active {
    transform: scale(0.97);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 16px; /* prevents iOS zoom */
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
    font-weight: 300;
}

.input-with-action {
    display: flex;
    gap: 8px;
}

.input-with-action input {
    flex: 1;
}

#add-fetch-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

#add-fetch-btn:active {
    transform: scale(0.96);
    background: var(--accent-hover);
}

.add-status {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.4;
    display: none;
}

.add-status.visible {
    display: block;
    animation: statusSlideIn 0.25s ease-out;
}

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

.add-status.status-success {
    background: var(--success-bg);
    color: var(--success);
}

.add-status.status-error {
    background: var(--error-bg);
    color: var(--error);
}

.add-status.status-loading {
    background: var(--accent-subtle);
    color: var(--accent);
}

.add-confirmation {
    text-align: left;
}
.add-confirm-header {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    opacity: 0.7;
}
.add-confirm-title {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 6px;
    color: var(--text);
}
.add-confirm-meta {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.add-confirm-abstract {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.add-confirm-doi {
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-narrow {
    flex: 0 0 90px;
}

.manual-submit {
    width: 100%;
    padding: 14px;
    background: var(--surface);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.manual-submit:active {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

/* Paste button */
.paste-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 8px;
    padding: 10px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.paste-btn:active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

/* Publisher / Drive action button */
.action-btn.publisher {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    min-height: 44px;
    justify-content: center;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.2);
}

.action-btn.publisher:active {
    background: var(--accent-hover);
}

@media (prefers-color-scheme: dark) {
    .action-btn.publisher {
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
}

/* ─── Toast Notifications ──────────────────────────────── */

.toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 20px) + 16px);
    left: 16px;
    right: 16px;
    padding: 14px 16px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: toastIn 0.3s ease-out;
    text-align: center;
}

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

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

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

/* ─── Skeleton Loading ─────────────────────────────────── */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-subtle) 25%,
        var(--border-light) 50%,
        var(--bg-subtle) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    padding: 14px;
    margin-bottom: 6px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.h-16 { height: 16px; }

/* ─── Search Body (sidebar + results) ─────────────────── */

.search-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────── */

.sidebar {
    display: none;
}

@media (min-width: 768px) {
    .sidebar {
        display: flex;
        flex-direction: column;
        width: 220px;
        flex-shrink: 0;
        padding: 16px 14px;
        border-right: 1px solid var(--border-light);
        overflow-y: auto;
        background: var(--bg);
    }
}

.sidebar-stats {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.8;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-stats .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-stats .stat-value {
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tag-rail-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 9px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: var(--text-tertiary);
}
.tag-rail-toggle input { margin: 0; }

.tag-rail-sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag-rail-sidebar .tag-pill {
    font-size: 0.72rem;
    padding: 3px 9px;
}

/* ─── Responsive ───────────────────────────────────────── */

@media (min-width: 600px) {
    .results-list {
        padding: 12px 24px;
    }

    .detail-card,
    .detail-section,
    .detail-meta-footer {
        max-width: 680px;
        margin-left: auto;
        margin-right: auto;
    }

    .add-form {
        max-width: 500px;
        margin: 0 auto;
    }
}

/* On desktop, hide mobile-only stats and tag rail */
@media (min-width: 768px) {
    #mobile-stats,
    #tag-rail-mobile {
        display: none;
    }

    .results-list {
        flex: 1;
        overflow-y: auto;
        max-width: none;
    }
}

/* ─── Home Stats Bar (mobile) ─────────────────────────── */

.home-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px 2px;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-tertiary);
    letter-spacing: 0.01em;
}

.home-stats .stat-sep {
    opacity: 0.4;
}

/* ─── Home Tabs (Accessed / Added / Both) ─────────────── */

.home-tabs {
    justify-content: center;
    padding: 4px 16px 4px;
}

/* ─── Home Two-Column Grid ("Both" view) ──────────────── */

.home-both-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    align-items: start;
}

.home-both-grid .home-section .section-label {
    padding-top: 8px;
}

@media (max-width: 767px) {
    .home-both-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Home Empty State (per-tab) ──────────────────────── */

.home-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
}

/* ─── Card Actions (share / PDF / DOI) ─────────────────── */

.result-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.result-btn-row {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 1;
    transition: opacity 0.15s ease;
}

@media (min-width: 768px) {
    .result-actions {
        margin-left: 12px;
    }
}

/* Mobile: always visible, below the body */
@media (max-width: 767px) {
    .result-item {
        flex-wrap: wrap;
    }
    .result-actions {
        margin-top: 6px;
    }
    .result-btn-row {
        opacity: 1;
    }
}

.result-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.result-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle, rgba(139, 90, 43, 0.06));
}
.result-action-btn svg {
    flex-shrink: 0;
    opacity: 0.8;
}
.result-action-btn:hover svg {
    opacity: 1;
}

/* ─── Scrollbar (Desktop) ─────────────────────────────── */

@media (min-width: 600px) {
    ::-webkit-scrollbar {
        width: 6px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-tertiary);
    }
}

/* ─── Accessibility ────────────────────────────────────── */

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

/* Focus visible for keyboard nav */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hide outline for mouse/touch */
:focus:not(:focus-visible) {
    outline: none;
}

/* ─── Tag Rail ──────────────────────────────────────── */

.tag-rail {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 6px;
    -webkit-mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
    mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
    scrollbar-width: none;
}

.tag-rail::-webkit-scrollbar {
    display: none;
}

.tag-pill {
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tag-pill:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Collections ──────────────────────────────────── */

.sidebar-collections {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.collection-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 5px 10px;
    border: none;
    border-left: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.collection-pill:hover {
    background: var(--accent-subtle);
    border-left-color: var(--accent);
    color: var(--text);
}

.collection-pill.active {
    background: var(--accent-subtle);
    border-left-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
}

.collection-pill .count {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    background: var(--bg-subtle);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin-left: 6px;
}

.sidebar-create-btn {
    display: block;
    width: 100%;
    padding: 5px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-create-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* Collection view header */
.collection-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0 12px;
}

.collection-header h2 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.collection-header .collection-meta {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.collection-meta a {
    color: var(--accent);
    text-underline-offset: 2px;
}

.collection-header .collection-delete-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.collection-header .collection-delete-btn:hover {
    border-color: var(--error);
    color: var(--error);
    background: var(--error-bg);
}

/* Create collection modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    animation: modalFadeIn 0.15s ease-out;
}

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

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 90%;
    max-width: 360px;
    animation: modalSlideIn 0.2s ease-out;
}

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

.modal-card h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.modal-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 12px;
}

.modal-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.modal-card input::placeholder {
    color: var(--text-tertiary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.modal-actions button {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-actions .modal-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.modal-actions .modal-cancel:hover {
    background: var(--bg-subtle);
}

.modal-actions .modal-confirm {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #fff;
}

.modal-actions .modal-confirm:hover {
    background: var(--accent-hover);
}

/* Detail page: item collections section */
.item-collections {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.item-collection-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 0.8rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
}

.item-collection-badge:hover {
    background: var(--accent-light);
}

.item-collection-badge .remove-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 10px;
    line-height: 1;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
}

.item-collection-badge:hover .remove-x {
    opacity: 0.7;
}

.item-collection-badge .remove-x:hover {
    opacity: 1;
    background: var(--accent-light);
}

.add-to-collection-select {
    padding: 4px 8px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.add-to-collection-select:hover,
.add-to-collection-select:focus {
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Selection Mode ──────────────────────────────────── */

.select-toggle-btn {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.select-toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Result checkbox */
.result-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 8px;
    margin-top: 2px;
    transition: all 0.15s ease;
    cursor: pointer;
}
.result-checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.result-item.selectable {
    cursor: pointer;
}
.result-item.selected {
    background: var(--accent-subtle, rgba(139, 90, 43, 0.06));
    border-color: var(--accent);
}

/* Bulk toolbar */
.bulk-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 150;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(100%);
    transition: transform 0.2s ease-out;
}
.bulk-toolbar.visible {
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
.bulk-count {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.bulk-add-btn {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 8px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.bulk-add-btn:hover {
    opacity: 0.9;
}

.bulk-btn {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 8px 14px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.bulk-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle, rgba(139, 90, 43, 0.06));
}
.bulk-btn-danger {
    color: var(--error, #b00020);
    border-color: var(--error, #b00020);
}
.bulk-btn-danger:hover {
    background: var(--error, #b00020);
    color: white;
    border-color: var(--error, #b00020);
}
.bulk-btn-cancel {
    color: var(--text-tertiary);
}
.bulk-toolbar {
    gap: 10px;
    flex-wrap: wrap;
}

.filter-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-right: 16px;
}
.select-toggle-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Collection picker modal list */
.collection-picker-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 12px -20px;
}
.collection-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s ease;
}
.collection-picker-item:hover {
    background: var(--accent-subtle, rgba(139, 90, 43, 0.06));
}
.collection-picker-item:last-child {
    border-bottom: none;
}
.collection-picker-item.create-new {
    color: var(--accent);
    font-weight: 500;
}
.collection-picker-item .count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ─── Shared collection view ───────────────────────────── */

.shared-header {
    text-align: center;
    padding: 40px 20px 30px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.shared-header h1 {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px;
}
.shared-meta {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin: 0;
}
.shared-description {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 12px auto 0;
    max-width: 600px;
}
.shared-items {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
}
.shared-item {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}
.shared-item:last-child {
    border-bottom: none;
}
.shared-item-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 6px;
}
.shared-item-authors {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 4px;
}
.shared-item-meta {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}
.shared-abstract {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}
.shared-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}
.shared-tag {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-tertiary);
}
.shared-item-links {
    display: flex;
    gap: 8px;
}
.shared-pdf-btn,
.shared-doi-btn {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 4px;
    text-decoration: none;
    transition: opacity 0.15s ease;
}
.shared-pdf-btn {
    background: var(--pdf-color, #b33a2e);
    color: white;
}
.shared-doi-btn {
    background: var(--accent);
    color: white;
}
.shared-pdf-btn:hover,
.shared-doi-btn:hover {
    opacity: 0.85;
}

/* ─── Share button in collection header ─────────────────── */

.collection-share-btn {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 4px 12px;
    border: 1px solid var(--accent);
    color: var(--accent);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.collection-share-btn:hover {
    background: var(--accent);
    color: white;
}

/* ─── Share modal ───────────────────────────────────────── */

.share-url-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    margin: 12px 0;
}
.share-copy-btn {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 8px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.share-copy-btn:hover {
    background: var(--accent-hover);
}
.share-note {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 12px;
    line-height: 1.5;
}
.shared-loading {
    text-align: center;
    padding: 60px 20px;
    font-family: var(--font-sans);
    color: var(--text-tertiary);
}

.share-dialog-overlay .modal-card { max-width: 560px; max-height: 85vh; overflow-y: auto; }
.share-dialog-overlay input[type="checkbox"] { width: auto; margin: 0 6px 0 0; padding: 0; vertical-align: middle; }
.share-dialog-overlay .modal-actions { flex-wrap: wrap; gap: 8px; }
.share-dialog-overlay .share-note { color: var(--text-secondary); }
.pdf-sharing-controls { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.pdf-sharing-controls p { font-size: 0.85rem; line-height: 1.5; }
.pdf-sharing-controls ul { margin: 8px 0 12px; padding-left: 18px; max-height: 180px; overflow-y: auto; }
.pdf-sharing-controls li { font-size: 0.85rem; line-height: 1.5; margin-bottom: 8px; overflow-wrap: anywhere; }
.pdf-sharing-controls a { color: var(--accent); white-space: nowrap; }
.pdf-sharing-controls [hidden] { display: none; }

/* ─── Share button in detail actions ──────────────────── */

.action-btn.share {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.action-btn.share:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

/* ─── Shared individual item (public read-only view) ──── */

.shared-detail-type {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}
.shared-journal {
    font-style: italic;
}
.shared-detail-body {
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
.shared-detail-section {
    margin-bottom: 24px;
}
.shared-section-title {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}
.shared-detail-prose {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.65;
}
.shared-detail-keypoints {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin: 0;
    padding-left: 20px;
}
.shared-detail-keypoints li {
    margin-bottom: 4px;
}
.shared-detail-footer {
    text-align: center;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    margin-top: 32px;
}

/* ─── Login Screen ────────────────────────────────────── */

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 24px;
    text-align: center;
}

.login-logo {
    color: var(--accent);
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
}

.login-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text);
    margin-bottom: 8px;
}

.login-subtitle {
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn-google:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-md);
}

.btn-google:active {
    transform: scale(0.98);
}

/* ─── Sign Out Button ─────────────────────────────────── */

.signout-btn {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

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

/* ─── Header Actions (gear + signout) ────────────────── */

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

.settings-btn {
    color: var(--text-tertiary);
    transition: color 0.15s;
}
.settings-btn:hover {
    color: var(--accent);
}

/* ─── Settings View ──────────────────────────────────── */

.settings-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.settings-section {
    margin-bottom: 32px;
}

#google-account-connect[hidden] { display: none; }
.google-account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.settings-section-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 6px;
}

.settings-section-desc {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 16px;
    line-height: 1.5;
}

.iphone-setup-card {
    background: linear-gradient(180deg, var(--surface), rgba(255, 248, 229, 0.72));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}

.iphone-setup-steps {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.iphone-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text);
}

.iphone-step-num {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-subtle);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
    flex-shrink: 0;
}

.iphone-setup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.iphone-guide-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    transition: border-color 0.15s, color 0.15s, transform 0.15s;
}

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

.iphone-setup-note {
    margin-top: 12px;
    font-family: var(--font-sans);
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* API Keys List */
.api-keys-list {
    margin-bottom: 16px;
}

.api-keys-loading {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text-tertiary);
    padding: 12px 0;
}

.api-key-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: border-color 0.15s;
}
.api-key-item:hover {
    border-color: var(--border);
}

.api-key-info {
    flex: 1;
    min-width: 0;
}

.api-key-prefix {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.02em;
}

.api-key-desc {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.api-key-meta {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.api-key-revoke {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--text-tertiary);
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    margin-left: 12px;
}
.api-key-revoke:hover {
    color: var(--error);
    border-color: var(--error);
}

.api-key-inactive {
    opacity: 0.5;
}
.api-key-inactive .api-key-prefix::after {
    content: ' (revoked)';
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.api-keys-empty {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text-tertiary);
    padding: 16px 0;
    text-align: center;
}

/* Created key display */
.api-key-created {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
}

.api-key-created-label {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.api-key-created-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key-raw {
    flex: 1;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.78rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    word-break: break-all;
    user-select: all;
    color: var(--text);
}

.api-key-copy-btn {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.api-key-copy-btn:hover {
    background: var(--accent-subtle);
}

/* Create form */
.api-key-create-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.api-key-desc-input {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
}
.api-key-desc-input:focus {
    border-color: var(--accent);
}
.api-key-desc-input::placeholder {
    color: var(--text-tertiary);
}

.api-key-create-btn {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.api-key-create-btn:hover {
    background: var(--accent-hover);
}
.api-key-create-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Export controls */
.export-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-format-picker {
    display: flex;
    gap: 8px;
}

.export-btn {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.export-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}
.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.export-status {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ─── Reader View Overlay ─────────────────────────────── */

.reader-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.reader-overlay.open {
    opacity: 1;
}
.reader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 25, 22, 0.6);
    backdrop-filter: blur(2px);
}
@media (prefers-color-scheme: dark) {
    .reader-backdrop {
        background: rgba(0, 0, 0, 0.7);
    }
}
.reader-panel {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-light);
    transform: translateY(12px);
    transition: transform 0.25s ease;
}
.reader-overlay.open .reader-panel {
    transform: translateY(0);
}
@media (min-width: 640px) {
    .reader-panel {
        margin-top: 2vh;
        max-height: 96vh;
        border-radius: var(--radius-lg);
    }
}
.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
}
.reader-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.reader-close:hover {
    background: var(--border);
    color: var(--text);
}

/* Reader prose — editorial typography */
.reader-content {
    padding: 32px 24px 48px;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.75;
    color: var(--text);
    overflow-wrap: break-word;
    word-break: break-word;
}
@media (min-width: 640px) {
    .reader-content {
        padding: 40px 48px 64px;
        font-size: 1.15rem;
    }
}
.reader-content h1,
.reader-content h2,
.reader-content h3,
.reader-content h4 {
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--text);
    margin: 1.8em 0 0.6em;
    line-height: 1.3;
}
.reader-content h1 { font-size: 1.6em; }
.reader-find { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.reader-find input { width: 100%; max-width: 270px; min-width: 80px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.reader-find-count { white-space: nowrap; font-size: 12px; color: var(--text-secondary); }
.reader-find button { background: transparent; color: var(--text); border: 0; border-radius: 6px; padding: 8px; cursor: pointer; }
.reader-find button:disabled { opacity: .35; cursor: default; }
.reader-content mark.reader-find-hit { background: #ffe9a1; color: #242424; }
.reader-content mark.reader-find-hit.current { background: #ffc857; outline: 1px solid #9c6900; }
.reader-content h2 { font-size: 1.3em; }
.reader-content h3 { font-size: 1.1em; }
.reader-content p {
    margin: 0 0 1.2em;
}
.reader-content a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.reader-content a:hover {
    text-decoration-thickness: 2px;
}
.reader-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 1em 0;
}
.reader-content blockquote {
    margin: 1.2em 0;
    padding: 0.8em 1.2em;
    border-left: 3px solid var(--accent);
    background: var(--accent-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-secondary);
}
.reader-content pre,
.reader-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.88em;
}
.reader-content pre {
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1em;
    overflow-x: auto;
    margin: 1.2em 0;
}
.reader-content ul,
.reader-content ol {
    margin: 0.8em 0 1.2em 1.5em;
}
.reader-content li {
    margin-bottom: 0.4em;
}
.reader-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 0.9em;
}
.reader-content th,
.reader-content td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}
.reader-content th {
    background: var(--bg-subtle);
    font-weight: 600;
}
.reader-content figure {
    margin: 1.5em 0;
    text-align: center;
}
.reader-content figcaption {
    font-family: var(--font-sans);
    font-size: 0.85em;
    color: var(--text-tertiary);
    margin-top: 8px;
}

/* Reader button in action bar */
.action-btn.reader {
    color: var(--accent);
    border-color: var(--accent);
}
.action-btn.reader:hover {
    background: var(--accent-subtle);
}
.attach-url-dialog { width: min(520px, calc(100% - 32px)); margin: auto; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg); color: var(--text); max-height: calc(100dvh - 32px); overflow-y: auto; }
.attach-url-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.attach-url-dialog h2 { font-family: var(--font-serif); margin-bottom: 12px; }
.attach-url-dialog p { margin: 12px 0; line-height: 1.5; }
.attach-url-dialog label { display: block; margin: 20px 0 8px; font-weight: 600; }
.attach-url-dialog input { width: 100%; font: inherit; font-size: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.attach-url-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.attach-url-actions button { min-height: 44px; }
.pdf-search-snippet {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary, #667085);
    max-width: 70ch;
}
.pdf-search-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 2px;
}
.pdf-coverage {
    color: var(--text-secondary);
    font-size: 11px;
    margin: -4px 0 12px;
}
