/* ═══════════════════════════════════════════════════════════════════════════
   Study Page — Bookmarks, Notes, Reading Plans
   ═══════════════════════════════════════════════════════════════════════════ */

/* Dark-mode aliases — these must be defined here since core.css only
   redefines the standard --color-* vars inside .dark-mode.
   Values here mirror core.css .dark-mode block. */
.dark-mode {
    --dm-surface: #1a1230;
    --dm-border: #3a2d55;
    --dm-text: #e8e4f0;
    --dm-text-muted: #a8a0c0;
    --dm-primary: #9d7bd4;
}

html, body {
    overflow-y: auto !important;
    height: auto !important;
}

/* ── Layout ── */
.study-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--color-bg);
}

.study-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.study-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.study-header .back-link {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
}
.study-header .back-link:hover { text-decoration: underline; }

.study-header h1 {
    font-size: 1.6rem;
    color: var(--color-primary-dark);
    margin: 0;
}

.dark-mode .study-header {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}
.dark-mode .study-header h1 {
    color: var(--dm-primary);
}

/* ── Navigation Tabs ── */
.study-nav {
    display: flex;
    gap: 2px;
    padding: 0 24px;
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
}

.study-nav-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--color-text-light);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -2px;
}

.study-nav-tab:hover {
    color: var(--color-primary);
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.05));
}

.study-nav-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.study-nav-tab .tab-count {
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.1));
    color: var(--color-primary);
    font-size: 0.75rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.dark-mode .study-nav {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}
.dark-mode .study-nav-tab {
    color: var(--dm-text-muted);
}
.dark-mode .study-nav-tab:hover {
    color: var(--dm-primary);
    background: rgba(99, 102, 241, 0.08);
}
.dark-mode .study-nav-tab.active {
    color: var(--dm-primary);
    border-bottom-color: var(--dm-primary);
}

/* ── Main Content Area ── */
.study-body {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.study-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.study-section {
    display: none;
}
.study-section.active {
    display: block;
}

/* ── Section Headers ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.3rem;
    color: var(--color-primary-dark);
    margin: 0;
}

.section-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dark-mode .section-header h2 {
    color: var(--dm-primary);
}

/* ── Bookmarks Grid ── */
.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.bookmark-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.bookmark-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1));
    transform: translateY(-1px);
}

.bookmark-card .bm-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.bookmark-card .bm-body {
    flex: 1;
    min-width: 0;
}

.bookmark-card .bm-name {
    font-weight: 600;
    color: var(--color-text);
    font-size: 1rem;
    margin-bottom: 4px;
}

.bookmark-card .bm-type {
    color: var(--color-text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bookmark-card .bm-note {
    color: var(--color-text-light);
    font-size: 0.85rem;
    margin-top: 4px;
    font-style: italic;
}

.bookmark-card .bm-time {
    color: var(--color-text-muted, #999);
    font-size: 0.75rem;
    margin-top: 6px;
}

.bookmark-card .bm-actions {
    display: flex;
    gap: 4px;
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}

.bookmark-card:hover .bm-actions {
    opacity: 1;
}

.bookmark-card .bm-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    border-radius: 4px;
    opacity: 0.7;
}
.bookmark-card .bm-actions button:hover {
    opacity: 1;
    background: rgba(0,0,0,0.05);
}

.dark-mode .bookmark-card {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}
.dark-mode .bookmark-card:hover {
    border-color: var(--dm-primary);
}
.dark-mode .bookmark-card .bm-name {
    color: var(--dm-text);
}
.dark-mode .bookmark-card .bm-type,
.dark-mode .bookmark-card .bm-note {
    color: var(--dm-text-muted);
}

/* ── Notes: Full-Width Cards ── */
.notes-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.study-section .note-topic-group {
    margin-bottom: 16px;
}

.study-section .note-topic-header {
    padding: 10px 14px;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.06));
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--color-border);
    border-bottom: none;
}

.study-section .note-item {
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-top: none;
    background: var(--color-surface);
}
.study-section .note-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.dark-mode .study-section .note-topic-header {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--dm-border);
}
.dark-mode .study-section .note-item {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

/* ── Plans: Full-Width Cards ── */
.study-section .plan-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}

.study-section .plan-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1));
}

