/* Block all transitions during initial theme application (class removed by JS after first paint) */
.no-transitions,
.no-transitions * {
    transition: none !important;
}

/* Smooth transitions for theme switching */
html {
    transition: background-color 0.3s ease, color 0.3s ease;
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.main-app-container {
    background: #f8fafc;
    color: #111827;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dark .main-app-container {
    background: #1f2937;
    color: #f3f4f6;
}

/* ===== Top Navigation ===== */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
    animation: slideDown 0.45s ease-out;
}

.dark .site-nav {
    background: rgba(15, 23, 42, 0.82);
    border-bottom-color: rgba(51, 65, 85, 0.4);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.3);
}

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

.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 3.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Logo */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}

.nav-logo-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.6rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    box-shadow: 0 2px 8px rgba(37,99,235,0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    padding: 0.25rem;
}

.nav-logo-image {
    width: 1.85rem;
    height: 1.85rem;
    object-fit: contain;
    display: block;
    filter: brightness(0) invert(1);
}

.nav-logo:hover .nav-logo-badge {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(37,99,235,0.45);
}

.nav-logo-text {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1e293b;
    transition: color 0.2s;
}

.nav-logo-text .logo-icc {
    color: #2563eb;
}

.dark .nav-logo-text {
    color: #f1f5f9;
}

.dark .nav-logo-text .logo-icc {
    color: #60a5fa;
}

/* Desktop links */
.nav-links {
    display: none;
    align-items: center;
    gap: 0.25rem;
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
    }
}

.nav-link {
    position: relative;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #475569;
    border-radius: 0.5rem;
    transition: color 0.2s ease, background 0.2s ease;
    text-decoration: none;
    overflow: hidden;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 0.75rem;
    width: 0;
    height: 2px;
    border-radius: 1px;
    background: linear-gradient(90deg, #3b82f6, #6366f1);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover {
    color: #2563eb;
    background: rgba(59, 130, 246, 0.07);
}

.nav-link:hover::after {
    width: calc(100% - 1.5rem);
}

.dark .nav-link {
    color: #94a3b8;
}

.dark .nav-link:hover {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.1);
}

/* Actions row */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lang-select-wrap {
    position: relative;
    display: none;
    align-items: center;
    min-width: 5.1rem;
}

@media (min-width: 768px) {
    .lang-select-wrap {
        display: flex;
    }
}

.lang-select-icon {
    position: absolute;
    left: 0.5rem;
    font-size: 0.95rem;
    color: #3b82f6;
    pointer-events: none;
}

.lang-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    height: 2.1rem;
    padding: 0.35rem 1.7rem 0.35rem 1.7rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.09), rgba(99, 102, 241, 0.07));
    color: #1e3a8a;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.lang-select:hover {
    border-color: rgba(59, 130, 246, 0.55);
    transform: translateY(-1px);
}

.lang-select:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.85);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.dark .lang-select {
    border-color: rgba(71, 85, 105, 0.8);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(99, 102, 241, 0.16));
    color: #bfdbfe;
}

.dark .lang-select:hover {
    border-color: rgba(96, 165, 250, 0.8);
}

.dark .lang-select-icon {
    color: #93c5fd;
}

.nav-divider {
    display: none;
    width: 1px;
    height: 1.4rem;
    background: rgba(148, 163, 184, 0.4);
}

@media (min-width: 768px) {
    .nav-divider {
        display: block;
    }
}

