/* Booky owns ONLY its page-content styling. The global design system -
   tokens, fonts, body background, and the topbar/sidebar/footer/profile/
   notification/language-switcher chrome - is served by account's shared
   shell (/api/shell/css/style.css, loaded first) so a change there adjusts
   every tool at once. Do NOT redefine :root tokens, body, or chrome here. */

:root {
    /* Native popups (select option lists) follow the dark page theme. */
    color-scheme: dark;
}

a { color: inherit; text-decoration: none; }

.text-muted { color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/* Buttons (booky content actions)                                         */
/* ---------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
}
.btn:hover { filter: brightness(1.1); }
.btn-block { display: flex; width: 100%; }
.btn.secondary, .btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn.danger, .btn-danger { background: var(--error); }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; }

/* ---------------------------------------------------------------------- */
/* Cards, forms, chips (booky-specific content)                            */
/* ---------------------------------------------------------------------- */
.card {
    background: var(--bg-panel);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.1rem 1.3rem;
    margin-bottom: 1.25rem;
}
/* backdrop-filter gives every .card its own stacking context, so a dropdown
   opened near the bottom of one card (e.g. Condition/Acquired from) would
   otherwise render behind the next card's background rather than on top of
   it, no matter how high the dropdown's own z-index is set. Bumping the
   whole card above its siblings while a lookup dropdown inside it is open
   fixes that without touching the widget's own stacking. */
.card:focus-within { position: relative; z-index: 30; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.1rem; }
.book-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.book-card:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.book-card-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--bg-input);
    display: block;
}
.book-card-cover--empty { display: flex; align-items: center; justify-content: center; color: var(--text-faint, var(--text-muted)); }
.book-card-cover--empty svg { width: 32%; height: 32%; opacity: 0.45; }
.book-card-body { flex: 1; padding: 0.7rem 0.8rem 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; }
.book-card-title { margin: 0; font-size: 0.95rem; font-weight: 600; line-height: 1.25; }
.book-card-author { margin: 0; color: var(--text-muted); font-size: 0.82rem; }
.book-card-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.2rem; }
.badge-rating { color: #eab308; letter-spacing: -1px; }

/* Status / format / book type / series: one pill style, overlaid at the top of
   the cover. A glassy dark pill + a soft top scrim keeps them readable on any
   cover, light or dark. */
.book-card-media { position: relative; }
.book-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.55rem 0.55rem 1.4rem;
    background: linear-gradient(to bottom, rgba(8, 6, 16, 0.5), rgba(8, 6, 16, 0));
    pointer-events: none;
}
.book-pill {
    display: inline-block;
    max-width: 100%;
    padding: 0.14rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(14, 12, 24, 0.62);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: var(--text-main);
    font-size: 0.72rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: auto;
}
.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-panel-hover);
    color: var(--text-main);
    margin-right: 0.25rem;
}
.badge-magenta { background: var(--accent-magenta); }

.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text-muted); }
.field input[type=text], .field input[type=number], .field input[type=date],
.field select, .field textarea,
.input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.25);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.field textarea { min-height: 5rem; resize: vertical; }
.input:hover:not(:disabled) { border-color: rgba(255,255,255,0.2); }
.input:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: rgba(0,0,0,0.35);
}
.input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(255,255,255,0.03);
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.required::after { content: " *"; color: var(--error); }
.help { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }

/* Live field validation (same green-valid language as account's login/register forms) */
.field input.field-valid, .field select.field-valid, .field textarea.field-valid,
.lookup-select-wrap input.field-valid {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}
.field input.field-invalid, .field select.field-invalid, .field textarea.field-invalid,
.lookup-select-wrap input.field-invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}
.field-feedback {
    font-size: 0.78rem;
    margin-top: 0.3rem;
    min-height: 0;
}
.field-feedback-error { color: var(--error); }
.field-feedback-success { color: #22c55e; }

/* Full rules checklist (account's login/register pattern) — one line per
   rule with its own live checkmark/x, used where a single blended message
   isn't enough to show which specific condition still needs meeting. */
.pw-rules {
    margin-top: 0.5rem;
    display: none;
    flex-direction: column;
    gap: 0.3rem;
}
.pw-rules.visible { display: flex; }
.pw-rule {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    transition: color 0.2s;
}
.pw-rule .pw-rule-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 800;
    flex-shrink: 0;
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
    transition: background 0.25s, color 0.25s;
}
.pw-rule.valid { color: #22c55e; }
.pw-rule.valid .pw-rule-icon { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.pw-rule.invalid { color: var(--error); }
.pw-rule.invalid .pw-rule-icon { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.form-error {
    color: var(--error);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    display: none;
}
.form-error.visible { display: block; }

.chip-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.chip { background: var(--bg-panel-hover); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.8rem; display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--border-color); }
.chip button { background: none; border: none; color: var(--text-main); cursor: pointer; font-size: 0.9rem; padding: 0; }

.image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.image-slot h4 { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--text-muted); }

/* Searchable single/multi select widgets (lookup-select.js) */
.lookup-select-wrap { position: relative; }
.lookup-search-input { width: 100%; }
.lookup-results {
    display: none;
    position: absolute;
    z-index: 20;
    top: 2.5rem; /* directly below the input, over any validation checks */
    left: 0;
    right: 0;
    margin-top: 0.15rem;
    max-height: 220px;
    overflow-y: auto;
    background: #14141c;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.lookup-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.7rem;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.85rem;
    cursor: pointer;
}
.lookup-option:hover { background: var(--bg-panel-hover); }
.lookup-option-add { color: var(--accent-purple); border-top: 1px solid var(--border-color); width: 100%; text-align: left; }
.lookup-add-row { display: flex; flex-direction: column; }
.lookup-make-default {
    padding: 0.4rem 0.7rem 0.6rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toggle switch (Settings: "make default", etc.) */
.switch-row { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .switch-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-panel-hover);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    transition: background 0.15s ease;
}
.switch .switch-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    top: 2px;
    background: var(--text-main);
    border-radius: 50%;
    transition: transform 0.15s ease;
}
.switch input:checked + .switch-slider { background: var(--accent-purple); border-color: var(--accent-purple); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.switch input:disabled + .switch-slider { opacity: 0.4; cursor: not-allowed; }

/* Toast notifications — same visual language and behavior as account's
   showToast (see amea-space-account/public/js/app.js), reimplemented here
   rather than shared since the two apps don't share a JS bundle. */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 100%;
    max-width: 400px;
    padding: 0 20px;
}
.toast {
    background: rgba(30, 30, 30, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    pointer-events: auto;
    cursor: pointer;
    animation: toast-slide-down 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.hiding { opacity: 0; transform: translateY(-20px) scale(0.95); }
.toast.error { border-left: 4px solid var(--error); }
.toast.success { border-left: 4px solid #22c55e; }
.toast.info { border-left: 4px solid var(--accent-purple); }
.toast-message { flex: 1; font-size: 0.95rem; line-height: 1.4; }
.toast-close { opacity: 0.6; transition: opacity 0.2s; font-size: 1.5rem; line-height: 1; display: flex; align-items: center; }
.toast:hover .toast-close { opacity: 1; }

@keyframes toast-slide-down {
    from { opacity: 0; transform: translateY(-40px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Pretty confirm dialog — account doesn't have a generic replacement for
   window.confirm() (it hand-builds a purpose-specific modal per case), but
   plain confirm() next to styled toasts would look inconsistent here, so
   this is a small reusable one instead. */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: confirm-fade-in 0.15s ease forwards;
}
.confirm-box {
    background: var(--bg-panel-hover);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 380px;
    width: calc(100% - 2rem);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.confirm-message { color: var(--text-main); font-size: 0.95rem; line-height: 1.5; margin: 0 0 1.25rem; }
.confirm-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }

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


/* ---------------------------------------------------------------------- */
/* Overview filter bar, search clear button, filter drawer, active chips   */
/* ---------------------------------------------------------------------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-bar__search { flex: 2; min-width: 220px; margin: 0; }
.filter-bar__sort { flex: 1; min-width: 170px; margin: 0; }
.filter-btn { height: 2.6rem; gap: 0.5rem; white-space: nowrap; }

/* Search input with an inline clear (X) button. The extra right padding keeps
   typed text from running underneath the button. */
.search-input { position: relative; }
.field .search-input input[type=text] { padding-right: 2.5rem; }
.search-input input::-webkit-search-cancel-button { display: none; }
.search-input__clear {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    width: 1.7rem;
    height: 1.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.search-input__clear:hover { color: var(--text-main); background: var(--bg-panel-hover); }
.search-input__clear:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }
.search-input__clear[hidden] { display: none; }

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--accent-purple);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
}
.filter-count[hidden] { display: none; }

/* Text-style action buttons ("Clear", "Clear all filters") */
.filter-link {
    background: none;
    border: none;
    padding: 0.2rem 0.3rem;
    color: var(--accent-purple);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    border-radius: 6px;
}
.filter-link:hover:not(:disabled) { text-decoration: underline; }
.filter-link:disabled { color: var(--text-muted); opacity: 0.5; cursor: default; }
.filter-link:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }
.filter-link[hidden] { display: none; }

/* Active filter chips under the bar */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: -0.4rem 0 1.25rem; }
.active-filters[hidden] { display: none; }
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    padding: 0.2rem 0.3rem 0.2rem 0.65rem;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.3);
    font-size: 0.8rem;
}
.filter-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.filter-chip button:hover { color: var(--text-main); background: rgba(139, 92, 246, 0.3); }
.filter-chip button:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }

/* Drawer sliding in from the right */
.filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 4, 12, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
    z-index: 2400;
}
.filter-overlay.is-open { opacity: 1; visibility: visible; }
.filter-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-left: 1px solid var(--border-soft);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
    z-index: 2500;
}
.filter-drawer.is-open { transform: none; visibility: visible; }
.filter-drawer__head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
}
.filter-drawer__head h2 { font-size: 1.05rem; margin: 0; flex: 1; }
.filter-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.filter-drawer__close:hover { color: var(--text-main); background: var(--bg-panel-hover); }
.filter-drawer__close:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }
.filter-drawer__body { flex: 1; overflow-y: auto; padding: 0.4rem 0; }
.filter-drawer__foot { padding: 0.9rem 1.1rem; border-top: 1px solid var(--border-soft); }

.filter-section { border-bottom: 1px solid var(--border-soft); }
.filter-section__head { display: flex; align-items: center; gap: 0.5rem; padding-right: 1.1rem; }
.filter-section__toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 0 0.85rem 1.1rem;
    background: none;
    border: none;
    color: var(--text-main);
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
}
.filter-section__toggle:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: -2px; }
.filter-section__chevron { margin-left: auto; color: var(--text-muted); transition: transform 0.15s ease; }
.filter-section__toggle[aria-expanded="true"] .filter-section__chevron { transform: rotate(180deg); }
.filter-section__body { padding: 0 1.1rem 0.9rem; }
.filter-section__body[hidden] { display: none; }
.filter-section__search { margin-bottom: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.85rem; }
.filter-section__empty { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.filter-options { list-style: none; margin: 0; padding: 0; max-height: 15rem; overflow-y: auto; }
.filter-options li[hidden] { display: none; }
.filter-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.2rem;
    border-radius: 8px;
    cursor: pointer;
}
.filter-option:hover { background: var(--bg-panel-hover); }
.filter-option__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.filter-option__count { color: var(--text-muted); font-size: 0.78rem; }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent-purple); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .filter-overlay, .filter-drawer, .filter-section__chevron, .book-card { transition: none; }
}

/* ---------------------------------------------------------------------- */
/* Add page + Editions                                                      */
/* ---------------------------------------------------------------------- */
.page-head { margin: 0 0 1.2rem; }
.page-head h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.page-head p { margin: 0; font-size: 0.9rem; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.add-edition-switch {
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0.9rem;
    margin-bottom: 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}
.add-edition-switch__text { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.9rem; }
.add-edition-switch__text .help { margin-top: 0; }
.field.isbn-off #f-isbn, .field.isbn-off .pw-rules { display: none !important; }
.field.isbn-off .add-no-isbn { margin-top: 0; }
.add-no-isbn { margin-top: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }

/* Picking the base book in edition mode */
.edition-results { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.4rem; }
.edition-result {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    text-align: left;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}
.edition-result:hover, .edition-result:focus-visible { border-color: var(--accent-purple); outline: none; }
.edition-result .text-muted { font-size: 0.8rem; }
.edition-chosen {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--accent-purple);
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.1);
}
.edition-chosen[hidden], #edition-pick[hidden], #edition-mode[hidden] { display: none; }
.edition-chosen__title { font-weight: 600; }

