/* ============================================================
   Bible Reader — Phase 1 styles
   Builds on styles.css tokens. Day (parchment) + night themes.
   ============================================================ */

:root {
    --site-nav-height: 64px;
    --reader-toolbar-height: 56px;
}

html, body {
    overflow-x: visible !important;
    overflow-y: visible !important;
}

@media (max-width: 768px) {
    :root {
        --site-nav-height: 50px;
        --reader-toolbar-height: 88px;
    }
}

.reader-main {
    min-height: 100vh;
    padding-top: 0;
    position: relative;
    z-index: 2;
}

#cursorFieldCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* behind content */
    pointer-events: none;
    /* allow clicks through canvas */
}

/* --- Site Nav sticky in reader --- */
.site-nav {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-parchment);
    border-bottom: 1px solid var(--border-delicate);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

body.reader-night .site-nav {
    background: #17130f;
    border-bottom-color: rgba(197, 160, 89, 0.28);
}

/* --- Fixed / Sticky Toolbar (Permanently docked beneath site-nav) --- */
.reader-toolbar {
    position: -webkit-sticky;
    position: sticky;
    top: var(--site-nav-height, 64px);
    left: 0;
    right: 0;
    width: auto;
    max-width: 1040px;
    margin: 0 auto;
    z-index: 95;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-top: none;
    border-bottom-left-radius: var(--radius-soft);
    border-bottom-right-radius: var(--radius-soft);

    transition: background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(43, 35, 31, 0.08);
}

body.reader-night .reader-toolbar {
    background: #221c16;
    border-color: rgba(197, 160, 89, 0.28);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.reader-toolbar-inner {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: var(--sp-2) var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    position: relative;
    box-sizing: border-box;
}

/* New labels aligned within toolbar */
.reader-library-labels {
    position: absolute;
    right: var(--sp-4);
    top: -24px;
    display: flex;
    gap: var(--sp-4);
    pointer-events: none;
    opacity: 0.8;
    max-width: calc(100% - var(--sp-8));
    overflow: hidden;
}

.lib-label-item {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-muted);
    font-family: var(--font-body);
}

body.reader-night .lib-label-item {
    color: var(--accent-gold);
    opacity: 0.7;
}

.reader-nav-group {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-shrink: 0;
}

.reader-picker {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.reader-select {
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--ink-primary);
    background-color: var(--bg-paper-light);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c7b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 10px 10px;
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: 0.45rem 1.4rem 0.45rem 0.55rem;
    min-height: 44px;
    height: 44px;
    cursor: pointer;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    overflow: visible;
    white-space: nowrap;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.reader-night .reader-select {
    background-color: #221c16;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    color: #e8ddc9;
    border-color: rgba(201, 169, 106, 0.35);
}

.reader-select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px rgba(197, 160, 89, 0.25);
}

.reader-select--book {
    min-width: 145px;
    max-width: 185px;
    flex-shrink: 0;
}

.reader-select--chapter {
    min-width: 52px;
    width: 52px;
    max-width: 52px;
    flex-shrink: 0;
    padding-left: 0.45rem;
}

.reader-select--verse {
    min-width: 52px;
    width: 52px;
    max-width: 52px;
    flex-shrink: 0;
    padding-left: 0.45rem;
    margin-right: 1.7rem;
}

.reader-nav-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--accent-mahogany);
    background: transparent;
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    cursor: pointer;
    transition: all 0.2s ease;
}

.reader-nav-btn:hover {
    border-color: var(--accent-gold);
    background: var(--bg-parchment);
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.reader-ctl {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--accent-mahogany);
    background: transparent;
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    cursor: pointer;
    transition: all 0.2s ease;
}

.reader-ctl:hover {
    border-color: var(--accent-gold);
    background: var(--bg-parchment);
}

.reader-ctl.is-on {
    background: var(--accent-mahogany);
    color: var(--bg-paper-light);
    border-color: var(--accent-mahogany);
}

.reader-ctl--active,
.reader-ctl--active:hover {
    background: var(--accent-mahogany);
    color: #fff;
    border-color: var(--accent-mahogany);
}

/* --- Body layout --- */
.reader-body {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-4) var(--sp-10);
    position: relative;
}

/* --- Scripture --- */
.reader-passage-head {
    text-align: center;
    margin-bottom: var(--sp-6);
}

.reader-passage-head h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 600;
    color: var(--ink-primary);
    margin: 0 0 var(--sp-1);
}

.reader-passage-sub {
    color: var(--ink-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 0;
}

.reader-text {
    font-family: var(--font-heading);
    line-height: 1.9;
    color: var(--ink-primary);
    max-width: 68ch;
    margin: 0 auto;
    outline: none;
    position: relative;
    z-index: 2;
}

body.reader-sans .reader-text {
    font-family: var(--font-body);
    line-height: 1.8;
}

/* --- Passage Header & Audio Controls --- */
.passage-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 68ch;
    margin: 0 auto var(--sp-3);
}

.passage-head-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.passage-lang-picker-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
    background: var(--bg-paper-light);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.5rem 0.3rem 0.7rem;
    transition: all 0.18s ease;
    box-shadow: 0 2px 6px rgba(43, 35, 31, 0.05);
}

.passage-lang-picker-wrapper:hover,
.passage-lang-picker-wrapper:focus-within {
    border-color: var(--accent-mahogany);
    box-shadow: 0 3px 10px rgba(201, 169, 106, 0.25);
}

.passage-lang-icon {
    font-size: 0.9rem;
    margin-right: 0.4rem;
    display: inline-flex;
    align-items: center;
    user-select: none;
}

.passage-lang-hero-select {
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-primary);
    cursor: pointer;
    outline: none;
    padding: 0.1rem 0.25rem 0.1rem 0;
}

body.reader-night .passage-lang-picker-wrapper {
    background: #25201b;
    border-color: rgba(201, 169, 106, 0.45);
}