/* Generic icon button */
.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.55rem;
    font-size: 1rem;
    color: #475569;
    background: transparent;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
}

    /* ===== DataTables Theme Support ===== */
    #livresTable_wrapper {
        color: #1f2937;
    }

    #livresTable_wrapper .dataTables_length label,
    #livresTable_wrapper .dataTables_filter label,
    #livresTable_wrapper .dataTables_info {
        color: #374151;
    }

    #livresTable_wrapper .dataTables_filter input,
    #livresTable_wrapper .dataTables_length select {
        color: #111827;
        background-color: #ffffff;
        border: 1px solid #d1d5db;
        border-radius: 0.5rem;
        padding: 0.25rem 0.5rem;
    }

    #livresTable_wrapper .dataTables_filter input {
        width: 50%;
        height: 2.1rem;
        margin: 5px;
    }

    #livresTable thead th,
    #livresTable tbody td {
        color: #111827;
    }

    /* ---- Dark mode ---- */
    .dark #livresTable_wrapper {
        color: #e5e7eb;
    }

    .dark #livresTable_wrapper .dataTables_length label,
    .dark #livresTable_wrapper .dataTables_filter label,
    .dark #livresTable_wrapper .dataTables_info,
    .dark #livresTable_wrapper .dataTables_paginate .paginate_button {
        color: #d1d5db !important;
    }

    .dark #livresTable_wrapper .dataTables_filter input,
    .dark #livresTable_wrapper .dataTables_length select {
        color: #f9fafb;
        background-color: #1f2937;
        border: 1px solid #4b5563;
    }

    /* Header */
    .dark #livresTable {
        border-color: #374151;
    }

    .dark #livresTable thead th {
        color: #f3f4f6;
        background-color: #1e293b;
        border-bottom-color: #4b5563;
        border-top-color: #4b5563;
    }

    /* Cells */
    .dark #livresTable tbody td {
        color: #f3f4f6;
        border-top-color: #374151;
    }

    /* Striping — .odd/.even set by DataTables on <tr> */
    .dark #livresTable.stripe tbody tr.odd > td,
    .dark #livresTable.stripe tbody tr.odd > th {
        background-color: #111827;
    }

    .dark #livresTable.stripe tbody tr.even > td,
    .dark #livresTable.stripe tbody tr.even > th {
        background-color: #1f2937;
    }

    /* Row hover */
    .dark #livresTable.hover tbody tr:hover > td,
    .dark #livresTable.hover tbody tr:hover > th {
        background-color: #374151 !important;
    }

    /* Pagination */
    .dark #livresTable_wrapper .dataTables_paginate .paginate_button.current,
    .dark #livresTable_wrapper .dataTables_paginate .paginate_button.current:hover {
        color: #111827 !important;
        background: #93c5fd !important;
        border: 1px solid #93c5fd !important;
    }

    .dark #livresTable_wrapper .dataTables_paginate .paginate_button:hover {
        color: #111827 !important;
        background: #60a5fa !important;
        border-color: #60a5fa !important;
    }

    /* Responsive extension — child rows */
    .dark #livresTable tbody tr.child td.child {
        background-color: #1f2937;
    }

    .dark #livresTable tbody tr.child ul.dtr-details li {
        border-bottom-color: #374151;
    }

    .dark #livresTable tbody tr.child span.dtr-title {
        color: #93c5fd;
    }

    .dark #livresTable tbody tr.child span.dtr-data {
        color: #e5e7eb;
    }

    /* Responsive toggle arrow */
    .dark #livresTable tbody td.dtr-control::before {
        border-color: transparent transparent transparent #93c5fd;
    }

.nav-icon-btn:hover {
    color: #2563eb;
    background: rgba(59, 130, 246, 0.08);
}

.nav-icon-btn:active {
    transform: scale(0.9);
}

.dark .nav-icon-btn {
    color: #94a3b8;
}

.dark .nav-icon-btn:hover {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
}

/* Theme toggle specific */
.theme-toggle-btn:hover {
    transform: rotate(14deg);
    background: rgba(59, 130, 246, 0.08);
}

.dark .theme-toggle-btn:hover {
    transform: rotate(14deg);
    background: rgba(59, 130, 246, 0.12);
}

/* Sun/moon icon visibility — driven by .dark class, no Tailwind needed */
.theme-toggle-btn .fa-sun  { display: none; }
.theme-toggle-btn .fa-moon { display: block; }
.dark .theme-toggle-btn .fa-sun  { display: block; }
.dark .theme-toggle-btn .fa-moon { display: none; }

/* Hamburger — hidden on desktop */
.hamburger-btn {
    font-size: 1.35rem;
}

