/* LRDWeb. Calm, library-like, system fonts, one accent. */

:root {
    --bg: #fbfaf8;
    --surface: #ffffff;
    --surface-2: #f2f0ec;
    --ink: #1c1a19;
    --ink-2: #44403c;
    --muted: #6b6560;
    --line: rgba(28, 26, 25, 0.09);
    --line-strong: rgba(28, 26, 25, 0.16);
    --accent: #0a66d8;
    --accent-soft: rgba(10, 102, 216, 0.16);
    --warn-bg: #fdf3dc;
    --warn-fg: #7a4f00;
    --shadow-sm: 0 1px 2px rgba(28, 26, 25, 0.05);
    --shadow-md: 0 10px 24px -12px rgba(28, 26, 25, 0.22), 0 2px 6px -2px rgba(28, 26, 25, 0.06);
    --toolbar-bg: rgba(251, 250, 248, 0.84);
    --skeleton: #eeebe7;

    --pdf-bg: #fdeceb;   --pdf-fg: #b42318;
    --text-bg: #e9f0fd;  --text-fg: #1d5bd6;
    --audio-bg: #f1ebfd; --audio-fg: #6941c6;
    --image-bg: #e7f6ec; --image-fg: #13803d;
    --data-bg: #eef0f2;  --data-fg: #475467;

    --radius: 14px;
    --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
    --serif: ui-serif, "New York", "Iowan Old Style", Charter, "Source Serif Pro", Georgia, serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #121110;
        --surface: #1b1a18;
        --surface-2: #252321;
        --ink: #f4f2ef;
        --ink-2: #d6d1cb;
        --muted: #a39d96;
        --line: rgba(255, 255, 255, 0.08);
        --line-strong: rgba(255, 255, 255, 0.15);
        --accent: #5aa2ff;
        --accent-soft: rgba(90, 162, 255, 0.22);
        --warn-bg: rgba(250, 196, 82, 0.12);
        --warn-fg: #f5c968;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 12px 28px -14px rgba(0, 0, 0, 0.7), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
        --toolbar-bg: rgba(18, 17, 16, 0.82);
        --skeleton: #22201e;
        --pdf-bg: rgba(249, 112, 102, 0.14);   --pdf-fg: #fda29b;
        --text-bg: rgba(132, 173, 255, 0.14);  --text-fg: #a9c7ff;
        --audio-bg: rgba(189, 164, 255, 0.15); --audio-fg: #cbb8ff;
        --image-bg: rgba(117, 224, 160, 0.13); --image-fg: #8ee3ae;
        --data-bg: rgba(208, 213, 221, 0.12);  --data-fg: #d0d5dd;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #121110;
    --surface: #1b1a18;
    --surface-2: #252321;
    --ink: #f4f2ef;
    --ink-2: #d6d1cb;
    --muted: #a39d96;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.15);
    --accent: #5aa2ff;
    --accent-soft: rgba(90, 162, 255, 0.22);
    --warn-bg: rgba(250, 196, 82, 0.12);
    --warn-fg: #f5c968;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 28px -14px rgba(0, 0, 0, 0.7), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
    --toolbar-bg: rgba(18, 17, 16, 0.82);
    --skeleton: #22201e;
    --pdf-bg: rgba(249, 112, 102, 0.14);   --pdf-fg: #fda29b;
    --text-bg: rgba(132, 173, 255, 0.14);  --text-fg: #a9c7ff;
    --audio-bg: rgba(189, 164, 255, 0.15); --audio-fg: #cbb8ff;
    --image-bg: rgba(117, 224, 160, 0.13); --image-fg: #8ee3ae;
    --data-bg: rgba(208, 213, 221, 0.12);  --data-fg: #d0d5dd;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.55 var(--sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--accent-soft); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
    position: absolute; left: 16px; top: -48px; z-index: 50;
    background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px;
    text-decoration: none; font-weight: 600; transition: top 0.15s ease;
}
.skip:focus { top: 12px; }
.mono { font-family: var(--mono); font-size: 0.92em; }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }
@media (min-width: 1024px) { .wrap { padding: 0 32px; } }