body.reader-night .passage-lang-hero-select {
    color: #e8ddc9;
    background: #25201b;
}

/* Parallel / Compare Bible Mode */
.passage-compare-picker-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
    background: var(--bg-paper-light);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.5rem 0.3rem 0.7rem;
    transition: all 0.18s ease;
    box-shadow: 0 2px 6px rgba(43, 35, 31, 0.05);
}

.passage-compare-picker-wrapper:hover,
.passage-compare-picker-wrapper:focus-within {
    border-color: var(--accent-mahogany);
    box-shadow: 0 3px 10px rgba(201, 169, 106, 0.25);
}

.passage-compare-icon {
    font-size: 0.95rem;
    margin-right: 0.35rem;
    display: inline-flex;
    align-items: center;
    color: var(--accent-gold);
    user-select: none;
    font-weight: bold;
}

.passage-compare-select {
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-primary);
    cursor: pointer;
    outline: none;
    padding: 0.1rem 0.25rem 0.1rem 0;
}

body.reader-night .passage-compare-picker-wrapper {
    background: #25201b;
    border-color: rgba(201, 169, 106, 0.45);
}

body.reader-night .passage-compare-select {
    color: #e8ddc9;
    background: #25201b;
}

/* Parallel Verse Container & Columns */
.reader-parallel-active .reader-content-text {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.reader-verse-parallel {
    scroll-margin-top: 165px;
    margin: 0 0 var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--radius-card);
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid var(--border-delicate);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}

.reader-verse-parallel:hover {
    background: rgba(197, 160, 89, 0.08);
    border-color: var(--accent-gold);
}

.parallel-col {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.parallel-col--secondary {
    border-left: 1px solid var(--border-delicate);
    padding-left: var(--sp-4);
}

.parallel-col-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.version-pill {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(197, 160, 89, 0.18);
    color: var(--accent-mahogany);
    display: inline-block;
}

body.reader-night .version-pill {
    background: rgba(201, 169, 106, 0.2);
    color: #ffd700;
}

.reader-verse-parallel.is-selected {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.reader-verse-parallel.is-highlighted {
    background: rgba(230, 215, 181, 0.55);
}

.reader-verse-parallel.is-spoken,
.reader-verse-parallel.is-reading {
    background: rgba(197, 160, 89, 0.22) !important;
    outline: 2px solid var(--accent-gold);
    box-shadow: 0 4px 16px rgba(197, 160, 89, 0.18);
}

body.reader-night .reader-verse-parallel {
    background: rgba(37, 32, 27, 0.6);
    border-color: rgba(201, 169, 106, 0.2);
}

body.reader-night .parallel-col--secondary {
    border-left-color: rgba(201, 169, 106, 0.2);
}

@media (max-width: 768px) {
    .reader-verse-parallel {
        grid-template-columns: 1fr;
        gap: var(--sp-3);
    }
    .parallel-col--secondary {
        border-left: none;
        border-top: 1px dashed var(--border-delicate);
        padding-left: 0;
        padding-top: var(--sp-3);
    }
}

.listen-passage-hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-mahogany);
    background: var(--accent-gold-light);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.listen-passage-hero-btn:hover {
    background: var(--accent-gold);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(201, 169, 106, 0.25);
}

.listen-passage-hero-btn.is-active {
    background: var(--accent-mahogany);
    color: #ffffff;
    border-color: var(--accent-mahogany);
}

@media (max-width: 650px) {
    .passage-head-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
    }
    .passage-head-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Floating / Embedded Passage Audio Bar */
.passage-audio-bar[hidden] {
    display: none !important;
}

.passage-audio-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 68ch;
    margin: 0 auto var(--sp-4);
    padding: 0.55rem 0.9rem;
    background: var(--bg-parchment);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-card);
    box-shadow: 0 4px 16px rgba(43, 35, 31, 0.08);
    animation: fadeInAudioBar 0.25s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.passage-audio-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.audio-pulsing-wave {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--accent-gold);
    border-radius: 50%;
    animation: audioWavePulse 1.2s infinite ease-in-out;
}

@keyframes audioWavePulse {

    0%,
    100% {
        transform: scale(0.85);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 10px var(--accent-gold);
    }
}

.passage-audio-meta {
    display: flex;
    flex-direction: column;
}

.passage-audio-status {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-mahogany);
}

.passage-audio-time {
    font-size: 0.72rem;
    color: var(--ink-muted);
}

.passage-audio-ctls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.audio-voice-select {
    min-height: 30px;
    padding: 0 0.5rem;
    font-family: var(--font-body);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--ink-primary);
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
}

.audio-voice-select:hover,
.audio-voice-select:focus {
    border-color: var(--accent-gold);
    color: var(--accent-mahogany);
}

body.reader-night .audio-voice-select {
    background: #25201b;
    color: #e8ddc9;
    border-color: rgba(201, 169, 106, 0.4);
}

.audio-bar-btn {
    min-height: 30px;
    padding: 0 0.55rem;
    font-family: var(--font-body);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--ink-primary);
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.audio-bar-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-mahogany);
}

.audio-bar-btn--close {
    font-size: 1rem;
    padding: 0 0.45rem;
    line-height: 1;
}

.reader-verse.is-spoken,
.reader-verse.is-reading {
    background: rgba(201, 169, 106, 0.18) !important;
    border-left: 3.5px solid var(--accent-gold) !important;
    box-shadow: 0 2px 14px rgba(201, 169, 106, 0.22);
    transition: all 0.25s ease-out;
}

body.reader-night .reader-verse.is-spoken,
body.reader-night .reader-verse.is-reading {
    background: rgba(212, 175, 55, 0.15) !important;
    border-left-color: #f3e5ab !important;
    box-shadow: 0 2px 14px rgba(212, 175, 55, 0.18);
}

