/* Prevent background scrolling when modal is open - CRITICAL for mobile */
body.modal-open,
html.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    touch-action: none !important;
    -webkit-overflow-scrolling: auto !important;
}

/* Modal header: always show blue bottom border, even when scrolling */
.modal-caption-fixed {
    border-bottom: 2px solid #337ab7 !important;
    z-index: 2 !important;
    background: #f4f8fb !important;
}
#modalUnifiedModalContent {
    background: #fff;
    color: #222;
    padding: 0.75em 1em;
    border-radius: 8px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.15);
    max-width: 600px;
    margin: 0.5em auto 2em auto;
    line-height: 1.5;
}

/* Compact h2 styling for Strong-ID title - minimal vertical spacing */
#modalUnifiedModalContent h2 {
    margin: 0 0 0.5em 0;
    padding: 0;
    line-height: 1.2;
}

/* Strong-ID modal action buttons - Search and Copy */
.strong-search-btn:hover {
    background: #2868a0 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.strong-copy-btn:hover {
    background: #218838 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.strong-search-btn:active,
.strong-copy-btn:active {
    transform: translateY(1px);
}

/* Note modal action buttons - Search and Copy */
.note-search-btn:disabled {
    cursor: not-allowed !important;
}

.note-copy-btn:hover {
    background: #218838 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.note-copy-btn:active {
    transform: translateY(1px);
}

@media (max-width: 600px) {
    #modalUnifiedModalContent {
        max-width: 95vw;
        padding: 0.6em 0.5em;
        margin: 0.4em auto 1em auto;
        word-break: break-word;
    }
}
body.modal-open {
    overflow: hidden !important;
    width: 100vw !important;
}
/* Block background content clicks when modal is open */
body.modal-open .main-content {
    pointer-events: none;
}
.modal-footer-fixed {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 3 !important;
    background: #fff !important;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.04) !important;
    padding: 12px 0 12px 0 !important;
}
/* Dimmed modal: hide or fade previous modals when a new one opens */
.modal-dimmed {
    opacity: 0.3 !important;
    pointer-events: none !important;
    filter: blur(2px) grayscale(0.7) brightness(0);
}
/*  strongid-modal-instance modals to be visible and obvious */
.strongid-modal-instance {
    display: flex !important;
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    width: 92vw !important;
    height: fit-content !important;
    max-height: 100vh !important; /* Allow up to full viewport height */
    border: 3px solid #337ab7 !important; /* Blue border for modal */
    overflow-y: auto !important;
    transform: translate(-50%, -50%) !important;
    z-index: 99999 !important;
    background: rgba(255,255,255,0.98) !important;
    opacity: 1 !important;
    pointer-events: all !important;
}
/* --- Sticky Header Mobile UX: Hamburger always visible, header scrollable (touch only) --- */
@media (pointer: coarse), (hover: none) {
    #sticky-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        z-index: 1000;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        padding: 0;
    }
    .sticky-hamburger-container {
        position: sticky;
        left: 0;
        top: 0;
        z-index: 1010;
        flex: 0 0 auto;
        box-shadow: 2px 0 6px rgba(0,0,0,0.07);
    }
    .sticky-header-content {
        flex: 1 1 0%;
        min-width: 0;
        overflow-x: auto;
        display: flex;
        align-items: center;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: 0.5em;
    }
    .hamburger-btn {
        min-width: 44px;
        min-height: 44px;
        background: none;
        border: none;
        padding: 0.5em 0.75em;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
/* Desktop: let header behave as before */
@media (pointer: fine) and (hover: hover) {
    .sticky-hamburger-container {
        position: static;
        box-shadow: none;
    }
    .sticky-header-content {
        overflow-x: visible;
        gap: 0.5em;
    }
}
/* Reduce vertical space above and below plain verses */
.rog-flex-verse:not(:has(.rog-flex-greek)) {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    gap: 0 !important;
}
.rog-flex-verse:not(:has(.rog-flex-greek)) > span,
.rog-flex-verse:not(:has(.rog-flex-greek)) > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
}
/* Use the same font-family as .rog-flex-romanian for Romanian text in plain verses */
/* Use Garamond for Romanian text in plain verses to match interlinear */
.rog-flex-verse:not(:has(.rog-flex-greek)) span > span:last-child {
    font-family: Arial, Verdana, sans-serif !important;
}
/* Increase font size for plain verse text (not the reference) */
/* .rog-flex-verse:not(:has(.rog-flex-greek)) span {
    font-size: 1.1em;
} */
}
/* Keep reference font size unchanged */
/* .rog-flex-verse:not(:has(.rog-flex-greek)) span > span:first-child {
    font-size: 1.1em;
} */
}
/* ROG INTERLINEAR: LXXRO LOGIC (ISOLATED) */
.rog-flex-chapter {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    margin-bottom: 1em;
}
.rog-flex-verse {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5em;
    background: #f8f8ff;
    border-radius: 6px;
    padding: 0.5em 0.5em 0.5em 0.7em;
    margin-bottom: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    text-align: left;
    flex-wrap: wrap;
}

