/* ReadRoad: the reader app at /projects/reader/ (page-reader.php). */

:root {
    --bg: #0b0a1a;
    --bg-2: #100f22;
    --surface: #15142b;
    --surface-2: #1c1a37;
    --surface-3: #262347;
    --line: rgba(255, 255, 255, 0.07);
    --line-2: rgba(255, 255, 255, 0.12);
    --text: #ecebfa;
    --text-2: #b0aecb;
    --text-3: #7a779a;
    --read-text: #bdbbd6;
    --accent: #a5a2ff;
    --accent-2: #c9c6ff;
    --accent-ink: #16123d;
    --accent-soft: rgba(165, 162, 255, 0.13);
    --danger: #f8837a;
    --ok: #86d7ad;
    --font-ui: 'Manrope', 'Noto Sans Georgian', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-book: 'Newsreader', 'Noto Serif Georgian', Georgia, serif;
    /* iPhone home-screen app: the header starts below the status bar and the Dynamic Island. */
    --safe-top: env(safe-area-inset-top, 0px);
    --hdr: calc(64px + var(--safe-top));
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);

    /* Older names still used by scriptreader.js */
    --primary: var(--accent);
    --text-main: var(--text);
    --text-muted: var(--text-2);
    --border: var(--line);
}

/* ---------- Base ---------- */
#wpadminbar, .trp-language-switcher { display: none !important; }
html, body {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden !important;
    position: fixed !important;
    background: var(--bg);
    color: var(--text);
}
#neural-app-root {
    position: fixed; inset: 0;
    height: 100dvh;
    z-index: 100000;
    display: flex;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    overscroll-behavior: none;
}
#neural-app-root *, #neural-app-root *::before, #neural-app-root *::after { box-sizing: border-box; }
#neural-app-root button, #neural-app-root select, #neural-app-root input {
    font: inherit; color: inherit; margin: 0;
    letter-spacing: normal; text-transform: none;
}
#neural-app-root button { background: none; border: 0; padding: 0; cursor: pointer; border-radius: 0; box-shadow: none; min-width: 0; min-height: 0; line-height: 1.2; }
#neural-app-root :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#neural-app-root svg { flex-shrink: 0; }
#neural-app-root .hidden, #neural-app-root [hidden], .rr-popover[hidden] { display: none !important; }

.main-pane { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; position: relative; }

/* ---------- Buttons ---------- */
#neural-app-root .icon-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; min-width: 40px; padding: 0 10px;
    border-radius: 12px;
    color: var(--text-2);
    font-size: 14px; font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}
#neural-app-root .icon-btn:hover { background: var(--surface-2); color: var(--text); }
#neural-app-root .icon-btn.active, #neural-app-root .icon-btn.is-active { background: var(--accent); color: var(--accent-ink); }
#neural-app-root .icon-btn svg { width: 20px; height: 20px; }
#neural-app-root .icon-btn.sm { height: 34px; min-width: 34px; padding: 0; border-radius: 10px; }
#neural-app-root .icon-btn.sm svg { width: 18px; height: 18px; }

#neural-app-root .pill-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    color: var(--text);
    font-size: 14px; font-weight: 700;
    white-space: nowrap;
    transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s;
}
#neural-app-root .pill-btn svg { width: 18px; height: 18px; }
#neural-app-root .pill-btn:hover { background: var(--surface-3); }
#neural-app-root .pill-btn:active { transform: scale(0.97); }
#neural-app-root .pill-btn.is-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 6px 20px -6px rgba(165, 162, 255, 0.55); }
#neural-app-root .pill-btn.is-primary:hover { background: var(--accent-2); }
#neural-app-root .pill-btn.is-danger { color: var(--danger); }
#neural-app-root .pill-btn:disabled { opacity: 0.4; cursor: default; }

#neural-app-root .lib-text-btn { color: var(--accent); font-size: 14px; font-weight: 700; padding: 6px 2px; }
#neural-app-root .lib-text-btn:hover { color: var(--accent-2); }

.action-label { font-size: 14px; font-weight: 600; }

/* ---------- Header: one bar that changes with the screen ---------- */
.header {
    flex: 0 0 var(--hdr);
    height: var(--hdr);
    padding-top: var(--safe-top); box-sizing: border-box;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 18px;
    /* Solid and equal to theme-color, so the phone status bar flows straight into the header */
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    position: relative; z-index: 50;
}
.header-left, .header-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.header-left { flex: 1 1 auto; }
.header-actions { flex: 0 0 auto; }

body.library-open .hdr-read, body:not(.library-open) .hdr-lib { display: none !important; }

/* Interface language: a small two-part pill, the current language lit. */
.rr-lang { display: inline-flex; align-items: center; height: 32px; padding: 3px; margin-right: 4px; border: 1px solid var(--line-2); border-radius: 999px; }
.rr-lang a { display: inline-flex; align-items: center; height: 100%; padding: 0 10px; border-radius: 999px; color: var(--text-2); font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-decoration: none; transition: color 0.2s, background 0.2s; }
.rr-lang a:hover { color: var(--text); }
.rr-lang a.is-active { background: var(--surface-3); color: var(--text); }
@media (max-width: 420px) { .rr-lang a { padding: 0 8px; } }
body.library-open:not(.is-reading):not(.is-editing-text) .lib-back-btn { display: none !important; }
body:not(.is-epub) #sidebar-toggle-btn { display: none !important; }
/* Editing is only for pasted text, never for an opened book */
body.is-epub #edit-btn { display: none !important; }
body.is-epub:not(.library-open) #sidebar-toggle-btn { display: inline-flex !important; }