html {
    scroll-padding-top: 130px;
}

.passage-audio-hint {
    margin: -0.5rem auto var(--sp-4);
    max-width: 68ch;
    padding: 0.35rem 0.75rem;
    font-size: 0.76rem;
    color: var(--ink-muted);
    font-style: italic;
    text-align: center;
    background: rgba(201, 169, 106, 0.08);
    border: 1px dashed rgba(201, 169, 106, 0.35);
    border-radius: var(--radius-soft);
    animation: fadeInAudioBar 0.25s ease-out;
}

.passage-audio-hint[hidden] {
    display: none !important;
}

.reader-empty {
    text-align: center;
    color: var(--ink-muted);
    font-style: italic;
    font-family: var(--font-body);
}

.reader-verse {
    scroll-margin-top: 165px;
    margin: 0 0 var(--sp-3);
    padding: var(--sp-2) var(--sp-3) var(--sp-2) 2.2rem;
    border-radius: var(--radius-soft);
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.reader-verse:hover {
    background: rgba(197, 160, 89, 0.08);
}

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

.reader-vnum {
    position: absolute;
    left: 0.5rem;
    top: 0.45rem;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-gold);
    min-width: 1.4rem;
    text-align: right;
    user-select: none;
    line-height: 1.4;
}

/* verse states */
.reader-verse.is-selected {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
    border-radius: 4px;
}

.reader-verse.is-highlighted {
    background: rgba(230, 215, 181, 0.55);
}

.reader-verse.is-highlighted:hover {
    background: rgba(230, 215, 181, 0.75);
}

/* Real-time Spoken Verse Highlight during Audio Playback */
.reader-verse.is-spoken,
.reader-verse.is-reading {
    background: rgba(197, 160, 89, 0.22) !important;
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
    border-radius: var(--radius-soft);
    box-shadow: 0 4px 16px rgba(197, 160, 89, 0.18);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

body.reader-night .reader-verse.is-spoken,
body.reader-night .reader-verse.is-reading {
    background: rgba(201, 169, 106, 0.28) !important;
    outline: 2px solid rgba(212, 175, 55, 0.85);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.reader-verse.is-spoken .reader-vnum,
.reader-verse.is-reading .reader-vnum {
    color: var(--accent-mahogany);
    font-weight: 900;
}

body.reader-night .reader-verse.is-spoken .reader-vnum,
body.reader-night .reader-verse.is-reading .reader-vnum {
    color: #ffd700;
}

.reader-verse.is-bookmarked::before {
    content: '';
    position: absolute;
    left: 0;
    top: var(--sp-2);
    bottom: var(--sp-2);
    width: 3px;
    border-radius: 2px;
    background: var(--accent-mahogany);
}

/* --- Verse Action Popover --- */
.verse-popover {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-paper-light);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-pill);
    padding: 4px 6px;
    box-shadow: 0 6px 24px rgba(43, 35, 31, 0.18);
    z-index: 90;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

body.reader-night .verse-popover {
    background: #25201b;
    border-color: rgba(201, 169, 106, 0.45);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

.verse-popover[hidden] {
    display: none !important;
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.verse-popover button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    border-radius: var(--radius-pill);
    color: var(--ink-primary);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

body.reader-night .verse-popover button {
    color: #e8ddc9;
}

.verse-popover button:hover {
    background: rgba(197, 160, 89, 0.2);
    color: var(--accent-mahogany);
}

body.reader-night .verse-popover button:hover {
    background: rgba(201, 169, 106, 0.25);
    color: #fff;
}

.verse-popover button[data-action="listen"] {
    color: var(--accent-mahogany);
    background: rgba(197, 160, 89, 0.18);
    font-weight: 700;
}

body.reader-night .verse-popover button[data-action="listen"] {
    color: #f3e5ab;
    background: rgba(212, 175, 55, 0.2);
}

.verse-popover button[data-action="listen"]:hover {
    background: var(--accent-mahogany);
    color: #ffffff;
}

.reader-note-preview {
    display: block;
    margin-top: var(--sp-1);
    font-family: var(--font-body);
    font-size: 0.78em;
    font-style: italic;
    color: var(--ink-muted);
    border-left: 2px solid var(--accent-gold);
    padding-left: var(--sp-2);
}

.reader-verse.flash {
    animation: verseFlash 1.4s ease;
}

@keyframes verseFlash {

    0%,
    100% {
        background: transparent;
    }

    25% {
        background: rgba(197, 160, 89, 0.35);
    }
}

/* --- Library sidebar --- */
.reader-library {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 92vw);
    background: #f5f1eb;
    /* solid opaque paper */
    border-left: 1px solid var(--border-delicate);
    box-shadow: -8px 0 30px rgba(43, 35, 31, 0.12);
    transform: translateX(105%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 105;
    isolation: isolate;
    /* new stacking context */
    display: flex;
    flex-direction: column;
}

.reader-library.is-open {
    transform: translateX(0);
}

.reader-library-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-faint);
}

.reader-library-head h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin: 0;
}

.reader-library-tabs {
    display: flex;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-4) 0;
}

.lib-tab {
    flex: 1;
    padding: 0.5rem 0;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.lib-tab.active {
    color: var(--accent-mahogany);
    border-bottom-color: var(--accent-gold);
}

.lib-panel {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-3) var(--sp-4);
}

.lib-empty {
    color: var(--ink-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.lib-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--sp-3);
    margin-bottom: var(--sp-2);
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    cursor: pointer;
    transition: all 0.15s ease;
}

.lib-item:hover {
    border-color: var(--accent-gold);
    background: var(--bg-paper-light);
}

.lib-item-ref {
    display: block;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-mahogany);
}