/* ---------- Masthead ---------- */
.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner { display: flex; align-items: center; gap: 10px; height: 60px; }
.brand { flex: none; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; min-height: 44px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.wordmark { font-weight: 650; font-size: 17px; letter-spacing: -0.015em; }
.indie {
    font-size: 11.5px; font-weight: 550; color: var(--muted); letter-spacing: 0.01em;
    border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 9px; white-space: nowrap;
    min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 400px) {
    .masthead-inner { gap: 8px; }
    .brand { gap: 8px; }
    .indie { font-size: 11px; padding: 2px 7px; }
    .masthead-actions { gap: 0; }
    .icon-btn { width: 40px; }
}
.masthead-actions { margin-left: auto; display: flex; gap: 4px; flex: none; }
.icon-btn {
    width: 44px; height: 44px; display: grid; place-items: center;
    border: 0; background: transparent; border-radius: 12px; color: var(--ink-2);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none !important; }
:root[data-theme="dark"] .i-sun { display: block !important; }
:root[data-theme="dark"] .i-moon { display: none !important; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .i-sun { display: block !important; }
    :root:not([data-theme="light"]) .i-moon { display: none !important; }
}

/* ---------- Intro ---------- */
.intro { padding-top: 36px; padding-bottom: 18px; }
@media (min-width: 768px) { .intro { padding-top: 56px; padding-bottom: 24px; } }
.intro h1 {
    font-family: var(--serif); font-weight: 600;
    font-size: clamp(2rem, 1.35rem + 2.6vw, 3rem); line-height: 1.08; letter-spacing: -0.02em;
    margin: 0 0 12px; text-wrap: balance;
}
.lede { margin: 0; max-width: 58ch; color: var(--ink-2); font-size: 17px; line-height: 1.55; text-wrap: pretty; }
.stats { margin: 14px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .stats { min-height: 3.1em; } } /* two lines once filled in */

/* ---------- Toolbar ---------- */
.toolbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--toolbar-bg);
    -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
    border-bottom: 1px solid transparent;
    padding: 10px 0 0;
    transition: border-color 0.2s ease;
}
.toolbar.stuck { border-bottom-color: var(--line); }
.search-row { display: flex; gap: 8px; align-items: center; }