.dark-mode .study-section .plan-item {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}
.dark-mode .study-section .plan-item:hover {
    border-color: var(--dm-primary);
}

.study-section .plan-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.study-section .plan-detail-header h3 {
    margin: 0;
    color: var(--color-primary-dark);
}

.dark-mode .study-section .plan-detail-header h3 {
    color: var(--dm-primary);
}

/* ── Bible Slide-Out Panel ── */
.bible-slideout {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: var(--color-surface);
    border-left: 2px solid var(--color-border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 500;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.bible-slideout.open {
    right: 0;
}

.bible-slideout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.04));
    flex-shrink: 0;
}

.bible-slideout-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-primary-dark);
}

.bible-slideout-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 4px 8px;
    border-radius: 4px;
}
.bible-slideout-close:hover {
    background: rgba(0,0,0,0.08);
}

.bible-slideout-controls {
    padding: 12px 18px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.bible-slideout-controls input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--color-bg);
    color: var(--color-text);
}

.bible-slideout-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
}

.bible-slideout-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.dark-mode .bible-slideout {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}
.dark-mode .bible-slideout-header {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--dm-border);
}
.dark-mode .bible-slideout-header h3 {
    color: var(--dm-primary);
}
.dark-mode .bible-slideout-close {
    color: var(--dm-text-muted);
}
.dark-mode .bible-slideout-controls {
    border-color: var(--dm-border);
}
.dark-mode .bible-slideout-controls input {
    background: var(--dm-bg, #1a1a2e);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
.dark-mode .bible-slideout-body {
    color: var(--dm-text);
}
.dark-mode .bible-slideout-nav {
    border-color: var(--dm-border);
}

/* Backdrop overlay when slideout is open */
.bible-slideout-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 499;
}
.bible-slideout-backdrop.open {
    display: block;
}

/* ── Bookmark Slideout (smaller) ── */
.bookmark-slideout {
    position: fixed;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100vh;
    background: var(--color-surface);
    border-left: 2px solid var(--color-border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 500;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.bookmark-slideout.open {
    right: 0;
}

.bookmark-slideout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--color-border);
}

.bookmark-slideout-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-primary-dark);
}

.bookmark-slideout-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}

.bookmark-slideout-body .bm-detail-type {
    color: var(--color-text-light);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.bookmark-slideout-body .bm-detail-note {
    color: var(--color-text);
    font-style: italic;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.04));
    border-radius: var(--radius);
}

.bookmark-slideout-body .bm-detail-time {
    color: var(--color-text-muted, #999);
    font-size: 0.85rem;
}

.bookmark-slideout-actions {
    display: flex;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--color-border);
}

.dark-mode .bookmark-slideout {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}
.dark-mode .bookmark-slideout-header h3 {
    color: var(--dm-primary);
}
.dark-mode .bookmark-slideout-body {
    color: var(--dm-text);
}
.dark-mode .bookmark-slideout-body .bm-detail-note {
    background: rgba(99, 102, 241, 0.08);
    color: var(--dm-text);
}
.dark-mode .bookmark-slideout-actions {
    border-color: var(--dm-border);
}

/* ── Entity Explore Slide-Out ── */
.explore-slideout {
    position: fixed;
    top: 0;
    right: -460px;
    width: 460px;
    max-width: 90vw;
    height: 100vh;
    background: var(--color-surface);
    border-left: 2px solid var(--color-border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.18);
    z-index: 510;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.explore-slideout.open {
    right: 0;
}

.explore-slideout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.04));
    flex-shrink: 0;
}

.explore-slideout-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-primary-dark);
}

.explore-slideout-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.explore-slideout-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}

/* Entity detail card inside explore slideout */
.explore-entity-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.explore-entity-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.08));
    flex-shrink: 0;
}

.explore-entity-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.explore-entity-type {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-light);
    margin-top: 2px;
}

.explore-description {
    color: var(--color-text);
    margin-bottom: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 12px;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.04));
    border-radius: var(--radius);
    border-left: 3px solid var(--color-primary);
}

.explore-detail-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.9rem;
}

.explore-detail-label {
    font-weight: 600;
    color: var(--color-text-light);
    min-width: 100px;
    flex-shrink: 0;
}