.lib-item-extra {
    display: block;
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--ink-muted);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Verse popover --- */
.verse-popover {
    position: absolute;
    z-index: 70;
    display: flex;
    gap: 2px;
    background: var(--ink-primary);
    border-radius: var(--radius-soft);
    padding: 4px;
    box-shadow: 0 8px 24px rgba(43, 35, 31, 0.3);
}

.verse-popover button {
    padding: 0.45rem 0.8rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--bg-paper-light);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.verse-popover button:hover {
    background: var(--accent-mahogany);
}

.reader-xref-badge {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0 0.4em;
    min-width: 1.4em;
    font-family: var(--font-body);
    font-size: 0.68em;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--accent-mahogany);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-pill, 999px);
    background: var(--accent-gold-light);
    vertical-align: middle;
    cursor: pointer;
}

.study-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(440px, 100vw);
    height: 100vh;
    z-index: 105;
    isolation: isolate;
    /* new stacking context */
    display: flex;
    flex-direction: column;
    background: #f5f1eb;
    /* solid opaque paper */
    border-left: 1px solid var(--border-delicate);
    box-shadow: -8px 0 32px rgba(43, 35, 31, 0.14);
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.study-panel[hidden] {
    display: none;
}

.study-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-delicate);
    background: var(--bg-paper-light);
}

.study-head-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.study-badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-gold);
}

.study-head h2 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--ink-primary);
    line-height: 1.2;
}

.reader-panel-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    height: 36px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--bg-parchment);
    color: var(--accent-mahogany);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill, 999px);
    cursor: pointer;
    transition: all 0.18s ease;
}

.reader-panel-close-btn:hover {
    background: var(--accent-mahogany);
    color: #ffffff;
    border-color: var(--accent-mahogany);
}

body.reader-night .reader-panel-close-btn {
    background: #2b231f;
    color: var(--accent-gold);
    border-color: rgba(212, 175, 55, 0.3);
}

body.reader-night .reader-panel-close-btn:hover {
    background: var(--accent-gold);
    color: #1a1511;
}

/* --- Multi-Mode Lookup Box & Auto-Suggest --- */
.study-lookup {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-faint);
    background: var(--bg-paper-light);
}

.study-search-box-wrap {
    position: relative;
    margin-bottom: var(--sp-2);
}

.study-search-input-box {
    display: flex;
    align-items: center;
    background: var(--bg-parchment);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: 0 0.4rem 0 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.study-search-input-box:focus-within {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-light);
}

.study-search-input-box .search-ico {
    color: var(--ink-muted);
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.study-search-input-box input {
    flex: 1;
    min-height: 42px;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink-primary);
    outline: none;
    padding: 0;
}

.study-search-clear {
    background: none;
    border: none;
    color: var(--ink-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.4rem;
    line-height: 1;
}

.study-search-clear:hover {
    color: var(--accent-mahogany);
}

.study-search-btn {
    min-height: 32px;
    padding: 0 0.75rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent-mahogany);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 0.35rem;
    transition: opacity 0.18s ease;
}

.study-search-btn:hover {
    opacity: 0.9;
}

/* Dropdown Suggestion Menu */
.strongs-suggest-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    box-shadow: 0 8px 24px rgba(43, 35, 31, 0.16);
    z-index: 70;
}

.suggest-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: none;
    border-bottom: 1px solid var(--border-faint);
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.suggest-item:last-child {
    border-bottom: none;
}

.suggest-item:hover,
.suggest-item:focus {
    background: var(--accent-gold-light);
}

.suggest-item-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.suggest-item-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.suggest-item-key {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--accent-mahogany);
    font-family: var(--font-heading);
}

.suggest-item-translit {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--ink-primary);
    font-weight: 600;
}

.suggest-item-def {
    font-size: 0.75rem;
    color: var(--ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.suggest-item-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--bg-parchment);
    color: var(--ink-muted);
    border: 1px solid var(--border-faint);
}

/* Auto-Suggest Quick Chips */
.study-suggest-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: var(--sp-2);
}

.chips-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-muted);
    margin-right: 0.2rem;
}

.strongs-chip {
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    background: var(--bg-parchment);
    color: var(--ink-primary);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.16s ease;
}

.strongs-chip:hover {
    background: var(--accent-gold-light);
    border-color: var(--accent-gold);
    color: var(--accent-mahogany);
}

/* --- Four Study Tabs --- */
.study-tabs {
    display: flex;
    padding: 0 var(--sp-3);
    border-bottom: 1px solid var(--border-delicate);
    background: var(--bg-paper-light);
    overflow-x: auto;
    scrollbar-width: none;
}

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

.study-tab {
    flex: 1;
    min-height: 44px;
    padding: 0 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.study-tab:hover {
    color: var(--ink-primary);
}

.study-tab.active {
    color: var(--accent-mahogany);
    border-bottom-color: var(--accent-gold);
}

.study-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.study-footer-attr {
    padding: var(--sp-2) var(--sp-4);
    border-top: 1px solid var(--border-faint);
    background: var(--bg-paper-light);
}

.study-attr {
    margin: 0;
    font-size: 0.7rem;
    color: var(--ink-muted);
    line-height: 1.4;
}

/* --- Structured Card: Definition Tab --- */
.strongs-hero-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-card);
    padding: var(--sp-4);
    box-shadow: 0 2px 8px rgba(43, 35, 31, 0.04);
}

.strongs-badge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}

.strongs-key-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-mahogany);
    background: var(--accent-gold-light);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(201, 169, 106, 0.4);
}

.pos-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill);
    color: var(--ink-muted);
}

.strongs-script-display {
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border-faint);
}

.s-trans-main {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink-primary);
    margin-bottom: 2px;
}

.s-orig-script {
    display: inline-block;
    font-size: 1.25rem;
    color: var(--accent-gold);
    font-family: "Times New Roman", Georgia, serif;
    letter-spacing: 0.04em;
}

