/* ============================================================
   KJV Bible Reader — Notes Workspace
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --font-primary:       'EB Garamond', Georgia, 'Times New Roman', serif;
    --color-bg:           #fdfcf8;
    --color-text:         #2c2416;
    --color-text-muted:   #6b5c4a;
    --color-header-bg:    #f5f3ee;
    --color-border:       #e0dcd3;
    --color-link:         #7b5e3a;
    --color-accent:       #d4a84b;
    --color-accent-light: rgba(212, 168, 75, 0.12);
}

html { font-size: 18px; }

body {
    font-family: var(--font-primary);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ───────────────────────────────────────────── */
.dash-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 2rem;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
}
.nav-logo:hover { color: var(--color-link); text-decoration: none; }
.logo-mark { color: var(--color-accent); }

.nav-links { display: flex; align-items: center; gap: 1.25rem; }

.nav-user {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-style: italic;
    text-decoration: none;
}
.nav-user:hover { color: var(--color-text); text-decoration: none; }

.nav-link {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-decoration: none;
}
.nav-link:hover { color: var(--color-text); text-decoration: none; }

.btn-nav {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    padding: 0.4rem 1.1rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 150ms ease;
}
.btn-nav:hover { background: #6a5132; text-decoration: none; color: #fff; }

.nav-signout {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    padding: 0;
}
.nav-signout:hover { color: var(--color-text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    border: 1px solid var(--color-link);
    cursor: pointer;
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-primary:hover { background: #6a5132; text-decoration: none; color: #fff; }

.btn-secondary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: transparent;
    color: var(--color-link);
    border: 1px solid var(--color-link);
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--color-accent-light); text-decoration: none; }


.btn-nav {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    padding: 0.4rem 1.1rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 150ms ease;
}
.btn-nav:hover { background: #6a5132; text-decoration: none; color: #fff; }

.nav-signout {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    padding: 0;
}
.nav-signout:hover { color: var(--color-text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    border: 1px solid var(--color-link);
    cursor: pointer;
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-primary:hover { background: #6a5132; text-decoration: none; color: #fff; }

.btn-secondary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: transparent;
    color: var(--color-link);
    border: 1px solid var(--color-link);
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--color-accent-light); text-decoration: none; }

/* ── Main layout ──────────────────────────────────────────── */
.dash-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

.btn-primary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    border: 1px solid var(--color-link);
    cursor: pointer;
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-primary:hover { background: #6a5132; text-decoration: none; color: #fff; }

.btn-secondary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: transparent;
    color: var(--color-link);
    border: 1px solid var(--color-link);
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--color-accent-light); text-decoration: none; }

/* ── Main layout ──────────────────────────────────────────── */
.dash-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

.btn-secondary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: transparent;
    color: var(--color-link);
    border: 1px solid var(--color-link);
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--color-accent-light); text-decoration: none; }

/* ── Main layout ──────────────────────────────────────────── */
.dash-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

.nav-signout {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    padding: 0;
}
.nav-signout:hover { color: var(--color-text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    border: 1px solid var(--color-link);
    cursor: pointer;
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-primary:hover { background: #6a5132; text-decoration: none; color: #fff; }

.btn-secondary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: transparent;
    color: var(--color-link);
    border: 1px solid var(--color-link);
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--color-accent-light); text-decoration: none; }

/* ── Main layout ──────────────────────────────────────────── */
.dash-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

/* ── Sermon Notes ─────────────────────────────────────────── */
.sermon-notes-list { display: flex; flex-direction: column; }

.sermon-note-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
}
.sermon-note-row:last-child { border-bottom: none; }
.sermon-note-row:hover .sermon-note-row-title { color: var(--color-link); }

.sermon-note-row-title {
    font-size: 1rem;
    font-weight: 500;
    transition: color 150ms ease;
}

.sermon-note-row-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.sermon-note-row-snippet {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.1rem;
}

.sermon-notes-empty {
    padding: 2rem 0;
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}


/* ── Sermon Note Editor Modal ─────────────────────────────── */
.note-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 36, 22, 0.45);
    z-index: 350;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.note-editor-overlay[hidden] { display: none; }