.logo { display: inline-flex; align-items: center; gap: 10px; margin-left: 4px; user-select: none; }
.logo-mark { width: 30px; height: 30px; color: var(--accent); }
.logo-title { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
/* Byline after a thin divider, linking to the main site */
#neural-app-root .logo-by { display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; padding-left: 14px; border-left: 1px solid var(--line-2); line-height: 18px; font-size: 13px; font-weight: 600; color: #8f8cae; text-decoration: none; white-space: nowrap; transition: color 0.25s; }
#neural-app-root .logo-by small { font-size: 13px; font-weight: 400; color: var(--text-3); }
#neural-app-root .logo-by:hover { color: var(--accent-2); }

.book-meta {
    display: flex; align-items: center; gap: 12px;
    min-width: 0; margin-left: 6px; padding: 4px 10px 4px 4px;
    border-radius: 12px; cursor: pointer;
    transition: background 0.2s;
    animation: rr-fade 0.4s var(--ease);
}
.book-meta:hover { background: var(--surface); }
#book-cover-img { width: 30px; height: 44px; object-fit: cover; border-radius: 3px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
#book-cover-img[src=""] { display: none; }
.book-text-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
#book-title-text { font-size: 14px; font-weight: 700; max-width: 38vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
#book-author-text { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 26vw; }
.progress-badge { flex: none; font-size: 11px; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.progress-badge.completed { color: var(--ok); background: rgba(134, 215, 173, 0.12); }

#account-btn .zk-acc-avatar { width: 26px; height: 26px; font-size: 12px; color: var(--accent-ink); background: linear-gradient(135deg, var(--accent-2), var(--accent)); }

#progress-container { flex: 0 0 2px; height: 2px; background: var(--line); position: relative; z-index: 40; }
#progress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.3s ease-out; }
body:not(.is-reading) #progress-container, body.library-open #progress-container { visibility: hidden; }

/* ---------- Reading area ---------- */
.reader-stage { flex: 1; min-height: 0; width: 100%; display: flex; justify-content: center; position: relative; overflow: hidden; }
.reader-column { width: 100%; max-width: 100%; min-width: min(520px, 100%); height: 100%; position: relative; transition: width 180ms ease; }
.reader-column.is-resizing { transition: none; user-select: none; }
body:not(.is-reading) .reader-column { width: 100% !important; }

.content-area {
    width: 100%; height: 100%;
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: 40px clamp(20px, 5vw, 64px) 140px;
    position: relative; z-index: 1;
    font-family: var(--font-book);
    font-size: 1.2rem;
    line-height: 1.75;
    color: var(--read-text);
}
.content-area::-webkit-scrollbar, .toc-list::-webkit-scrollbar, .lib-scroll::-webkit-scrollbar, .settings-modal-body::-webkit-scrollbar { width: 8px; }
.content-area::-webkit-scrollbar-thumb, .toc-list::-webkit-scrollbar-thumb, .lib-scroll::-webkit-scrollbar-thumb, .settings-modal-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.content-area::-webkit-scrollbar-track, .toc-list::-webkit-scrollbar-track, .lib-scroll::-webkit-scrollbar-track { background: transparent; }

.paragraph { margin-bottom: 1.1em; }
.sentence { cursor: pointer; border-radius: 5px; padding: 2px 3px; transition: opacity 0.25s ease, background-color 0.2s ease, color 0.2s ease; }
.sentence:hover { color: var(--text); }
/* Read sentence: light and crisp, GPU-friendly (no blur) */
.sentence.read { opacity: 0.38 !important; color: var(--text-3) !important; background: transparent !important; box-shadow: none !important; }
/* Active sentence: a faint wash, easy on the eyes over long reading */
.sentence.active { opacity: 1 !important; color: var(--text) !important; background: rgba(165, 162, 255, 0.05) !important; box-shadow: inset 2px 0 0 0 rgba(165, 162, 255, 0.4) !important; border-radius: 4px; }

.epub-header { font-family: var(--font-book); font-weight: 600; display: inline; line-height: 1.3; color: var(--text); }
.epub-header-h1 { font-size: 2em; color: var(--accent-2); }
.epub-header-h2 { font-size: 1.6em; }
.epub-header-h3 { font-size: 1.35em; }
.epub-header-h4, .epub-header-h5 { font-size: 1.15em; color: var(--text-2); }
.epub-header-h6 { font-size: 1.05em; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }

/* What books carry inside their text. Pictures never overflow the page and keep their proportions;
   a small inline picture (a symbol, a letter) stays in the line. */
.content-area img { max-width: 100%; height: auto; border-radius: 4px; vertical-align: middle; }
.content-area .sentence-figure { display: block; text-align: center; }
.content-area .sentence-figure img { display: block; margin: 0.6em auto; max-height: 80vh; object-fit: contain; }
.content-area sup, .content-area sub { font-size: 0.7em; line-height: 0; }
.content-area .noteref { color: var(--accent); font-weight: 600; padding: 0 1px; font-size: 0.7em; vertical-align: super; line-height: 0; }
.content-area sup .noteref { font-size: inherit; vertical-align: baseline; }
.content-area .epub-note { font-size: 0.82em; line-height: 1.6; color: var(--text-2); }
.content-area code { font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; background: var(--surface-2); border-radius: 4px; padding: 0 4px; }
.content-area mark { background: rgba(165, 162, 255, 0.2); color: inherit; border-radius: 3px; }
/* Long web addresses and codes break instead of widening the page. */
.content-area .paragraph { overflow-wrap: anywhere; }

/* The reading cursor drifts like a ghost: a soft glow that fades in and out
   instead of a solid block, and the words already spoken step back. */
.word { border-radius: 4px; transition: color 0.45s ease, background-color 0.45s ease, box-shadow 0.45s ease, text-shadow 0.45s ease, opacity 0.6s ease; }
.word.active {
    color: #fff;
    background: rgba(165, 162, 255, 0.15);
    box-shadow: 0 0 14px 2px rgba(165, 162, 255, 0.15);
    text-shadow: 0 0 10px rgba(201, 198, 255, 0.5);
    position: relative; z-index: 2;
}
.sentence.active .word.read { opacity: 0.5; }

.chapter-nav-footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 60px; padding: 20px 0; border-top: 1px solid var(--line); font-family: var(--font-ui); }
#neural-app-root .nav-chapter-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 18px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--line);
    color: var(--text-2); font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s var(--ease);
}
#neural-app-root .nav-chapter-btn:hover { background: var(--surface-2); color: var(--text); transform: translateY(-2px); }
#neural-app-root .nav-chapter-btn.hidden { visibility: hidden; pointer-events: none; display: flex !important; }