.strongs-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: var(--sp-3) 0 var(--sp-1);
}

.strongs-def-text {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--ink-primary);
    margin: 0 0 var(--sp-3);
}

.kjv-render-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.kjv-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: 4px;
    color: var(--accent-mahogany);
    font-weight: 500;
}

/* --- Structured Card: Word Roots Tab --- */
.roots-container {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.root-intro-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    padding: var(--sp-3) var(--sp-4);
    font-size: 0.85rem;
    color: var(--ink-muted);
    line-height: 1.5;
}

.root-item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.root-item-card:hover {
    border-color: var(--accent-gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(43, 35, 31, 0.06);
}

.root-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.root-item-key {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-mahogany);
}

.root-item-translit {
    font-style: italic;
    font-size: 0.88rem;
    color: var(--ink-primary);
    font-weight: 600;
}

.root-item-gloss {
    font-size: 0.78rem;
    color: var(--ink-muted);
}

.root-item-btn-tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    background: var(--accent-gold-light);
    color: var(--accent-mahogany);
    border-radius: var(--radius-pill);
    border: 1px solid rgba(201, 169, 106, 0.4);
}

/* --- Structured Card: Cross-References Tab --- */
.xref-list-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.xref-card {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    cursor: pointer;
    transition: all 0.2s ease;
}

.xref-card:hover {
    border-color: var(--accent-gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(43, 35, 31, 0.08);
}

.xref-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.xref-ref-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-mahogany);
}

.xref-votes-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    background: var(--accent-gold-light);
    color: var(--accent-mahogany);
    border-radius: var(--radius-pill);
    border: 1px solid rgba(201, 169, 106, 0.35);
}

.xref-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--ink-muted);
}

.xref-category-pill {
    text-transform: uppercase;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0.1rem 0.4rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: 4px;
    color: var(--accent-gold);
}

/* --- Structured Card: Usage in Scripture Tab --- */
.usage-container {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.usage-verse-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
    transition: all 0.18s ease;
}

.usage-verse-card:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 4px 12px rgba(43, 35, 31, 0.06);
}

.usage-verse-ref {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-mahogany);
    margin-bottom: 0.2rem;
}

.usage-verse-quote {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-primary);
    font-style: italic;
}

.usage-search-btn-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: var(--sp-3);
    background: var(--accent-mahogany);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-soft);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.usage-search-btn-card:hover {
    opacity: 0.92;
}

/* --- Scripture Search Panel --- */
.find-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: min(440px, 100vw);
    height: 100vh;
    z-index: 105;
    isolation: isolate;
    /* new stacking context */
    display: flex;
    flex-direction: column;
    background: #f5f1eb;
    /* solid opaque paper */
    border-right: 1px solid var(--border-delicate);
    box-shadow: 8px 0 32px rgba(43, 35, 31, 0.14);
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.find-panel[hidden] {
    display: none;
}

/* Search Mode Tabs */
.search-tabs {
    display: flex;
    padding: 0 var(--sp-3);
    border-bottom: 1px solid var(--border-delicate);
    background: var(--bg-paper-light);
}

.search-tab {
    flex: 1;
    min-height: 44px;
    padding: 0 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    text-align: center;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.search-tab:hover {
    color: var(--ink-primary);
}

.search-tab.active {
    color: var(--accent-mahogany);
    border-bottom-color: var(--accent-gold);
}

.search-mode-desc {
    padding: var(--sp-2) var(--sp-4);
    font-size: 0.74rem;
    color: var(--ink-muted);
    line-height: 1.4;
    background: var(--bg-parchment);
    border-bottom: 1px solid var(--border-faint);
}

/* Search Box & Controls */
.search-panel-lookup {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-faint);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    background: var(--bg-paper-light);
}

.search-panel-box {
    display: flex;
    align-items: center;
    background: var(--bg-parchment);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: 0 0.4rem 0 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-panel-box:focus-within {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-light);
}

.search-panel-box .search-ico {
    color: var(--ink-muted);
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.search-panel-box input {
    flex: 1;
    min-height: 42px;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink-primary);
    outline: none;
    padding: 0;
}

.search-panel-clear {
    background: none;
    border: none;
    color: var(--ink-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.4rem;
    line-height: 1;
}

.search-panel-clear:hover {
    color: var(--accent-mahogany);
}

.search-panel-btn {
    min-height: 32px;
    padding: 0 0.75rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent-mahogany);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 0.35rem;
    transition: opacity 0.18s ease;
}

.search-panel-btn:hover {
    opacity: 0.9;
}

/* Example Chips */
.search-example-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.search-chip {
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    background: var(--bg-parchment);
    color: var(--ink-primary);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.16s ease;
}

.search-chip:hover {
    background: var(--accent-gold-light);
    border-color: var(--accent-gold);
    color: var(--accent-mahogany);
}

/* Collapsible Search Tips Accordion */
.search-tips-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    overflow: hidden;
    margin-top: 2px;
}

.search-tips-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.search-tips-summary::-webkit-details-marker {
    display: none;
}

.search-tips-summary:hover {
    color: var(--accent-mahogany);
}

.tips-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

details[open] .tips-arrow {
    transform: rotate(180deg);
}

.search-tips-content {
    padding: 0.4rem 0.6rem 0.55rem;
    border-top: 1px solid var(--border-faint);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.72rem;
    background: var(--bg-paper-light);
}

.tip-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tip-label {
    font-weight: 700;
    color: var(--accent-mahogany);
}

.tip-desc code {
    font-family: monospace;
    font-size: 0.72rem;
    background: var(--bg-parchment);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid var(--border-faint);
    color: var(--ink-primary);
}

.find-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

/* --- Structured Search Result Cards --- */
.search-summary-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-card);
    padding: var(--sp-4);
    box-shadow: 0 2px 8px rgba(43, 35, 31, 0.04);
}

