/* ===== Tokens ===== */
:root {
    /* Dark is the default */
    --bg: #0e0f12;
    --bg-elev: #16181d;
    --bg-elev-2: #1d2027;
    --bg-hover: #23262e;
    --border: #2a2d36;
    --text: #eceef2;
    --text-muted: #9aa0ad;
    --text-faint: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2f6fde;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --warning-soft: rgba(251, 191, 36, 0.14);
    --warning: #fbbf24;
    --danger: #f87171;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --overlay: rgba(5, 6, 8, 0.6);
    --cover-from: #1f2937;
    --cover-to: #111827;
    --radius: 10px;
    --radius-lg: 14px;
    --topbar-h: 60px;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f5f6f8;
        --bg-elev: #ffffff;
        --bg-elev-2: #f0f2f5;
        --bg-hover: #e8ebf0;
        --border: #e2e5ea;
        --text: #111318;
        --text-muted: #5b6270;
        --text-faint: #8a909c;
        --accent: #2563eb;
        --accent-hover: #1d4fd8;
        --accent-soft: rgba(37, 99, 235, 0.1);
        --success: #059669;
        --success-soft: rgba(5, 150, 105, 0.1);
        --warning: #b45309;
        --warning-soft: rgba(180, 83, 9, 0.1);
        --danger: #dc2626;
        --shadow: 0 10px 30px rgba(17, 19, 24, 0.12);
        --overlay: rgba(17, 19, 24, 0.35);
        --cover-from: #dbe2ec;
        --cover-to: #c5cfdc;
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #f5f6f8;
    --bg-elev: #ffffff;
    --bg-elev-2: #f0f2f5;
    --bg-hover: #e8ebf0;
    --border: #e2e5ea;
    --text: #111318;
    --text-muted: #5b6270;
    --text-faint: #8a909c;
    --accent: #2563eb;
    --accent-hover: #1d4fd8;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.1);
    --warning: #b45309;
    --warning-soft: rgba(180, 83, 9, 0.1);
    --danger: #dc2626;
    --shadow: 0 10px 30px rgba(17, 19, 24, 0.12);
    --overlay: rgba(17, 19, 24, 0.35);
    --cover-from: #dbe2ec;
    --cover-to: #c5cfdc;
    color-scheme: light;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

a { color: var(--accent); }

.icon { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

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

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 14px;
    border-radius: 8px; border: 1px solid transparent;
    font-weight: 500; cursor: pointer; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--bg-elev); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0;
    border-radius: 8px; border: 1px solid transparent; background: transparent;
    color: var(--text-muted); cursor: pointer;
    transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ===== Top bar ===== */
.topbar {
    position: sticky; top: 0; z-index: 40;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1600px; margin: 0 auto;
    height: var(--topbar-h); padding: 0 24px;
    display: flex; align-items: center; gap: 16px;
}
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text); text-decoration: none; font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
}
.brand-mark {
    width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
    background-image:
        linear-gradient(#fff, #fff), linear-gradient(#fff, #fff),
        linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
    background-size: 7px 7px;
    background-position: 5px 5px, 14px 5px, 5px 14px, 14px 14px;
    background-repeat: no-repeat;
}
.search {
    flex: 1; max-width: 520px; position: relative;
    display: flex; align-items: center;
}
.search .icon { position: absolute; left: 12px; color: var(--text-faint); pointer-events: none; }
.search input {
    width: 100%; height: 38px; padding: 0 12px 0 38px;
    border-radius: 9px; border: 1px solid var(--border);
    background: var(--bg-elev); outline: none;
    transition: border-color .15s, background-color .15s;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: var(--accent); background: var(--bg-elev-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Menu */
.menu { position: relative; }
.menu-list {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 6px; z-index: 50;
}
.menu-list a {
    display: block; padding: 8px 10px; border-radius: 6px;
    color: var(--text); text-decoration: none;
}
.menu-list a:hover, .menu-list button:hover { background: var(--bg-hover); }
.menu-list button {
    display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
    border: 0; background: transparent; cursor: pointer;
}
.menu-list .menu-danger { color: var(--danger); border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; margin-top: 4px; }
.menu-version { margin: 4px 0 0; padding: 6px 10px 2px; font-size: 11.5px; color: var(--text-faint); border-top: 1px solid var(--border); }

/* ===== Empty state ===== */
.empty {
    min-height: calc(100vh - var(--topbar-h));
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px 16px; gap: 16px;
}
.dropzone {
    width: 100%; max-width: 560px;
    padding: 48px 32px; text-align: center;
    background: var(--bg-elev);
    border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
    cursor: pointer; transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--bg-elev-2); }
.dropzone-icon {
    width: 56px; height: 56px; margin: 0 auto 18px;
    border-radius: 14px; background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.dropzone-icon svg { width: 28px; height: 28px; fill: currentColor; }
.dropzone h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.02em; }
.dropzone p { margin: 0 0 20px; color: var(--text-muted); }
.dropzone .dropzone-formats { margin: 14px 0 0; font-size: 12px; color: var(--text-faint); letter-spacing: 0.04em; }
.dropzone a { color: var(--accent); text-decoration: none; }
.dropzone a:hover { text-decoration: underline; }

.receiving { text-align: center; max-width: 420px; }
.receiving h1 { margin: 18px 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.receiving p { margin: 0; color: var(--text-muted); }
.spinner {
    display: inline-block; width: 40px; height: 40px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.privacy-note {
    display: flex; align-items: center; gap: 8px;
    margin: 0; color: var(--text-muted); font-size: 13px;
}
.privacy-note .icon { color: var(--success); width: 16px; height: 16px; }
.error-message {
    max-width: 560px; margin: 0; padding: 10px 14px; border-radius: 8px;
    background: rgba(248, 113, 113, 0.12); color: var(--danger); text-align: center;
}

/* ===== Library ===== */
.library { max-width: 1600px; margin: 0 auto; padding: 24px; }

/* Stats */
.stats {
    display: grid; gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.6fr);
    margin-bottom: 24px;
}
.stat {
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; min-width: 0;
}
.stat-label { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.stat-value {
    margin-top: 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-sub { margin-top: 2px; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.stat-value.multi { font-size: 16px; line-height: 1.35; white-space: normal; }
.stat-value.multi div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value .saved { color: var(--success); }

.years { display: flex; flex-direction: column; }
.years-chart {
    display: flex; align-items: flex-end; gap: 4px;
    margin-top: 8px; min-height: 64px;
}
.year-bar {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    justify-content: flex-end; min-width: 0;
}
.year-bar span.bar {
    width: 100%; max-width: 28px; border-radius: 4px 4px 2px 2px;
    background: var(--accent); opacity: .85; min-height: 2px;
}
.year-bar:hover span.bar { opacity: 1; }
.year-bar span.lbl { font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* Toolbar */
.toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    height: 32px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--border); background: transparent; color: var(--text-muted);
    font-weight: 500; cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--text); background: var(--bg-elev); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-count { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-right: 4px; }

.select select {
    height: 36px; padding: 0 32px 0 12px; border-radius: 8px;
    border: 1px solid var(--border); background-color: var(--bg-elev); cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239aa0ad'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 18px;
}

/* Popover */
.popover { position: relative; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.popover-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 300px;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 14px;
    display: flex; flex-direction: column; gap: 12px;
}
.popover-panel fieldset { border: 0; margin: 0; padding: 0; }
.popover-panel legend { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-faint); }
.field-row input {
    width: 100%; height: 34px; padding: 0 8px; border-radius: 7px;
    border: 1px solid var(--border); background: var(--bg-elev-2); outline: none; min-width: 0;
}
.field-row input:focus { border-color: var(--accent); }

/* Grid */
.grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
    display: flex; flex-direction: column; text-align: left;
    padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-elev); overflow: hidden; cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow); }
.cover {
    position: relative; aspect-ratio: 460 / 215; overflow: hidden;
    background: linear-gradient(135deg, var(--cover-from), var(--cover-to));
}
.cover-initials {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700; letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--text) 35%, transparent);
    user-select: none;
}
.cover img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    opacity: 0; transition: opacity .3s ease;
}
.cover img.is-loaded { opacity: 1; }
/* Wikipedia box art is portrait: shown whole (contain) over a blurred, darkened copy that fills the frame */
.cover .cover-blur {
    position: absolute; inset: -12px;
    background-size: cover; background-position: center;
    filter: blur(14px) brightness(.55) saturate(1.2);
}
.cover img.cover-contain { object-fit: contain; }