.search {
    flex: 1; min-width: 0; position: relative; display: flex; align-items: center;
    height: 46px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
    box-shadow: var(--shadow-sm); transition: border-color 0.15s ease, box-shadow 0.15s ease; cursor: text;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search > svg { width: 18px; height: 18px; margin: 0 2px 0 13px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
    padding: 0 8px; font-size: 16px; color: var(--ink);
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.kbd {
    font: 600 11.5px/1 var(--mono); color: var(--muted); border: 1px solid var(--line-strong);
    border-bottom-width: 2px; border-radius: 6px; padding: 4px 7px; margin-right: 10px;
}
@media (hover: none) { .kbd { display: none; } }
.clear {
    width: 36px; height: 36px; margin-right: 5px; display: grid; place-items: center;
    border: 0; border-radius: 9px; background: transparent; color: var(--muted);
}
.clear:hover { background: var(--surface-2); color: var(--ink); }
.clear svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.search:has(.clear:not([hidden])) .kbd { display: none; }

.types {
    display: none; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px;
    border: 1px solid var(--line);
}
.types button {
    height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent;
    color: var(--ink-2); font-size: 14px; font-weight: 550; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.types button:hover { color: var(--ink); }
.types button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.types .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 12.5px; }

.type-select { position: relative; flex: none; }
.type-select select {
    appearance: none; -webkit-appearance: none; height: 46px; padding: 0 34px 0 14px; width: 128px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
    font-size: 15px; font-weight: 550; color: var(--ink); box-shadow: var(--shadow-sm); cursor: pointer;
}
.type-select svg { position: absolute; right: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); pointer-events: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 900px) {
    .types { display: inline-flex; }
    .type-select { display: none; }
}

.chips-scroller {
    margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
}
.chips-scroller::-webkit-scrollbar { display: none; }
@media (min-width: 640px) { .chips-scroller { margin: 0 -24px; padding: 0 24px; } }
.chips { display: flex; gap: 8px; padding: 10px 0 12px; width: max-content; min-height: 58px; } /* reserved before load */
.chip {
    position: relative; height: 36px; padding: 0 14px; display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
    color: var(--ink-2); font-size: 14px; font-weight: 550; white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip::after { content: ""; position: absolute; inset: -4px 0; }
.chip:hover { border-color: var(--muted); color: var(--ink); }
.chip .n { color: var(--muted); font-weight: 500; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.chip.is-empty:not([aria-pressed="true"]) { opacity: 0.5; }

/* ---------- Results ---------- */
.results { padding-top: 18px; padding-bottom: 56px; outline: none; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 44px; }
@media (max-width: 560px) { .results-head { flex-direction: column; align-items: flex-start; gap: 0; } }
/* Hold the page open while the catalog loads, so the footer does not flash in
   and then jump away. */
.list[aria-busy="true"] { min-height: 100vh; }
.count { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.switch.is-pending { visibility: hidden; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); cursor: pointer; min-height: 44px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
    width: 38px; height: 23px; border-radius: 999px; background: var(--line-strong); position: relative;
    transition: background-color 0.2s ease; flex: none;
}
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.group-title {
    font-family: var(--serif); font-weight: 600; font-size: 24px; letter-spacing: -0.015em; line-height: 1.2;
    margin: 36px 0 4px; display: flex; align-items: baseline; gap: 10px;
}
.group-title:first-child { margin-top: 12px; }
.group-title .n, .sub-title .n { font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.sub-title {
    margin: 22px 0 10px; font-size: 12.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--muted); display: flex; align-items: baseline; gap: 8px;
}
.sub-title .sep { opacity: 0.55; margin: 0 1px; }
.group-title + .grid { margin-top: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }

/* ---------- Card ---------- */
.card {
    display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 12px; align-content: start;
    padding: 14px 14px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    animation: rise 0.22s ease-out both;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.card:hover .card-action { color: var(--accent); }
.card:hover .card-action svg { transform: translate(1px, -1px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.tile {
    width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; overflow: hidden;
    background: var(--data-bg); color: var(--data-fg);
}
.tile svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.card[data-type="pdf"] .tile { background: var(--pdf-bg); color: var(--pdf-fg); }
.card[data-type="text"] .tile { background: var(--text-bg); color: var(--text-fg); }
.card[data-type="audio"] .tile { background: var(--audio-bg); color: var(--audio-fg); }
.card[data-type="image"] .tile { background: var(--image-bg); color: var(--image-fg); }

.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-bottom: 12px; }
.card-title {
    font-weight: 600; font-size: 15px; line-height: 1.3; letter-spacing: -0.005em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-meta .dot { opacity: 0.6; }
.badge {
    font-size: 11.5px; font-weight: 650; letter-spacing: 0.01em; padding: 2px 7px; border-radius: 6px;
    background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.card-note { font-size: 12.5px; line-height: 1.4; color: var(--warn-fg); }

.card-foot {
    grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; justify-content: space-between;
    border-top: 1px solid var(--line); min-height: 42px;
}
.card-place {
    min-width: 0; padding: 9px 0; font-size: 12.5px; line-height: 1.35; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-action {
    flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; font-weight: 600;
    color: var(--ink-2); transition: color 0.15s ease;
}
.card-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s ease; }

.card[data-status="unverified"] { background: transparent; border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.card[data-status="unverified"] .card-title { color: var(--ink-2); }
.card[data-status="unverified"] .tile { filter: grayscale(1); opacity: 0.7; }
.card.is-disabled { cursor: default; }

/* ---------- Loading, empty and error states ---------- */
.skeleton { pointer-events: none; animation: none; }
.skeleton .tile, .skeleton .bar { background: var(--skeleton); }
.skeleton .bar { display: block; height: 11px; border-radius: 6px; }
.skeleton .bar + .bar { margin-top: 8px; }
.skeleton .card-body { padding-top: 4px; }
@media (prefers-reduced-motion: no-preference) {
    .skeleton .tile, .skeleton .bar { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.55; } }

.empty {
    text-align: center; max-width: 440px; margin: 40px auto; padding: 36px 20px;
    border: 1px dashed var(--line-strong); border-radius: 18px;
}
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); }
.empty-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.empty h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.empty p { margin: 0 auto; color: var(--muted); font-size: 14.5px; max-width: 36ch; }
.empty .btn { margin-top: 18px; }
.btn {
    display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px;
    border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 14.5px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.btn:hover { border-color: var(--muted); }

.more { height: 1px; }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.foot-inner { padding-top: 28px; padding-bottom: calc(44px + env(safe-area-inset-bottom)); }
.foot p { margin: 0 0 8px; max-width: 76ch; }
.foot strong { color: var(--ink-2); font-weight: 600; }
.foot a { color: var(--ink-2); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.foot a:hover { color: var(--ink); text-decoration-color: currentColor; }

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