.note-editor-modal {
    background: var(--color-bg);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.note-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.note-editor-header h2 { font-size: 1.1rem; font-weight: 500; }

#sermon-note-close {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.25rem;
    line-height: 1;
}
#sermon-note-close:hover { color: var(--color-text); }

.note-editor-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.sermon-note-view-title {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

#sermon-note-title-input {
    width: 100%;
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}
#sermon-note-title-input:focus,
#sermon-note-textarea:focus {
    outline: none;
    border-color: var(--color-link);
}

#sermon-note-textarea {
    width: 100%;
    min-height: 260px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
    resize: vertical;
    line-height: 1.5;
}

.note-char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    margin-bottom: 1rem;
}

.chapter-note-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}
.chapter-note-hint code {
    background: var(--color-header-bg);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

.note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
#sermon-note-view-actions[hidden],
#sermon-note-view[hidden],
#sermon-note-edit[hidden] {
    display: none;
}

.note-actions button {
    font-family: var(--font-primary);
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
    cursor: pointer;
    transition: all 150ms ease;
}
.note-actions button:hover { background: var(--color-header-bg); }

.note-actions button.primary {
    background: var(--color-link);
    border-color: var(--color-link);
    color: white;
}
.note-actions button.primary:hover { background: #6a5132; border-color: #6a5132; }

.note-actions button.danger {
    color: #a03e3e;
    border-color: #a03e3e;
    margin-right: auto;
}
.note-actions button.danger:hover { background: #a03e3e; color: white; }

/* Rendered markdown-lite note view (shared with reader's note-editor markup) */
.note-markdown {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 1rem;
    line-height: 1.6;
}
.note-markdown h4, .note-markdown h5, .note-markdown h6 {
    font-weight: 600;
    margin: 0.75em 0 0.35em;
}
.note-markdown h4 { font-size: 1.15rem; }
.note-markdown h5 { font-size: 1.05rem; }
.note-markdown h6 { font-size: 0.95rem; }
.note-markdown p { margin-bottom: 0.75em; }
.note-markdown ul, .note-markdown ol { margin: 0 0 0.75em 1.5em; }
.note-markdown li { margin-bottom: 0.25em; }

.note-verse-link, .note-collection-link, .note-passage-link, .note-range-link {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.note-verse-link:hover, .note-collection-link:hover, .note-passage-link:hover, .note-range-link:hover { color: var(--color-text); }

.note-insert-passage-btn {
    margin-right: auto;
}

/* Insert Scripture picker */
.passage-insert-search {
    display: block;
    width: 100%;
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    box-sizing: border-box;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
}

.passage-insert-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0 0 0.65rem;
    border-bottom: 1px solid var(--color-border);
}

.passage-insert-tab {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.passage-insert-tab:hover { color: var(--color-text); }

.passage-insert-tab.active {
    color: var(--color-text);
    border-bottom-color: var(--color-link);
}

.passage-insert-badge {
    display: inline-block;
    margin-left: 0.45rem;
    font-size: 0.7rem;
    color: var(--color-link);
    vertical-align: middle;
}

.collections-empty {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.collections-count {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.collections-list {
    max-height: min(45vh, 360px);
    overflow-y: auto;
}

.passage-insert-row {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 0.35rem;
    font-family: var(--font-primary);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    color: inherit;
}

.passage-insert-row:hover {
    border-color: var(--color-link);
}

.search-result-item,
.passage-insert-verse-hit {
    display: block;
    width: 100%;
    text-align: left;
    font-family: var(--font-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: 0.65rem 0.15rem;
    cursor: pointer;
    color: inherit;
}

.search-result-item:hover,
.passage-insert-verse-hit:hover {
    background: var(--color-accent-light);
}

.search-result-ref {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.search-result-text {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.search-result-text mark {
    background: var(--color-accent-light);
    color: var(--color-text);
}

.passage-insert-back {
    display: block;
    margin: 0 0 0.5rem;
    padding: 0;
    border: none;
    background: none;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    color: var(--color-link);
    cursor: pointer;
    text-align: left;
}

.passage-insert-back:hover { text-decoration: underline; }

.passage-insert-expand-hint {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.passage-insert-chapters {
    max-height: min(45vh, 360px);
    overflow-y: auto;
    margin: 0 -0.25rem 0.5rem;
}

.passage-picker-loading {
    padding: 1rem 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.pp-chapter-section { margin-bottom: 0.75rem; }

.pp-chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.25rem;
}

.pp-chapter-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.pp-select-all-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.pp-verse-row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.3rem 0.25rem;
    cursor: pointer;
}

.pp-verse-row:hover { background: var(--color-accent-light); }

.pp-verse-cb {
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--color-link);
}

.pp-verse-num {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    min-width: 1.5rem;
    text-align: right;
}

.pp-verse-text {
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.45;
}

.passage-insert-save {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--color-border);
}

.passage-insert-save[hidden] {
    display: none;
}

.passage-insert-save-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}

.passage-insert-save-check input {
    accent-color: var(--color-link);
    cursor: pointer;
}

.passage-insert-title {
    flex: 1 1 12rem;
    min-width: 10rem;
    padding: 0.4rem 0.65rem;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
}

.passage-insert-title:disabled {
    opacity: 0.55;
}

.passage-insert-expand-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.75rem;
    border-top: none;
}

.passage-insert-confirm-btn {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    cursor: pointer;
}

.passage-insert-confirm-btn:hover:not(:disabled) {
    background: #6a5132;
}

.passage-insert-confirm-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-bg);
    padding: 0.6rem 1.25rem;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 500;
    opacity: 1;
    transition: opacity 400ms ease, transform 400ms ease;
    white-space: nowrap;
    pointer-events: none;
}

.toast.toast-hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(0.5rem);
}


/* ── Notes workspace layout ───────────────────────────────── */
.notes-workspace {
    display: flex;
    height: calc(100vh - 3.6rem);
    max-width: none;
    margin: 0;
    overflow: hidden;
}

.notes-sidebar {
    flex: 0 0 320px;
    width: 320px;
    border-right: 1px solid var(--color-border);
    background: var(--color-header-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notes-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.notes-sidebar-title {
    font-size: 1.25rem;
    font-weight: 500;
}

.notes-sidebar .sermon-notes-list {
    overflow-y: auto;
    flex: 1 1 auto;
    padding: 0.35rem 0.5rem 1rem;
}

.notes-sidebar .sermon-notes-empty {
    padding: 1.25rem 1.1rem;
}

.sermon-note-row {
    width: 100%;
    text-align: left;
    font-family: var(--font-primary);
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 0.75rem 0.7rem;
    border-bottom: none;
}

.sermon-note-row + .sermon-note-row {
    margin-top: 0.15rem;
}

.sermon-note-row.active,
.sermon-note-row:hover {
    background: rgba(123, 94, 58, 0.08);
}

.sermon-note-row.active .sermon-note-row-title {
    color: var(--color-link);
}

.notes-pane {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

.notes-pane-empty {
    margin: auto;
    color: var(--color-text-muted);
    font-style: italic;
    padding: 2rem;
}

.notes-pane-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 1.25rem 1.75rem 1.5rem;
    overflow: hidden;
}

.notes-pane-body[hidden] { display: none !important; }

.notes-pane-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.notes-pane-header h2,
.sermon-note-view-title {
    font-size: 1.35rem;
    font-weight: 500;
    margin: 0;
}

.notes-pane .note-markdown {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: none;
}

.notes-pane-edit #sermon-note-title-input {
    width: 100%;
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 500;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}

.notes-pane-edit #sermon-note-textarea {
    flex: 1 1 auto;
    width: 100%;
    min-height: 280px;
    font-family: var(--font-primary);
    font-size: 0.98rem;
    line-height: 1.55;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
    resize: none;
}

.notes-pane-edit #sermon-note-title-input:focus,
.notes-pane-edit #sermon-note-textarea:focus {
    outline: none;
    border-color: var(--color-link);
}

@media (max-width: 900px) {
    .notes-workspace {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 3.6rem);
    }
    .notes-sidebar {
        flex: none;
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .notes-pane {
        min-height: 60vh;
    }
}