/* Reduce left space for plain verses in ABA (no .rog-flex-greek child) */
.rog-flex-verse:not(:has(.rog-flex-greek)) {
    padding-left: 0.1em !important;
}
.rog-flex-ref {
    min-width: 60px;
    max-width: 90px;
    font-weight: bold;
    color: #336699;
    /* font-size: 1.1em; */
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
}
.rog-flex-word {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0 4px;
    text-align: left;
}
.rog-flex-strong {
    /* font-size: 0.95em; */
    color: #336699;
    font-weight: bold;
    text-align: left;
}
.rog-flex-greek {
    /* font-size: 1.1em; */
    font-family: "Candara", Garamond, sans-serif;
    text-align: left;
}
.rog-flex-romanian {
    /* font-size: 1.05em; */
    color: #d9463b;
    text-align: left;
    font-family: Arial, Verdana, sans-serif;
}
.rog-flex-title {
    background: #e0eaff;
    font-weight: bold;
    padding: 0.5em 0;
    text-align: left;
    /* font-size: 1.08em; */
    border-radius: 4px;
    margin-bottom: 0.2em;
}
.rog-invert {
    background: #d9463b;
    color: #fff;
    padding: 0 2px;
    border-radius: 2px;
}

/* Make sticky-header larger on mobile devices */
@media (max-width: 600px) {
    #sticky-header {
        min-height: 64px !important;
        font-size: 1.15em !important;
        padding-top: 0.7em !important;
        padding-bottom: 0.7em !important;
    }
    #sticky-header .header-left, #sticky-header .header-right {
        min-height: 48px !important;
        font-size: 1.08em !important;
    }
    .hamburger-title {
        font-size: 1.35em !important;
    }
}
/* END ROG INTERLINEAR: LXXRO LOGIC */

/* Modal content styling for ROG notes */
#modalRoNoteClickText {
    background: #fff;
    color: #222;
    padding: 1.5em 2em;
    border-radius: 8px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.15);
    max-width: 600px;
    margin: 2em auto;
    line-height: 1.5;
}

@media (max-width: 600px) {
    #modalRoNoteClickText {
        max-width: 95vw;
        padding: 1em 0.5em;
        margin: 1em auto;
        word-break: break-word;
    }
}
.tts-highlight {
  background: #ffe066 !important;
  font-weight: bold;
  border-radius: 3px;
  transition: background 0.2s;
}

/* --- Consistent font size for modals and main content on mobile --- */
@media (max-width: 700px) {
    .main-content {
        font-size: 1.1em;
    }
}

/* ============================================
   VERSE SELECTION FEATURE
   ============================================ */
/* Verse reference clickable styling */
.verse-ref-number {
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
    /* Prevent text selection on mobile to avoid conflict with long-press copy */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent touch callout menu on iOS */
    -webkit-touch-callout: none;
    /* Keep verse ref and button together on same line */
    display: inline-block;
    white-space: nowrap;
}

/* Copy button inline with verse reference */
.verse-copy-btn {
    display: inline-block;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 3px;
    margin-left: 3px;
    margin-right: 6px;
    vertical-align: baseline;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
    animation: copyBtnFadeIn 0.3s ease;
    width: 15px;
    height: 14px;
    text-align: center;
}

.verse-copy-btn:hover {
    background: #229954;
    transform: scale(1.15);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.verse-copy-btn:active {
    transform: scale(0.95);
    background: #1e8449;
}

.verse-copy-btn.copied {
    background: #3498db;
    animation: copyBtnSuccess 0.5s ease;
}

@keyframes copyBtnFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes copyBtnSuccess {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.verse-ref-number:hover {
    color: #2980b9; /* Subtle blue on hover */
    transform: scale(1.05); /* Slight zoom effect */
}

.verse-ref-number:active {
    transform: scale(0.98); /* Press effect */
}
/* ============================================
   COPY VERSE FEATURE - Toast Animation
   ============================================ */
@keyframes fadeInOut {
    0% { 
        opacity: 0; 
        transform: translateX(-50%) translateY(10px); 
    }
    10% { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0); 
    }
    90% { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0); 
    }
    100% { 
        opacity: 0; 
        transform: translateX(-50%) translateY(-10px); 
    }
}

/* ============================================
   HOVER MODAL - Hide on touch devices
   ============================================ */
/* Hide hover tooltip modal on touch devices (where hover doesn't make sense) */
@media (hover: none) and (pointer: coarse) {
    #modalRoNoteHover {
        display: none !important;
    }
}

/* ============================================
   WELCOME MODAL - Version Announcement
   ============================================ */
.welcome-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.welcome-modal-content .modal-header {
    background: #337ab7;
    color: #fff;
    padding: 20px;
    border-radius: 8px 8px 0 0;
}

.welcome-modal-content .modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.welcome-modal-content .modal-body {
    padding: 0;
}