@media (min-width: 768px) {
    .hamburger-btn {
        display: none;
    }
}

/* CTA button (guest) */
.nav-cta {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 2rem;
    background: linear-gradient(135deg, #3b82f6, #4f46e5);
    color: white;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.nav-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5);
}

.nav-cta:active {
    transform: translateY(0) scale(0.97);
}

@media (min-width: 768px) {
    .nav-cta {
        display: flex;
    }
}

/* User pill (logged-in) */
.nav-user-btn {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.65rem 0.3rem 0.3rem;
    border-radius: 2rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1.5px solid rgba(59, 130, 246, 0.2);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}
.nav-user-btn:hover {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.45);
    transform: translateY(-1px);
}
.dark .nav-user-btn {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
}
.dark .nav-user-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(96, 165, 250, 0.5);
}
@media (min-width: 768px) {
    .nav-user-btn { display: flex; }
}

/* Initials circle */
.nav-user-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(37,99,235,0.35);
}
.nav-user-avatar--photo {
    background: transparent;
    box-shadow: none;
}
.nav-user-avatar--photo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
/* Small variant for mobile menu */
.nav-user-avatar--sm {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.62rem;
}
.nav-user-avatar--sm.nav-user-avatar--photo {
    background: transparent;
    box-shadow: none;
}

/* Name label next to avatar */
.nav-user-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e293b;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark .nav-user-name { color: #e2e8f0; }

/* ===== Mobile Menu ===== */
#mobile-menu {
    overflow: hidden;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.dark #mobile-menu {
    border-top-color: rgba(51, 65, 85, 0.4);
}

.mobile-menu-inner {
    padding: 0.75rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.dark .mobile-menu-inner {
    background: rgba(15, 23, 42, 0.9);
}

.mobile-lang-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.25rem 0.35rem;
}

.mobile-lang-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.dark .mobile-lang-label {
    color: #94a3b8;
}

.mobile-lang-select-wrap {
    display: flex;
    min-width: 9.2rem;
}

@media (min-width: 768px) {
    .mobile-lang-row {
        display: none;
    }
}

.mobile-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.mobile-link:hover {
    color: #2563eb;
    background: rgba(59, 130, 246, 0.07);
    transform: translateX(4px);
}

.dark .mobile-link {
    color: #94a3b8;
}

.dark .mobile-link:hover {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.1);
}

.mobile-link-icon {
    font-size: 0.85rem;
    width: 1.75rem;
    min-width: 1.75rem;
    color: #3b82f6;
    transition: transform 0.2s ease;
    text-align: center;
}

.mobile-link:hover .mobile-link-icon {
    transform: scale(1.15);
}

.mobile-link-cta {
    margin-top: 0.15rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.08));
    color: #2563eb;
}