/* Difference rows: [field | value | remove] */
.edition-rows { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.6rem; }
.edition-row {
    display: grid;
    grid-template-columns: minmax(8rem, 11rem) 1fr auto;
    gap: 0.5rem;
    align-items: start;
}
.edition-row select, .edition-row input, .edition-row textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-main);
    font: inherit;
    font-size: 0.9rem;
}
.edition-row textarea { min-height: 4.5rem; resize: vertical; }
.edition-row select:focus, .edition-row input:focus, .edition-row textarea:focus {
    outline: none;
    border-color: var(--accent-purple);
}
.edition-row input:disabled { opacity: 0.5; }
.edition-row__remove {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}
.edition-row__remove:hover { color: var(--error); border-color: var(--error); }
.edition-row__error { grid-column: 1 / -1; color: var(--error); font-size: 0.8rem; }
.edition-row__error:empty { display: none; }
.edition-add-row { margin-top: 0.2rem; }
@media (max-width: 560px) {
    .edition-row { grid-template-columns: 1fr auto; }
    .edition-row__value { grid-column: 1 / -1; grid-row: 2; }
    .edition-row__remove { grid-column: 2; grid-row: 1; }
}

/* Editions section on the edit page */
.editions-list { display: flex; flex-direction: column; gap: 0.7rem; margin: 0.8rem 0; }
.edition-card {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-purple);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}
.edition-card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.edition-card__actions { display: flex; gap: 0.3rem; }
.edition-card__rows {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
    font-size: 0.88rem;
}
.edition-card__rows dt { color: var(--text-muted); }
.edition-card__rows dd { margin: 0; overflow-wrap: anywhere; }
.edition-editor-panel {
    margin: 0.8rem 0;
    padding: 1rem;
    border: 1px solid var(--accent-purple);
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.06);
}
.edition-editor-panel[hidden], #btn-add-edition[hidden] { display: none; }
.edition-editor-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.8rem; }
.filter-link--danger { color: var(--error); }

/* "N details still empty" hint on the edit page */
.completeness-hint { border-color: rgba(139, 92, 246, 0.45); }
.completeness-hint[hidden] { display: none; }
.completeness-hint__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.completeness-hint .help { margin: 0.3rem 0 0.6rem; }
.completeness-hint__chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.completeness-chip {
    padding: 0.3rem 0.75rem;
    font: inherit;
    font-size: 0.8rem;
    color: var(--text-main);
    background: var(--bg-panel-hover);
    border: 1px dashed var(--accent-purple);
    border-radius: 999px;
    cursor: pointer;
}
.completeness-chip:hover { background: rgba(139, 92, 246, 0.25); }
.field.is-missing > label::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 0.4rem;
    vertical-align: middle;
    border-radius: 50%;
    background: var(--accent-magenta);
}
.edition-add-row, #btn-add-edition, .edition-editor-actions .btn, .edition-chosen .btn { width: auto; }
.edition-name { margin: 0.7rem 0 0.8rem; }
.edition-make-main.switch-row { display: flex; }
.edition-make-main {
    align-items: flex-start;
    gap: 0.8rem;
    margin-top: 0.9rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}
.edition-make-main__text { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.9rem; }
.edition-make-main__text .help { margin-top: 0; }

/* ---------------------------------------------------------------------- */
/* Book detail view (/collection/view)                                      */
/* ---------------------------------------------------------------------- */
.detail-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.detail-topbar__links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.detail-topbar .btn[hidden], .detail-topbar__links a[hidden] { display: none; }
.detail-topbar .btn { width: auto; }
.book-detail[hidden] { display: none; }

.detail-hero {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 1.8rem;
    margin-bottom: 1.4rem;
}
.detail-media { display: flex; flex-direction: column; gap: 0.6rem; }
.detail-cover {
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-cover--empty { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.85rem; }
.detail-thumbs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.detail-thumb {
    width: 52px;
    aspect-ratio: 2 / 3;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: none;
    cursor: pointer;
}
.detail-thumb:hover, .detail-thumb:focus-visible { border-color: var(--accent-purple); outline: none; }
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-info { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.detail-title { margin: 0; font-size: 1.9rem; line-height: 1.2; overflow-wrap: anywhere; }
.detail-subtitle { margin: 0; font-size: 1.1rem; color: var(--text-muted); }
.detail-author { margin: 0; font-size: 1.05rem; }
.detail-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.detail-pills .book-pill { position: static; }
.detail-rating { align-self: flex-start; font-size: 1.1rem; }
.detail-blurb, .detail-text { margin: 0.4rem 0 0; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }

/* Cards flow in columns (masonry-like) so a short card never leaves an empty gap beside a tall one. */
.detail-grid { display: block; column-width: 280px; column-gap: 1rem; margin-bottom: 1rem; }
.detail-card h3 { margin: 0 0 0.7rem; font-size: 1rem; }
.detail-card { margin-bottom: 1rem; }
.detail-grid .detail-card { margin-bottom: 1rem; break-inside: avoid; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.2rem; margin: 0; font-size: 0.9rem; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-sessions { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.25rem; }
.detail-card .edition-card { margin-bottom: 0.7rem; }
.detail-link:hover { border-color: var(--accent-purple); }

@media (max-width: 700px) {
    .detail-hero { grid-template-columns: 1fr; }
    .detail-media { max-width: 240px; }
    .detail-title { font-size: 1.5rem; }
}

/* ---------------------------------------------------------------------- */
/* Reviews                                                                  */
/* ---------------------------------------------------------------------- */
.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }
.form-actions .btn { width: auto; }
.form-actions [hidden] { display: none; }
textarea.tall { min-height: 10rem; }

.star-picker { display: flex; gap: 0.15rem; }
.star {
    padding: 0.1rem 0.2rem;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text-muted);
    opacity: 0.45;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
}
.star:hover { transform: scale(1.12); opacity: 0.8; }
.star.is-on { color: #eab308; opacity: 1; }
.star:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; border-radius: 4px; }

/* Overview */
.review-list { display: flex; flex-direction: column; gap: 0.9rem; }
.review-row { display: flex; gap: 1rem; margin-bottom: 0; cursor: pointer; }
.review-row:hover, .review-row:focus-visible { border-color: var(--accent-purple); outline: none; }
.review-row__cover {
    flex: 0 0 64px;
    align-self: flex-start;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
}
.review-row__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.review-row__title { margin: 0; font-size: 1.02rem; overflow-wrap: anywhere; }
.review-row__author { margin: 0; font-size: 0.85rem; color: var(--text-muted); }
.review-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.review-row__meta .book-pill { position: static; }
.review-row__actions { display: flex; gap: 0.5rem; }
.review-excerpt { margin: 0.2rem 0 0; font-size: 0.9rem; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.review-card .review-excerpt { color: var(--text-muted); }
.review-card .edition-card__actions a { text-decoration: none; }

/* On the book detail view */
.detail-reviews { margin: 1.4rem 0 1rem; }
.detail-reviews__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.detail-reviews__head h2 { margin: 0; font-size: 1.2rem; }
.detail-reviews__head .btn { width: auto; }
.review-block { scroll-margin-top: 5rem; padding: 1.4rem; overflow: hidden; }
.review-block.is-targeted { border-color: var(--accent-purple); box-shadow: 0 0 0 1px var(--accent-purple); }
.review-block__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.review-block__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; font-size: 0.9rem; }
.review-block__meta .book-pill { position: static; }
.review-block .detail-list { margin-bottom: 0.8rem; }
.review-block__sub { margin: 1rem 0 0.3rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.review-quotes { font-style: italic; }

/* ---------------------------------------------------------------------- */
/* Structured review: form sections, scores, pictures                       */
/* ---------------------------------------------------------------------- */
.review-form { display: flex; flex-direction: column; gap: 1rem; max-width: 980px; }
.review-form .card { margin-bottom: 0; }
.review-section h2 { margin: 0 0 0.9rem; font-size: 1.1rem; }
.review-profile { margin-bottom: 0.4rem; }


.score-list { display: flex; flex-direction: column; gap: 0.6rem; }
.score-row { display: grid; grid-template-columns: minmax(9rem, 14rem) 5rem 1fr; gap: 0.6rem; align-items: start; }
.score-row__label { padding-top: 0.55rem; font-size: 0.9rem; color: var(--text-main); }
.score-row input, .score-row textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-main);
    font: inherit;
    font-size: 0.9rem;
}
.score-row textarea { resize: vertical; min-height: 2.4rem; overflow: hidden; }
.score-row input:focus, .score-row textarea:focus { outline: none; border-color: var(--accent-purple); }
.score-row__images { margin: -0.1rem 0 0.4rem 0; padding-left: 0.2rem; }
@media (max-width: 640px) {
    .score-row { grid-template-columns: 1fr 5rem; }
    .score-row__label { grid-column: 1; padding-top: 0; }
    .score-row__points { grid-column: 2; grid-row: 1; }
    .score-row__reason { grid-column: 1 / -1; }
}

.review-total {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.9rem;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.08);
}
.review-total__label { font-size: 0.85rem; color: var(--text-muted); }
.review-total__value { font-size: 1.4rem; }
.review-total .help { margin: 0; }

.image-slot-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.image-slot-grid:empty { display: none; }
.image-slot-tile { position: relative; width: 96px; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); background: rgba(0, 0, 0, 0.25); }
.image-slot-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-slot-tile__remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.image-slot-tile__remove:hover { background: var(--error); }

/* Detail view of a review */
.review-total-badge { background: rgba(139, 92, 246, 0.2); }
.review-summary { margin: 0 0 0.9rem; font-size: 1.02rem; }
.review-block__chips { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.7rem; margin-bottom: 0.5rem; }
.review-block__chips-label { font-size: 0.82rem; color: var(--text-muted); }
.review-block__chips .chip-list { margin: 0; }
.score-view { display: flex; flex-direction: column; gap: 0.3rem; }
.score-view__row { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr 3.2rem; gap: 0.7rem; align-items: center; font-size: 0.9rem; }
.score-view__meter { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.score-view__fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue)); }
.score-view__points { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.score-view__reason { margin: 0 0 0.5rem; font-size: 0.85rem; line-height: 1.5; color: var(--text-muted); white-space: pre-line; overflow-wrap: anywhere; }
.review-gallery { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.2rem 0 0.7rem; }
.review-gallery__item { display: block; width: 110px; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); }
.review-gallery__item:hover { border-color: var(--accent-purple); }
.review-gallery__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-spoiler { margin: 1rem 0 0.4rem; border: 1px solid var(--border-color); border-radius: 8px; padding: 0.5rem 0.8rem; background: rgba(0, 0, 0, 0.18); }
.review-spoiler summary { cursor: pointer; font-size: 0.9rem; color: var(--accent-magenta); }
.review-spoiler[open] summary { margin-bottom: 0.5rem; }
@media (max-width: 640px) {
    .score-view__row { grid-template-columns: 1fr 5rem 3rem; }
}