.search-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-2);
}

.search-query-heading {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-mahogany);
}

.search-matches-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    background: var(--accent-gold-light);
    color: var(--accent-mahogany);
    border-radius: var(--radius-pill);
    border: 1px solid rgba(201, 169, 106, 0.4);
}

.search-breakdown-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border-faint);
}

.search-breakdown-pill {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill);
    color: var(--ink-muted);
}

.search-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: var(--sp-3) 0 var(--sp-2);
}

.search-preview-item {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: var(--sp-3);
    margin-bottom: var(--sp-2);
    cursor: pointer;
    transition: all 0.18s ease;
}

.search-preview-item:hover {
    border-color: var(--accent-gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(43, 35, 31, 0.06);
}

.search-preview-ref {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-mahogany);
    margin-bottom: 2px;
}

.search-preview-text {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-primary);
}

.search-view-all-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    margin-top: var(--sp-3);
    padding: 0.6rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-soft);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-mahogany);
    cursor: pointer;
    transition: all 0.18s ease;
}

.search-view-all-action:hover {
    background: var(--accent-gold-light);
}

/* --- AI Ask Theology Card --- */
.ask-answer-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-left: 3px solid var(--accent-gold);
    border-radius: var(--radius-card);
    padding: var(--sp-4);
    box-shadow: 0 2px 8px rgba(43, 35, 31, 0.04);
}

.ask-answer-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: var(--sp-2);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-gold);
}

.ask-answer-text {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--ink-primary);
    margin: 0;
    white-space: pre-wrap;
}

/* --- Sermon Citations --- */
.sermon-citation-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: var(--sp-2) var(--sp-3);
    background: rgba(139, 105, 20, 0.05);
    border-radius: var(--radius-soft);
    margin-bottom: var(--sp-2);
    border: 1px solid rgba(139, 105, 20, 0.1);
    animation: fadeIn 0.3s ease-out;
}

.sermon-icon {
    font-size: 1.2rem;
}

.sermon-info {
    display: flex;
    flex-direction: column;
}

.sermon-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink-primary);
}

.sermon-date {
    font-size: 0.72rem;
    color: var(--ink-muted);
}

body.reader-night .sermon-citation-item {
    background: rgba(201, 169, 106, 0.08);
    border-color: rgba(201, 169, 106, 0.2);
}

body.reader-night .sermon-title {
    color: #f5f2e9;
}

.find-group {
    margin-bottom: var(--sp-3);
}

.find-group h3 {
    margin: 0 0 var(--sp-2);
    font-family: var(--font-heading);
    font-size: 0.92rem;
    color: var(--accent-mahogany);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- Study Tools (Word Study Panel) --- */
.tools-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: min(440px, 100vw);
    height: 100vh;
    z-index: 105;
    isolation: isolate;
    /* new stacking context */
    display: flex;
    flex-direction: column;
    background: #f5f1eb;
    /* solid opaque paper */
    border-right: 1px solid var(--border-delicate);
    box-shadow: 8px 0 32px rgba(43, 35, 31, 0.14);
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tools-panel[hidden] {
    display: none;
}

.tools-tabs {
    display: flex;
    padding: 0 var(--sp-3);
    border-bottom: 1px solid var(--border-delicate);
    background: var(--bg-paper-light);
    overflow-x: auto;
    scrollbar-width: none;
}

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

.tools-tab {
    flex: 1;
    min-height: 44px;
    padding: 0 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--ink-muted);
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.tools-tab:hover {
    color: var(--ink-primary);
}

.tools-tab.active {
    color: var(--accent-mahogany);
    border-bottom-color: var(--accent-gold);
}

.tools-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

/* --- Word Search & Concordance Styles --- */
.study-tools-lookup {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.study-tools-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.study-tools-search-box {
    display: flex;
    align-items: center;
    background: var(--bg-parchment);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: 0 0.4rem 0 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.study-tools-search-box:focus-within {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-light);
}

.study-tools-search-box .search-ico {
    color: var(--ink-muted);
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.study-tools-search-box input {
    flex: 1;
    min-height: 42px;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink-primary);
    outline: none;
    padding: 0;
}

.study-tools-clear {
    background: none;
    border: none;
    color: var(--ink-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.4rem;
    line-height: 1;
}

.study-tools-clear:hover {
    color: var(--accent-mahogany);
}

.study-tools-btn {
    min-height: 32px;
    padding: 0 0.75rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent-mahogany);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 0.35rem;
    transition: opacity 0.18s ease;
}

.study-tools-btn:hover {
    opacity: 0.9;
}

/* Quick Example Word Chips */
.study-tools-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.study-tools-chip {
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    background: var(--bg-parchment);
    color: var(--ink-primary);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.16s ease;
}

.study-tools-chip:hover {
    background: var(--accent-gold-light);
    border-color: var(--accent-gold);
    color: var(--accent-mahogany);
}

/* --- Structured Concordance Result Card --- */
.conc-hero-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-card);
    padding: var(--sp-4);
    box-shadow: 0 2px 8px rgba(43, 35, 31, 0.04);
}

.conc-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-2);
}

.conc-word-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-mahogany);
    text-transform: capitalize;
}

.conc-occurrences-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    background: var(--accent-gold-light);
    color: var(--accent-mahogany);
    border-radius: var(--radius-pill);
    border: 1px solid rgba(201, 169, 106, 0.4);
}

.conc-distribution-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border-faint);
}

.conc-dist-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-pill);
    color: var(--ink-muted);
}

.conc-section-heading {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: var(--sp-3) 0 var(--sp-2);
}

.conc-top-verse-card {
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: var(--sp-3);
    margin-bottom: var(--sp-2);
    cursor: pointer;
    transition: all 0.18s ease;
}