.explore-detail-value {
    color: var(--color-text);
}

.explore-verse-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--color-primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    transition: color 0.15s;
}

.explore-verse-link:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.explore-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-primary);
    margin: 20px 0 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--color-primary);
}

.explore-rel-group {
    margin-bottom: 12px;
}

.explore-rel-type {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 4px;
}

.explore-rel-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.explore-rel-item {
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--color-primary);
    cursor: pointer;
    transition: background 0.1s;
}

.explore-rel-item:hover {
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.08));
}

.explore-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.explore-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-light);
}

.explore-loading::after {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 16px auto 0;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Dark mode explore slideout */
.dark-mode .explore-slideout {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

.dark-mode .explore-slideout-header {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--dm-border);
}

.dark-mode .explore-slideout-header h3 {
    color: var(--dm-primary);
}

.dark-mode .explore-entity-name {
    color: var(--dm-text);
}

.dark-mode .explore-entity-type {
    color: var(--dm-text-muted);
}

.dark-mode .explore-description {
    color: var(--dm-text);
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--dm-primary);
}

.dark-mode .explore-detail-label {
    color: var(--dm-text-muted);
}

.dark-mode .explore-detail-value {
    color: var(--dm-text);
}

.dark-mode .explore-detail-row {
    border-color: rgba(255,255,255,0.05);
}

.dark-mode .explore-section-title {
    color: var(--dm-primary);
    border-color: var(--dm-primary);
}

.dark-mode .explore-rel-item {
    color: var(--dm-primary);
}

.dark-mode .explore-rel-item:hover {
    background: rgba(99, 102, 241, 0.12);
}

.dark-mode .explore-actions {
    border-color: var(--dm-border);
}

.dark-mode .explore-verse-link {
    color: var(--dm-primary);
}

/* ── Empty State ── */
.study-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
}

.study-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.study-empty h3 {
    margin: 0 0 8px;
    color: var(--color-text);
}
.study-empty p {
    max-width: 400px;
    margin: 0 auto;
}

.dark-mode .study-empty {
    color: var(--dm-text-muted);
}
.dark-mode .study-empty h3 {
    color: var(--dm-text);
}