.mobile-link-cta:hover {
    background: linear-gradient(135deg, #3b82f6, #4f46e5);
    color: white;
}

.mobile-link-cta .mobile-link-icon {
    color: inherit;
}

.dark .mobile-link-cta {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

.dark .mobile-link-cta:hover {
    background: linear-gradient(135deg, #3b82f6, #4f46e5);
    color: white;
}

.mobile-divider {
    height: 1px;
    background: rgba(148, 163, 184, 0.25);
    margin: 0.25rem 0.25rem;
}

.dark .mobile-divider {
    background: rgba(51, 65, 85, 0.5);
}

/* Opening animation */
#mobile-menu.show {
    animation: slideDownOpen 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Closing animation */
#mobile-menu.closing {
    animation: slideUpClose 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideDownOpen {
    from {
        opacity: 0;
        transform: translateY(-16px) scaleY(0.92);
        max-height: 0;
    }
    60% {
        opacity: 1;
        transform: translateY(0) scaleY(1.01);
        max-height: 250px;
    }
    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
        max-height: 400px;
    }
}

@keyframes slideUpClose {
    from {
        opacity: 1;
        transform: translateY(0) scaleY(1);
        max-height: 400px;
    }
    to {
        opacity: 0;
        transform: translateY(-16px) scaleY(0.92);
        max-height: 0;
    }
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 20;
}

.dark .bottom-nav {
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid rgba(31, 41, 55, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ===== Reading Panes ===== */
.reading-panes-wrapper {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

.reading-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    border-right: 1px solid rgba(226, 232, 240, 0.7);
    min-width: 0;
    transition: flex 0.3s ease;
}

.dark .reading-pane {
    border-right-color: rgba(55, 65, 81, 0.7);
}

.reading-pane:last-child {
    border-right: none;
}

.pane-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0.5rem 2.25rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    flex-shrink: 0;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.dark .pane-header {
    background: rgba(17, 24, 39, 0.92);
    border-bottom-color: rgba(55, 65, 81, 0.8);
}

.pane-header.scroll-blur {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.97);
}

.dark .pane-header.scroll-blur {
    background: rgba(17, 24, 39, 0.97);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.pane-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    /* Hide "Bible :" and "Livre :" labels to save space */
    .pane-label:not(.pane-label-chapter) {
        display: none;
    }

    /* Also hide "Chapitre :" label — icon/select is self-explanatory in compact row */
    .pane-label-chapter {
        display: none;
    }

    /* Row 1: Bible (flex-grow) + Chapitre (shrinks to fit) */
    /* Row 2: Livre (full width) */
    .pane-nav {
        gap: 0.4rem 0.5rem;
    }

    /* Bible autocomplete wrap — 1st child div */
    .pane-nav > div:nth-child(1) {
        order: 1;
        flex: 1 1 0;
        min-width: 0;
    }

    /* Livre — 2nd child div → pushed to second row */
    .pane-nav > div:nth-child(2) {
        order: 2;
        flex: 1 1 100%;
    }

    /* Chapitre — 3rd child div → same row as Bible */
    .pane-nav > div:nth-child(3) {
        order: 1;
        flex: 0 0 auto;
    }

    /* Bible text input fills its container */
    .pane-bible-input {
        width: 100%;
    }

    /* Book select fills its container */
    .pane-book-select {
        width: 100%;
    }
}

.many-panes .pane-label:not(.pane-label-chapter) {
    display: none;
}

.many-panes .pane-label-chapter {
    display: none;
}

/* Many-panes: row 1 = Bible (grow) + Chapitre, row 2 = Livre */
.many-panes .pane-nav {
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
}

.many-panes .pane-nav > div:nth-child(1) {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
}

.many-panes .pane-nav > div:nth-child(2) {
    order: 2;
    flex: 1 1 100%;
}

.many-panes .pane-nav > div:nth-child(3) {
    order: 1;
    flex: 0 0 auto;
}

.many-panes .pane-bible-input {
    width: 100%;
}

.many-panes .pane-book-select {
    width: 100%;
}

/* ===== Bible Autocomplete ===== */
.bible-autocomplete-wrap {
    position: relative;
}

.pane-bible-input {
    width: 9rem;
    min-width: 0;
}

.bible-autocomplete-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
    min-width: 240px;
    padding: 3px 0;
    list-style: none;
    margin: 0;
}

.dark .bible-autocomplete-dropdown {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.bible-autocomplete-dropdown.open {
    display: block;
}

.bible-autocomplete-dropdown li {
    padding: 5px 10px;
    font-size: 0.72rem;
    color: #111827;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .bible-autocomplete-dropdown li {
    color: #f3f4f6;
}

.bible-autocomplete-dropdown li:hover,
.bible-autocomplete-dropdown li.active {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

.dark .bible-autocomplete-dropdown li:hover,
.dark .bible-autocomplete-dropdown li.active {
    background: rgba(96, 165, 250, 0.15);
    color: #93c5fd;
}

/* ===== Verse hover & cross-pane highlight ===== */
.verse-line {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin-left: -4px;
    transition: background-color 0.15s ease;
}

.verse-line:hover,
.verse-line.verse-highlighted {
    background-color: rgba(59, 130, 246, 0.12);
}

.dark .verse-line:hover,
.dark .verse-line.verse-highlighted {
    background-color: rgba(96, 165, 250, 0.15);
}

/* Surlignage persistant au clic */
.verse-line.verse-selected {
    background-color: rgba(250, 204, 21, 0.35);
    border-left: 3px solid #f59e0b;
    margin-left: -7px;
    padding-left: 7px;
}

.dark .verse-line.verse-selected {
    background-color: rgba(251, 191, 36, 0.22);
    border-left: 3px solid #fbbf24;
    margin-left: -7px;
    padding-left: 7px;
}

.verse-line.verse-selected:hover,
.verse-line.verse-selected.verse-highlighted {
    background-color: rgba(250, 204, 21, 0.50);
}

.dark .verse-line.verse-selected:hover,
.dark .verse-line.verse-selected.verse-highlighted {
    background-color: rgba(251, 191, 36, 0.35);
}

/* Verset avec commentaire */
.verse-line.verse-has-comment {
    background-color: rgba(167, 243, 208, 0.28);
    border-left: 3px solid #10b981;
    margin-left: -7px;
    padding-left: 7px;
}
.dark .verse-line.verse-has-comment {
    background-color: rgba(52, 211, 153, 0.15);
    border-left: 3px solid #34d399;
    margin-left: -7px;
    padding-left: 7px;
}
.verse-line.verse-has-comment:hover,
.verse-line.verse-has-comment.verse-highlighted {
    background-color: rgba(167, 243, 208, 0.45);
}
.dark .verse-line.verse-has-comment:hover,
.dark .verse-line.verse-has-comment.verse-highlighted {
    background-color: rgba(52, 211, 153, 0.28);
}
/* Verset à la fois marqué (signet) ET commenté : couleur violette distincte */
.verse-line.verse-selected.verse-has-comment {
    background-color: rgba(167, 139, 250, 0.28);
    border-left: 3px solid #7c3aed;
    margin-left: -7px;
    padding-left: 7px;
}
.dark .verse-line.verse-selected.verse-has-comment {
    background-color: rgba(139, 92, 246, 0.20);
    border-left: 3px solid #a78bfa;
    margin-left: -7px;
    padding-left: 7px;
}
.verse-line.verse-selected.verse-has-comment:hover,
.verse-line.verse-selected.verse-has-comment.verse-highlighted {
    background-color: rgba(167, 139, 250, 0.45);
}
.dark .verse-line.verse-selected.verse-has-comment:hover,
.dark .verse-line.verse-selected.verse-has-comment.verse-highlighted {
    background-color: rgba(139, 92, 246, 0.35);
}

.footnote-marker {
    font-size: 0.65em;
    color: #f59e0b;
    cursor: help;
    margin: 0 1px;
    vertical-align: super;
    font-style: italic;
}

.dark .footnote-marker {
    color: #fbbf24;
}

/* ===== Assistant FAB ===== */
#assistantFab {
    position: fixed;
    bottom: 104px;
    right: 20px;
    z-index: 40;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#assistantFab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.55);
}
#assistantFab.open {
    background: linear-gradient(135deg, #1e293b 0%, #374151 100%);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ===== Settings Panel ===== */
.settings-panel {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    z-index: 49;
    width: calc(100% - 2rem);
    max-width: 360px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
}
.dark .settings-panel {
    background: #1e293b;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}
.settings-panel.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.9rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.75rem;
}
.dark .settings-row {
    border-color: #334155;
}
.settings-row:last-of-type {
    border-bottom: none;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: #374151;
    white-space: nowrap;
}
.dark .settings-label { color: #cbd5e1; }

.settings-stepper {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.settings-step-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.settings-step-btn:hover { background: #e5e7eb; }
.dark .settings-step-btn {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
.dark .settings-step-btn:hover { background: #3e526a; }

.settings-step-val {
    min-width: 3rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: #1f2937;
}
.dark .settings-step-val { color: #e2e8f0; }

.settings-font-btns {
    display: flex;
    gap: 0.3rem;
}
.settings-font-btn {
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.settings-font-btn:hover { background: #e5e7eb; }
.settings-font-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.dark .settings-font-btn {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
.dark .settings-font-btn:hover { background: #3e526a; }
.dark .settings-font-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.settings-footer {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0.9rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}
.dark .settings-footer {
    background: #0f172a;
    border-color: #334155;
}
.settings-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    color: #6b7280;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    transition: color 0.15s;
}
.settings-reset-btn:hover { color: #ef4444; }
.dark .settings-reset-btn { color: #94a3b8; }
.dark .settings-reset-btn:hover { color: #f87171; }

/* ===== Assistant Panel ===== */
.assistant-panel {
    position: fixed;
    bottom: 164px;
    right: 16px;
    z-index: 39;
    width: 320px;
    max-width: calc(100vw - 32px);
    max-height: 68vh;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
    /* Hidden by default */
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.dark .assistant-panel {
    background: #1e293b;
    border-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.assistant-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.assistant-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
    flex-shrink: 0;
}
.assistant-header-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.assistant-header-btn:hover {
    background: rgba(255,255,255,0.15);
}

.assistant-context {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: #f0f7ff;
    border-bottom: 1px solid #e2ecfa;
    flex-shrink: 0;
    color: #1e3a8a;
    font-size: 0.72rem;
}
.dark .assistant-context {
    background: #1e2d45;
    border-color: #2d3f5a;
    color: #93c5fd;
}

.assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 80px;
}
.assistant-msg {
    font-size: 0.8rem;
    line-height: 1.55;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    max-width: 92%;
    word-break: break-word;
    overflow-wrap: break-word;
}
.assistant-msg.user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 3px;
}
.assistant-msg.bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 3px;
}
.dark .assistant-msg.bot {
    background: #293548;
    color: #e2e8f0;
}
.assistant-msg.loading {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.65rem 0.85rem;
}
.assistant-msg.loading span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: assistantDot 1.2s infinite ease-in-out;
}
.assistant-msg.loading span:nth-child(2) { animation-delay: 0.2s; }
.assistant-msg.loading span:nth-child(3) { animation-delay: 0.4s; }
@keyframes assistantDot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quota épuisé */
.assistant-msg--quota {
    background: #fef3c7 !important;
    color: #92400e !important;
    border-left: 3px solid #f59e0b;
}
.dark .assistant-msg--quota {
    background: #422006 !important;
    color: #fcd34d !important;
    border-left-color: #d97706;
}

/* Indication du quota restant sous une réponse */
.assistant-quota-hint {
    margin-top: 0.45rem;
    font-size: 0.65rem;
    opacity: 0.55;
    text-align: right;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 0.3rem;
}

/* Formatage markdown de la réponse IA */
.assistant-msg.bot p       { margin: 0 0 0.3rem; }
.assistant-msg.bot br      { display: block; margin: 0.2rem 0; content: ''; }
.assistant-msg.bot .ai-heading2 {
    font-weight: 700;
    font-size: 0.8rem;
    margin: 0.6rem 0 0.2rem;
    color: #1e40af;
}
.dark .assistant-msg.bot .ai-heading2 { color: #93c5fd; }
.assistant-msg.bot .ai-heading3 {
    font-weight: 600;
    font-size: 0.75rem;
    margin: 0.5rem 0 0.15rem;
    color: #374151;
}
.dark .assistant-msg.bot .ai-heading3 { color: #d1d5db; }
.assistant-msg.bot .ai-list {
    margin: 0.2rem 0 0.3rem 1rem;
    padding: 0;
    list-style: disc;
}
.assistant-msg.bot .ai-list li { margin-bottom: 0.15rem; }

/* ===== Comment Panel (bottom sheet) ===== */
.comment-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 48;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.comment-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.comment-panel {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(110%);
    z-index: 49;
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.dark .comment-panel {
    background: #1e293b;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.55);
}
.comment-panel.open {
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 560px) {
    .comment-panel {
        bottom: 96px;
        border-radius: 16px;
        transform: translateX(-50%) translateY(14px);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.25s ease, opacity 0.25s ease;
    }
    .comment-panel.open {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        pointer-events: all;
    }
}

.comment-handle {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
}
.dark .comment-handle { background: #475569; }
@media (min-width: 560px) { .comment-handle { display: none; } }

.comment-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem 0.55rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
    flex-shrink: 0;
}
.comment-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.15s;
}
.comment-close-btn:hover { color: #fff; }

.comment-verse-text {
    font-size: 0.78rem;
    color: #374151;
    padding: 0.6rem 0.9rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    line-height: 1.55;
    max-height: 78px;
    overflow-y: auto;
    flex-shrink: 0;
    font-style: italic;
}
.dark .comment-verse-text {
    color: #cbd5e1;
    background: #0f172a;
    border-color: #334155;
}

.comment-guest-msg {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #92400e;
    background: #fef3c7;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid #fde68a;
    flex-shrink: 0;
}
.dark .comment-guest-msg {
    background: #292524;
    color: #fbbf24;
    border-color: #44403c;
}

.comment-textarea {
    flex: 1;
    min-height: 110px;
    max-height: 220px;
    resize: none;
    border: none;
    padding: 0.75rem 0.9rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: #1f2937;
    background: #fff;
    outline: none;
    font-family: inherit;
}
.dark .comment-textarea {
    background: #1e293b;
    color: #e2e8f0;
}

.comment-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.9rem;
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
    gap: 0.5rem;
}
.dark .comment-footer {
    background: #0f172a;
    border-color: #334155;
}

.comment-btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #fca5a5;
    background: #fff;
    color: #ef4444;
    cursor: pointer;
    transition: background 0.15s;
}
.comment-btn-delete:hover { background: #fee2e2; }
.dark .comment-btn-delete { background: #1e293b; border-color: #7f1d1d; color: #f87171; }
.dark .comment-btn-delete:hover { background: #2d1515; }
.comment-btn-delete.hidden { display: none !important; }

.comment-btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 1.1rem;
    border-radius: 8px;
    border: none;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    margin-left: auto;
    transition: background 0.15s;
}
.comment-btn-save:hover { background: #1d4ed8; }
.comment-btn-save:disabled { opacity: 0.6; cursor: default; }

.assistant-quick-actions {
    display: flex;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.dark .assistant-quick-actions {
    border-color: #2d3748;
}
.assistant-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.assistant-quick-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}
.dark .assistant-quick-btn {
    background: #1e2d45;
    border-color: #2d4a7a;
    color: #93c5fd;
}
.dark .assistant-quick-btn:hover {
    background: #243553;
}

.assistant-input-row {
    display: flex;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.dark .assistant-input-row {
    border-color: #2d3748;
}
.assistant-input {
    flex: 1;
    font-size: 0.78rem;
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s;
}
.assistant-input:focus {
    border-color: #2563eb;
    background: #fff;
}
.dark .assistant-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
.dark .assistant-input:focus {
    border-color: #3b82f6;
    background: #1e293b;
}
.assistant-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.assistant-send-btn:hover {
    background: #1d4ed8;
}

.pane-close-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    color: #9ca3af;
    transition: color 0.2s, background 0.2s;
    font-size: 1rem;
}

.pane-close-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    padding-bottom: 5.5rem;
    background: #ffffff;
    color: #111827;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dark .pane-content {
    background: #111827;
    color: #f3f4f6;
}

/* Mobile pane tabs */
.mobile-pane-tabs {
    display: flex;
    background: white;
    border-bottom: 2px solid #e5e7eb;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}

.mobile-pane-tabs::-webkit-scrollbar {
    display: none;
}

.dark .mobile-pane-tabs {
    background: #1f2937;
    border-bottom-color: #374151;
}

.pane-tab {
    flex: 1;
    min-width: 4rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
    text-align: center;
}

.pane-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.dark .pane-tab {
    color: #9ca3af;
}

.dark .pane-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* Disabled add button */
#addPaneBtn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .reading-pane {
        display: none;
    }

    .reading-pane.active {
        display: flex;
    }

    .mobile-pane-tabs.has-multiple {
        display: flex;
    }
}