/* Drag handle that sets the width of the text column */
body:not(.is-reading) #content-width-handle, body.library-open #content-width-handle { display: none !important; }
#neural-app-root .content-width-handle {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 28px; height: 72px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-2); border-radius: 999px;
    background: rgba(21, 20, 43, 0.9); color: var(--text-2);
    cursor: ew-resize; touch-action: none; opacity: 0.6; z-index: 30;
    transition: opacity 220ms ease, transform 220ms ease, color 160ms ease;
}
#neural-app-root .content-width-handle.is-idle { opacity: 0; pointer-events: none; transform: translateY(-50%) translateX(8px); }
#neural-app-root .content-width-handle:hover, #neural-app-root .content-width-handle:focus-visible, .reader-column.is-resizing #content-width-handle { opacity: 1; color: var(--text); border-color: var(--accent); }
#neural-app-root .content-width-handle svg { width: 16px; height: 16px; pointer-events: none; }
#neural-app-root .content-width-handle::after {
    content: attr(data-width); position: absolute; right: 36px; top: 50%; transform: translateY(-50%);
    padding: 5px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text);
    font: 600 12px var(--font-ui); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 140ms ease;
}
#neural-app-root .content-width-handle:hover::after, .reader-column.is-resizing #content-width-handle::after { opacity: 1; }
body.reader-width-resizing, body.reader-width-resizing * { cursor: ew-resize !important; }

/* ---------- Editing pasted text ---------- */
.edit-mode-active { outline: 1px dashed rgba(165, 162, 255, 0.5) !important; outline-offset: -12px; border-radius: 16px; min-height: 250px; font-family: var(--font-ui); }
.edit-mode-active:empty::before { content: "Type or paste your text here (ჩაწერეთ ან ჩასვით ტექსტი)..."; color: var(--text-3); pointer-events: none; display: block; }
.edit-mode-floating-bar { position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: calc(100% - 24px); }
.edit-mode-pill {
    display: flex; align-items: center; gap: 14px;
    padding: 8px 8px 8px 18px; border-radius: 999px;
    background: rgba(28, 26, 55, 0.92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
    animation: rr-rise 0.35s var(--ease);
}
.edit-mode-status { display: flex; align-items: center; gap: 10px; }
.edit-mode-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: rr-pulse 1.6s infinite; }
.edit-mode-label { font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.edit-mode-actions { display: flex; gap: 6px; }
#neural-app-root .big-save-btn, #neural-app-root .cancel-edit-btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
#neural-app-root .big-save-btn { background: var(--accent); color: var(--accent-ink); }
#neural-app-root .big-save-btn:hover { background: var(--accent-2); }
#neural-app-root .big-save-btn svg { width: 16px; height: 16px; }
#neural-app-root .cancel-edit-btn { color: var(--text-2); }
#neural-app-root .cancel-edit-btn:hover { background: var(--surface-3); color: var(--text); }
body.is-editing-text .controls-overlay { display: none !important; }

/* ---------- Player ---------- */
.controls-overlay {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; justify-content: center;
    padding: 28px 16px calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 35%, rgba(11, 10, 26, 0));
    pointer-events: none;
    opacity: 0; transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s var(--ease);
}
body.is-reading:not(.library-open) .controls-overlay { opacity: 1; transform: none; }
body.is-reading:not(.library-open) .controls { pointer-events: auto; }
.controls {
    display: flex; align-items: center; gap: 4px;
    padding: 7px; border-radius: 999px;
    background: rgba(28, 26, 55, 0.85); -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-pop);
}
#neural-app-root .ctrl-btn { width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); transition: background 0.2s, color 0.2s, transform 0.15s var(--ease); }
#neural-app-root .ctrl-btn svg { width: 20px; height: 20px; }
#neural-app-root .ctrl-btn:hover { background: var(--surface-3); color: var(--text); }
#neural-app-root .ctrl-btn:active { transform: scale(0.92); }
#neural-app-root .ctrl-btn.play { width: 58px; height: 58px; margin: 0 4px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 26px -6px rgba(165, 162, 255, 0.65); }
#neural-app-root .ctrl-btn.play:hover { background: var(--accent-2); }
#neural-app-root .ctrl-btn.play svg { width: 26px; height: 26px; }
#neural-app-root .ctrl-btn.stop:hover { color: var(--danger); }
.ctrl-sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 4px; }

.tts-status-indicator {
    position: absolute; left: 50%; bottom: calc(112px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
    font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.tts-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: rr-spin 0.8s linear infinite; }

/* ---------- Table of contents ---------- */
.sidebar {
    position: relative; flex-shrink: 0;
    width: 300px; max-width: 85vw; height: 100%;
    display: flex; flex-direction: column;
    background: var(--bg-2); border-right: 1px solid var(--line);
    z-index: 100;
    transition: width 0.4s var(--ease), transform 0.4s var(--ease);
}
body:not(.is-epub) #sidebar, body:not(.is-epub) #sidebar-overlay, body.library-open #sidebar, body.library-open #sidebar-overlay { display: none !important; }
.sidebar-header {
    flex: 0 0 var(--hdr); display: flex; align-items: center; justify-content: space-between; padding-top: var(--safe-top); box-sizing: border-box;
    padding: 0 12px 0 22px; border-bottom: 1px solid var(--line);
    font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3);
}
.toc-list { flex: 1; overflow-y: auto; padding: 12px 10px 40px; }
.toc-item {
    display: flex; align-items: center; padding: 10px 14px; margin-bottom: 2px;
    border-radius: 10px; cursor: pointer;
    color: var(--text-2); font-size: 14px; line-height: 1.4;
    transition: background 0.2s, color 0.2s;
}
.toc-item:hover { background: var(--surface); color: var(--text); }
.toc-item.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.toc-item.read-chapter { opacity: 0.45; }
.toc-item.read-chapter.active { opacity: 1; }
.sidebar-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 90; transition: opacity 0.3s; }
.sidebar-overlay.hidden { opacity: 0; pointer-events: none; }
@media (min-width: 769px) {
    .sidebar.collapsed { width: 0; border-right: 0; overflow: hidden; }
    .sidebar-overlay { display: none !important; }
}