/* ── Note Editor (full width on study page) ── */
.study-section .note-editor {
    max-width: 800px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.dark-mode .study-section .note-editor {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

/* ── Passage Cards in Study Page ── */
.study-section .plan-passage-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    transition: all 0.15s;
}

.study-section .plan-passage-card:hover {
    border-color: var(--color-primary);
}

.dark-mode .study-section .plan-passage-card {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

/* ── Bible Content Styles (inside slideout) ── */
.bible-slideout-body .verse-num {
    font-weight: 700;
    color: var(--color-primary);
    margin-right: 4px;
    font-size: 0.8em;
    vertical-align: super;
}

.bible-slideout-body .verse-text {
    margin-bottom: 4px;
}

.bible-slideout-body h3 {
    color: var(--color-primary-dark);
    margin: 16px 0 8px;
    font-size: 1.1rem;
}

.dark-mode .bible-slideout-body h3 {
    color: var(--dm-primary);
}
.dark-mode .bible-slideout-body .verse-num {
    color: var(--dm-primary);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .study-header {
        padding: 12px 16px;
    }
    .study-header h1 {
        font-size: 1.2rem;
    }
    .study-nav {
        padding: 0 12px;
        overflow-x: auto;
    }
    .study-nav-tab {
        padding: 10px 16px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    .study-content {
        padding: 16px;
    }
    .bookmarks-grid {
        grid-template-columns: 1fr;
    }
    .bible-slideout {
        width: 100%;
        right: -100%;
    }
    .bookmark-slideout {
        width: 100%;
        right: -100%;
    }
    .explore-slideout {
        width: 100%;
        right: -100%;
    }
}

/* ── Footer ── */
.study-footer {
    padding: 12px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted, #999);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.dark-mode .study-footer {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text-muted);
}

/* ── AI Clarification / Suggestion UI ── */
.plan-ai-clarification {
    padding: 16px;
    text-align: left;
}

.plan-ai-clarification h4 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.plan-ai-clarification p {
    margin: 0 0 12px;
    line-height: 1.5;
    color: var(--color-text, #333);
}

.dark-mode .plan-ai-clarification p {
    color: #ccc;
}

.plan-ai-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted, #888);
    font-style: italic;
}

.plan-ai-suggestions {
    margin: 12px 0;
}

.plan-ai-suggestions strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.plan-ai-suggestions ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.plan-ai-suggestion-item {
    padding: 8px 14px;
    background: var(--color-surface-hover, #f0f0f0);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 0.9rem;
}

.plan-ai-suggestion-item:hover {
    background: var(--color-primary-light, #e8e0ff);
    border-color: var(--color-primary, #6366f1);
}

.dark-mode .plan-ai-suggestion-item {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
    color: #ddd;
}

.dark-mode .plan-ai-suggestion-item:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
}

/* ═══════════════════════════════════════════════════════════════════════
   Bible Tab (Full Reader on Study Page)
   ═══════════════════════════════════════════════════════════════════════ */

.study-bible-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 0;
    flex-wrap: wrap;
}

.study-bible-ref-input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--color-bg);
    color: var(--color-text);
}

.dark-mode .study-bible-ref-input {
    background: var(--dm-bg, #1a1a2e);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

.study-bible-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 12px;
}

.study-bible-current {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary-dark);
}
.dark-mode .study-bible-current {
    color: var(--dm-primary);
}

.study-bible-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 300px;
    max-height: calc(100vh - 340px);
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.dark-mode .study-bible-content {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

.study-bible-content .bible-verse,
.study-bible-content .verse-text {
    margin-bottom: 4px;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
    cursor: context-menu;
}

.study-bible-content .verse-num {
    font-weight: 700;
    color: var(--color-primary);
    margin-right: 4px;
    font-size: 0.8em;
    vertical-align: super;
}

.dark-mode .study-bible-content .verse-num {
    color: var(--dm-primary);
}

.study-bible-content .bible-verse-highlighted {
    background: rgba(255, 255, 0, 0.15);
    border-radius: 3px;
    padding: 4px 6px;
    margin: 2px -6px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Reading Theme Panel
   ═══════════════════════════════════════════════════════════════════════ */

.reading-theme-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.dark-mode .reading-theme-panel {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

.theme-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.theme-row:last-child {
    margin-bottom: 0;
}

.theme-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 80px;
}

.dark-mode .theme-row label {
    color: var(--dm-text);
}

.theme-row input[type="range"] {
    flex: 1;
    max-width: 200px;
    accent-color: var(--color-primary);
}

.theme-row span {
    font-size: 0.8rem;
    color: var(--color-text-light);
    min-width: 40px;
}

.theme-color-swatches {
    display: flex;
    gap: 6px;
}

.theme-swatch {
    width: 32px;
    height: 32px;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    background: var(--color-surface);
}

.theme-swatch:hover {
    border-color: var(--color-primary);
    transform: scale(1.1);
}

.theme-swatch.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
}

.dark-mode .theme-swatch {
    border-color: var(--dm-border);
    background: var(--dm-surface);
}

.dark-mode .theme-swatch.active {
    border-color: var(--dm-primary);
    box-shadow: 0 0 0 2px var(--dm-primary);
}

/* ═══════════════════════════════════════════════════════════════════════
   Context Menu (right-click on verses)
   ═══════════════════════════════════════════════════════════════════════ */

.study-context-menu {
    position: fixed;
    z-index: 1000;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 4px 0;
    min-width: 200px;
    max-width: 280px;
}

.dark-mode .study-context-menu {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.study-ctx-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.1s;
}

.study-ctx-item:hover {
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.08));
    color: var(--color-primary);
}

.dark-mode .study-ctx-item {
    color: var(--dm-text);
}

.dark-mode .study-ctx-item:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--dm-primary);
}

.study-ctx-sep {
    height: 1px;
    background: var(--color-border);
    margin: 4px 8px;
}

.dark-mode .study-ctx-sep {
    background: var(--dm-border);
}

/* ═══════════════════════════════════════════════════════════════════════
   Verse Highlighting
   ═══════════════════════════════════════════════════════════════════════ */