.conc-top-verse-card:hover {
    border-color: var(--accent-gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(43, 35, 31, 0.06);
}

.conc-verse-ref {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-mahogany);
    margin-bottom: 2px;
}

.conc-verse-snippet {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-primary);
}

.conc-view-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    margin-top: var(--sp-3);
    padding: 0.6rem;
    background: var(--bg-paper-light);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-soft);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-mahogany);
    cursor: pointer;
    transition: all 0.18s ease;
}

.conc-view-all-btn:hover {
    background: var(--accent-gold-light);
}

/* --- Themes Tab Styles --- */
.themes-container {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.theme-card {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-card);
    padding: var(--sp-4);
    box-shadow: 0 2px 8px rgba(43, 35, 31, 0.04);
}

.theme-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.theme-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.theme-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-mahogany);
    margin: 0;
}

.theme-subtitle {
    margin: 0 0 var(--sp-3);
    font-size: 0.78rem;
    color: var(--ink-muted);
    line-height: 1.4;
}

.theme-verse-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.theme-verse-item {
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
    transition: all 0.18s ease;
}

.theme-verse-item:hover {
    border-color: var(--accent-gold);
    transform: translateY(-1px);
}

.theme-verse-item-ref {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent-mahogany);
    margin-bottom: 2px;
}

.theme-verse-item-text {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ink-primary);
    line-height: 1.45;
}

/* --- Notes & Highlights Tab Styles --- */
.notes-tab-container {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.notes-tab-section {
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-card);
    padding: var(--sp-3) var(--sp-4);
}

.notes-tab-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--accent-mahogany);
    margin: 0 0 var(--sp-2);
}

.notes-item-card {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--bg-paper-light);
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-2);
    cursor: pointer;
    transition: all 0.18s ease;
}

.notes-item-card:hover {
    border-color: var(--accent-gold);
}

.notes-item-ref {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--accent-mahogany);
}

.notes-item-text {
    font-size: 0.8rem;
    color: var(--ink-primary);
    margin-top: 2px;
}

.tools-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.tools-stat {
    padding: var(--sp-3);
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
    text-align: center;
}

.tools-stat b {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--accent-mahogany);
}

.tools-stat span {
    font-size: 0.72rem;
    color: var(--ink-muted);
}

.tools-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.7rem;
    align-items: baseline;
    line-height: 1.2;
    margin-bottom: var(--sp-3);
}

.tools-cloud span {
    color: var(--accent-mahogany);
    cursor: default;
}

.tools-saved-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
    padding: var(--sp-2);
    background: var(--bg-parchment);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-soft);
}

.tools-saved-item .save-run {
    flex: 1;
    text-align: left;
    min-height: 44px;
    background: none;
    border: none;
    color: var(--accent-mahogany);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
}

.tools-saved-item .save-del {
    min-height: 44px;
    padding: 0 0.7rem;
    background: none;
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-soft);
    color: var(--ink-muted);
    cursor: pointer;
}

/* --- Night theme --- */
body.reader-night {
    --bg-parchment: #17130f;
    --bg-paper-light: #221c16;
    --ink-primary: #e8ddc9;
    --ink-muted: #a89a85;
    --accent-mahogany: #C25E56;
    --accent-mahogany-hover: #D47068;
    --border-delicate: rgba(197, 160, 89, 0.28);
    --border-faint: rgba(232, 221, 201, 0.1);
    background-color: #17130f;
}

body.reader-night .reader-verse:hover {
    background: rgba(197, 160, 89, 0.14);
}

body.reader-night .reader-verse.is-highlighted {
    background: rgba(120, 88, 30, 0.5);
}

body.reader-night .reader-verse.is-highlighted:hover {
    background: rgba(120, 88, 30, 0.7);
}

body.reader-night .reader-library {
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
}

body.reader-night .reader-library,
body.reader-night .find-panel,
body.reader-night .tools-panel,
body.reader-night .study-panel {
    background: #1e1814;
    /* solid dark background for night mode */
}

/* --- Backdrop overlay --- */
.reader-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 24, 20, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 55;
    transition: opacity 0.2s ease;
}

body.reader-night .reader-backdrop {
    background: rgba(0, 0, 0, 0.65);
}

.reader-backdrop[hidden] {
    display: none;
}

body.panel-open {
    overflow: hidden;
}

/* --- Responsive Toolbar (Desktop & Tablet) --- */
@media (min-width: 769px) {
    .reader-toolbar-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--sp-3);
        flex-wrap: nowrap;
        max-width: 1040px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .reader-toolbar-inner::-webkit-scrollbar {
        display: none;
    }

    .reader-controls {
        display: flex;
        gap: 6px;
        flex-wrap: nowrap;
        min-width: 0;
        flex-shrink: 0;
    }

    .reader-controls .reader-ctl {
        flex: 0 0 44px;
        min-width: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .reader-nav-group {
        flex-shrink: 0;
    }
}