/* ---------- Library (the home screen) ---------- */
.library-view {
    position: absolute; left: 0; right: 0; bottom: 0; top: var(--hdr);
    z-index: 30;
    background: var(--bg);
    animation: rr-fade 0.35s var(--ease);
}
.lib-scroll {
    height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    background: radial-gradient(1100px 480px at 12% -12%, rgba(165, 162, 255, 0.09), transparent 62%), radial-gradient(900px 420px at 100% 0%, rgba(120, 140, 255, 0.08), transparent 60%);
}
.lib-inner { max-width: 1320px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 120px; }

/* First visit */
.lib-welcome { padding: clamp(24px, 6vh, 64px) 0 clamp(36px, 6vh, 56px); animation: rr-rise 0.6s var(--ease); }
.lib-eyebrow { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 18px; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
/* Georgian has no capitals (uppercase turns it into Mtavruli) and no italic face. */
html[lang^="ka"] .lib-eyebrow, html[lang^="ka"] .settings-section-title { text-transform: none; letter-spacing: 0.02em; }
html[lang^="ka"] .lib-display em { font-style: normal; }
html[lang^="ka"] .logo-by small { display: none; }
.lib-eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: rr-pulse 2s infinite; }
.lib-display { margin: 0; font-size: clamp(2.6rem, 7vw, 5rem); font-weight: 800; line-height: 0.98; letter-spacing: -0.045em; color: var(--text); }
.lib-display em { font-family: var(--font-book); font-style: italic; font-weight: 400; letter-spacing: -0.02em; color: var(--accent-2); }
.lib-lead { max-width: 34em; margin: 22px 0 0; font-size: clamp(1rem, 1.6vw, 1.12rem); line-height: 1.6; color: var(--text-2); }
.lib-start { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 36px; max-width: 920px; }
#neural-app-root .lib-start-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
    padding: 20px; border-radius: 18px;
    background: var(--surface); border: 1px solid var(--line);
    transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s;
}
#neural-app-root .lib-start-card:hover { transform: translateY(-3px); border-color: var(--line-2); background: var(--surface-2); }
#neural-app-root .lib-start-card strong { margin-top: 14px; font-size: 16px; font-weight: 700; color: var(--text); }
#neural-app-root .lib-start-card span:last-child { font-size: 13.5px; color: var(--text-3); }
.lib-start-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text); }
.lib-start-icon svg { width: 22px; height: 22px; }
#neural-app-root .lib-start-card.is-main { background: linear-gradient(150deg, rgba(165, 162, 255, 0.2), rgba(165, 162, 255, 0.05)); border-color: rgba(165, 162, 255, 0.35); }
#neural-app-root .lib-start-card.is-main .lib-start-icon { background: var(--accent); color: var(--accent-ink); }

/* Section headings */
.lib-section-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 18px; }
.lib-section-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.025em; }
.lib-count { font-size: 14px; font-weight: 600; color: var(--text-3); }
.lib-section-head .lib-text-btn { margin-left: auto; }

/* Continue reading */
.lib-continue { margin-bottom: 44px; }
.lib-continue-row { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 14px; margin: 0 -2px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.lib-continue-row::-webkit-scrollbar { height: 6px; }
.lib-continue-row::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; }
.lib-continue-row::-webkit-scrollbar-track, .lib-continue-row::-webkit-scrollbar-button { display: none; background: transparent; }
#neural-app-root .resume-card {
    flex: 0 0 auto; width: 320px; scroll-snap-align: start;
    display: grid; grid-template-columns: 76px 1fr; gap: 16px; align-items: center;
    padding: 12px 16px 12px 12px; border-radius: 18px;
    background: var(--surface); border: 1px solid var(--line);
    transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s;
}
#neural-app-root .resume-card:hover { transform: translateY(-3px); background: var(--surface-2); border-color: var(--line-2); }
.resume-card .book-cover-container { width: 76px; }
.resume-card .card-progress { display: block !important; margin-top: 12px; }
.resume-card .card-resume { color: var(--accent); font-weight: 700; }
.resume-card .card-resume::after { content: " \2192"; }

/* Toolbar */
.lib-toolbar {
    position: sticky; top: 0; z-index: 5;
    margin: 0 -8px 26px; padding: 12px 8px;
    background: rgba(11, 10, 26, 0.88); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    display: flex; flex-direction: column; gap: 12px;
}
.lib-search { position: relative; display: flex; align-items: center; height: 48px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); transition: border-color 0.2s, background 0.2s; }
.lib-search:focus-within { border-color: rgba(165, 162, 255, 0.55); background: var(--surface-2); }
.lib-search svg { width: 20px; height: 20px; margin: 0 4px 0 16px; color: var(--text-3); }
#neural-app-root .lib-search input { flex: 1; min-width: 0; height: 100%; padding: 0 10px; background: none; border: 0; outline: 0; font-size: 15px; font-weight: 500; color: var(--text); }
.lib-search input::placeholder { color: var(--text-3); }
.lib-search input::-webkit-search-cancel-button { filter: invert(0.6); }
.lib-search kbd { margin-right: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line-2); font: 600 12px var(--font-ui); color: var(--text-3); }
.lib-filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lib-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.lib-chips::-webkit-scrollbar { display: none; }
#neural-app-root .lib-chips button {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    height: 36px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line-2); color: var(--text-2);
    font-size: 13.5px; font-weight: 600;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
