/* Root Variables */
:root {
    --primary: #5B4B8A;
    --primary-dark: #4A3B73;
    --primary-light: #7C6BA6;
    --secondary: #8B7355;
    --background: #FAF9F6;
    --surface: #FFFFFF;
    --text-primary: #2C2416;
    --text-secondary: #6B5D54;
    --border: #E5E1DB;
    --highlight: #FFF9E6;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

    /* RGB variants for rgba() usage (glassmorphism, etc.) */
    --primary-rgb: 91, 75, 138;
    --bg-primary-rgb: 255, 255, 255;
    --bg-secondary-rgb: 248, 248, 248;
    --border-rgb: 229, 225, 219;

    /* Responsive sizing */
    --nav-rail-width: 110px;
    --sidebar-width: 450px;
    --touch-target-min: 44px;
    --content-padding: 1.5rem;
}

/* Dark Theme */
[data-theme="dark"] {
    --background: #1A1A1A;
    --surface: #2A2A2A;
    --text-primary: #E5E5E5;
    --text-secondary: #A0A0A0;
    --border: #404040;
    --highlight: #3A3A3A;

    --primary-rgb: 91, 75, 138;
    --bg-primary-rgb: 26, 26, 26;
    --bg-secondary-rgb: 42, 42, 42;
    --border-rgb: 64, 64, 64;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden; /* app-body handles all scrolling */
}