/* Choice cards (POV, focus) with a short explanation */
.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.6rem; }
.choice-card {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.field .choice-card { display: flex; margin: 0; color: var(--text-main); }
.choice-card:hover { border-color: rgba(255, 255, 255, 0.25); }
.choice-card input[type=radio] { width: 1.05rem; height: 1.05rem; flex: none; margin: 0.15rem 0 0; padding: 0; accent-color: var(--accent-purple); }
.choice-card:has(input:checked) { border-color: var(--accent-purple); background: rgba(139, 92, 246, 0.12); }
.choice-card:has(input:focus-visible) { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.choice-card__body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.choice-card__title { font-size: 0.92rem; font-weight: 600; }
.choice-card__desc { font-size: 0.78rem; line-height: 1.4; color: var(--text-muted); }
.choice-group.field-invalid { outline: 1px solid var(--error); outline-offset: 4px; border-radius: 10px; }

/* Score rows with explanations and validation messages */
.scales-hint { margin: 0 0 0.8rem; }
.score-row__labelcell { display: flex; flex-direction: column; gap: 0.2rem; padding-top: 0.4rem; }
.score-row__labelcell .score-row__label { padding-top: 0; }
.score-row__desc { font-size: 0.78rem; line-height: 1.4; color: var(--text-muted); }
.score-row input.field-invalid, .score-row textarea.field-invalid { border-color: var(--error); }
.score-row .field-feedback { margin-top: 0.25rem; }
.field-invalid > .lookup-search-input { border-color: var(--error); }
@media (max-width: 640px) {
    .score-row__labelcell { grid-column: 1; padding-top: 0; }
    .score-row__pointscell { grid-column: 2; grid-row: 1; }
    .score-row__reasoncell { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------------- */
/* Lists page: grouped menu on the left, the selected list on the right.   */
/* On narrow screens the menu becomes wrapped pills above the list.        */
/* ---------------------------------------------------------------------- */
.lists-layout { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.lists-nav {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
}
.lists-nav__title {
    margin: 0.6rem 0.5rem 0.25rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.lists-nav__title:first-child { margin-top: 0.1rem; }
.lists-nav__item {
    padding: 0.45rem 0.6rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
}
.lists-nav__item:hover { background: rgba(139, 92, 246, 0.14); color: var(--text-main); }
.lists-nav__item.is-active { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); font-weight: 600; }
.lists-nav__item:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }
.lists-heading { margin: 0 0 1rem; font-size: 1.15rem; }
/* Lists rows are table-like: one grid column per kind of info (--list-cols is set by lists.html),
   so names, tags, counts and buttons line up whatever the numbers are. */
.list-head, .list-row { display: grid; grid-template-columns: var(--list-cols, 1fr auto); align-items: center; column-gap: 0.75rem; }
.list-head { padding: 0 0 0.4rem; border-bottom: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.list-head__center { text-align: center; }
.list-row { padding: 0.5rem 0; border-bottom: 1px solid var(--border-color); }
.list-row input.input { min-width: 0; width: 100%; }
.list-row__default { display: flex; justify-content: center; }
.list-row__actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.list-count { display: flex; justify-content: center; align-items: center; border: none; background: transparent; color: var(--text-main); font: inherit; font-variant-numeric: tabular-nums; padding: 0.15rem 0.5rem; border-radius: 999px; min-width: 2.2rem; }
.list-count--zero { color: var(--text-muted); }
.list-count--link { cursor: pointer; background: rgba(139, 92, 246, 0.12); color: var(--accent-purple); }
.list-count--link:hover { background: rgba(139, 92, 246, 0.25); }
.list-count__full { display: none; }
@media (max-width: 760px) {
    .list-head { display: none; }
    .list-row { grid-template-columns: 1fr 1fr; row-gap: 0.4rem; padding: 0.7rem 0; }
    .list-row input.input { grid-column: 1 / -1; }
    .list-row__default { justify-content: flex-start; }
    .list-count { justify-content: flex-start; padding-left: 0; }
    .list-count--link { padding-left: 0.5rem; }
    .list-count__num { display: none; }
    .list-count__full { display: inline; }
    .list-row__actions { grid-column: 1 / -1; justify-content: flex-start; }
}
/* The shared stylesheet's .btn is full-width; list rows and the add box want compact buttons. */
.list-row .btn, .lists-add .btn { width: auto; margin: 0; flex-shrink: 0; }
.lists-add { display: flex; gap: 0.5rem; align-items: flex-end; }
.lists-add__field { flex: 1; min-width: 0; }
.lists-add .btn { height: 2.6rem; }
#settings-error:empty { display: none; }
.list-row__make-default { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
@media (max-width: 860px) {
    .lists-layout { grid-template-columns: minmax(0, 1fr); }
    .lists-nav { position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
    .lists-nav__title { flex-basis: 100%; margin: 0.4rem 0.2rem 0; }
    .lists-nav__item { border: 1px solid var(--border-soft); }
}

/* ---------------------------------------------------------------------- */
/* Pick-or-add fields: "browse all values" button, dropdown hints / keyboard */
/* highlight, and the right-hand picker drawer (list-picker.js).            */
/* The drawer reuses the filter drawer's look (.filter-overlay/.filter-drawer). */
/* ---------------------------------------------------------------------- */
.lookup-input-row { position: relative; }
.lookup-input-row > input.lookup-search-input,
.field .lookup-input-row > input[type=text],
.lookup-input-row > input[type=text] { padding-right: 2.6rem; }
.lookup-browse {
    position: absolute;
    top: 0.2rem;
    right: 0.3rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.lookup-browse:hover { color: var(--text-main); background: var(--bg-panel-hover); }
.lookup-browse:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }
.lookup-hint { padding: 0.4rem 0.7rem; color: var(--text-muted); font-size: 0.78rem; border-bottom: 1px solid var(--border-soft); }
.lookup-option.is-active { background: rgba(139, 92, 246, 0.18); color: var(--text-main); }

.lp-search { padding: 0.8rem 1.1rem 0.4rem; }
.lp-search input { width: 100%; }
.lp-count { margin-top: 0.35rem; color: var(--text-muted); font-size: 0.75rem; }
.lp-body { padding: 0.3rem 1.1rem 0.8rem; }
.lp-list { max-height: none; overflow: visible; }
.lp-row { width: 100%; border: none; background: transparent; color: inherit; font: inherit; text-align: left; }
.lp-row.is-selected { color: var(--accent-purple); font-weight: 600; }
.lp-row__check { display: flex; color: var(--accent-purple); }
.lp-add { margin-top: 0.6rem; }
.lp-add .lookup-option-add { width: 100%; text-align: left; border: 1px dashed var(--border-strong); border-radius: 8px; padding: 0.55rem 0.7rem; background: transparent; cursor: pointer; }
.lp-empty { color: var(--text-muted); font-size: 0.85rem; margin: 0.6rem 0 0; }
.lp-empty[hidden] { display: none; }
.lp-more { color: var(--text-muted); font-size: 0.78rem; padding: 0.5rem 0.2rem; list-style: none; }

/* Overall score: 10 stars, partly filled (score 1-100, 10 points per star). */
.score-stars { display: inline-flex; align-items: baseline; gap: 0.35rem; white-space: nowrap; }
.score-stars__icons {
    --fill: 0%;
    display: inline-block;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #eab308 var(--fill), rgba(255, 255, 255, 0.22) var(--fill));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.score-stars__num { font-variant-numeric: tabular-nums; font-size: 0.85em; color: var(--text-main); letter-spacing: 0; }
.score-input { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.score-slider {
    font-size: 1.9rem;
    line-height: 1;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    padding: 0.2rem 0.1rem;
    border-radius: 8px;
}
.score-slider:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.score-slider.is-locked { cursor: default; opacity: 0.8; }
.score-input__number { width: 5.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.score-input .btn { width: auto; margin: 0; }
.review-detailed-switch { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin: 0.4rem 0 1rem; }
.review-subhead { margin: 1.4rem 0 0.6rem; font-size: 1.05rem; }
.badge-rating .score-stars__icons { font-size: 0.8rem; }
.book-card-badges .score-stars__icons { font-size: 0.7rem; }
.review-picture-group { margin: 0.8rem 0 0.3rem; }
.image-gallery__bar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.image-gallery__label { display: flex; align-items: center; gap: 0.4rem; }
.image-gallery__bar .btn { width: auto; margin: 0; }
.image-gallery-grid { gap: 0.75rem; }
.image-gallery-tile { display: flex; flex-direction: column; gap: 0.3rem; width: 120px; }
.image-gallery-tile .image-slot-tile { width: 120px; }
.image-gallery-tile select { font-size: 0.78rem; padding: 0.25rem 0.4rem; }
.score-input input.score-input__number { width: 5.5rem; flex: none; }
.score-input .help { margin: 0; }
.image-gallery__bar select { width: auto; }

.review-note { display: flex; flex-direction: column; gap: 0.15rem; margin: 0 0 1rem; padding: 0.75rem 1rem; border-radius: 10px; border: 1px solid rgba(139, 92, 246, 0.35); background: rgba(139, 92, 246, 0.1); font-size: 0.9rem; }
.review-note span { color: var(--text-muted); }

/* Favourite quotes: one row per quote with who said it. */
.quote-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.6rem; }
.quote-list:empty { display: none; }
.quote-row { display: grid; grid-template-columns: 1fr minmax(8rem, 14rem) auto; gap: 0.5rem; align-items: start; }
.quote-row textarea { min-height: 2.6rem; resize: vertical; }
.quote-row .btn { width: auto; margin: 0; }
@media (max-width: 640px) { .quote-row { grid-template-columns: 1fr auto; } .quote-row__quote { grid-column: 1 / -1; } }
.review-quote { margin: 0.6rem 0; padding: 0.2rem 0 0.2rem 0.9rem; border-left: 3px solid var(--accent-purple); }
.review-quote p { margin: 0; white-space: pre-wrap; }
.review-quote cite { display: block; margin-top: 0.2rem; color: var(--text-muted); font-size: 0.85rem; font-style: normal; }
/* Picture category dropdowns: same look as the form's selects (the shell only themes the popup). */
select.image-gallery__select {
    width: 100%;
    min-width: 8.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
}
select.image-gallery__select:hover { border-color: rgba(255, 255, 255, 0.2); }
select.image-gallery__select:focus-visible { outline: none; border-color: var(--accent-purple); background: rgba(0, 0, 0, 0.35); }
.image-gallery__bar select.image-gallery__select { width: auto; }
.image-gallery-tile select.image-gallery__select { width: 120px; min-width: 0; padding: 0.35rem 0.5rem; font-size: 0.8rem; }

/* Content scales on the review page: ten icons, filled = points. */
.score-view__row--icons { grid-template-columns: minmax(8rem, 14rem) auto 3.2rem; }
.scale-icons { display: inline-flex; gap: 0.2rem; align-items: center; }
.scale-icons__icon { width: 1.5rem; height: 1.5rem; fill: rgba(255, 255, 255, 0.14); flex: none; }
.scale-icons__icon.is-on { fill: var(--icon-color, #eab308); }
@media (max-width: 640px) {
    .score-view__row--icons { grid-template-columns: 1fr auto; row-gap: 0.2rem; }
    .score-view__row--icons .scale-icons { grid-column: 1 / -1; grid-row: 2; }
    .scale-icons__icon { width: 1.1rem; height: 1.1rem; }
}

/* Full-screen picture viewer (lightbox.js). */
body.lightbox-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; background: rgba(5, 5, 10, 0.94); padding: 3.5rem 1rem 2.5rem; }
.lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.lightbox__close, .lightbox__nav { position: absolute; display: flex; align-items: center; justify-content: center; border: none; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: #fff; cursor: pointer; line-height: 1; }
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox__close:focus-visible, .lightbox__nav:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.lightbox__close { top: 0.8rem; right: 0.8rem; width: 2.6rem; height: 2.6rem; font-size: 1.8rem; }
.lightbox__nav { top: 50%; transform: translateY(-50%); width: 2.8rem; height: 2.8rem; font-size: 2rem; }
.lightbox__nav--prev { left: 0.8rem; }
.lightbox__nav--next { right: 0.8rem; }
.lightbox__counter { position: absolute; bottom: 0.8rem; left: 50%; transform: translateX(-50%); color: rgba(255, 255, 255, 0.7); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.detail-cover.is-zoomable { cursor: zoom-in; }
.detail-cover.is-zoomable:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 3px; }

/* Draft reviews */
.badge-draft { color: #f59e0b; border: 1px dashed rgba(245, 158, 11, 0.6); background: rgba(245, 158, 11, 0.1); }
.review-draft-switch { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }

/* Connected books: cards with cover, details and the relationship; search + add panel. */
.connection-list { display: flex; flex-direction: column; gap: 0.6rem; }
.connection-card { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.7rem; border: 1px solid var(--border-color); border-radius: 10px; background: rgba(0, 0, 0, 0.18); }
.connection-card__cover { flex: none; width: 52px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.06); display: flex; align-items: center; justify-content: center; }
.connection-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.connection-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.connection-card__title { font-weight: 600; color: var(--text-main); text-decoration: none; overflow-wrap: anywhere; }
.connection-card__title:hover { color: var(--accent-purple); }
.connection-card__author, .connection-card__meta { font-size: 0.82rem; }
.connection-card__relations { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.connection-card__rel { font-size: 0.78rem; padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid rgba(139, 92, 246, 0.4); background: rgba(139, 92, 246, 0.12); }
.connection-card__actions { display: flex; flex-direction: column; gap: 0.35rem; }
.connection-card__actions .btn, .connection-editor .btn, .connection-add .btn { width: auto; margin: 0; }
.connection-editor, .connection-add { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; padding: 0.8rem; border: 1px dashed var(--border-strong, var(--border-color)); border-radius: 10px; }
.connection-add[hidden] { display: none; }
.connection-add__head { display: flex; align-items: center; gap: 0.7rem; }
.connection-field { display: flex; flex-direction: column; gap: 0.25rem; }
.connection-editor__buttons { display: flex; gap: 0.5rem; }
.connection-search { width: 100%; }
.connection-result { display: flex; align-items: center; gap: 0.7rem; text-align: left; }
.connection-result__text { display: flex; flex-direction: column; min-width: 0; }
.connection-result .connection-card__cover { width: 36px; }
select.connection-select { width: 100%; min-width: 0; padding: 0.45rem 0.6rem; border-radius: 8px; border: 1px solid var(--border-color); background: rgba(0, 0, 0, 0.25); color: var(--text-main); font-size: 0.88rem; font-family: inherit; }
@media (max-width: 560px) { .connection-card { flex-wrap: wrap; } .connection-card__actions { flex-direction: row; width: 100%; } }
.connection-card__cover.is-empty { color: var(--text-muted); }

/* Autosave status line on the book edit form. */
.autosave-status { min-height: 1.2rem; margin: 0 0 0.6rem; font-size: 0.8rem; color: var(--text-muted); }
.autosave-status:empty { display: none; }
.autosave-status[data-state="saved"] { color: #22c55e; }
.autosave-status[data-state="invalid"], .autosave-status[data-state="error"] { color: #f59e0b; }
.autosave-status[data-state="error"] { color: var(--error, #ef4444); }

/* Book edit form: grouped sections instead of one long pile of fields. */
.form-section { margin-bottom: 1rem; }
.form-section__head { margin-bottom: 1rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--border-color); }
.form-section__head h2 { margin: 0; font-size: 1.05rem; }
.form-section__head .help { margin: 0.2rem 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); column-gap: 1rem; row-gap: 0.2rem; align-items: start; }
.form-grid > .field { margin-bottom: 0.8rem; min-width: 0; }
.form-grid > .span-all { grid-column: 1 / -1; }
.form-grid > .field[hidden] { display: none; }
.form-grid textarea { min-height: 7rem; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .form-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .form-grid--2, .form-grid--4 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------- */
/* Book cover: 2D / 3D display (book-cover.js)                              */
/* ---------------------------------------------------------------------- */
.book-cover { position: relative; width: 100%; max-width: 480px; }
.book-cover__stage { position: relative; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: radial-gradient(ellipse at 50% 30%, rgba(139, 92, 246, 0.14), transparent 70%), rgba(0, 0, 0, 0.18); overflow: hidden; touch-action: pan-y; }
.book-cover__stage.is-3d { cursor: grab; touch-action: none; }
.book-cover__stage.is-dragging { cursor: grabbing; }
.book-cover__stage:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.book3d { position: relative; width: 100%; height: 100%; perspective: 1400px; }
.book3d__obj { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.book-face { position: absolute; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-sizing: border-box; user-select: none; }
.book-face--flat { position: relative; display: block; margin: 12px auto; backface-visibility: visible; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); border-radius: 2px 4px 4px 2px; }
.book-face img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }
.book-face--generated { --face-bg: #2b2d33; background: linear-gradient(135deg, #34363d, var(--face-bg)); color: #f1f1f4; font-size: calc(var(--u, 14px) * 0.8); }
.book-face--front.book-face--generated { display: flex; align-items: center; justify-content: center; text-align: center; padding: 10%; }
.book-face__text { display: flex; flex-direction: column; gap: 0.5em; max-width: 100%; overflow-wrap: anywhere; }
.book-face__title { font-size: 1.25em; line-height: 1.2; }
.book-face__subtitle { font-size: 0.85em; opacity: 0.85; }
.book-face__author { font-size: 0.95em; margin-top: 0.6em; letter-spacing: 0.04em; }
.book-face__publisher { font-size: 0.7em; opacity: 0.6; margin-top: 1em; text-transform: uppercase; letter-spacing: 0.08em; }
.book-face--back.book-face--generated { padding: 9%; font-size: calc(var(--u, 14px) * 0.62); line-height: 1.5; }
.book-face__blurb { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.book-face--spine.book-face--generated { --face-bg: #23252a; display: flex; align-items: center; justify-content: center; }
.book-face__spine-text { writing-mode: vertical-rl; display: flex; flex-direction: row; align-items: center; gap: 0.9em; max-height: 92%; overflow: hidden; font-size: 0.85em; white-space: nowrap; text-overflow: ellipsis; }
.book-face__spine-text span { opacity: 0.8; font-size: 0.85em; }
.book-face__spine-author { margin-top: auto; }
.book-face--paper { background-color: #f3efe4; }
.book-face--fore:not(.book-face--photo) { background-image: repeating-linear-gradient(90deg, rgba(120, 110, 90, 0.18) 0 1px, transparent 1px 3px); }
.book-face--top:not(.book-face--photo), .book-face--bottom:not(.book-face--photo) { background-image: repeating-linear-gradient(0deg, rgba(120, 110, 90, 0.18) 0 1px, transparent 1px 3px); }
.book-face--front::after, .book-face--back::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 6%, transparent 94%, rgba(255, 255, 255, 0.05)); }
.book-cover__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; margin-top: 0.6rem; }
.book-cover__view { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.book-cover__view button { border: none; background: transparent; color: var(--text-muted); font: inherit; font-size: 0.8rem; padding: 0.3rem 0.8rem; cursor: pointer; }
.book-cover__view button.is-active { background: rgba(139, 92, 246, 0.25); color: var(--text-main); }
.book-cover__sides { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.book-cover__side { border: 1px solid var(--border-color); background: transparent; color: var(--text-muted); border-radius: 999px; font: inherit; font-size: 0.78rem; padding: 0.2rem 0.7rem; cursor: pointer; }
.book-cover__side:hover, .book-cover__side.is-active { color: var(--text-main); border-color: var(--accent-purple); }
.book-cover__hint { margin: 0; flex-basis: 100%; }
@media (prefers-reduced-motion: reduce) { .book3d__obj { transition: none !important; } }

/* Cover & size card (cover-editor.js) and the cutout selector (photo-cutout.js). */
.cover-editor { display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 860px) { .cover-editor { grid-template-columns: 1fr; } }
.cover-editor__sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.8rem; }
.cover-side { padding: 0.7rem; border: 1px solid var(--border-color); border-radius: 10px; background: rgba(0, 0, 0, 0.14); min-width: 0; }
.cover-side h4 { margin: 0 0 0.5rem; font-size: 0.9rem; }
.cover-side__thumb { max-width: 100%; max-height: 120px; border-radius: 6px; display: block; margin-bottom: 0.5rem; }
.cover-side__empty { margin: 0 0 0.5rem; }
.cover-side__actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cover-side__actions .btn { width: auto; margin: 0; }
.cover-sizes__head { display: flex; align-items: center; justify-content: space-between; margin: 1.2rem 0 0.2rem; }
.cover-sizes__head h4 { margin: 0; }
.cover-size { display: grid; grid-template-columns: 6rem 5.5rem 1fr; gap: 0.6rem; align-items: center; margin: 0.5rem 0; }
.cover-size__auto-switch { font-size: 0.8rem; color: var(--text-muted); }
.cover-size__derived { font-variant-numeric: tabular-nums; color: var(--text-main); }
.cover-size__manual { display: grid; grid-template-columns: 1fr 6rem; gap: 0.6rem; align-items: center; }
.cover-size [hidden] { display: none; }
.cover-size__label { font-size: 0.85rem; color: var(--text-muted); }
.cover-size__number { width: 100%; text-align: center; }
.cover-size__auto { font-size: 0.75rem; color: var(--text-muted); }
.cover-size__reset { width: auto; margin: 0; }
.cover-size__slider { width: 100%; accent-color: var(--accent-purple); }
@media (max-width: 560px) { .cover-size { grid-template-columns: 1fr auto; } .cover-size__derived, .cover-size__manual { grid-column: 1 / -1; } }
.detail-cover3d { width: 100%; max-width: 380px; }
.cutout__row { display: flex; gap: 0.8rem; align-items: flex-start; flex-wrap: wrap; }
.cutout__stage { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; cursor: crosshair; line-height: 0; overflow: hidden; border-radius: 6px; }
.cutout__stage img { display: block; max-width: 100%; max-height: 70vh; pointer-events: none; }
.cutout__box { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6); border: 2px solid #fff; cursor: move; box-sizing: border-box; }
.cutout__box:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.cutout__handle { position: absolute; width: 18px; height: 18px; background: #fff; border: 2px solid var(--accent-purple); border-radius: 3px; box-sizing: border-box; }
.cutout__handle--nw { left: -10px; top: -10px; cursor: nwse-resize; } .cutout__handle--ne { right: -10px; top: -10px; cursor: nesw-resize; }
.cutout__handle--sw { left: -10px; bottom: -10px; cursor: nesw-resize; } .cutout__handle--se { right: -10px; bottom: -10px; cursor: nwse-resize; }
.cutout__handle--n { left: calc(50% - 9px); top: -10px; cursor: ns-resize; } .cutout__handle--s { left: calc(50% - 9px); bottom: -10px; cursor: ns-resize; }
.cutout__handle--w { top: calc(50% - 9px); left: -10px; cursor: ew-resize; } .cutout__handle--e { top: calc(50% - 9px); right: -10px; cursor: ew-resize; }
.cutout__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-top: 0.6rem; }
.cutout__tools .btn { width: auto; margin: 0; }
.cutout__lock { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--text-muted); }
.cutout__result { display: flex; flex-direction: column; gap: 0.3rem; line-height: 1.2; }
.cutout__preview { max-width: 260px; max-height: 40vh; width: auto; height: auto; border-radius: 4px; background: rgba(255, 255, 255, 0.05); cursor: zoom-in; }
@media (max-width: 700px) { .cutout__result { flex: 1 1 100%; align-items: center; } .cutout__preview { max-width: 100%; max-height: 50vh; } }
.cutout__info { margin: 0; }
.cover-side--editing { grid-column: 1 / -1; }

/* Small covers in lists and cards (BookCover.thumb): fit the parent, keep the book's proportions. */
.thumb-slot, .book-card-media { container-type: size; display: flex; align-items: center; justify-content: center; }
.book-card-media { aspect-ratio: 2 / 3; background: var(--bg-input); }
.book-thumb { container-type: inline-size; width: 100%; max-height: 100%; /* fallback: no container query units (iOS < 16) */ width: min(100cqw, calc(100cqh * var(--ar, 0.667))); aspect-ratio: var(--ar, 0.667); flex: none; }
.book-thumb .book-face--thumb { width: 100%; height: 100%; margin: 0; box-shadow: none; border-radius: 3px; }
.book-thumb .book-face--generated { font-size: 0.8rem; font-size: 8.5cqw; }
.book-thumb .book-face--front.book-face--generated { padding: 8%; }
.book-thumb .book-face__author { margin-top: 0.4em; }
.book-thumb .book-face__publisher { margin-top: 0.6em; }
.connection-card__cover.thumb-slot { background: transparent; }

/* Cover in full screen (book-cover.js openFullscreen). */
.lightbox--cover { flex-direction: column; padding: 3.5rem 1rem 1rem; }
.book-cover-full { width: 100%; max-width: none; display: flex; justify-content: center; }
.book-cover-full .book-cover { max-width: none; width: 100%; }
.book-cover-full .book-cover__controls { justify-content: center; }
.book-cover-full .book-cover__hint { text-align: center; }
.book-cover__fullbtn { position: absolute; top: 0.5rem; right: 0.5rem; z-index: 2; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); border-radius: 8px; background: rgba(0, 0, 0, 0.45); color: var(--text-muted); cursor: pointer; padding: 0; }
.book-cover__fullbtn:hover { color: var(--text-main); border-color: var(--accent-purple); }
.book-cover__fullbtn:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }

/* ---------------------------------------------------------------------- */
/* Digital library (library-render.js, library-shelf-page.js)               */
/* ---------------------------------------------------------------------- */
.lib-head, .lib-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lib-page-head h1 { margin: 0.2rem 0 0; font-size: 1.4rem; }
.lib-head .btn { width: auto; }
.lib-page-tools { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.lib-page-tools .btn { width: auto; margin: 0; }
.lib-zoom { display: flex; align-items: center; gap: 0.4rem; }
.lib-zoom input { width: 110px; accent-color: var(--accent-purple); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.lib-card { display: flex; flex-direction: column; gap: 0.3rem; text-decoration: none; color: inherit; transition: border-color 0.15s ease, transform 0.15s ease; }
.lib-card:hover { border-color: var(--accent-purple); transform: translateY(-2px); }
.lib-card__preview { height: 220px; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.2); border-radius: 8px; overflow: hidden; }
.lib-card__title { margin: 0.4rem 0 0; font-size: 1.02rem; }
.lib-card__meta { margin: 0; font-size: 0.82rem; }
.lib-empty { text-align: center; }
.lib-empty .btn { width: auto; }

/* shelf: 2D */
.lib-root { display: inline-block; vertical-align: top; }
.lib-shelf2d { position: relative; flex: none; user-select: none; }
.lib-bg, .lib-piece, .lib-row { position: absolute; box-sizing: border-box; }
.lib-piece.lib-board { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18); z-index: 2; }
.lib-piece.lib-wall { box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.3), inset 1px 0 0 rgba(255, 255, 255, 0.12); z-index: 3; }
.lib-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 18%); pointer-events: none; }
.lib-row { z-index: 1; }
.lib-book { position: absolute; box-sizing: border-box; cursor: grab; }
.lib-book:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; z-index: 5; }
.lib-book:hover { filter: brightness(1.12); }
.lib-book__face { position: relative; width: 100%; height: 100%; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 1px 0 3px rgba(0, 0, 0, 0.4); }
.lib-book .book-face--generated { font-size: max(7px, calc(var(--u, 4px) * 1.35)); }
.lib-book .book-face--front.book-face--generated { padding: 8%; }
.lib-book .book-face--spine.book-face--generated { font-size: max(6px, calc(var(--u, 4px) * 1.25)); }
.lib-book .book-face--back.book-face--generated { font-size: max(5px, calc(var(--u, 4px) * 0.9)); padding: 8%; }
.book-face--in-shelf { backface-visibility: visible; }
.lib-ghost { pointer-events: none; opacity: 0.85; z-index: 6; cursor: default; }
.lib-ghost.is-ok { outline: 2px solid #22c55e; }
.lib-ghost.is-bad { outline: 2px solid #ef4444; opacity: 0.6; }
body.lib-dragging { cursor: grabbing; user-select: none; }
.lib-float { position: fixed; left: 0; top: 0; z-index: 10001; pointer-events: none; opacity: 0.9; }
.lib-float.is-over-shelf { opacity: 0; }
.lib-float__thumb { width: 54px; height: 80px; display: flex; align-items: center; justify-content: center; container-type: size; }

/* shelf: 3D */
.lib-scene3d { position: relative; width: min(100%, 900px); margin: 0 auto; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.lib-world { position: relative; width: 0; height: 0; transform-style: preserve-3d; }
.lib-box, .lib-book3d { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.lib-face { position: absolute; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-sizing: border-box; }
.lib-book3d .book-face { backface-visibility: hidden; }
.lib-book3d { cursor: pointer; }

/* shelf page layout */
.lib-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .lib-layout { grid-template-columns: 1fr; } }
.lib-stage { min-width: 0; }
.lib-stage__scroll { overflow: auto; padding: 0.4rem; border-radius: 12px; background: radial-gradient(ellipse at 50% 20%, rgba(139, 92, 246, 0.1), transparent 70%), rgba(0, 0, 0, 0.18); text-align: center; min-height: 260px; }
.lib-hint { margin: 0.5rem 0 0; }
.lib-sidebar { position: sticky; top: 0.8rem; max-height: calc(100vh - 2rem); overflow: auto; padding: 0.9rem; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card, rgba(255, 255, 255, 0.03)); transition: border-color 0.15s ease, background 0.15s ease; }
.lib-sidebar h2 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.lib-sidebar.is-drop { border-color: var(--accent-purple); background: rgba(139, 92, 246, 0.14); }
.lib-side-search { width: 100%; margin: 0.4rem 0 0.6rem; }
.lib-side-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.6rem; }
.lib-side-book { display: flex; gap: 0.6rem; align-items: center; padding: 0.4rem; border: 1px solid var(--border-color); border-radius: 8px; cursor: grab; touch-action: none; user-select: none; background: rgba(0, 0, 0, 0.14); }
.lib-side-book:hover { border-color: var(--accent-purple); }
.lib-side-book__thumb { flex: none; width: 40px; height: 60px; }
.lib-side-book__text { display: flex; flex-direction: column; min-width: 0; font-size: 0.85rem; }
.lib-side-book__text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-side-book__text span { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-replace-banner { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.6rem; margin-bottom: 0.6rem; border: 1px dashed var(--accent-purple); border-radius: 8px; font-size: 0.85rem; }
.lib-replace-banner .btn { width: auto; align-self: flex-start; margin: 0; }
.lib-sidebar .btn { width: auto; margin: 0 0 0.6rem; }
.lib-side-hint { margin-top: 0.4rem; }

/* click menu */
.lib-menu { position: fixed; z-index: 10002; width: 260px; display: flex; flex-direction: column; gap: 0.35rem; padding: 0.8rem; border: 1px solid var(--border-strong, var(--border-color)); border-radius: 12px; background: var(--bg-card-alt, #14151b); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); }
.lib-menu__title { overflow-wrap: anywhere; }
.lib-menu__meta { font-size: 0.78rem; }
.lib-menu__label { margin-top: 0.3rem; }
.lib-menu__orient { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.lib-menu__orient-btn { border: 1px solid var(--border-color); background: transparent; color: var(--text-muted); border-radius: 999px; font: inherit; font-size: 0.76rem; padding: 0.2rem 0.6rem; cursor: pointer; }
.lib-menu__orient-btn:hover, .lib-menu__orient-btn.is-active { color: var(--text-main); border-color: var(--accent-purple); }
.lib-menu__orient-btn.is-active { background: rgba(139, 92, 246, 0.22); }
.lib-menu__actions { display: flex; gap: 0.4rem; margin-top: 0.4rem; flex-wrap: wrap; }
.lib-menu__actions .btn { width: auto; margin: 0; }

/* settings panel */
.lib-settings-panel { margin-bottom: 1rem; }
.lib-settings-panel h2 { margin: 0 0 0.2rem; font-size: 1.1rem; }
.lib-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.2rem; margin-top: 0.8rem; }
.lib-settings__group { min-width: 0; }
.lib-settings__group h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.lib-field { margin-bottom: 0.6rem; }
.lib-check { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; font-size: 0.88rem; cursor: pointer; }
.lib-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 0.4rem; margin: 0.4rem 0 0.8rem; }
.lib-swatch { height: 34px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.lib-swatch.is-active { border-color: var(--accent-purple); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35); }
.lib-gap { display: block; margin-top: 0.4rem; }
.lib-bg-row, .lib-bg-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.4rem 0; }
.lib-bg-actions .btn, .lib-row-actions .btn { width: auto; margin: 0; }
.lib-row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.lib-rowlist { display: flex; flex-direction: column; gap: 0.4rem; }
.lib-rowedit { display: grid; grid-template-columns: 4.5rem 1fr auto auto auto; gap: 0.4rem; align-items: center; }
.lib-rowedit__label { font-size: 0.82rem; color: var(--text-muted); }
.lib-rowedit .btn { width: auto; margin: 0; padding: 0.3rem 0.6rem; }
.lib-settings__foot { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border-color); }
.lib-settings__foot input { flex: 1; min-width: 160px; max-width: 280px; }
.lib-settings__foot .btn { width: auto; margin: 0; }
.lib-settings__foot #btn-delete-shelf { margin-left: auto; }

/* new shelf dialog */
.lib-modal { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(5, 5, 10, 0.75); }
.lib-modal__box { width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 1.2rem; border: 1px solid var(--border-strong, var(--border-color)); border-radius: 14px; background: var(--bg-card-alt, #14151b); }
.lib-modal__box h2 { margin: 0 0 0.2rem; }
.lib-modal__actions { display: flex; gap: 0.6rem; margin-top: 1rem; }
.lib-modal__actions .btn { width: auto; margin: 0; }
.lib-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; margin: 0.8rem 0; }
.lib-templates__heading { grid-column: 1 / -1; margin: 0.4rem 0 0; font-size: 0.9rem; }
.lib-template-wrap { position: relative; }
.lib-template { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 0.6rem; border: 2px solid var(--border-color); border-radius: 10px; background: rgba(0, 0, 0, 0.16); color: inherit; font: inherit; font-size: 0.82rem; cursor: pointer; text-align: center; }
.lib-template:hover { border-color: rgba(139, 92, 246, 0.6); }
.lib-template.is-selected { border-color: var(--accent-purple); background: rgba(139, 92, 246, 0.14); }
.lib-template__preview { height: 110px; display: flex; align-items: center; justify-content: center; }
.lib-template__delete { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: none; border-radius: 999px; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; line-height: 1; padding: 0; }
/* In small previews the generated covers are plain blocks (no tiny text). */
.lib-card__preview .book-face--generated > *, .lib-template__preview .book-face--generated > * { display: none; }
.lib-check input[type=checkbox] { width: auto; flex: none; margin: 0; }
.lib-check { justify-content: flex-start; }
.lib-root--3d { display: block; width: 100%; }
.lib-scene3d { user-select: none; }

/* Sidebar that folds away (arrow button) - closed by default */
.lib-layout { transition: grid-template-columns 0.2s ease; }
.lib-layout.is-collapsed { grid-template-columns: minmax(0, 1fr) 48px; }
@media (max-width: 900px) { .lib-layout.is-collapsed { grid-template-columns: 1fr; } }
.lib-side-toggle { display: flex; align-items: center; gap: 0.5rem; width: 100%; margin: 0 0 0.5rem; padding: 0.35rem 0.4rem; border: 1px solid var(--border-color); border-radius: 8px; background: rgba(0, 0, 0, 0.2); color: var(--text-main); font: inherit; font-size: 0.85rem; cursor: pointer; }
.lib-side-toggle:hover { border-color: var(--accent-purple); }
.lib-side-toggle__arrow { flex: none; transition: transform 0.2s ease; transform: rotate(180deg); }
.lib-sidebar:not(.is-collapsed) .lib-side-toggle__arrow { transform: rotate(0deg); }
.lib-side-toggle__badge { margin-left: auto; padding: 0 0.45rem; border-radius: 999px; background: rgba(139, 92, 246, 0.3); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.lib-sidebar.is-collapsed { padding: 0.4rem; overflow: hidden; }
.lib-sidebar.is-collapsed .lib-side-body { display: none; }
.lib-sidebar.is-collapsed .lib-side-toggle { flex-direction: column; padding: 0.6rem 0.2rem; gap: 0.7rem; }
.lib-sidebar.is-collapsed .lib-side-toggle__label { writing-mode: vertical-rl; margin: 0; }
.lib-sidebar.is-collapsed .lib-side-toggle__badge { margin: 0; }
@media (max-width: 900px) { .lib-sidebar.is-collapsed { position: static; max-height: none; } .lib-sidebar.is-collapsed .lib-side-toggle { flex-direction: row; } .lib-sidebar.is-collapsed .lib-side-toggle__label { writing-mode: horizontal-tb; } }

/* "+" drop strips of a dynamic shelf */
.lib-root--spots { padding: 0 44px 44px 0; }
.lib-spot { position: absolute; display: flex; align-items: center; justify-content: center; box-sizing: border-box; border: 2px dashed rgba(139, 92, 246, 0.55); border-radius: 8px; color: rgba(139, 92, 246, 0.9); font-size: 1.4rem; line-height: 1; background: rgba(139, 92, 246, 0.06); transition: background 0.12s ease, border-color 0.12s ease; }
.lib-spot--row { height: 30px; }
.lib-spot--column { width: 30px; }
.lib-spot.is-hot { background: rgba(34, 197, 94, 0.25); border-color: #22c55e; color: #22c55e; }
.lib-settings-panel { position: relative; }
.lib-settings-close { position: absolute; top: 0.6rem; right: 0.6rem; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); border-radius: 8px; background: transparent; color: var(--text-muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0; }
.lib-settings-close:hover { color: var(--text-main); border-color: var(--accent-purple); }
.lib-colblock { margin: 0.6rem 0; padding: 0.6rem; border: 1px solid var(--border-color); border-radius: 10px; background: rgba(0, 0, 0, 0.14); }
.lib-colblock__head { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 0.4rem; align-items: center; margin-bottom: 0.5rem; }
.lib-colblock__head strong { font-size: 0.88rem; }
.lib-colblock .btn { width: auto; margin: 0; padding: 0.3rem 0.6rem; }
.lib-colblock .lib-row-actions { margin: 0.2rem 0 0.4rem; }
.lib-columns-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.lib-columns-actions .btn { width: auto; margin: 0; }
.lib-dynamic { display: block; margin: 0.4rem 0 0.2rem; padding: 0.6rem; border: 1px solid var(--border-color); border-radius: 8px; }
.lib-side-filter { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.6rem; }
.lib-side-filter__row { display: flex; gap: 0.4rem; align-items: center; }
.lib-side-filter__row select { flex: 1; min-width: 0; }
.lib-side-filter__row .btn { width: auto; margin: 0; white-space: nowrap; }
.lib-autofill-btn { width: 100%; margin-bottom: 0.5rem; }
.lib-autofill { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.7rem; margin-bottom: 0.7rem; border: 1px dashed var(--accent-purple); border-radius: 10px; }
.lib-autofill[hidden] { display: none; }
.lib-autofill .help { margin: 0; }
.lib-field-inline { display: flex; flex-direction: column; gap: 0.2rem; }
.lib-autofill__actions { display: flex; gap: 0.5rem; }
.lib-autofill__actions .btn { width: auto; margin: 0; }

/* Straighten the photo in the cutout selector */
.cutout__canvas { display: block; max-width: 100%; max-height: 70vh; pointer-events: none; }
.cutout__turn { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; flex-basis: 100%; }
.cutout__turn-label { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; font-size: 0.82rem; color: var(--text-muted); flex: 1 1 100%; min-width: 0; }
.cutout__turn-label > span:first-child { flex-basis: 100%; }
.cutout__rotate { flex: 1 1 0; min-width: 0; accent-color: var(--accent-purple); }
.cutout__rotate-value { min-width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-main); }
.cutout__turn .btn { width: auto; margin: 0; flex-shrink: 0; }
.lib-side-filter select, .lib-autofill select { width: 100%; padding: 0.45rem 0.6rem; border-radius: 8px; border: 1px solid var(--border-color); background: rgba(0, 0, 0, 0.25); color: var(--text-main); font-size: 0.85rem; font-family: inherit; }
.lib-side-filter .search-input input { width: 100%; }

/* Review state banner (draft / published + autosave status) */
.review-state { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.review-state__main { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; flex: 1; min-width: 220px; }
.review-state__main .help { margin: 0; }
.badge-published { color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.1); }
.review-state .autosave-status { margin: 0; }

/* Emoji picker (emoji-picker.js): popover + the button inside text fields. The picker is a web
   component themed through its CSS custom properties. */
#emoji-picker-popover { border-radius: var(--radius-lg, 12px); border: 1px solid var(--border-strong, var(--border-color)); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45); overflow: hidden; }
emoji-picker {
    height: 320px;
    width: 280px;
    --num-columns: 8;
    --background: var(--bg-card-alt, #14151b);
    --border-color: var(--border-strong, rgba(255, 255, 255, 0.2));
    --border-radius: var(--radius-lg, 12px);
    --input-border-radius: var(--radius-md, 8px);
    --input-border-color: var(--border-strong, rgba(255, 255, 255, 0.2));
    --input-font-color: var(--text-main);
    --input-placeholder-color: var(--text-muted);
    --category-font-color: var(--text-muted);
    --indicator-color: var(--accent-purple);
    --outline-color: var(--accent-purple);
    --button-hover-background: rgba(139, 92, 246, 0.15);
    --button-active-background: rgba(139, 92, 246, 0.25);
}
.emoji-field { position: relative; width: 100%; }
.emoji-field > input, .emoji-field > textarea { padding-right: 2.4rem; }
.emoji-field-btn { position: absolute; top: 0.45rem; right: 0.45rem; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border: none; border-radius: 6px; background: transparent; color: var(--accent-purple); cursor: pointer; padding: 0; opacity: 0.75; }
.emoji-field-btn:hover, .emoji-field-btn:focus-visible { opacity: 1; background: rgba(139, 92, 246, 0.15); outline: none; }
.emoji-field--area .emoji-field-btn { top: 0.5rem; }

/* Reading recommendation: a colour per level (red = do not read ... green = yes, purple/pink = mandatory) */
.rec { --rec: #eab308; --rec-bg: #d97706; }
.rec--epic_no { --rec: #ef4444; --rec-bg: #991b1b; }
.rec--strong_no { --rec: #f87171; --rec-bg: #dc2626; }
.rec--no { --rec: #fb923c; --rec-bg: #ea580c; }
.rec--maybe { --rec: #facc15; --rec-bg: #ca8a04; }
.rec--yes { --rec: #4ade80; --rec-bg: #16a34a; }
.rec--strong_yes { --rec: #34d399; --rec-bg: #047857; }
.rec--epic_yes { --rec: #c084fc; --rec-bg: #7c3aed; }
.review-verdict { background: rgba(255, 255, 255, 0.06); display: flex; align-items: center; gap: 0.6rem; margin: -1.4rem -1.4rem 1rem; padding: 0.8rem 1.4rem; border-radius: 0; border: none; border-bottom: 1px solid var(--rec); background: rgba(255, 255, 255, 0.06); background: color-mix(in srgb, var(--rec) 16%, transparent); color: var(--rec); font-size: 1.1rem; font-weight: 700; letter-spacing: 0.01em; }
.review-verdict::before { content: ''; flex: none; width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rec) 25%, transparent); }
.rec--epic_yes.review-verdict { background: linear-gradient(90deg, rgba(124, 58, 237, 0.22), rgba(219, 39, 119, 0.18)); }
.rec-pill { display: inline-flex; align-items: center; padding: 0.15rem 0.7rem; border-radius: 999px; background: var(--rec-bg); color: #fff; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.rec--epic_yes.rec-pill { background: linear-gradient(90deg, #7c3aed, #db2777); }
.detail-rating .rec-pill { margin-left: 0.5rem; }

.review-verdict__label { font-weight: 500; opacity: 0.85; }

.rec-pill__label { font-weight: 500; opacity: 0.9; margin-right: 0.3rem; }
/* Small shelf pictures (overview cards, template chooser): always centred in their box. */
.lib-card__preview .lib-root, .lib-template__preview .lib-root { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; padding: 0; }
.lib-card__preview .lib-shelf2d, .lib-template__preview .lib-shelf2d { margin: 0 auto; flex: none; }

/* Shelf page: switchers, zoom and settings stay in view while the shelf is scrolled. */
.lib-page-head--sticky { position: sticky; top: 0; z-index: 30; margin: 0 -0.5rem 1rem; padding: 0.6rem 0.5rem; background: var(--bg-main, var(--bg-body, #0b0b12)); border-bottom: 1px solid var(--border-color); }
.lib-page-head--sticky + .form-error + .lib-settings-panel, .lib-page-head--sticky ~ .lib-layout .lib-sidebar { top: 5.2rem; max-height: calc(100vh - 6rem); }

.lib-menu__open { display: inline-block; width: auto; margin: 0.4rem 0 0.2rem; text-decoration: none; text-align: center; }

/* ---------------------------------------------------------------------- */
/* Reading times: header timer, overview, entry page, book section         */
/* ---------------------------------------------------------------------- */
.rt-mini { display: flex; align-items: center; gap: 0.5rem; min-width: 0; font-size: 0.85rem; }
.rt-mini__start, .rt-mini__btn, .rt-mini__details { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; height: 32px; padding: 0 0.7rem; border: 1px solid var(--border-soft, var(--border-color)); border-radius: 8px; background: var(--bg-input, transparent); color: var(--text-main); font: inherit; font-size: 0.82rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.rt-mini__btn { width: 32px; padding: 0; }
.rt-mini__start:hover, .rt-mini__btn:hover, .rt-mini__details:hover { border-color: var(--accent-purple); }
.rt-mini__dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; flex: none; }
.rt-mini.is-running .rt-mini__dot { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: rt-pulse 1.6s infinite; }
@keyframes rt-pulse { 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
@media (prefers-reduced-motion: reduce) { .rt-mini.is-running .rt-mini__dot { animation: none; } }
.rt-mini__time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.2rem; }
.rt-mini__book { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); text-decoration: none; }
@media (max-width: 700px) { .rt-mini__book, .rt-mini__start span { display: none; } }

.rt-picker { position: fixed; inset: 0; z-index: 10005; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 1rem 1rem; background: rgba(0, 0, 0, 0.55); }
.rt-picker__box { width: min(480px, 100%); max-height: 80vh; display: flex; flex-direction: column; gap: 0.7rem; }
.rt-picker__box h3 { margin: 0; }
.rt-picker__list { overflow: auto; display: flex; flex-direction: column; gap: 0.3rem; min-height: 80px; }
.rt-picker__row { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border-soft, var(--border-color)); border-radius: 8px; background: transparent; color: var(--text-main); font: inherit; text-align: left; cursor: pointer; }
.rt-picker__row:hover, .rt-picker__row:focus-visible { border-color: var(--accent-purple); outline: none; }

.rt-toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; }
.rt-toolbar__actions, .rt-toolbar__filters { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-end; }
.rt-toolbar .btn { width: auto; margin: 0; }
.rt-toolbar .field { margin-bottom: 0; }
.rt-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.rt-tile { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.9rem 1rem; }
.rt-tile strong { font-size: 1.4rem; }
.rt-list--cards { display: flex; flex-direction: column; gap: 0.7rem; }
.rt-card { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 1rem; color: inherit; text-decoration: none; }
.rt-card:hover { border-color: var(--accent-purple); }
.rt-cover { flex: none; width: 56px; height: 84px; }
.rt-card__body { flex: 1; min-width: 0; }
.rt-card__body h3 { margin: 0; font-size: 1rem; }
.rt-card__body p { margin: 0.1rem 0 0; font-size: 0.85rem; }
.rt-card__notes { color: var(--text-main); white-space: pre-wrap; overflow-wrap: anywhere; }
.rt-card__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; text-align: right; }
.rt-status { text-transform: none; }
.rt-status--running { color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.1); }
.rt-status--paused { color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.1); }

.rt-entry { display: flex; align-items: center; gap: 1rem; }
.rt-entry__book { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-start; }
.rt-entry__title { font-size: 1.15rem; font-weight: 700; color: var(--text-main); text-decoration: none; }
.rt-clock { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1rem; }
.rt-clock[hidden] { display: none; }
.rt-clock__time { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.rt-clock__buttons { display: flex; gap: 0.6rem; margin-left: auto; }
.rt-clock__buttons .btn { width: auto; margin: 0; }
.rt-form { margin-top: 1rem; }
.rt-form__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.rt-duration { display: flex; align-items: center; gap: 0.35rem; }
.rt-duration input { width: 5.2rem; }
.rt-section { margin-top: 1rem; }
.rt-section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.7rem; }
.rt-section__head h2 { margin: 0; font-size: 1.15rem; }
.rt-section__actions { display: flex; gap: 0.5rem; }
.rt-section__actions .btn { width: auto; margin: 0; }
.rt-list { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.5rem; }
.rt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 1rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border-soft, var(--border-color)); border-radius: 8px; color: inherit; text-decoration: none; }
.rt-row:hover { border-color: var(--accent-purple); }
.rt-row__date { color: var(--text-muted); min-width: 10rem; }
.rt-row__time { min-width: 6rem; }
.rt-host { margin-top: 1rem; }

/* Library worth */
.worth-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1rem; }
.worth-total strong { font-size: 2.2rem; }
.worth-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.worth-wish { border-style: dashed; }
.worth-notice { margin-bottom: 1rem; }
.worth-notice summary { cursor: pointer; font-weight: 600; }
.worth-notice ol { margin: 0.4rem 0 0.8rem 1.2rem; padding: 0; }
.worth-defaults { border-collapse: collapse; margin-bottom: 0.8rem; }
.worth-defaults td { padding: 0.15rem 1.2rem 0.15rem 0; }
.worth-shown { margin: 0.8rem 0 0.4rem; }
.worth-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.3rem 0 0 !important; }
.worth-source { font-size: 0.78rem; }
.worth-source--paid { color: #22c55e; }

/* Shelf decorations */
.lib-side-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.7rem; }
.lib-side-tab { flex: 1; padding: 0.4rem 0.6rem; border: 1px solid var(--border-soft, var(--border-color)); border-radius: 8px; background: transparent; color: var(--text-muted); font: inherit; cursor: pointer; }
.lib-side-tab.is-active { color: var(--text-main); border-color: var(--accent-purple); background: rgba(139, 92, 246, 0.15); }
.lib-decor-heading { margin: 0.9rem 0 0.4rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.lib-decor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.lib-decor-tile { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.5rem; border: 1px solid var(--border-soft, var(--border-color)); border-radius: 10px; font-size: 0.8rem; }
.lib-decor-tile strong { font-size: 0.82rem; }
.lib-decor-tile__picture { height: 84px; display: flex; align-items: flex-end; justify-content: center; cursor: grab; touch-action: none; }
.lib-decor-tile__picture img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.lib-decor-tile__scale { width: 100%; margin: 0.2rem 0 0; padding: 0; }
.lib-decor img, .lib-float__thumb--decor img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; user-select: none; }
.lib-decor { position: absolute; inset: 0; box-shadow: none; overflow: visible; }
.lib-decor img { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4)); }
.lib-float__thumb--decor { background: transparent; box-shadow: none; }
.lib-float__thumb--decor img { width: 100%; height: 100%; object-fit: contain; }
.lib-menu__scale { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.lib-menu__scale input { flex: 1; }
.lib-menu__scale-value { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }

/* A decoration in 3D: a sprite that faces the viewer, standing on its bottom edge. */
.lib-decor3d { position: absolute; background-size: 100% 100%; background-repeat: no-repeat; transform-origin: 50% 100%; transform: rotateY(calc(var(--ay, 0deg) * -1)) rotateX(calc(var(--ax, 0deg) * -1)); filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45)); pointer-events: auto; }

/* Book jar */
.jar-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.8rem; margin: 1rem 0 0.4rem; }
.jar-count { margin: 0; font-size: 1.15rem; font-weight: 700; }
.jar-bar__tools { display: flex; align-items: center; gap: 0.7rem; }
.jar-bar__tools .btn { width: auto; margin: 0; }
.jar-stage { display: flex; justify-content: center; padding: 1rem 0 2rem; overflow-x: clip; }
.jar-wrap { padding-top: 130px; position: relative; }
.jar__canvas { position: absolute; left: 0; z-index: 1; clip-path: inset(0 0 0 0 round 0 0 43px 43px); }
.jar { box-sizing: content-box; position: relative; border: 3px solid rgba(var(--glass, 190, 225, 255), 0.5); border-top: none; border-radius: 0 0 46px 46px; background: rgba(var(--glass, 190, 225, 255), 0.04); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4); }
.jar__rim { z-index: 12; position: absolute; left: -12px; right: -12px; top: -12px; height: 14px; border: 3px solid rgba(var(--glass, 190, 225, 255), 0.55); border-radius: 10px; background: rgba(var(--glass, 190, 225, 255), 0.14); pointer-events: none; }
.jar__shine { position: absolute; left: 10px; top: 8px; bottom: 30px; width: 10px; border-radius: 8px; background: linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05)); pointer-events: none; z-index: 11; }
.jar.is-shaking, .jar3d-world.is-shaking { animation: jar-shake 0.6s ease-in-out; }
@keyframes jar-shake { 0%, 100% { translate: 0 0; } 15% { translate: -9px 0; } 30% { translate: 8px 0; } 45% { translate: -7px 2px; } 60% { translate: 6px 0; } 80% { translate: -3px 0; } }
@media (prefers-reduced-motion: reduce) { .jar.is-shaking, .jar3d-world.is-shaking { animation: none; } }
.jar3d-scene { position: relative; width: min(100%, 700px); display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; user-select: none; perspective-origin: 50% 35%; }
.jar3d-world { position: relative; transform-style: preserve-3d; transform: rotateX(var(--rx, -8deg)) rotateY(var(--ry, -24deg)); }
.jar3d-books { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.jar3d-book { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; cursor: pointer; }
.jar3d-book .book-face { backface-visibility: hidden; }
.jar3d-glass { position: absolute; border: 2px solid rgba(var(--glass, 190, 225, 255), 0.35); background: linear-gradient(135deg, rgba(var(--glass, 190, 225, 255), 0.16), rgba(var(--glass, 190, 225, 255), 0.04)); pointer-events: none; box-sizing: border-box; }
.jar3d-glass--back { background: linear-gradient(135deg, rgba(var(--glass, 190, 225, 255), 0.1), rgba(var(--glass, 190, 225, 255), 0.03)); }
.jar3d-glass--floor { background: rgba(var(--glass, 190, 225, 255), 0.22); }
.jar3d-glass.jar3d-rim { border: 3px solid rgba(var(--glass, 190, 225, 255), 0.6); border-radius: 10px; background: transparent; }
.jar3d-book .book-face--generated { font-size: max(3px, calc(var(--u, 2px) * 1.5)); }
.jar3d-book .book-face--spine.book-face--generated { font-size: max(3px, calc(var(--u, 2px) * 1.2)); }
.jar3d-book .book-face--back.book-face--generated { font-size: max(2px, calc(var(--u, 2px) * 0.8)); padding: 8%; }
.jar3d-book .book-face--front.book-face--generated { padding: 8%; }

/* The glass in front of the books: they are inside the jar, behind the pane (also while shaking). */
.jar__glass { position: absolute; inset: 0; z-index: 10; pointer-events: none; border-radius: 0 0 46px 46px; background: linear-gradient(100deg, rgba(var(--glass, 190, 225, 255), 0.14), rgba(var(--glass, 190, 225, 255), 0.03) 45%, rgba(var(--glass, 190, 225, 255), 0.09)); box-shadow: inset 0 -10px 24px rgba(var(--glass, 190, 225, 255), 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.12); }

/* Round 3D glass (a ring of panels), floor and flared lip */
.jar3d-panel { position: absolute; background: linear-gradient(90deg, rgba(var(--glass, 190, 225, 255), 0.09), rgba(var(--glass, 190, 225, 255), 0.03)); border-left: 1px solid rgba(var(--glass, 190, 225, 255), 0.07); border-right: 1px solid rgba(var(--glass, 190, 225, 255), 0.07); pointer-events: none; box-sizing: border-box; }
.jar3d-panel--shine { background: linear-gradient(90deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.04)); }
.jar3d-disc { position: absolute; border-radius: 50%; pointer-events: none; box-sizing: border-box; }
.jar3d-disc--floor { background: radial-gradient(circle, rgba(var(--glass, 190, 225, 255), 0.28), rgba(var(--glass, 190, 225, 255), 0.12)); }
.jar3d-disc--base { border: 4px solid rgba(var(--glass, 190, 225, 255), 0.3); }
.jar3d-disc--lip-in { border: 2px solid rgba(var(--glass, 190, 225, 255), 0.55); }
.jar3d-disc--lip-mid { border: 2px solid rgba(var(--glass, 190, 225, 255), 0.32); }
.jar3d-disc--lip-out { border: 5px solid rgba(235, 247, 255, 0.7); box-shadow: 0 0 10px rgba(var(--glass, 190, 225, 255), 0.35); }

.jar-meta { margin: 0.1rem 0 0; font-size: 0.9rem; }
.jar-bar__tools { flex-wrap: wrap; }
.jar-options { margin: 0.4rem 0 0.6rem; }
.jar-options summary { cursor: pointer; font-weight: 700; }
.jar-options__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.8rem; margin: 0.9rem 0; }
.jar-legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 0.2rem; }
.jar-legend__chip { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.25rem 0.7rem; border-radius: 999px; border: 1px solid var(--border, rgba(255, 255, 255, 0.15)); background: transparent; color: inherit; font: inherit; font-size: 0.85rem; cursor: pointer; width: auto; margin: 0; }
.jar-legend__chip.is-active { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.5); }
.jar-legend__dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; flex: none; }
.jar-stage--spot { background: radial-gradient(ellipse at 50% 35%, rgba(255, 236, 190, 0.16), transparent 62%); }
.jar-stage--table .jar-wrap::after { content: ""; position: absolute; left: 50%; bottom: -26px; width: min(100vw - 32px, 640px); height: 26px; transform: translateX(-50%); border-radius: 0 0 14px 14px; background: linear-gradient(#a06b3c, #6e4524); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45); }
.jar-stage--table .jar-wrap::before { content: ""; position: absolute; left: 50%; bottom: -2px; width: min(100vw - 32px, 640px); height: 6px; transform: translateX(-50%); background: #c58b53; border-radius: 6px; z-index: 0; }
.jar__lid { position: absolute; left: -10px; right: -10px; top: -22px; height: 24px; border-radius: 8px 8px 4px 4px; z-index: 13; opacity: 0; transform: translateY(-14px); transition: opacity 0.4s, transform 0.4s; pointer-events: none; display: none; }
.is-settled .jar__lid { opacity: 1; transform: none; }
.jar__lid--cork { display: block; background: repeating-linear-gradient(90deg, #c49a64 0 6px, #b88a52 6px 11px); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4); }
.jar__lid--metal { display: block; background: linear-gradient(#e5e8ee, #8d95a3); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4); }
.jar__lid--gold { display: block; background: linear-gradient(#f9e27d, #b8860b); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4); }
.jar3d-disc--lid { position: absolute; display: block; opacity: 0; transition: opacity 0.4s; top: 0; transform-style: flat; height: auto; right: auto; border-radius: 50%; }
.is-settled .jar3d-disc--lid { opacity: 1; }
.jar3d-face__title { position: absolute; inset: 8% 6%; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden; color: #fff; font-weight: 700; font-size: max(3px, calc(var(--u, 2px) * 1.4)); line-height: 1.1; overflow-wrap: anywhere; }
.jar3d-table { position: absolute; backface-visibility: hidden; pointer-events: none; }
.jar3d-table--top { background: repeating-linear-gradient(90deg, #b07a46 0 38px, #a06b3c 38px 40px, #b98450 40px 78px, #94622f 78px 80px); box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35); }
.jar3d-table--side { background: linear-gradient(#7a4d27, #5a3718); }
.jar3d-face { background-size: 100% 100%; }

/* Book hallway (first-person CSS-3D walk) */
.hall-bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1.2rem; margin: 1rem 0 0.4rem; }
.hall-status { margin: 0; font-size: 1.05rem; font-weight: 700; }
.hall-help { margin: 0; }
.hall-wrap { position: relative; }
.hall-wrap.is-fullscreen { background: #07070c; }
.hall-wrap.is-fullscreen .hall-scene { height: 100vh; border: 0; border-radius: 0; }
.hall-scene { position: relative; height: min(78vh, 780px); min-height: 380px; overflow: hidden; border-radius: 14px; border: 1px solid var(--border-color); background: #07070c; cursor: grab; touch-action: none; user-select: none; outline: none; perspective-origin: 50% 50%; }
.hall-scene:focus-visible { box-shadow: 0 0 0 2px var(--accent-purple); }
.hall-world { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.hall-section { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.hall-floor, .hall-ceiling, .hall-wall, .hall-end, .hall-startwall, .hall-lamp { position: absolute; }
.hall-floor { background: repeating-linear-gradient(90deg, #5a4129 0 118px, #4d3722 118px 120px); }
.hall-ceiling { background: #2b2b35; }
.hall-lamp { background: radial-gradient(ellipse, #fff8dc 0%, #f6e7a6 55%, rgba(246, 231, 166, 0) 100%); filter: blur(2px); }
.hall-wall { background: linear-gradient(#2f2219, #261b14); overflow: hidden; }
.hall-board { position: absolute; background: linear-gradient(#8a6238, #6b4a2a); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
.hall-post { position: absolute; background: #5b3f24; }
.hall-book { position: absolute; cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.hall-book:hover { filter: brightness(1.35); }
.hall-book .book-face--spine.book-face--generated { font-size: max(5px, calc(var(--u, 4px) * 1.05)); }
.hall-end { background: linear-gradient(#3a2d22, #2a2018); display: flex; align-items: center; justify-content: center; }
.hall-end__sign { padding: calc(var(--u) * 6) calc(var(--u) * 10); border: calc(var(--u) * 1.5) solid #c9a35c; border-radius: calc(var(--u) * 3); color: #f1e3c0; font-size: calc(var(--u) * 14); font-weight: 700; text-align: center; background: rgba(0, 0, 0, 0.35); }
.hall-startwall { background: linear-gradient(#3b3026, #2c231b); }
.hall-door { position: absolute; left: 50%; bottom: 0; width: calc(var(--u) * 90); height: calc(var(--u) * 210); transform: translateX(-50%); border: calc(var(--u) * 4.5) solid #6b4a2a; border-bottom: none; border-radius: 10px 10px 0 0; background: linear-gradient(90deg, #8f6a3f, #a47c4a 50%, #8f6a3f); cursor: pointer; padding: 0; }
.hall-door:hover { filter: brightness(1.12); }
.hall-door__sign { position: absolute; left: 50%; top: calc(var(--u) * -23); transform: translateX(-50%); padding: calc(var(--u) * 1.5) calc(var(--u) * 7); background: #1f8a4c; color: #fff; font-weight: 800; letter-spacing: calc(var(--u) * 1.5); font-size: calc(var(--u) * 10); border-radius: calc(var(--u) * 1.5); white-space: nowrap; }
.hall-door__knob { position: absolute; right: calc(var(--u) * 9); top: 55%; width: calc(var(--u) * 8.5); height: calc(var(--u) * 8.5); border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f3dc8a, #b58d2d); }
.hall-card { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start; padding: 0.7rem 0.9rem; max-width: 260px; }
.hall-card .btn { width: auto; margin: 0.3rem 0 0; }
.hall-pad { position: absolute; right: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(3, 46px); grid-template-areas: ". f ." "l b r"; gap: 6px; }
.hall-pad__btn { height: 46px; border: 1px solid var(--border-soft, var(--border-color)); border-radius: 10px; background: rgba(20, 20, 30, 0.75); color: var(--text-main); font-size: 1.2rem; cursor: pointer; touch-action: none; }
.hall-pad__btn[data-hold="forward"] { grid-area: f; }
.hall-pad__btn[data-hold="turnLeft"] { grid-area: l; }
.hall-pad__btn[data-hold="back"] { grid-area: b; }
.hall-pad__btn[data-hold="turnRight"] { grid-area: r; }

/* Shared (public profile) book page */
.shared-head { display: flex; flex-wrap: wrap; gap: 1.4rem; margin: 0.6rem 0 1.2rem; }
.shared-cover { flex: none; width: min(100%, 340px); }
.shared-info { flex: 1; min-width: 260px; }
.shared-info h1 { margin: 0 0 0.2rem; font-size: 1.6rem; }
.shared-subtitle { margin: 0 0 0.3rem; color: var(--text-muted); }
.shared-author { margin: 0 0 0.6rem; font-size: 1.05rem; }
.shared-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.shared-chip { position: static; }
.shared-meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0.8rem 0 0; }
.shared-meta dt { color: var(--text-muted); }
.shared-meta dd { margin: 0; }
.shared-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.shared-scores { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0.3rem 0 0.6rem; }
.shared-scores dt { color: var(--text-muted); }
.shared-scores dd { margin: 0; }
.shared-quote { margin: 0.5rem 0; padding-left: 0.8rem; border-left: 3px solid var(--accent-purple); font-style: italic; }

/* Lucky wheel */
.wheel-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.8rem 1.5rem; margin: 1rem 0; }
.wheel-count { margin: 0; font-size: 1.1rem; font-weight: 700; }
.wheel-options { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.4rem; }
.wheel-option { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.wheel-option input[type=range] { width: 140px; padding: 0; }
.wheel-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(240px, 1fr); gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .wheel-layout { grid-template-columns: 1fr; } }
.wheel-stage { position: relative; width: 100%; max-width: 560px; margin: 0 auto; }
.wheel-stage canvas { display: block; width: 100%; height: auto; border-radius: 50%; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); }
.wheel-pointer { position: absolute; left: 50%; top: -6px; z-index: 3; width: 0; height: 0; transform: translateX(-50%); border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 34px solid #f5d142; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }
.wheel-spin { position: absolute; left: 50%; top: 50%; z-index: 2; width: 84px; height: 84px; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.6); background: linear-gradient(135deg, #8b5cf6, #4f46e5); color: #fff; font-weight: 800; letter-spacing: 1px; cursor: pointer; }
.wheel-spin:disabled { opacity: 0.6; cursor: default; }
.wheel-spin:not(:disabled):hover { filter: brightness(1.15); }
.wheel-side { display: flex; flex-direction: column; gap: 1rem; }
.wheel-result { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.wheel-result__cover { max-width: 140px; max-height: 210px; border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.wheel-result__title { font-size: 1.25rem; }
.wheel-result .btn { width: auto; margin: 0.3rem 0 0; }
.wheel-history { margin: 0.5rem 0 0.8rem 1.2rem; padding: 0; font-size: 0.88rem; }

.reading-numbers h2 { margin: 0 0 0.2rem; }
.rn-bars { display: grid; gap: 0.7rem; margin: 0.8rem 0; }
.rn-bar { display: grid; gap: 0.3rem; }
.rn-bar__track { height: 0.7rem; border-radius: 999px; background: var(--border, rgba(127, 127, 127, 0.25)); overflow: hidden; }
.rn-bar__fill { height: 100%; border-radius: 999px; background: var(--accent, #6c8cff); }

.cutout__holder { display: flex; align-items: center; justify-content: center; max-width: 100%; }
.cutout__fine { min-width: 2rem; padding-left: 0.5rem; padding-right: 0.5rem; }
@media (pointer: coarse) { .cutout__handle { width: 26px; height: 26px; } .cutout__handle--nw { left: -14px; top: -14px; } .cutout__handle--ne { right: -14px; top: -14px; } .cutout__handle--sw { left: -14px; bottom: -14px; } .cutout__handle--se { right: -14px; bottom: -14px; } .cutout__handle--n { left: calc(50% - 13px); top: -14px; } .cutout__handle--s { left: calc(50% - 13px); bottom: -14px; } .cutout__handle--w { top: calc(50% - 13px); left: -14px; } .cutout__handle--e { top: calc(50% - 13px); right: -14px; } }
.camera-box { max-width: 560px; }
.camera-stage { position: relative; background: #000; border-radius: 8px; overflow: hidden; line-height: 0; margin-bottom: 0.8rem; }
.camera-video, .camera-still { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.camera-video.is-mirrored { transform: scaleX(-1); }
.camera-message { margin: 0 0 0.8rem; }
.camera-actions { flex-wrap: wrap; }
.camera-actions .btn { width: auto; margin: 0; }
.camera-actions [hidden] { display: none; }
.camera-stage [hidden] { display: none; }
.camera-stage { touch-action: none; user-select: none; }
.camera-focus { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 2px solid #fff; border-radius: 10px; pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
.camera-focus.is-pulse { animation: camera-focus-pulse 0.8s ease-out; }
@keyframes camera-focus-pulse { from { transform: scale(1.4); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
.camera-zoom { display: flex; align-items: center; gap: 0.6rem; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.camera-zoom__slider { flex: 1; min-width: 0; accent-color: var(--accent-purple); }
.camera-zoom__value { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-main); }
.camera-zoom[hidden], .camera-focus[hidden] { display: none; }
.cutout__prompt { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; border: 1px solid var(--accent-purple); border-radius: 8px; font-size: 0.85rem; color: var(--text-main); }
.cutout__prompt[hidden] { display: none; }
.cutout__prompt .btn { width: auto; margin: 0; }
.cutout__prompt-source { color: var(--text-muted); font-size: 0.78rem; flex-basis: 100%; }
.backtext-bar { margin-top: 0.4rem; }
.backtext-bar .btn { width: auto; margin: 0; }
.backtext-box { max-width: 560px; }
.backtext-title { margin: 0 0 0.6rem; }
.backtext-result { width: 100%; margin-bottom: 0.8rem; }
.backtext-actions { flex-wrap: wrap; }
.backtext-actions .btn { width: auto; margin: 0; }

/* Mobile overview size switch: large = 1 column, medium = 2, small = 3 (title only). Desktop keeps the auto-fill grid. */
.view-switch { display: none; }
@media (max-width: 640px) {
    .view-switch { display: flex; justify-content: flex-end; gap: 0.25rem; margin-bottom: 0.75rem; }
    .view-switch__btn { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border: 1px solid var(--border-soft); border-radius: var(--radius-md, 8px); background: var(--bg-card); color: var(--text-muted); cursor: pointer; }
    .view-switch__btn[aria-pressed="true"] { color: var(--accent-purple); border-color: var(--accent-purple); }
    .book-grid[data-view="large"] { grid-template-columns: 1fr; }
    .book-grid[data-view="medium"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
    .book-grid[data-view="small"] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
    .book-grid[data-view="small"] .book-card-body { padding: 0.4rem 0.45rem 0.5rem; gap: 0.15rem; }
    .book-grid[data-view="small"] .book-card-title { font-size: 0.72rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .book-grid[data-view="small"] .book-card-author,
    .book-grid[data-view="small"] .book-card-overlay { display: none; }
    .book-grid[data-view="small"] .badge-rating { font-size: 0.65rem; }
    .book-grid[data-view="medium"] .book-card-title { font-size: 0.85rem; }
    .book-grid[data-view="medium"] .book-card-author { font-size: 0.75rem; }
}
=======
/* Add form: "this ISBN already exists" suggestion tile */
.isbn-suggestion { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.isbn-suggestion[hidden] { display: none; }
.isbn-suggestion__intro { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.isbn-suggestion__row { display: flex; gap: 0.8rem; align-items: center; }
.isbn-suggestion__cover { width: 56px; border-radius: 4px; flex: none; }
.isbn-suggestion__text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }

/* Social tab */
a.book-card { color: inherit; text-decoration: none; }
.book-card-owner { margin: 0; color: var(--accent-purple); font-size: 0.75rem; }
.social-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; margin: 1.2rem 0; }
.social-page { min-width: 2.2rem; height: 2.2rem; border: 1px solid var(--border-soft); border-radius: var(--radius-md, 8px); background: var(--bg-card); color: var(--text-main); cursor: pointer; }
.social-page.active { border-color: var(--accent-purple); color: var(--accent-purple); }
.social-page:disabled { opacity: 0.4; cursor: default; }
.social-gap { align-self: center; color: var(--text-muted); }

/* Hallway: entrance, mouse look crosshair, full screen */
.hall-entrance { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.hall-plainwall { position: absolute; background: linear-gradient(#3b3026, #2c231b); }
.hall-plant { position: absolute; display: flex; align-items: center; justify-content: center; line-height: 1; user-select: none; }
.hall-end__note { margin-top: calc(var(--u) * 3); font-size: calc(var(--u) * 6); font-weight: 400; opacity: 0.85; }
.hall-crosshair { display: none; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); pointer-events: none; z-index: 4; }
.hall-wrap.is-locked .hall-crosshair { display: block; }
.hall-fullscreen { position: absolute; left: 12px; bottom: 12px; z-index: 6; padding: 0.45rem 0.9rem; border: 1px solid var(--border-color); border-radius: 10px; background: rgba(20, 20, 30, 0.75); color: var(--text-main); cursor: pointer; font: inherit; font-size: 0.85rem; }
.hall-esc { display: none; position: absolute; right: 14px; top: 14px; z-index: 6; padding: 0.45rem 0.9rem; border-radius: 10px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 0.85rem; pointer-events: none; }
.hall-wrap.is-fullscreen .hall-esc { display: block; }
.hall-wrap.is-fullscreen .hall-fullscreen { display: none; }

/* Digital library: priority list of the automatic arrangement */
.lib-factors { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.6rem; }
.lib-factors__list { list-style: decimal inside; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.lib-factors__item { display: flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.5rem; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--bg-card); }
.lib-factors__name { flex: 1; font-size: 0.9rem; }
.lib-factors__btn { width: 1.9rem; height: 1.9rem; border: 1px solid var(--border-soft); border-radius: 6px; background: transparent; color: var(--text-main); cursor: pointer; }
.lib-factors__btn:disabled { opacity: 0.35; cursor: default; }

/* Social tab: number of books, quiet text under the filters */
.result-count { margin: 0.4rem 0 0.8rem; color: var(--text-muted); font-size: 0.85rem; }
.result-count:empty { display: none; }
.isbn-suggestion__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.isbn-suggestion__list.is-scrollable { max-height: 13rem; overflow-y: auto; padding-right: 0.3rem; }
.isbn-suggestion__row { display: flex; gap: 0.8rem; align-items: center; }
.isbn-suggestion__row .btn { margin-left: auto; flex: none; width: auto; }
.duplicate-warning { border-color: #eab308; background: rgba(234, 179, 8, 0.08); margin-bottom: 1rem; }
.duplicate-warning[hidden] { display: none; }
.duplicate-warning__list { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }

/* Reviews by others on the book detail page */
.community-reviews__filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 1rem; }
.community-reviews .filter-bar { margin-bottom: 1rem; }
.community-reviews__reach { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0.3rem 0.75rem; border-radius: 999px; background: rgba(139, 92, 246, 0.14); border: 1px solid rgba(139, 92, 246, 0.3); font-size: 0.85rem; cursor: pointer; }
.community-reviews__item { margin-bottom: 1.2rem; }
.community-reviews__by { display: inline-block; margin: 0 0.5rem 0.4rem 0; font-weight: 600; }