.welcome-modal-content .modal-body ul {
    line-height: 1.8;
    font-size: 1.05em;
}

.welcome-modal-content .modal-footer {
    padding: 10px 20px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    background: transparent;
}

.welcome-modal-close-btn {
    background: #4CAF50;
    color: #fff;
    border: none;
    padding: 12px 40px;
    font-size: 1.1em;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s ease;
    display: inline-block;
    width: auto;
    max-width: fit-content;
    text-align: center !important;
}

.welcome-modal-close-btn:hover {
    background: #45a049;
}

/* Mobile responsiveness for Welcome Modal */
@media (max-width: 600px) {
    .welcome-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .welcome-modal-content .modal-header {
        padding: 15px;
    }
    
    .welcome-modal-content .modal-header h2 {
        font-size: 1.2em;
    }
}

/* Animations for Welcome Modal */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}


/* ============================================
   VERSE CONTEXT MENU - v1.1.10.beta1
   ============================================ */

/* Context Menu Backdrop */
#verseContextBackdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#verseContextBackdrop.active {
    opacity: 1;
}

/* Context Menu - Mobile (Bottom Sheet) */
.verse-context-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 70vh;
    overflow-y: auto;
}

.verse-context-menu.active {
    transform: translateY(0);
}

/* Context Menu Header */
.context-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e7ff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
}

.context-menu-verse-ref {
    font-weight: 600;
    font-size: 1.1em;
    color: white;
}

.context-menu-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 24px;
    line-height: 1;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.context-menu-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Context Menu Body */
.context-menu-body {
    padding: 0;
}

/* Menu Items */
.menu-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
    background: white;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover:not(.disabled) {
    background: linear-gradient(to right, #f8f9ff 0%, #ffffff 100%);
    transform: translateX(2px);
}

.menu-item:active:not(.disabled) {
    background: #f0f4ff;
}

.menu-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.menu-item.disabled:active {
    background: transparent;
}

.menu-item .icon {
    font-size: 18px;
    width: 36px;
    height: 36px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Icon colors for different actions */
.menu-item:nth-child(1) .icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.menu-item:nth-child(2) .icon {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.menu-item:nth-child(3) .icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.menu-item:nth-child(4) .icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.menu-item:nth-child(5) .icon {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.menu-item.disabled .icon {
    background: #e5e7eb;
    opacity: 0.6;
}

.menu-item .label {
    flex: 1;
    font-size: 1em;
    color: #1f2937;
    font-weight: 500;
}

.menu-item .badge {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 600;
}

/* Desktop: Popover Style */
@media (min-width: 768px) {
    .verse-context-menu {
        position: fixed;  /* Fixed to viewport, not document */
        bottom: auto;
        left: 0;
        right: auto;
        width: 280px;
        border-radius: 8px;
        max-height: 400px;
    }
    
    .context-menu-header {
        border-radius: 8px 8px 0 0;
    }
}

/* ============================================
   COPY RANGE MODAL
   ============================================ */
.copy-range-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.copy-range-modal.active {
    transform: translateY(0);
}

.copy-range-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #667eea;
    color: white;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.copy-range-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.copy-range-modal .modal-header .context-menu-close {
    color: white;
}

.copy-range-modal .modal-body {
    padding: 16px 0;
    overflow-y: auto;
    flex: 1 1 auto;
}

.copy-range-instruction {
    padding: 0 20px 12px;
    margin: 0;
    color: #000;
    font-size: 0.95em;
    font-weight: 500;
}

.verse-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.verse-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 60px;
    display: flex;
    gap: 12px;
}

.verse-item:hover {
    background: #fff9c4;
}

.verse-item:active {
    background: #fff59d;
}

.verse-item.start-verse {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
}

.verse-item.in-range {
    background: #f1f8ff;
}

.verse-item.end-verse {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.verse-num {
    font-weight: 600;
    color: #000;
    min-width: 40px;
    flex-shrink: 0;
}

.verse-text {
    color: #000;
    font-size: 0.95em;
    line-height: 1.4;
}

.copy-range-modal .modal-footer {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.copy-range-modal .btn-copy-range {
    flex: 1;
    background: #667eea;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 6px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    min-width: 0;
}

.copy-range-modal .btn-copy-range:hover {
    background: #5568d3;
}

.copy-range-modal .btn-copy-range:active {
    background: #4451b9;
}

.copy-range-modal .btn-cancel {
    flex: 0 0 auto;
    background: #e0e0e0;
    color: #000;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
    max-width: 90px;
}

.copy-range-modal .btn-cancel:hover {
    background: #d0d0d0;
}

.copy-range-modal .btn-cancel:active {
    background: #c0c0c0;
}

/* Desktop: Modal as Centered Dialog */
@media (min-width: 768px) {
    .copy-range-modal {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0;
        width: 520px;
        max-height: 600px;
        border-radius: 8px;
    }
    
    .copy-range-modal.active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    
    .copy-range-modal .modal-header {
        border-radius: 8px 8px 0 0;
    }
}