/* ── Stained Glass Header (shared across all modals/popups) ────────────── */
.frosted-header {
    background:
        linear-gradient(135deg,
            #1B1464 0%,
            #2E1A78 20%,
            #1a4a7a 40%,
            #1a6b9e 50%,
            #1a4a7a 60%,
            #2E1A78 80%,
            #1B1464 100%
        );
    border-bottom: 2px solid rgba(0, 0, 0, 0.35);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), inset 0 -1px 0 rgba(0,0,0,0.25);
}
.frosted-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.15'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: overlay;
}
.frosted-header,
.frosted-header h2,
.frosted-header h3,
.frosted-header span,
.frosted-header .brf-header-title {
    color: #ffffff;
    font-size: 1.2rem;
    font-family: 'Crimson Text', serif;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.frosted-header button {
    cursor: pointer;
    color: #ffffff;
}
.frosted-header-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #ffffff;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.13s, border-color 0.13s;
}
.frosted-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.8);
}
.frosted-header-btn:active {
    transform: scale(0.97);
}
.frosted-close-btn {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.13s;
}
.frosted-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* App body: rail + content side by side, fills full viewport */
.app-body {
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Bible nav — pinned at top of bible-content, verses scroll beneath */
.bible-nav {
    position: relative;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px 12px 0 0;
}


.bible-nav .nav-container {
    gap: 0.5rem;
}

/* Right-side nav mode */
body[data-nav-side="right"] .app-body {
    flex-direction: row-reverse;
}

/* Icon nav rail */
.icon-nav {
    width: var(--nav-rail-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

body[data-nav-side="right"] .icon-nav {
    border-right: none;
    border-left: 1px solid var(--border);
}

.icon-nav-top,
.icon-nav-bottom {
    display: flex;
    flex-direction: column;
}

.icon-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.85rem 0.5rem 0.7rem;
    margin: 2px 6px;
    width: calc(100% - 12px);
    border: 1px solid rgba(var(--border-rgb), 0.5);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    color: var(--text-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
}

body[data-nav-side="right"] .icon-nav-btn {
    /* no side-specific overrides needed with card style */
}

.icon-nav-btn:hover {
    background: var(--highlight);
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.icon-nav-btn.active {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(var(--primary-rgb), 0.04));
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.3);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.15);
}

body[data-nav-side="right"] .icon-nav-btn.active {
    /* same card style both sides */
}

.icon-nav-btn-saved {
    color: #fff !important;
    background: linear-gradient(135deg, #43a047, #66bb6a) !important;
    box-shadow: 0 2px 12px rgba(67, 160, 71, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    transition: all 0.3s ease;
}

.icon-nav-btn-clean {
    color: #fff !important;
    background: linear-gradient(135deg, #1565c0, #42a5f5) !important;
    box-shadow: 0 2px 12px rgba(21, 101, 192, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
    transition: all 0.4s ease;
}

.icon-nav-btn-dirty {
    color: #fff !important;
    background: linear-gradient(135deg, #c62828, #ef5350) !important;
    box-shadow: 0 2px 16px rgba(198, 40, 40, 0.45), inset 0 1px 0 rgba(255,255,255,0.15);
    animation: dirtyGlow 2s ease-in-out infinite;
}

@keyframes dirtyGlow {
    0%, 100% { box-shadow: 0 2px 12px rgba(198, 40, 40, 0.4); }
    50% { box-shadow: 0 2px 28px rgba(198, 40, 40, 0.75); }
}

.icon-nav-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.icon-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

.icon-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-nav-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: var(--primary);
    color: white;
    font-size: 0.58rem;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.icon-nav-badge:empty {
    display: none;
}

.icon-nav-side-toggle {
    opacity: 0.5;
    font-size: 0.6rem;
}

.icon-nav-side-toggle:hover {
    opacity: 1;
}

/* Nav separator line between study and word groups */
.icon-nav-divider {
    width: 60%;
    height: 1px;
    background: rgba(0, 0, 0, 0.12);
    margin: 4px auto;
    flex-shrink: 0;
}

body[data-theme="dark"] .icon-nav-divider {
    background: rgba(255, 255, 255, 0.15);
}

/* Emoji icons in nav (e.g. verse trail 👣) */
.icon-nav-emoji {
    font-size: 1.4rem;
    line-height: 1;
    display: block;
}

/* Nav drag-and-drop reordering */
.icon-nav-btn[draggable="true"] {
    cursor: grab;
}
.icon-nav-btn.nav-dragging {
    opacity: 0.35;
    cursor: grabbing;
}
.icon-nav-btn.nav-drag-over {
    border-top: 2px solid var(--primary);
}

/* Navigation */
.nav-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── Nav Reference Display (replaces book/chapter selects) ─────────────── */

.nav-ref-display {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-family: 'Crimson Text', 'Georgia', serif;
    font-size: 1.05rem;
    color: var(--text-primary);
    line-height: 1;
    user-select: none;
}

.nav-ref-segment {
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    font-weight: 600;
}

.nav-ref-segment:hover {
    color: var(--primary);
    background: rgba(91, 75, 138, 0.07);
}

.nav-ref-dot,
.nav-ref-colon {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0 0.05rem;
}

/* ── Nav Picker Panel ──────────────────────────────────────────────────── */

.nav-picker-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 10010;
    animation: np-fade-in 0.15s ease;
}

.nav-picker-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, 92vw);
    max-height: 70vh;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10011;
    animation: np-slide-in 0.18s ease;
}

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

@keyframes np-slide-in {
    from { opacity: 0; transform: translate(-50%, -48%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

.nav-picker-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.np-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
    line-height: 1;
}

.np-back-btn:hover {
    color: var(--primary);
    background: rgba(91, 75, 138, 0.07);
}

.np-back-btn[hidden] {
    visibility: hidden;
    pointer-events: none;
}

.nav-picker-crumb {
    flex: 1;
    font-family: 'Crimson Text', 'Georgia', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.np-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: color 0.15s ease;
    line-height: 1;
}

.np-close-btn:hover {
    color: var(--text-primary);
}

.nav-picker-body {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
}

.np-group-header {
    grid-column: 1 / -1;
    padding: 0.5rem 0.75rem 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.np-book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.np-book-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: 'Crimson Text', 'Georgia', serif;
    font-size: 0.92rem;
    color: var(--text-primary);
    transition: background 0.12s ease, color 0.12s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-book-item:hover {
    background: rgba(91, 75, 138, 0.06);
    color: var(--primary);
}

.np-book-item.current {
    color: var(--primary);
    font-weight: 700;
}

.np-number-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
    padding: 0.75rem 1rem;
}

.np-num-btn {
    aspect-ratio: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.np-num-btn:hover {
    background: rgba(91, 75, 138, 0.07);
    border-color: var(--primary-light);
    color: var(--primary);
}

.np-num-btn.current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── Nav Picker — mobile overrides ─────────────────────────────────────── */

@media (max-width: 480px) {
    .nav-picker-panel {
        width: 96vw;
        max-height: 80vh;
    }

    .np-book-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .np-number-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .nav-ref-display {
        font-size: 0.95rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ── Verse focused state (IntersectionObserver tracks scroll position) ─── */

.verse-container.verse-focused {
    background: rgba(91, 75, 138, 0.04);
    box-shadow: inset 3px 0 0 rgba(91, 75, 138, 0.35);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Translation nav button — text label instead of SVG icon */
.translation-btn-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 22px;
    color: currentColor;
}

/* Translation picker flyout panel */
.translation-panel {
    position: fixed;
    z-index: 10001;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    padding: 0.5rem;
    animation: translation-panel-in 0.15s ease-out;
}

@keyframes translation-panel-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.translation-panel-pills {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.translation-lang-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem 0;
    margin-top: 0.15rem;
}

.translation-lang-label:first-child {
    margin-top: 0;
}

.translation-lang-row {
    display: flex;
    gap: 0.3rem;
}

.translation-pill {
    display: block;
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: nowrap;
}

.translation-pill:hover {
    background: var(--highlight);
    border-color: var(--primary-light);
}

.translation-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.translation-pill.active:hover {
    background: var(--primary-dark, var(--primary));
}

/* chapter-display hidden — book + chapter selectors already show this info */
.chapter-display {
    display: none;
}

.nav-btn {
    padding: 0.3rem 0.7rem;
    background: linear-gradient(to bottom, var(--surface), var(--background));
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.3);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Layout — flex child of .app-body, scrolls independently */
.main-container {
    flex: 1;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding: 0.5rem var(--content-padding) var(--content-padding);
    display: flex;
    gap: 2rem;
}

/* Bible Content — flex column so nav is pinned, verses scroll */
.bible-content {
    flex: 1;
    min-height: 0;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Verses area scrolls independently */
#content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.25rem 1.25rem;
}

.chapter-container {
    font-family: 'Crimson Text', serif;
    font-size: 1.25rem;
    line-height: 1.8;
}

.verse-container {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    transition: background 0.3s ease;
    position: relative;
}

.verse-container:hover {
    background: var(--highlight);
}

.verse-container.highlight {
    background: rgba(70, 130, 200, 0.15);
    animation: fadeHighlight 3s ease-out;
}

@keyframes fadeHighlight {
    0% { background: rgba(70, 130, 200, 0.2); }
    100% { background: transparent; }
}

/* Bible reference links — appear in note text and study text read mode */
.bible-ref-link {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    font-weight: 500;
    border-radius: 2px;
    padding: 0 1px;
    transition: background 0.15s;
}
.bible-ref-link:hover {
    background: rgba(91, 75, 138, 0.1);
    text-decoration-style: solid;
}

.search-word-highlight {
    background: rgba(70, 130, 200, 0.3);
    border-radius: 2px;
    padding: 0 1px;
    animation: fadeWordHighlight 5s ease-out forwards;
}

@keyframes fadeWordHighlight {
    0%, 60% { background: rgba(70, 130, 200, 0.3); }
    100% { background: transparent; }
}

/* ── Bible Text Highlights ────────────────────────────────────────────── */
mark.hl-yellow  { background: rgba(255, 235, 59, 0.35); border-radius: 2px; }
mark.hl-green   { background: rgba(76, 175, 80, 0.30); border-radius: 2px; }
mark.hl-blue    { background: rgba(66, 165, 245, 0.30); border-radius: 2px; }
mark.hl-red     { background: rgba(211, 47, 47, 0.25); border-radius: 2px; }
mark.hl-orange  { background: rgba(255, 152, 0, 0.35); border-radius: 2px; }
mark.hl-purple  { background: rgba(171, 71, 188, 0.30); border-radius: 2px; }

/* Highlight right-click context menu */
/* Highlight context menu — glassmorphism style */
.highlight-menu {
    position: fixed;
    z-index: 10200;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: hlMenuIn 0.12s ease-out;
}
@keyframes hlMenuIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
.highlight-menu-colors {
    display: flex;
    gap: 8px;
    padding: 2px;
}
.hl-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    outline: none;
}
.hl-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.hl-swatch-active {
    transform: scale(1.15);
    box-shadow: 0 0 0 2.5px var(--accent, #4a90d9);
    border-color: var(--accent, #4a90d9);
}
.hl-swatch-yellow  { background: #FFE066; }
.hl-swatch-green   { background: #81C784; }
.hl-swatch-blue    { background: #64B5F6; }
.hl-swatch-red     { background: #D32F2F; }
.hl-swatch-orange  { background: #FFB74D; }
.hl-swatch-purple  { background: #BA68C8; }

.highlight-menu-remove {
    display: block;
    width: 100%;
    padding: 6px 0;
    margin-top: 2px;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: none;
    color: #999;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-align: center;
    transition: color 0.15s;
}
.highlight-menu-remove:hover {
    color: #e53935;
}

/* Dark mode overrides */
[data-theme="dark"] .highlight-menu,
.dark .highlight-menu {
    background: rgba(40, 40, 45, 0.88);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .hl-swatch,
.dark .hl-swatch {
    border-color: rgba(40, 40, 45, 0.8);
}
[data-theme="dark"] .highlight-menu-remove,
.dark .highlight-menu-remove {
    border-top-color: rgba(255, 255, 255, 0.06);
    color: #777;
}
[data-theme="dark"] .highlight-menu-remove:hover,
.dark .highlight-menu-remove:hover {
    color: #ef5350;
}

.verse-number {
    font-weight: 600;
    color: var(--secondary);
    margin-right: 0.5rem;
    font-size: 0.875em;
    vertical-align: super;
}

.verse-text {
    display: inline;
}

/* Verse action bar — tag, notes, bookmark in one tight row */
.verse-action-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.35rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Verse action button */
.verse-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: 38px;
    height: 26px;
    padding: 0;
    background: var(--surface);
    border: 1px solid rgba(var(--border-rgb), 0.4);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.15s ease;
    opacity: 0.6;
}
.verse-action-btn svg { width: 13px; height: 13px; }
.verse-action-btn .action-badge { font-size: 0.65rem; font-weight: 700; }
.verse-action-btn .action-badge:empty { display: none; }
.verse-action-btn:hover { opacity: 1; border-color: rgba(var(--primary-rgb),0.3); color: var(--primary); }
.verse-action-btn.has-count { opacity: 1; border-color: rgba(var(--primary-rgb),0.25); color: var(--primary); background: rgba(var(--primary-rgb),0.04); }
.verse-action-btn.has-count:hover { background: var(--primary); color: white; }
.verse-action-btn.bookmarked { opacity: 1; border-color: rgba(var(--primary-rgb),0.3); color: var(--primary); background: rgba(var(--primary-rgb),0.05); }

.verse-container:hover .verse-action-bar {
    opacity: 1;
}

/* Keep bar visible when any button has data */
.verse-action-bar:has(.has-count),
.verse-action-bar:has(.bookmarked) {
    opacity: 1;
}

/* Strong's Numbers */
.word[data-strongs] {
    color: var(--primary);
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.word[data-strongs]:hover {
    background: var(--primary);
    color: white;
}

.word[data-strongs].word-selected {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 2px rgba(91, 75, 138, 0.3);
}

.word[data-strongs].strongs-hidden {
    color: inherit;
    cursor: text;
}

.word[data-strongs].strongs-hidden:hover {
    background: transparent;
    color: inherit;
}

sup.strongs.strongs-hidden {
    display: none;
}

/* Body-level class — persists strongs visibility across all renders, including newly loaded chapters */
body.strongs-hidden .word[data-strongs] {
    color: inherit;
    cursor: text;
}
body.strongs-hidden .word[data-strongs]:hover {
    background: transparent;
    color: inherit;
}
body.strongs-hidden sup.strongs {
    display: none;
}

/* Sidebar — scrolls independently, fills its flex cell */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-clear-all-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.sidebar-clear-all-btn:hover {
    color: #E57373;
    border-color: #E57373;
    background: rgba(229, 115, 115, 0.08);
}

/* Strong's Numbers in Text */
sup.strongs {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    margin: 0 0.125rem;
    background: var(--highlight);
    border: 1px solid var(--primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    line-height: 1;
    position: relative;
    top: -0.25rem;
}

sup.strongs:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

sup.strongs.word-selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 2px rgba(91, 75, 138, 0.3);
}

/* Strong's Display */
.strongs-display {
    padding: 1rem;
    background: var(--highlight);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow-x: hidden;
}

.strongs-number {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.strongs-lemma {
    font-size: 1.75rem;
    font-family: 'Crimson Text', serif;
}

.strongs-definition {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.strongs-kjv {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Tabs */
.tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-bottom: 2.5px solid transparent;
    border-radius: 0;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: #007aff;
    border-bottom-color: #007aff;
    background: transparent;
}

.tab-content {
    padding: 1rem 0;
}

/* Letter Analysis */
.letter-analysis-item {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.hebrew-letter {
    font-size: 2rem;
    color: var(--primary);
    font-weight: bold;
}

.letter-name {
    font-weight: 600;
    color: var(--text-primary);
}

.letter-details {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.letter-meaning {
    color: var(--text-primary);
    line-height: 1.5;
    margin-top: 0.5rem;
}

.prefix-badge {
    background: #FFD700;
    color: #000;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.gematria-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
    font-weight: bold;
}

/* Anagrams */
.anagrams-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.anagram-summary {
    background: var(--highlight);
    border-radius: 8px;
    padding: 0.75rem;
}
.anagram-summary .anagram-summary-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.anagram-group {
    margin-bottom: 0.5rem;
}
.anagram-group-header {
    background: linear-gradient(90deg, var(--primary), transparent);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.anagram-category {
    margin-bottom: 1rem;
}
.anagram-category-label {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}
.anagram-category-label.words { color: var(--primary); }
.anagram-category-label.names { color: #8B4513; }
.anagram-category-label.places { color: #2E8B57; }

.anagram-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.anagram-card {
    padding: 0.75rem;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}
.anagram-card:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}
.anagram-card.name {
    background: #FFF5EE;
    border-color: #8B4513;
}
.anagram-card.place {
    background: #F0FFF0;
    border-color: #2E8B57;
}
.anagram-card.root {
    background: #FFF8DC;
    border-color: #DAA520;
}

.anagram-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}
.anagram-root-badge {
    font-size: 0.75rem;
    color: #DAA520;
}

.anagram-number {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--primary);
}

.anagram-lemma {
    font-size: 1.25rem;
    font-family: 'Crimson Text', serif;
    margin-bottom: 0.25rem;
}

.anagram-translit {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.anagram-def {
    font-size: 0.75rem;
    color: var(--text-primary);
    margin-top: 0.25rem;
    line-height: 1.3;
}

.anagram-footer {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #FFF8DC;
    border: 2px solid #FFD700;
    border-radius: 8px;
}
.anagram-footer p {
    font-size: 0.75rem;
    color: #856404;
    margin: 0.5rem 0 0 0;
}

/* Bookmarks */
.bookmark-item {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--highlight);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.bookmark-item:hover {
    background: var(--primary);
    color: white;
}

.remove-bookmark-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.remove-bookmark-btn:hover {
    opacity: 1;
    color: var(--text-primary);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    width: 90%;
    max-width: 500px;
    height: 80vh;
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
    z-index: 1;
    cursor: grab;
}
.settings-header:active { cursor: grabbing; }
.settings-header button { cursor: pointer; }

.settings-header h3 {
    margin: 0;
    color: white;
    font-size: 1.25rem;
}

.settings-content {
    background: var(--surface);
    border-radius: 0 0 12px 12px;
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Settings Groups */
.settings-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.settings-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-group h4 {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.attribution-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.attribution-list li {
    padding: 0.3rem 0;
}
.attribution-list strong {
    color: var(--text-primary);
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 0.5rem;
}

.font-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.font-size-display {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-width: 60px;
    text-align: center;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Reset Button */
.reset-nav-order-btn {
    width: 100%;
    padding: 0.6rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.reset-nav-order-btn:hover {
    background: var(--border);
}

.reset-all-btn {
    width: 100%;
    padding: 0.75rem;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.reset-all-btn:hover {
    background: #c82333;
}

.setting-row {
    margin-bottom: 1rem;
}

.setting-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.font-size-controls, .theme-toggle, .reading-mode-toggle, .strongs-visibility-toggle {
    display: flex;
    gap: 0.5rem;
}

.font-btn, .theme-btn, .reading-mode-btn, .strongs-visibility-btn,
.tag-autoclose-toggle, .tag-autoclose-sec-btn, .tag-bible-toggle, .tag-study-toggle, .tag-word-toggle,
.study-mode-toggle {
    flex: 1;
    padding: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.theme-btn:not(.active), .reading-mode-btn:not(.active), .strongs-visibility-btn:not(.active),
.tag-autoclose-toggle:not(.active), .tag-autoclose-sec-btn:not(.active),
.tag-bible-toggle:not(.active), .tag-study-toggle:not(.active), .tag-word-toggle:not(.active),
.study-mode-toggle:not(.active) {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* Auto-close seconds row */
.tag-autoclose-seconds {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 0.4rem;
}
.tag-autoclose-seconds > span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Seconds buttons — compact pills */
.tag-autoclose-sec-btn {
    flex: 0 0 auto !important;
    min-width: 32px;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem;
    border-radius: 12px !important;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading-spinner {
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Reading Modes */
.reading-mode-focus .verse-container:not(:hover) {
    opacity: 0.7;
}

.reading-mode-focus .verse-container:hover {
    opacity: 1;
    transform: scale(1.02);
}

/* Responsive Design */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 320px;
        --content-padding: 1rem;
    }
}

@media (max-width: 768px) {
    /* Nav rail → horizontal bottom bar */
    .app-body {
        flex-direction: column;
    }

    body[data-nav-side="right"] .app-body {
        flex-direction: column;
    }

    .icon-nav {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-top: 1px solid var(--border);
        order: 2;
        flex-shrink: 0;
        -webkit-overflow-scrolling: touch;
    }

    body[data-nav-side="right"] .icon-nav {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .icon-nav-top,
    .icon-nav-bottom {
        flex-direction: row;
    }

    /* Separator becomes a vertical line in horizontal bottom bar */
    .icon-nav-divider {
        width: 1px;
        height: 60%;
        align-self: center;
        margin: 0 4px;
    }

    .icon-nav-btn {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        padding: 0.4rem 0.6rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    body[data-nav-side="right"] .icon-nav-btn {
        border-right: none;
        border-bottom: 3px solid transparent;
    }

    .icon-nav-btn.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary);
    }

    body[data-nav-side="right"] .icon-nav-btn.active {
        border-right-color: transparent;
        border-bottom-color: var(--primary);
    }

    .icon-nav-label {
        display: none;
    }

    .icon-nav-side-toggle {
        display: none;
    }

    .main-container {
        order: 1;
        flex: 1;
        min-height: 0;
    }

    .bible-content {
        padding: 1rem;
    }

    .chapter-container {
        font-size: 1.125rem;
    }

    /* Sidebar → slide-over drawer */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 85vw;
        max-width: 400px;
        height: 100%;
        height: 100dvh;
        z-index: 9000;
        border-radius: 0;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 8999;
    }

    .sidebar-backdrop.visible {
        display: block;
    }
}

@media (max-width: 480px) {
    :root {
        --content-padding: 0.5rem;
    }

    .nav-container {
        flex-wrap: nowrap;
        gap: 0.35rem;
    }

    .bible-nav {
        padding: 0.3rem 0.5rem;
    }

    .chapter-display {
        min-width: auto;
        font-size: 0.8rem;
    }

    #content {
        padding: 0.75rem 1rem 1rem;
    }

    .verse-container {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }

    .chapter-title {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }

    .chapter-container {
        font-size: 1rem;
    }

    /* Touch targets — 44px minimum */
    .nav-btn {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
    }

    .nav-ref-display {
        min-height: var(--touch-target-min);
        font-size: 1rem;
    }

    .tab-btn {
        min-height: var(--touch-target-min);
        padding: 0.5rem 0.75rem;
    }

    /* Translation picker — reposition above bottom nav on mobile */
    .translation-panel {
        bottom: 60px;
        top: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%);
    }

    /* iOS auto-zoom prevention — Safari zooms on inputs < 16px */
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* Reading focus mode — disable transform on touch devices */
@media (hover: none) {
    .reading-mode-focus .verse-container:not(:hover) {
        opacity: 1;
    }

    .reading-mode-focus .verse-container:hover {
        transform: none;
    }
}

/* Strong's Numbers Styling */
.strongs {
    color: var(--primary);
    font-size: 0.75em;
    vertical-align: super;
    cursor: pointer;
    margin: 0 0.125rem;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.strongs:hover {
    background: var(--highlight);
    color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Hebrew Practice Modal Styles */
.hebrew-practice-modal {
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.hebrew-modal-content {
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.hebrew-verse-block:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hebrew-verse-block[data-highlighted="true"] {
    animation: highlightPulse 1s ease;
}

@keyframes highlightPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.05);
}

.modal-close-btn:hover {
    transform: scale(1.2) rotate(90deg);
    transition: transform 0.3s ease;
}

/* Hebrew text styling */
.hebrew-row {
    font-feature-settings: "kern" 1;
    letter-spacing: 0.05em;
}

/* Pronunciation row (Language Practice modal) */
.pronunciation-row {
    font-size: 1.2em;
    color: #B8860B;
    margin-bottom: 0.75rem;
    line-height: 1.6;
    font-weight: 500;
}

/* Word-level hover tokens */
.lang-word {
    display: inline;
    border-radius: 3px;
    padding: 0 1px;
    transition: background 0.15s;
    cursor: default;
}

.lang-word.word-hover {
    background: rgba(74, 144, 226, 0.2);
}

/* Responsive modal */
@media (max-width: 768px) {
    .hebrew-modal-content {
        width: 98%;
        margin: 0.5% auto;
    }

    .hebrew-modal-header {
        padding: 0.5rem 0.75rem !important;
    }

    /* title font now inherited from .frosted-header */

    .modal-controls {
        flex-direction: row !important;
        gap: 0.35rem !important;
    }

    .modal-btn {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.85rem !important;
    }

    .modal-close-btn {
        font-size: 1.5rem !important;
    }

    .hebrew-modal-body {
        padding: 0.75rem;
        max-height: 82vh;
    }

    .hebrew-verse-block {
        padding: 0.75rem !important;
    }
}

/* Print styles for Hebrew practice */
@media print {
    .hebrew-practice-modal {
        position: static;
        background: white;
    }
    
    .hebrew-modal-content {
        box-shadow: none;
        width: 100%;
        margin: 0;
    }
    
    .modal-controls,
    .modal-close-btn,
    .hebrew-modal-footer {
        display: none;
    }
    
    .hebrew-verse-block {
        page-break-inside: avoid;
        border: 1px solid #ddd;
    }
}


/* Beautiful Verse Styling */
.verse-container {
    margin-bottom: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--border);
    transition: all 0.3s ease;
}

.verse-container:hover {
    transform: translateX(2px);
    background: var(--surface);
    border-left-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.verse-number {
    display: inline-block;
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
    margin-right: 0.75rem;
    padding: 0.15rem 0.4rem;
    background: linear-gradient(135deg, #e8f4f8, rgba(74,144,226,0.1));
    border-radius: 6px;
    min-width: 2rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.verse-text {
    font-family: 'Crimson Text', serif;
    font-size: 1.125rem;
    line-height: 1.65;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

/* Chapter Title */
.chapter-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.25rem;
    text-align: center;
    font-family: 'Crimson Text', serif;
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* ── Mobile verse compaction (must come AFTER Beautiful Verse Styling) ── */
@media (max-width: 480px) {
    #content {
        padding: 0.5rem 0.4rem 0.75rem;
    }

    .verse-container {
        padding: 0.5rem 0.6rem;
        margin-bottom: 0.6rem;
        border-left-width: 3px;
        border-radius: 6px;
    }

    .verse-container:hover {
        transform: none;
    }

    .verse-number {
        font-size: 0.85rem;
        margin-right: 0.4rem;
        padding: 0.15rem 0.35rem;
        min-width: 1.8rem;
    }

    .verse-text {
        font-size: 1rem;
        line-height: 1.65;
    }

    .chapter-title {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
}

@media (hover: none) {
    .verse-container:hover {
        transform: none;
    }
}

/* (Old .verse-note-actions / .note-count-btn removed — unified into .verse-action-btn) */

/* Note List Items (sidebar) */
.note-list-item:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Notes Dialog */
.notes-dialog {
    animation: dialogFadeIn 0.2s ease;
}

@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.notes-dialog-header:active {
    cursor: grabbing;
}

.notes-nav-btn:hover {
    background: rgba(255, 255, 255, 0.35) !important;
}

.note-dialog-item {
    transition: all 0.2s ease;
}

.note-dialog-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.note-edit-btn:hover {
    text-decoration: underline;
}

.note-delete-btn:hover {
    text-decoration: underline;
}

.note-add-submit-btn:hover {
    filter: brightness(1.1);
}

/* Lexicon History Items */
.lexicon-history-item:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.lexicon-verse-link:hover {
    text-decoration: underline;
    color: var(--primary) !important;
}

.remove-lexicon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.remove-lexicon-btn:hover {
    opacity: 1;
    color: var(--text-primary);
}

/* ====================== Search UI ====================== */

.search-ui {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-input-container {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 0.5rem 3.5rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(91, 75, 138, 0.15);
}

.search-clear-btn {
    position: absolute;
    right: 2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.search-input:not(:placeholder-shown) ~ .search-clear-btn {
    opacity: 0.5;
}

.search-clear-btn:hover {
    opacity: 1;
    color: var(--text-primary);
}

.search-go-btn {
    position: absolute;
    right: 0.3rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.2s, background 0.2s, box-shadow 0.2s;
    opacity: 0.6;
}

.search-go-btn:hover {
    color: var(--primary);
    background: rgba(91, 75, 138, 0.08);
    opacity: 1;
}

.search-input:focus ~ .search-go-btn {
    color: var(--primary);
    opacity: 0.8;
}

.search-language-select {
    padding: 0.5rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
}

/* Virtual Keyboard */
.vk-container {
    padding: 0.375rem 0;
}

.vk-row {
    display: flex;
    justify-content: center;
    gap: 3px;
    margin-bottom: 3px;
}

.vk-key {
    min-width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
}

.vk-key:hover {
    background: var(--highlight);
}

.vk-key:active {
    transform: scale(0.95);
    background: var(--primary-light);
    color: white;
}

.vk-utils {
    margin-top: 2px;
}

.vk-backspace,
.vk-space,
.vk-clear {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    min-width: 3rem;
    padding: 0 0.5rem;
}

.vk-space {
    flex: 1;
    max-width: 6rem;
}

/* Search Results */
.search-result-item {
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.search-result-item:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.search-result-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-result-strongs {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.85rem;
}

.search-result-lemma {
    font-family: 'Crimson Text', serif;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.search-result-translit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.search-result-count {
    font-size: 0.7rem;
    color: var(--surface);
    background: var(--secondary);
    padding: 0.05rem 0.4rem;
    border-radius: 9px;
    font-weight: 600;
    margin-left: auto;
}

.search-result-def {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.search-result-verses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.4rem;
}

.search-verse-link {
    font-size: 0.7rem;
    color: var(--primary);
    background: var(--highlight);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-verse-link:hover {
    background: var(--primary);
    color: white;
}

.search-verse-more {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 0.1rem 0.35rem;
    font-style: italic;
}

.search-verse-expand,
.search-verse-collapse {
    cursor: pointer;
    color: var(--primary);
    font-style: italic;
    transition: color 0.15s;
}

.search-verse-expand:hover,
.search-verse-collapse:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.remove-search-result-btn {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0.15rem;
    line-height: 1;
}

.search-result-item:hover .remove-search-result-btn {
    opacity: 0.6;
}

.remove-search-result-btn:hover {
    opacity: 1 !important;
    color: var(--text-primary);
}

/* Search overlay (shown while searching) */
.search-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* No results state */
.search-no-results {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.search-no-results-icon {
    font-size: 2.5rem;
    opacity: 0.4;
    margin-bottom: 0.5rem;
}

.search-no-results-text {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.search-no-results-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ============================================================
   Cross-Reference Dropdown Panel (verse cards, main Bible reader)
   ============================================================ */

.xref-toggle {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: none;
    border: none;
    border-top: 1px solid var(--border, #e8e0f0);
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-align: left;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s, color 0.15s;
    border-radius: 0;
}

.xref-toggle:hover,
.xref-toggle.open {
    opacity: 1;
    color: var(--primary, #5B4B8A);
}

.xref-arrow {
    margin-left: 0.3rem;
    font-size: 0.65rem;
    vertical-align: middle;
}

.xref-panel {
    display: none;
    padding: 0.5rem 0.6rem 0.6rem;
    background: var(--bg-secondary, #f8f6fc);
    border-top: 1px solid var(--border, #e8e0f0);
    font-size: 0.8rem;
    line-height: 1.7;
}

.xref-refs {
    columns: 2;
    column-gap: 1.5rem;
}

.xref-book-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: block;
    margin-top: 0.3rem;
    margin-bottom: 0.25rem;
    width: 100%;
}

/* Pill-style bible-ref-link — used in xref panels AND all verse reference grids */
.xref-panel .bible-ref-link,
.verse-ref-grid .bible-ref-link {
    display: inline-block;
    color: var(--primary, #5B4B8A);
    text-decoration: none;
    cursor: pointer;
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
    font-size: 0.78rem;
    background: var(--bg-primary, white);
    border: 1px solid var(--border, #ddd);
    transition: background 0.15s;
}

.xref-panel .bible-ref-link:hover,
.verse-ref-grid .bible-ref-link:hover {
    background: var(--primary, #5B4B8A);
    color: white;
    border-color: var(--primary, #5B4B8A);
}

/* 2-column grid for verse reference lists */
.verse-ref-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 0.5rem;
}

.xref-empty {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.78rem;
}

/* ─── Commentary panel (inline below verse) ────────────────────────────── */
/* .commentary-verse-btn base styling handled by .verse-action-btn */

.verse-commentary-panel {
    display: none;
    padding: 0.75rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    background: var(--highlight);
    border-left: 3px solid #d4a017;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.verse-commentary-panel.open {
    display: block;
}
.commentary-source-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.commentary-text {
    font-style: italic;
}
.commentary-empty {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.78rem;
}

/* Commentary tab bar — source abbreviation tabs */
.commentary-tab-bar {
    display: flex;
    gap: 2px;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
    flex-wrap: wrap;
}
.commentary-tab {
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: 0.02em;
}
.commentary-tab:hover {
    color: #d4a017;
}
.commentary-tab.active {
    color: #d4a017;
    border-bottom-color: #d4a017;
}

/* Commentary panes — only active one visible */
.commentary-pane { display: none; }
.commentary-pane.active { display: block; }

/* Commentary entry inside pane */
.commentary-entry-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.3rem;
}
.commentary-tag-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}
.commentary-tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
/* Commentary panel tag/note buttons use .verse-action-btn */
.commentary-tag-btn { margin-left: auto; }

/* Commentary cross-reference links */
.commentary-ref {
    color: var(--accent-color, #4a90d9);
    cursor: pointer;
    text-decoration: underline dotted;
    text-decoration-color: var(--accent-color, #4a90d9);
}
.commentary-ref:hover {
    text-decoration: underline solid;
}

/* Commentary "Pin to Study" button — matches .bookmarked style */
.commentary-add-to-study.in-study {
    opacity: 1;
    border-color: rgba(var(--primary-rgb),0.3);
    color: var(--primary);
    background: rgba(var(--primary-rgb),0.05);
}

/* Commentary "Send to Study" context menu */
.commentary-send-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #ccc);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0.25rem;
}
.commentary-send-menu button {
    display: block;
    width: 100%;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 4px;
    white-space: nowrap;
}
.commentary-send-menu button:hover {
    background: var(--accent-color, #4a90d9);
    color: white;
}

/* Commentary tag picker layer badge color */
.tag-picker-layer.commentary {
    background: #d4a017;
    color: white;
}

/* ─── References pagination nav ──────────────────────────────────────────── */
.refs-nav-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--highlight);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.verse-ref-grid + .refs-nav-bar {
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.refs-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface, #fff);
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
}

.refs-nav-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.refs-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.refs-book-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 0.5rem;
    justify-content: center;
}

.refs-book-pill {
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.6rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.refs-book-pill:hover {
    background: var(--hover);
    color: var(--text);
}

.refs-book-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* BibleRefPopup Strong's styles moved to css/bible-ref-popup.css */

/* ────────────────────────────────────────────────────────────────────────────
   TOUCH DEVICES — show hover-only action buttons at reduced opacity
   ──────────────────────────────────────────────────────────────────────────── */
@media (hover: none) {
    .verse-action-bar { opacity: 0.7; }
    .remove-search-result-btn { opacity: 0.5; }
}