#neural-app-root .lib-chips button:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }
#neural-app-root .lib-chips button.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.lib-chips .n { font-size: 12px; font-weight: 700; opacity: 0.6; }
.lib-chips .n:empty { display: none; }
.lib-tools { display: flex; align-items: center; gap: 8px; }
.lib-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
#neural-app-root .lib-seg button { height: 30px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-3); transition: background 0.2s, color 0.2s; }
#neural-app-root .lib-seg button:hover { color: var(--text); }
#neural-app-root .lib-seg button.active { background: var(--surface-3); color: var(--text); }
#neural-app-root .lib-view button { width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.lib-view svg { width: 16px; height: 16px; }
.lib-sort { position: relative; display: inline-flex; align-items: center; height: 38px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.lib-sort svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
#neural-app-root .lib-sort select { height: 100%; padding: 0 14px 0 34px; background: none; border: 0; outline: 0; appearance: none; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.lib-sort select option { background: var(--surface-2); color: var(--text); }

.lib-hint { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -8px 0 22px; padding: 12px 16px; border-radius: 14px; background: var(--accent-soft); font-size: 14px; color: var(--text-2); }

/* Book cards */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 34px 24px; }
#neural-app-root .book-card { position: relative; cursor: pointer; outline-offset: 6px; border-radius: 6px; content-visibility: auto; contain-intrinsic-size: 150px 320px; }
.lib-grid.is-animated .book-card { animation: rr-rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 22ms); }
.book-cover-container {
    position: relative; aspect-ratio: 2 / 3; overflow: hidden;
    border-radius: 3px 7px 7px 3px;
    background: var(--surface-2);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 12px 26px -10px rgba(0, 0, 0, 0.75);
    transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
/* Light falling on a printed spine */
.book-cover-container::after {
    content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.32) 0, rgba(255, 255, 255, 0.12) 2.5%, rgba(255, 255, 255, 0) 7%, rgba(0, 0, 0, 0) 92%, rgba(0, 0, 0, 0.12) 100%);
}
.lib-grid .book-card:hover .book-cover-container { transform: translateY(-6px); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 24px 40px -14px rgba(0, 0, 0, 0.85); }
.book-real-cover { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; animation: rr-fade 0.5s ease; }

.card-body { min-width: 0; padding-top: 14px; }
.resume-card .card-body { padding: 0; }
.book-card-title { font-family: var(--font-book); font-size: 16px; font-weight: 500; line-height: 1.28; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.book-card-author { margin-top: 4px; font-size: 13px; font-weight: 500; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card-author:empty { display: none; }
.card-progress { display: none; height: 3px; margin-top: 10px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.card-progress i { display: block; height: 100%; width: var(--progress, 0%); background: var(--accent); border-radius: inherit; }
.book-card[data-state="reading"] .card-progress { display: block; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.card-progress-label:empty { display: none; }
.book-card[data-state="reading"] .card-progress-label { color: var(--accent); }
.book-card[data-state="finished"] .card-progress-label { color: var(--ok); }
.card-source { font-weight: 600; opacity: 0.75; }
.card-progress-label:not(:empty) + .card-source::before { content: "\00b7"; margin-right: 8px; }
.book-card[data-state="finished"] .book-cover-container::before {
    content: "\2713"; position: absolute; top: 8px; left: 10px; z-index: 3;
    width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #0d1f16; background: var(--ok); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#neural-app-root .card-menu-btn {
    position: absolute; top: 8px; right: 8px; z-index: 4;
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(11, 10, 26, 0.72); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    color: var(--text);
    opacity: 0; transform: scale(0.9);
    transition: opacity 0.2s, transform 0.2s var(--ease), background 0.2s;
}
#neural-app-root .card-menu-btn svg { width: 18px; height: 18px; }
#neural-app-root .card-menu-btn:hover { background: rgba(11, 10, 26, 0.92); }
#neural-app-root .book-card:hover .card-menu-btn, #neural-app-root .book-card:focus-within .card-menu-btn { opacity: 1; transform: none; }
@media (hover: none) { #neural-app-root .card-menu-btn { opacity: 0.85; transform: none; top: 5px; right: 5px; width: 26px; height: 26px; } #neural-app-root .card-menu-btn svg { width: 15px; height: 15px; } }

/* List view */
.lib-grid.is-list { grid-template-columns: 1fr; gap: 0; }
.lib-grid.is-list .book-card {
    display: grid; grid-template-columns: 46px 1fr 40px; gap: 18px; align-items: center;
    padding: 10px 6px; border-bottom: 1px solid var(--line); border-radius: 0;
    contain-intrinsic-size: 600px 90px;
}
.lib-grid.is-list .book-card:hover { background: var(--surface); }
.lib-grid.is-list .book-cover-container { border-radius: 2px 4px 4px 2px; box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.8); }
.lib-grid.is-list .book-card:hover .book-cover-container { transform: none; }
.lib-grid.is-list .book-card[data-state="finished"] .book-cover-container::before { display: none; }
.lib-grid.is-list .card-body { padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) 160px; grid-template-areas: "title foot" "author progress"; column-gap: 24px; align-items: center; }
.lib-grid.is-list .book-card-title { grid-area: title; -webkit-line-clamp: 1; font-size: 16px; }
.lib-grid.is-list .book-card-author { grid-area: author; margin-top: 2px; }
.lib-grid.is-list .card-progress { grid-area: progress; margin: 6px 0 0; }
.lib-grid.is-list .card-foot { grid-area: foot; margin: 0; justify-content: flex-end; }
.lib-grid.is-list .card-menu-btn { position: static; opacity: 1; transform: none; background: none; color: var(--text-3); }
.lib-grid.is-list .card-menu-btn:hover { color: var(--text); background: var(--surface-2); }
.lib-grid.is-list .procedural-book-cover > * { display: none; }

/* Selecting many books */
.is-selecting .lib-grid .book-card[data-key^="drive:"] .book-cover-container::before {
    content: ""; position: absolute; top: 8px; left: 8px; z-index: 3;
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85); background: rgba(11, 10, 26, 0.5);
}
.is-selecting .lib-grid .book-card.is-picked .book-cover-container::before {
    content: "\2713"; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
}
.is-selecting .lib-grid .book-card.is-picked .book-cover-container { outline: 2px solid var(--accent); outline-offset: 3px; }
.is-selecting .lib-grid .book-card.is-locked { opacity: 0.3; pointer-events: none; }
.is-selecting .card-menu-btn { display: none !important; }
.lib-selectbar {
    position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
    display: flex; align-items: center; gap: 14px;
    padding: 8px 8px 8px 20px; border-radius: 999px;
    background: rgba(28, 26, 55, 0.94); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
    font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap;
    animation: rr-rise 0.3s var(--ease);
}

.lib-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 64px 16px; text-align: center; color: var(--text-3); }

/* Questions about ReadRoad: quiet, at the end of the library, one answer open at a time by choice. */
.lib-faq { max-width: 760px; margin: 56px 0 24px; }
.lib-faq-item { border-top: 1px solid var(--line); }
.lib-faq-item:last-child { border-bottom: 1px solid var(--line); }
.lib-faq-item summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 2px; cursor: pointer; list-style: none; color: var(--text); font-size: 15px; font-weight: 600; }
.lib-faq-item summary::-webkit-details-marker { display: none; }
.lib-faq-item summary::after { content: '+'; flex-shrink: 0; color: var(--text-2); font-size: 20px; font-weight: 400; line-height: 1; transition: transform 0.2s ease; }
.lib-faq-item[open] summary::after { transform: rotate(45deg); }
.lib-faq-item summary:hover { color: var(--accent); }
.lib-faq-item p { margin: 0 2px 18px; color: var(--text-2); font-size: 14.5px; line-height: 1.65; }
.lib-empty strong { font-size: 18px; color: var(--text); }