.verse-highlighted {
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════
   Entity Tooltip (floating tooltip on entity click)
   ═══════════════════════════════════════════════════════════════════════ */

.study-entity-tooltip {
    position: fixed;
    z-index: 600;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 14px 16px;
    min-width: 220px;
    max-width: 340px;
    animation: fadeInUp 0.15s ease;
}

.dark-mode .study-entity-tooltip {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.set-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 10px;
}

.dark-mode .set-header {
    color: var(--dm-text);
}

.set-type {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
}

.set-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.set-actions .btn {
    font-size: 0.8rem;
    padding: 4px 10px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Entity Links in Bible text (study page versions)
   ═══════════════════════════════════════════════════════════════════════ */

.bible-entity-link {
    color: var(--color-primary);
    cursor: pointer;
    border-bottom: 1px dotted var(--color-primary);
    transition: all 0.15s;
    padding: 0 1px;
}

.bible-entity-link:hover {
    background: rgba(99, 102, 241, 0.08);
    border-bottom-style: solid;
}

.bible-entity-link.active {
    background: rgba(99, 102, 241, 0.15);
    border-bottom-style: solid;
    border-radius: 2px;
}

.dark-mode .bible-entity-link {
    color: var(--dm-primary);
    border-bottom-color: var(--dm-primary);
}

/* ═══════════════════════════════════════════════════════════════════════
   Toast Notification
   ═══════════════════════════════════════════════════════════════════════ */

.study-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-primary-dark, #4338ca);
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.study-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════
   Entity Autocomplete Dropdown (in notes editor)
   ═══════════════════════════════════════════════════════════════════════ */

.entity-ac-dropdown {
    position: fixed;
    z-index: 700;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    min-width: 220px;
    max-width: 320px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.dark-mode .entity-ac-dropdown {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.eac-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text);
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.eac-item:hover,
.eac-item.active {
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.08));
    color: var(--color-primary);
}

.dark-mode .eac-item {
    color: var(--dm-text);
}

.dark-mode .eac-item:hover,
.dark-mode .eac-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--dm-primary);
}

.eac-type {
    font-size: 0.75rem;
    color: var(--color-text-muted, #999);
    margin-left: auto;
}

/* Note entity tags (inline in contenteditable) */
.note-entity-tag {
    display: inline-block;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.1));
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.85em;
    color: var(--color-primary);
    font-weight: 500;
    cursor: default;
    user-select: none;
    vertical-align: baseline;
    margin: 0 2px;
}

.dark-mode .note-entity-tag {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--dm-primary);
    color: var(--dm-primary);
}

/* ═══════════════════════════════════════════════════════════════════════
   Plan Day Detail (enhanced view with notes + AI)
   ═══════════════════════════════════════════════════════════════════════ */

.plan-day-detail {
    max-width: 800px;
    margin: 0 auto;
}

.plan-day-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.plan-day-detail-header h3 {
    margin: 0;
    color: var(--color-primary-dark);
    font-size: 1.2rem;
}

.dark-mode .plan-day-detail-header h3 {
    color: var(--dm-primary);
}

.plan-day-passages-detail {
    margin-bottom: 24px;
}

.plan-passage-detail-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    transition: all 0.15s;
}

.plan-passage-detail-card:hover {
    border-color: var(--color-primary);
}

.dark-mode .plan-passage-detail-card {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

.plan-day-notes-section,
.plan-day-ai-section {
    margin-bottom: 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.dark-mode .plan-day-notes-section,
.dark-mode .plan-day-ai-section {
    background: var(--dm-surface);
    border-color: var(--dm-border);
}

.plan-day-notes-section h4,
.plan-day-ai-section h4 {
    margin: 0 0 12px;
    font-size: 1rem;
    color: var(--color-primary-dark);
}

.dark-mode .plan-day-notes-section h4,
.dark-mode .plan-day-ai-section h4 {
    color: var(--dm-primary);
}

.plan-day-note-editor {
    min-height: 100px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    background: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 10px;
}

.plan-day-note-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--color-text-muted, #999);
}

.plan-day-note-editor:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.dark-mode .plan-day-note-editor {
    background: var(--dm-bg, #1a1a2e);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

.plan-day-ai-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.plan-day-ai-prompt {
    flex: 1;
}

.plan-day-ai-response {
    min-height: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-text);
}

.plan-day-ai-response:empty {
    display: none;
}

.dark-mode .plan-day-ai-response {
    color: var(--dm-text);
}

.plan-ai-answer {
    padding: 12px;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.04));
    border-radius: var(--radius);
    border-left: 3px solid var(--color-primary);
}