/* ===== Pagination ===== */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin: 28px 0 8px; flex-wrap: wrap;
}
.page-numbers { display: flex; align-items: center; gap: 4px; }
.page-btn {
    min-width: 38px; height: 38px; padding: 0 10px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    border: 1px solid transparent; background: transparent; color: var(--text-muted);
    font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}
.page-btn:hover:not(:disabled) { background: var(--bg-elev); color: var(--text); }
.page-btn[aria-current="page"] { background: var(--text); color: var(--bg); cursor: default; }
.page-btn.page-step { border-color: var(--border); background: var(--bg-elev); color: var(--text); padding: 0 14px; }
.page-btn.page-step:hover:not(:disabled) { background: var(--bg-hover); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-btn .icon { width: 18px; height: 18px; }
.page-gap { min-width: 24px; text-align: center; color: var(--text-faint); }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title {
    margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: calc(1.35em * 2); word-break: break-word;
}
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.card-date { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.tag {
    display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
    border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tag-free { background: var(--success-soft); color: var(--success); }
.tag-paid { background: var(--bg-elev-2); color: var(--text); }
.tag-unknown { background: var(--bg-elev-2); color: var(--text-faint); }
.tag-gift { background: var(--warning-soft); color: var(--warning); }

.no-results { text-align: center; color: var(--text-muted); padding: 48px 16px; }

/* ===== Drawer ===== */
.drawer-backdrop {
    position: fixed; inset: 0; z-index: 60; background: var(--overlay);
    animation: fade-in .2s ease;
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
    width: min(440px, 100%);
    background: var(--bg-elev); border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateX(100%); transition: transform .25s ease;
    display: flex; flex-direction: column;
    visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer-close {
    position: absolute; top: 10px; right: 10px; z-index: 2;
    background: var(--overlay); color: #fff;
}
.drawer-close:hover { background: rgba(0, 0, 0, 0.7); color: #fff; }
.drawer-body { overflow-y: auto; flex: 1; }
.drawer .cover { border-radius: 0; }
.drawer-content { padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.drawer h2 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: -0.01em; word-break: break-word; }
.drawer-sub { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--text-muted); font-size: 13px; }
.section-title { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kv { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kv-row {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 12px; border-top: 1px solid var(--border);
}
.kv-row:first-child { border-top: 0; }
.kv-row dt { color: var(--text-muted); margin: 0; }
.kv-row dd {
    margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums;
    min-width: 0; word-break: break-all; display: flex; align-items: center; gap: 6px; justify-content: flex-end;
}
.kv-row.total dd { font-size: 16px; font-weight: 700; }
.kv-row .discount { color: var(--success); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.copy-btn { width: 28px; height: 28px; }
.copy-btn .icon { width: 15px; height: 15px; }

.order-items { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.order-item {
    display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px;
    border-top: 1px solid var(--border); text-align: left; background: transparent; border-left: 0; border-right: 0; border-bottom: 0;
    width: 100%; cursor: pointer;
}
.order-item:first-child { border-top: 0; }
.order-item:hover { background: var(--bg-hover); }
.order-item.is-current { background: var(--accent-soft); cursor: default; }
.order-item span:last-child { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.drawer-links { display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-links a {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
    border-radius: 8px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px;
}
.drawer-links a:hover { background: var(--bg-hover); }

/* ===== Export dialog ===== */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 80; background: var(--overlay);
    display: flex; align-items: center; justify-content: center; padding: 16px;
    animation: fade-in .18s ease;
}
.modal {
    width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); padding: 22px;
    display: flex; flex-direction: column; gap: 16px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.modal-sub { margin: -12px 0 0; color: var(--text-muted); font-size: 13px; }
.modal fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.modal legend { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; padding: 0; text-transform: uppercase; letter-spacing: .06em; }
.segmented { display: flex; gap: 0; }
.segmented legend { width: 100%; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: flex; align-items: center; justify-content: center; height: 36px;
    border: 1px solid var(--border); background: var(--bg-elev-2); cursor: pointer;
    font-weight: 600; font-size: 13px; letter-spacing: .03em; color: var(--text-muted);
    transition: background-color .15s, color .15s;
}
.segmented label:first-of-type span { border-radius: 8px 0 0 8px; }
.segmented label:last-of-type span { border-radius: 0 8px 8px 0; }
.segmented label + label span { border-left: 0; }
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.field-hint { margin: -8px 0 0; font-size: 12.5px; color: var(--text-faint); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.field-check {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-elev-2); cursor: pointer; min-width: 0;
}
.field-check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.field-check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-check small { display: block; color: var(--text-faint); font-size: 11px; }
.field-check.is-unavailable { opacity: .5; cursor: not-allowed; }
.field-check.is-core { border-style: dashed; }
.export-summary { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; color: var(--text); }
.export-summary.is-empty { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal .btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Drag overlay & toast ===== */
.drag-overlay {
    position: fixed; inset: 0; z-index: 100; pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border: 3px dashed var(--accent);
}
.drag-overlay span {
    padding: 12px 20px; border-radius: 10px; background: var(--bg-elev);
    font-weight: 600; box-shadow: var(--shadow);
}
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 110;
    padding: 10px 16px; border-radius: 9px; background: var(--text); color: var(--bg);
    font-weight: 500; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats .years { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .topbar-inner { padding: 0 16px; gap: 8px; flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding-top: 10px; padding-bottom: 10px; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    #load-another-btn span, #export-btn span { display: none; }
    #load-another-btn, #export-btn { width: 36px; padding: 0; }
    .field-grid { grid-template-columns: 1fr; }
    .page-step span { display: none; }
    .page-btn { min-width: 34px; height: 36px; padding: 0 6px; }
    .page-btn.page-step { padding: 0 8px; }
    .library { padding: 16px; }
    .stat-value { font-size: 18px; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .card-body { padding: 8px 10px 10px; }
    .card-title { font-size: 13px; }
    .toolbar-right { width: 100%; }
    .result-count { margin-right: auto; }
    .popover-panel { position: fixed; left: 16px; right: 16px; top: auto; width: auto; }
    .drawer { width: 100%; border-left: 0; }
    .dropzone { padding: 36px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