.lib-toast {
    position: absolute; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25;
    max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border-radius: 14px;
    background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
    font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--text);
    animation: rr-rise 0.3s var(--ease);
}
.lib-toast.is-error { background: #3a1f1d; border-color: rgba(248, 131, 122, 0.35); color: #ffd9d5; }

.lib-drop-hint { display: none; position: absolute; inset: 14px; z-index: 40; border-radius: 24px; border: 2px dashed var(--accent); background: rgba(11, 10, 26, 0.86); align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: var(--accent-2); pointer-events: none; }
.library-view.is-dragover .lib-drop-hint { display: flex; }

/* Menus (Add books, card actions) */
.rr-popover {
    position: fixed; z-index: 100200; min-width: 260px; max-width: calc(100vw - 24px);
    padding: 6px; border-radius: 16px;
    background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
    font-family: var(--font-ui); color: var(--text);
    animation: rr-pop 0.18s var(--ease);
}
#neural-app-root .rr-menu-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; text-align: left; transition: background 0.15s; }
#neural-app-root .rr-menu-item:hover, #neural-app-root .rr-menu-item:focus-visible { background: var(--surface-3); outline: none; }
.rr-menu-item svg { width: 20px; height: 20px; color: var(--accent); }
.rr-menu-item span { display: flex; flex-direction: column; }
.rr-menu-item strong { font-size: 14px; font-weight: 700; }
.rr-menu-item small { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.rr-menu-item.is-danger strong { color: var(--danger); }

/* Typographic covers for books without a picture */
.procedural-book-cover {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 16% 12% 12% 16%;
    color: #f3efe7;
}
.procedural-book-cover::before { content: ""; position: absolute; left: 16%; right: 12%; top: 9%; height: 1px; background: rgba(243, 239, 231, 0.3); }
.cover-book-title { font-family: var(--font-book); font-size: clamp(12px, 1.15vw, 17px); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.cover-book-author { font-size: clamp(8px, 0.65vw, 10px); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-card .cover-book-title { font-size: 10px; -webkit-line-clamp: 4; overflow-wrap: break-word; }
.resume-card .cover-book-author { display: none; }
.procedural-palette-0 { background: linear-gradient(160deg, #34465a, #1c2733); }
.procedural-palette-1 { background: linear-gradient(160deg, #5a3530, #2e1c19); }
.procedural-palette-2 { background: linear-gradient(160deg, #35513e, #1c2b21); }
.procedural-palette-3 { background: linear-gradient(160deg, #5c4f35, #2c261b); }
.procedural-palette-4 { background: linear-gradient(160deg, #46365a, #241c2e); }
.procedural-palette-5 { background: linear-gradient(160deg, #285059, #16292f); }
.procedural-palette-6 { background: linear-gradient(160deg, #5a4430, #2e2318); }
.procedural-palette-7 { background: linear-gradient(160deg, #45454c, #232326); }

/* Google's file picker must open above the app */
.picker-dialog-bg, .picker-dialog { z-index: 2147483001 !important; }

/* ---------- Dialogs: book details and settings ---------- */
.info-modal-overlay {
    position: fixed; inset: 0; z-index: 100100;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(4, 4, 12, 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    animation: rr-fade 0.25s ease;
}
.info-modal-content {
    position: relative; width: min(640px, 100%); max-height: 86vh; overflow-y: auto;
    padding: 30px; border-radius: 22px;
    background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
    font-family: var(--font-ui); color: var(--text);
    animation: rr-rise 0.35s var(--ease);
}
#neural-app-root .close-modal { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); z-index: 2; }
#neural-app-root .close-modal:hover { background: var(--surface-3); color: var(--text); }
.close-modal svg { width: 20px; height: 20px; }
.modal-header { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 24px; padding-right: 30px; }
.modal-cover-container { flex: 0 0 120px; aspect-ratio: 2 / 3; border-radius: 3px 7px 7px 3px; overflow: hidden; background: var(--surface-2); box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.8); }
.modal-cover-container:empty { display: none; }
.modal-cover-container img { width: 100%; height: 100%; object-fit: cover; }
.modal-title-group { min-width: 0; }
.modal-title-group h2 { margin: 0; font-family: var(--font-book); font-size: 28px; font-weight: 500; line-height: 1.15; }
.modal-title-group h3 { margin: 8px 0 0; font-size: 15px; font-weight: 600; color: var(--text-2); }
.publisher-info, .date-info { margin-top: 6px; font-size: 13px; color: var(--text-3); }
.genre-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.genre-tag { padding: 4px 10px; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-weight: 600; color: var(--text-2); }
.modal-body h4 { margin: 0 0 10px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.desc-text { font-family: var(--font-book); font-size: 16px; line-height: 1.65; color: var(--text-2); }
.desc-text p { margin: 0 0 0.8em; }

/* Settings: a panel that slides in from the right */
.settings-overlay { justify-content: flex-end; align-items: stretch; padding: 0; }
.info-modal-content.settings-modal-card {
    width: min(420px, 100%); max-height: none; height: 100%;
    padding: 0; border-radius: 22px 0 0 22px; border-width: 0 0 0 1px;
    display: flex; flex-direction: column; overflow: hidden;
    animation: rr-slide 0.38s var(--ease);
}
.settings-head { flex: 0 0 var(--hdr); padding-top: var(--safe-top) !important; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 26px; border-bottom: 1px solid var(--line); }
.settings-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
#neural-app-root .settings-head .close-modal { position: static; }
.settings-modal-body { flex: 1; overflow-y: auto; padding: 4px 26px calc(32px + env(safe-area-inset-bottom)); }
.settings-section-title { margin: 26px 0 14px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.setting-group { margin-bottom: 20px; }
.setting-group > label:not(.settings-toggle-label), .slider-header-row label { display: block; margin-bottom: 8px; font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.select-wrapper { position: relative; }
#neural-app-root .settings-select, #neural-app-root .setting-group select {
    width: 100%; height: 48px; padding: 0 40px 0 14px;
    border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2);
    font-size: 14.5px; font-weight: 600; color: var(--text);
    appearance: none; cursor: pointer; outline: 0;
}
#neural-app-root .settings-select:focus { border-color: rgba(165, 162, 255, 0.55); }
.settings-select option, .settings-select optgroup { background: var(--surface-2); color: var(--text); }
.select-chevron { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex; color: var(--text-3); pointer-events: none; }
.slider-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.slider-header-row label { margin-bottom: 0 !important; }
.slider-val-badge { flex: none; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 12.5px; font-weight: 800; color: var(--accent); }
#neural-app-root input[type="range"] { width: 100%; height: 28px; margin: 6px 0 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
#neural-app-root input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
#neural-app-root input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
#neural-app-root input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
#neural-app-root input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.setting-hint { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.settings-toggle-label { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.settings-toggle-checkbox { position: absolute; opacity: 0; pointer-events: none; }
.settings-toggle-custom { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.settings-toggle-custom::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform 0.25s var(--ease), background 0.2s; }
.settings-toggle-checkbox:checked + .settings-toggle-custom { background: var(--accent); }
.settings-toggle-checkbox:checked + .settings-toggle-custom::after { transform: translateX(18px); background: var(--accent-ink); }
.settings-toggle-checkbox:focus-visible + .settings-toggle-custom { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text-block { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.toggle-desc { font-size: 12.5px; color: var(--text-3); }
#neural-app-root .settings-download-btn { margin-top: 10px; height: 40px; padding: 0 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 700; }
#neural-app-root .settings-download-btn:hover { background: rgba(165, 162, 255, 0.22); }
#neural-app-root .settings-refresh-btn { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; height: 40px; padding: 0 14px; border-radius: 12px; color: var(--text-3); font-size: 13.5px; font-weight: 600; }
#neural-app-root .settings-refresh-btn:hover { background: var(--surface-2); color: var(--text); }
.settings-refresh-btn svg { width: 16px; height: 16px; }

/* ---------- Opening screen ---------- */
/* Shown until the shelf is loaded (web-reader/library.js), so the first view never jumps. */
.rr-splash {
    position: absolute; inset: 0; z-index: 100500;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    background: radial-gradient(600px 380px at 50% 42%, rgba(165, 162, 255, 0.1), transparent 70%), var(--bg);
    transition: opacity 0.55s var(--ease), visibility 0.55s;
}
.rr-splash.is-done { opacity: 0; visibility: hidden; }
.rr-splash.is-done .rr-splash-mark { transform: scale(1.08); }
.rr-splash-mark {
    width: 64px; height: 64px; color: var(--accent);
    filter: drop-shadow(0 12px 32px rgba(165, 162, 255, 0.35));
    animation: rr-splash-in 0.7s var(--ease) both;
    transition: transform 0.55s var(--ease);
}
/* The pages open out from the road, then its markings appear one after another. */
.rr-splash-page { transform-box: fill-box; animation: rr-splash-open 0.8s 0.15s var(--ease) both; }
.rr-splash-page.is-left { transform-origin: right center; }
.rr-splash-page.is-right { transform-origin: left center; }
.rr-road rect { animation: rr-fade 0.3s var(--ease) both; }
.rr-road rect:nth-child(1) { animation-delay: 0.55s; }
.rr-road rect:nth-child(2) { animation-delay: 0.7s; }
.rr-road rect:nth-child(3) { animation-delay: 0.85s; }
@keyframes rr-splash-open { from { transform: scaleX(0); } to { transform: none; } }
.rr-splash-name { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); animation: rr-rise 0.6s 0.25s var(--ease) both; }
.rr-splash-line { position: relative; width: 120px; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; animation: rr-fade 0.4s 0.4s both; }
.rr-splash-line i { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: inherit; background: var(--accent); animation: rr-splash-run 1.2s 0.4s ease-in-out infinite; }
@keyframes rr-splash-in { from { opacity: 0; transform: scale(0.82); } to { opacity: 1; transform: none; } }
@keyframes rr-splash-run { to { left: 100%; } }
/* ---------- Opening a book ---------- */
.rr-book-loader {
    position: absolute; inset: 0; z-index: 100400;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px;
    background: radial-gradient(520px 420px at 50% 45%, rgba(165, 162, 255, 0.08), transparent 70%), var(--bg);
    text-align: center;
    transition: opacity 0.45s var(--ease);
}
.rr-book-loader.is-done { opacity: 0; pointer-events: none; }
.rr-book-loader .rr-loader-cover { width: 170px; flex: none; margin-bottom: 16px; transform-origin: top left; box-shadow: 0 30px 60px -18px rgba(0, 0, 0, 0.9), 0 0 60px -10px rgba(165, 162, 255, 0.25); }
.rr-loader-cover .cover-book-title { font-size: 19px; }
.rr-loader-cover .cover-book-author { font-size: 10px; }
.rr-loader-title { max-width: 420px; font-family: var(--font-book); font-size: 22px; font-weight: 500; line-height: 1.25; color: var(--text); animation: rr-rise 0.5s 0.3s var(--ease) both; }
.rr-loader-author { font-size: 14px; color: var(--text-3); animation: rr-rise 0.5s 0.38s var(--ease) both; }
.rr-loader-author:empty { display: none; }
.rr-book-loader .rr-splash-line { margin-top: 14px; }
/* ---------- Motion ---------- */
@keyframes rr-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rr-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes rr-pop { from { opacity: 0; transform: translateY(-4px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes rr-slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rr-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes rr-spin { to { transform: rotate(360deg); } }
.lib-selectbar, .lib-toast { animation-name: rr-rise-center; }
@keyframes rr-rise-center { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.edit-mode-pill { animation-name: rr-rise; }
@media (prefers-reduced-motion: reduce) {
    #neural-app-root *, .rr-popover { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 1100px) {
    .header-actions .action-label { display: none; }
    #neural-app-root .header-actions .icon-btn { padding: 0; }
}
@media (max-width: 768px) {
    :root { --hdr: calc(56px + var(--safe-top)); }
    #neural-app-root { flex-direction: column; font-size: 14px; }
    .header { padding: 0 8px; gap: 6px; }
    .action-label { display: none; }
    #neural-app-root .icon-btn { padding: 0; }
    #neural-app-root #add-btn { width: 40px; padding: 0; }
    #neural-app-root .lib-back-btn span { display: none; }
    #neural-app-root .lib-back-btn { width: 40px; padding: 0; }
    .logo-title { font-size: 16px; }
    /* Too cramped beside the header buttons on a phone */
    #neural-app-root .logo-by { display: none; }
    #neural-app-root .logo-by small { font-size: 12px; }
    .book-meta { margin-left: 0; padding-right: 4px; }
    #book-title-text { max-width: 100%; font-size: 13.5px; }
    #book-author-text { display: none; }
    .sidebar { position: absolute; top: 0; left: 0; transform: translateX(-100%); box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5); }
    .sidebar.open { transform: none; }
    #neural-app-root .content-width-handle { display: none !important; }
    .reader-column { width: 100% !important; min-width: 0; }
    .content-area { padding: 24px 18px 150px; font-size: 1.1rem; }
    .controls-overlay { padding: 24px 12px calc(14px + env(safe-area-inset-bottom)); }
    .edit-mode-label { display: none; }

    .lib-inner { padding: 20px 16px 120px; }
    .lib-start { grid-template-columns: 1fr; gap: 10px; margin-top: 28px; }
    #neural-app-root .lib-start-card { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 14px; row-gap: 0; align-items: center; padding: 14px 16px; }
    #neural-app-root .lib-start-card .lib-start-icon { grid-row: span 2; }
    #neural-app-root .lib-start-card strong { margin: 0; font-size: 15px; }
    .lib-lead { margin-top: 16px; }
    .lib-section-head h2 { font-size: 19px; }
    .lib-continue { margin-bottom: 32px; }
    #neural-app-root .resume-card { width: 270px; grid-template-columns: 60px 1fr; gap: 14px; }
    .resume-card .book-cover-container { width: 60px; }
    .lib-toolbar { position: static; margin-bottom: 20px; gap: 10px; }
    .lib-search { height: 44px; }
    .lib-search kbd { display: none; }
    .lib-filters { flex-direction: column; align-items: stretch; gap: 10px; }
    .lib-tools { justify-content: space-between; }
    .lib-tools .lib-sort { flex: 1; }
    #neural-app-root .lib-sort select { width: 100%; }
    .lib-grid { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 24px 14px; }
    .book-card-title { font-size: 14px; }
    .book-card-author { font-size: 12px; }
    .card-source { display: none; }
    .cover-book-title { font-size: 11px; }
    .cover-book-author { font-size: 7px; }
    .lib-grid.is-list .card-body { grid-template-columns: 1fr; grid-template-areas: "title" "author" "progress" "foot"; }
    .lib-grid.is-list .card-foot { justify-content: flex-start; margin-top: 4px; }

    .info-modal-content { padding: 22px; max-height: 88vh; }
    .modal-header { gap: 16px; }
    .modal-cover-container { flex-basis: 84px; }
    .modal-title-group h2 { font-size: 22px; }
    .settings-overlay { align-items: flex-end; }
    .info-modal-content.settings-modal-card { width: 100%; height: auto; max-height: 88vh; border-radius: 22px 22px 0 0; border-width: 1px 0 0; animation-name: rr-rise; }
}
@media (max-width: 380px) {
    .lib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 10px; }
    #neural-app-root .lib-seg button { padding: 0 9px; }
}
@media (hover: none) {
    .lib-grid .book-card:hover .book-cover-container { transform: none; }
}