.dark-mode .plan-ai-answer {
    background: rgba(99, 102, 241, 0.08);
}

.plan-day-open-btn {
    margin-left: auto;
    font-size: 0.75rem !important;
    padding: 2px 8px !important;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.plan-day-header:hover .plan-day-open-btn {
    opacity: 1;
}

/* Plan picker modal for context menu */
.plan-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.plan-picker-item {
    text-align: left !important;
    padding: 10px 14px !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   Study Header: Dark Toggle + Profile
   ═══════════════════════════════════════════════════════════════════════ */

.study-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.study-header-right .btn-header {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--color-text);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.study-header-right .btn-header:hover {
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.08));
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.dark-mode .study-header-right .btn-header {
    border-color: var(--dm-border);
    color: var(--dm-text);
}

.dark-mode .study-header-right .btn-header:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--dm-primary);
    color: var(--dm-primary);
}

/* ═══════════════════════════════════════════════════════════════════════
   Bible Slideout: Header Actions (Theme + Close)
   ═══════════════════════════════════════════════════════════════════════ */

.bible-slideout-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bible-slideout-header-actions .btn-secondary {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 5px;
    background: var(--color-accent-bg, rgba(99, 102, 241, 0.08));
    border: 1px solid var(--color-border);
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.15s;
}

.bible-slideout-header-actions .btn-secondary:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--color-primary);
}

.dark-mode .bible-slideout-header-actions .btn-secondary {
    background: rgba(99, 102, 241, 0.12);
    border-color: var(--dm-border);
    color: var(--dm-primary);
}

/* Slideout cloned theme panel */
.bible-slideout-body .reading-theme-panel {
    margin: 0;
    border-radius: 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.dark-mode .bible-slideout-body .reading-theme-panel {
    border-color: var(--dm-border);
}

/* ═══════════════════════════════════════════════════════════════════════
   Note Expand / Collapse
   ═══════════════════════════════════════════════════════════════════════ */

.note-item-body {
    flex: 1;
    min-width: 0;
}

.note-item-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.note-expand-btn {
    display: inline-block;
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 4px 0;
    margin-top: 4px;
    transition: color 0.15s;
}

.note-expand-btn:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.dark-mode .note-expand-btn {
    color: var(--dm-primary);
}

.dark-mode .note-expand-btn:hover {
    color: #a5b4fc;
}

.note-expand-content {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 6px;
    background: var(--color-bg, #f9fafb);
    border: 1px solid var(--color-border);
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--color-text);
}

.dark-mode .note-expand-content {
    background: rgba(0, 0, 0, 0.15);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

.note-expand-html p {
    margin: 0 0 8px;
}

.note-expand-html p:last-child {
    margin-bottom: 0;
}

/* Entity tags in expanded notes should look clickable */
.note-expand-content .note-entity-tag {
    cursor: pointer;
    transition: all 0.15s;
}

.note-expand-content .note-entity-tag:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.dark-mode .note-expand-content .note-entity-tag:hover {
    background: var(--dm-primary);
    color: #fff;
    border-color: var(--dm-primary);
}

.note-item-expanded {
    background: var(--color-surface) !important;
    box-shadow: var(--shadow-sm);
}

.dark-mode .note-item-expanded {
    background: var(--dm-surface) !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   Responsive — new elements
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .study-bible-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .study-bible-controls select {
        width: 100%;
    }
    .study-bible-ref-input {
        min-width: 100%;
    }
    .reading-theme-panel {
        padding: 12px;
    }
    .theme-row {
        flex-wrap: wrap;
    }
    .theme-row label {
        min-width: 60px;
    }
    .study-context-menu {
        left: 10px !important;
        right: 10px !important;
        max-width: none;
    }
    .study-entity-tooltip {
        left: 10px !important;
        right: 10px !important;
        max-width: none;
    }
    .plan-day-ai-input-row {
        flex-direction: column;
    }
    .study-header-right .btn-header {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
    .note-expand-content {
        padding: 10px;
        font-size: 0.88rem;
    }
}