/* --- Mobile & Tablet Portrait Overhaul (<= 768px) --- */
@media (max-width: 768px) {
    .site-nav {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 0.65rem 0;
    }

    .reader-toolbar {
        padding: 0;
        position: -webkit-sticky;
        position: sticky;
        top: var(--site-nav-height, 50px);
        z-index: 95;
        max-width: 100%;
        width: 100%;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .reader-library-labels {
        display: none;
    }

    .reader-verse {
        scroll-margin-top: 175px;
    }

    .reader-toolbar-inner {
        padding: 0.45rem 0.65rem;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
        max-width: 100%;
    }

    .reader-nav-group {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: 0.35rem;
    }

    .reader-picker {
        display: flex;
        flex: 1;
        gap: 0.35rem;
        min-width: 0;
    }

    .reader-select {
        height: 40px;
        min-height: 40px;
        font-size: 0.86rem;
        padding: 0.35rem 1.35rem 0.35rem 0.45rem;
        background-position: right 0.35rem center;
        background-size: 10px 10px;
        box-sizing: border-box;
    }

    .reader-select--book {
        flex: 2.1;
        min-width: 100px;
        max-width: none;
    }

    .reader-select--chapter {
        flex: 1;
        min-width: 52px;
        max-width: 64px;
        flex-shrink: 0;
        padding-left: 0.4rem;
    }

    .reader-select--verse {
        min-width: 52px;
        width: 52px;
        max-width: 64px;
        flex-shrink: 0;
        padding-left: 0.4rem;
        margin-right: 0;
    }

    .reader-nav-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        flex-shrink: 0;
        font-size: 1.3rem;
    }

    .reader-controls {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 0;
    }

    .reader-controls::-webkit-scrollbar {
        display: none;
    }

    .reader-ctl {
        flex: 1;
        min-width: 34px;
        max-width: 44px;
        height: 36px;
        padding: 0;
        font-size: 0.85rem;
        border-radius: 6px;
        flex-shrink: 0;
    }

    .reader-body {
        padding: var(--sp-4) var(--sp-3) var(--sp-8);
    }

    .passage-head-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.6rem;
    }

    .passage-head-row h1 {
        font-size: 1.65rem;
    }

    .listen-passage-hero-btn {
        width: auto;
        padding: 0.45rem 1.1rem;
        font-size: 0.88rem;
    }

    .passage-audio-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.6rem 0.75rem;
    }

    .passage-audio-left {
        justify-content: space-between;
        width: 100%;
    }

    .passage-audio-ctls {
        width: 100%;
        justify-content: space-between;
        gap: 0.35rem;
    }

    .passage-audio-ctls .audio-bar-btn {
        flex: 1;
        height: 34px;
        font-size: 0.82rem;
    }

    /* Hide site-nav and toolbar when a full-screen panel is open on mobile */
    body.panel-open .site-nav {
        z-index: 10 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }

    body.panel-open .reader-toolbar {
        z-index: 15 !important;
    }

    /* Side Panels Mobile Full-Screen View */
    .find-panel,
    .tools-panel,
    .study-panel,
    .reader-library {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 9999 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5) !important;
        background: #f5f1eb !important;
    }

    .find-panel[hidden],
    .tools-panel[hidden],
    .study-panel[hidden],
    .reader-library:not(.is-open) {
        display: none !important;
    }

    body.reader-night .find-panel,
    body.reader-night .tools-panel,
    body.reader-night .study-panel,
    body.reader-night .reader-library {
        background: #1e1814 !important;
    }

    .reader-backdrop {
        z-index: 9990 !important;
    }

    .study-head,
    .reader-library-head {
        padding: max(0.65rem, env(safe-area-inset-top)) var(--sp-4) 0.65rem !important;
        min-height: 56px !important;
        background: #f5f1eb !important;
        border-bottom: 1px solid var(--border-delicate) !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10000 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.75rem !important;
        flex-shrink: 0 !important;
    }

    body.reader-night .study-head,
    body.reader-night .reader-library-head {
        background: #1e1814 !important;
        border-bottom-color: var(--border-delicate) !important;
    }

    .reader-panel-close-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.35rem !important;
        padding: 0.4rem 0.9rem !important;
        height: 38px !important;
        min-width: 82px !important;
        font-family: var(--font-body) !important;
        font-size: 0.88rem !important;
        font-weight: 700 !important;
        background: var(--accent-mahogany) !important;
        color: #ffffff !important;
        border: 1px solid var(--accent-mahogany) !important;
        border-radius: var(--radius-pill, 999px) !important;
        cursor: pointer !important;
        box-shadow: 0 2px 8px rgba(74, 18, 14, 0.25) !important;
        transition: transform 0.15s ease, background 0.15s ease !important;
        flex-shrink: 0 !important;
    }

    .reader-panel-close-btn:hover {
        background: #5a1510 !important;
        border-color: #5a1510 !important;
    }

    .reader-panel-close-btn:active {
        transform: scale(0.94) !important;
    }

    body.reader-night .reader-panel-close-btn {
        background: var(--accent-gold) !important;
        color: #1a1511 !important;
        border-color: var(--accent-gold) !important;
        box-shadow: 0 2px 8px rgba(212, 175, 55, 0.25) !important;
    }

    .panel-bottom-close-btn {
        width: 100%;
        margin-top: var(--sp-4);
        padding: 0.75rem 1rem;
        font-family: var(--font-body);
        font-size: 0.9rem;
        font-weight: 600;
        text-align: center;
        color: var(--accent-mahogany);
        background: var(--bg-parchment);
        border: 1px solid var(--border-delicate);
        border-radius: var(--radius-soft);
        cursor: pointer;
        box-shadow: 0 2px 6px rgba(43, 35, 31, 0.06);
        transition: all 0.18s ease;
    }

    .panel-bottom-close-btn:hover {
        background: var(--accent-gold-light);
        border-color: var(--accent-gold);
        color: var(--accent-mahogany);
    }

    .panel-bottom-close-btn:active {
        transform: scale(0.98);
    }

    body.reader-night .panel-bottom-close-btn {
        background: #2b231f;
        color: var(--accent-gold);
        border-color: rgba(212, 175, 55, 0.3);
    }

    .search-tabs,
    .tools-tabs,
    .study-tabs,
    .reader-library-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .search-tabs::-webkit-scrollbar,
    .tools-tabs::-webkit-scrollbar,
    .study-tabs::-webkit-scrollbar,
    .reader-library-tabs::-webkit-scrollbar {
        display: none;
    }

    .search-tab,
    .tools-tab,
    .study-tab,
    .lib-tab {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
    }

    .study-body,
    .tools-body,
    .find-body,
    .lib-panel {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: max(var(--sp-8), env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .reader-verse.flash {
        animation: none;
    }

    .reader-library {
        transition: none;
    }
}
