/* ============================================================
   KJV Bible Website — Book-like Stylesheet
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --parchment:    #FAF6EF;
    --parchment-dk: #F0E8D8;
    --ink:          #2C1E10;
    --ink-light:    #5C4A30;
    --ink-muted:    #8B7355;
    --gold:         #8B6914;
    --gold-light:   #C9A84C;
    --accent:       #6B2D0E;
    --border:       #C8B89A;
    --page-shadow:  rgba(0,0,0,0.35);
    --bg:           #1A0F06;

    --font-body:    Georgia, "Book Antiqua", "Palatino Linotype", serif;
    --font-ui:      "Segoe UI", Tahoma, Geneva, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(80,40,10,0.4) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 30%, rgba(60,30,5,0.3) 0%, transparent 60%);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* ---------- Site Header ---------- */
.site-header {
    background: linear-gradient(180deg, #0D0703 0%, #2A1608 100%);
    border-bottom: 2px solid var(--gold);
    padding: 1.25rem 2rem 0;
    text-align: center;
    flex-shrink: 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-ornament {
    color: var(--gold-light);
    font-size: 1rem;
    opacity: 0.8;
}

.site-title {
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: var(--gold-light);
    font-weight: normal;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.site-title a { color: inherit; text-decoration: none; }
.site-title a:hover { color: #FFD980; text-decoration: none; }

.site-subtitle {
    font-size: 0.78rem;
    color: var(--ink-muted);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-top: 0.1rem;
    flex-basis: 100%;
}

.top-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-top: 0.85rem;
    border-top: 1px solid rgba(200,184,154,0.2);
}

.nav-link {
    display: inline-block;
    padding: 0.45rem 1.5rem;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #C9A84C;
    border-top: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.nav-link:hover, .nav-link.active {
    color: #FFD980;
    border-top-color: var(--gold-light);
    text-decoration: none;
}

/* ---------- Site Footer ---------- */
.site-footer {
    background: #0D0703;
    border-top: 1px solid var(--gold);
    padding: 1rem;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--ink-muted);
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

/* ============================================================
   HOME PAGE
   ============================================================ */
.home-page { }

.home-main {
    flex: 1;
    padding: 2rem 1.5rem 3rem;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.search-bar-home {
    margin: 0 auto 2.5rem;
    max-width: 600px;
    display: flex;
    justify-content: center;
}

.search-bar-home form {
    display: flex;
    width: 100%;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.search-input-home {
    flex: 1;
    padding: 0.65rem 1rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: var(--parchment);
    color: var(--ink);
    border: none;
    outline: none;
}

.search-input-home::placeholder { color: var(--ink-muted); font-style: italic; }

.search-btn-home {
    padding: 0.65rem 1.4rem;
    background: var(--accent);
    color: #FAF0E0;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn-home:hover { background: #8B3A1A; }

.testament-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: start;
}

.testament-divider {
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--gold), transparent);
    min-height: 400px;
    align-self: stretch;
}

.testament-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
    font-family: var(--font-ui);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.testament-rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold));
}

.testament-heading .testament-rule:last-child {
    background: linear-gradient(to left, transparent, var(--gold));
}

.book-list {
    list-style: none;
    columns: 2;
    column-gap: 0.5rem;
}

.book-item { break-inside: avoid; margin-bottom: 0.15rem; }

.book-link {
    display: block;
    padding: 0.28rem 0.6rem;
    color: var(--parchment);
    font-size: 0.88rem;
    border-radius: 2px;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.book-link:hover {
    background: rgba(201, 168, 76, 0.15);
    color: var(--gold-light);
    text-decoration: none;
}

/* ============================================================
   READER PAGE
   ============================================================ */
.reader-page { }

.reader-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #150C04;
    border-right: 1px solid rgba(200,184,154,0.25);
    overflow-y: auto;
    max-height: calc(100vh - 120px);
    position: sticky;
    top: 0;
}

.sidebar-inner { padding: 1rem 0.75rem; }

.sidebar-current-book {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--gold-light);
    letter-spacing: 0.05em;
    text-align: center;
    padding: 0.5rem 0.25rem 0.75rem;
    border-bottom: 1px solid rgba(200,184,154,0.2);
    margin-bottom: 0.75rem;
}

.sidebar-books-accordion {
    margin-top: 1.25rem;
}

.sidebar-books-toggle {
    cursor: pointer;
    list-style: none;
    margin-bottom: 0;
    user-select: none;
    border-bottom: 1px solid rgba(200,184,154,0.2);
    padding-bottom: 0.35rem;
}

.sidebar-books-toggle::-webkit-details-marker { display: none; }

.sidebar-books-accordion[open] .sidebar-books-toggle {
    color: var(--gold-light);
}

.sidebar-heading {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(200,184,154,0.2);
}

.sidebar-testament-label {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: 0.75rem 0 0.3rem;
}

.sidebar-book-list {
    list-style: none;
    margin-bottom: 0.5rem;
}

.sidebar-book-list li { line-height: 1; }

.sidebar-book-list a {
    display: block;
    padding: 0.22rem 0.4rem;
    font-size: 0.8rem;
    color: #C8B89A;
    border-radius: 2px;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
}

.sidebar-book-list a:hover {
    background: rgba(201,168,76,0.1);
    color: var(--gold-light);
    text-decoration: none;
}

.sidebar-book-list li.active a {
    background: rgba(107,45,14,0.35);
    color: var(--gold-light);
    font-weight: bold;
}

.chapter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.chapter-num-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: #C8B89A;
    border: 1px solid rgba(200,184,154,0.2);
    border-radius: 2px;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.chapter-num-link:hover {
    background: rgba(201,168,76,0.15);
    color: var(--gold-light);
    border-color: var(--gold);
    text-decoration: none;
}

.chapter-num-link.active {
    background: var(--accent);
    color: #FAF0E0;
    border-color: var(--accent);
}

/* ---------- Book Page ---------- */
.book-page-wrap {
    flex: 1;
    padding: 2rem 1.5rem 3rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

.book-page {
    background: var(--parchment);
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    color: var(--ink);
    width: 100%;
    max-width: 760px;
    min-height: 80vh;
    padding: 3.5rem 4rem;
    position: relative;
    box-shadow:
        -6px 0 18px -4px rgba(0,0,0,0.5),
        6px 0 18px -4px rgba(0,0,0,0.5),
        0 10px 40px rgba(0,0,0,0.6);
    border: 1px solid var(--border);
}

.book-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50px;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent 5%, rgba(200,184,154,0.4) 15%, rgba(200,184,154,0.4) 85%, transparent 95%);
    pointer-events: none;
}

.book-page-header,
.book-page-footer {
    position: absolute;
    left: 0; right: 0;
    font-family: var(--font-ui);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.book-page-header {
    top: 1.2rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin: 0 3rem;
}

.book-page-footer {
    bottom: 1.2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin: 0 3rem;
}

.chapter-title-block {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-top: 0.5rem;
}

.chapter-ornament {
    color: var(--gold);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.chapter-heading {
    font-size: 1.4rem;
    font-weight: normal;
    letter-spacing: 0.12em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.chapter-number-display {
    font-size: 4rem;
    line-height: 1;
    color: var(--gold);
    font-family: Georgia, serif;
    font-weight: normal;
    margin-top: 0.1rem;
    text-shadow: 1px 1px 0 rgba(139,105,20,0.3);
}

/* ---------- Verses ---------- */
.verses-block {
    font-size: 1.05rem;
    color: var(--ink);
}

.verse-unit {
    display: block;
    line-height: 1.85;
    padding: 0.2rem 0;
}

.no-verses {
    color: var(--ink-muted);
    font-style: italic;
    text-align: center;
    padding: 3rem 0;
}

/* ---------- Page Turn Nav ---------- */
.page-turn-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.page-turn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--parchment-dk);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
    min-width: 100px;
}

.page-turn:hover {
    background: var(--accent);
    color: #FAF0E0;
    border-color: var(--accent);
    text-decoration: none;
}

.page-turn.disabled { visibility: hidden; }

.page-turn .arrow { font-size: 1.2em; line-height: 1; }
.prev-page { justify-content: flex-start; }
.next-page { justify-content: flex-end; }

.current-reference {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: var(--ink-muted);
    letter-spacing: 0.1em;
    text-align: center;
}

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-main {
    flex: 1;
    padding: 2rem 1.5rem 3rem;
}

.search-container {
    max-width: 820px;
    margin: 0 auto;
}

.search-panel {
    background: var(--parchment);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.search-heading {
    font-size: 1.1rem;
    font-weight: normal;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-align: center;
    margin-bottom: 1.25rem;
}

.search-form { display: flex; flex-direction: column; gap: 1rem; }

.search-row {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.search-input {
    flex: 1;
    padding: 0.7rem 1rem;
    font-family: var(--font-body);
    font-size: 1rem;
    background: #FDFAF5;
    color: var(--ink);
    border: none;
    outline: none;
}

.search-input::placeholder { color: var(--ink-muted); font-style: italic; }

.search-btn {
    padding: 0.7rem 1.6rem;
    background: var(--accent);
    color: #FAF0E0;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover { background: #8B3A1A; }

.search-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--ink-light);
}

.book-filter-select {
    flex: 1;
    max-width: 280px;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    background: #FDFAF5;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 3px;
    outline: none;
}

.search-meta { margin-bottom: 1rem; }

.results-count {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--parchment);
    opacity: 0.8;
}

.no-results {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    color: var(--parchment);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.search-error {
    background: rgba(139,45,14,0.2);
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 0.75rem 1rem;
    color: #FFB09A;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ---------- Results ---------- */
.results-list { display: flex; flex-direction: column; gap: 1rem; }

.result-item {
    background: var(--parchment);
    border: 1px solid var(--border);
    border-left: 4px solid var(--gold);
    border-radius: 2px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.result-ref {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.35rem;
    text-decoration: none;
}

.result-ref:hover { color: var(--gold); text-decoration: underline; }

.result-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--ink);
}

.result-text mark {
    background: #F5D76E;
    color: #3B2000;
    border-radius: 2px;
    padding: 0 2px;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--parchment);
    border: 1px solid rgba(200,184,154,0.3);
    border-radius: 2px;
    background: rgba(255,255,255,0.06);
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.page-link:hover {
    background: rgba(201,168,76,0.2);
    color: var(--gold-light);
    border-color: var(--gold);
    text-decoration: none;
}

.page-link.active {
    background: var(--accent);
    color: #FAF0E0;
    border-color: var(--accent);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar { width: 180px; }
    .book-page { padding: 2.5rem 2rem; }
}

@media (max-width: 700px) {
    .reader-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        max-height: 240px;
        position: static;
        border-right: none;
        border-bottom: 1px solid rgba(200,184,154,0.25);
    }
    .sidebar-book-list { display: flex; flex-wrap: wrap; gap: 0; }
    .sidebar-book-list li { flex: 0 0 auto; }
    .book-page { padding: 2rem 1.2rem; }
    .book-page::before { display: none; }
    .testament-container { grid-template-columns: 1fr; }
    .testament-divider { display: none; }
    .book-list { columns: 1; }
}

@media (max-width: 500px) {
    .book-page { padding: 1.5rem 1rem; }
    .drop-cap { font-size: 3.2em; }
    .chapter-number-display { font-size: 3rem; }
    .page-turn-label { display: none; }
}

/* ============================================================
   USER NAVIGATION
   ============================================================ */
.user-nav {
    display: flex;
    align-items: center;
    gap: 0;
    margin-left: auto;
}

.user-nav-link {
    display: inline-block;
    padding: 0.45rem 1rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: #C9A84C;
    text-decoration: none;
    transition: color 0.2s;
    border-top: 2px solid transparent;
}

.user-nav-link:hover { color: #FFD980; text-decoration: none; }

.user-nav-name {
    padding: 0.45rem 0.75rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--ink-muted);
    font-style: italic;
    border-left: 1px solid rgba(200,184,154,0.2);
}

.user-nav-register {
    background: rgba(107,45,14,0.25);
    border-radius: 2px;
    color: #FAF0E0;
}

.user-nav-register:hover { background: rgba(107,45,14,0.5); color: #FFD980; }

.user-nav-signout { color: var(--ink-muted); font-size: 0.72rem; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page { }

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
}

.auth-card {
    background: var(--parchment);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2.5rem 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    text-align: center;
}

.auth-ornament {
    color: var(--gold);
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.auth-heading {
    font-size: 1.3rem;
    font-weight: normal;
    color: var(--accent);
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
}

.auth-form { text-align: left; }

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--ink-light);
    margin-bottom: 0.3rem;
}

.form-group label small { color: var(--ink-muted); font-size: 0.75em; }

.form-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: #FDFAF5;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 3px;
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--gold); }

.form-textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: #FDFAF5;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 3px;
    outline: none;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.15s;
}

.form-textarea:focus { border-color: var(--gold); }

.form-actions { display: flex; gap: 0.75rem; align-items: center; }

.auth-btn {
    width: 100%;
    padding: 0.7rem;
    margin-top: 0.5rem;
    background: var(--accent);
    color: #FAF0E0;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-btn:hover:not(:disabled) { background: #8B3A1A; }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-cancel {
    padding: 0.55rem 1rem;
    background: transparent;
    color: var(--ink-muted);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-cancel:hover { color: var(--ink); }

.auth-error {
    background: rgba(139,45,14,0.12);
    border: 1px solid rgba(139,45,14,0.4);
    border-radius: 3px;
    padding: 0.65rem 0.85rem;
    color: #8B2D0E;
    font-family: var(--font-ui);
    font-size: 0.83rem;
    margin-bottom: 1rem;
    text-align: left;
}

.auth-success {
    background: rgba(20,100,40,0.1);
    border: 1px solid rgba(20,100,40,0.35);
    border-radius: 3px;
    padding: 0.65rem 0.85rem;
    color: #1A6428;
    font-family: var(--font-ui);
    font-size: 0.83rem;
    margin-bottom: 1rem;
}

.auth-switch {
    margin-top: 1.25rem;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--ink-muted);
}

/* ============================================================
   USER PAGES (bookmarks, studies, study)
   ============================================================ */
.user-page { }

.user-main {
    flex: 1;
    padding: 2rem 1.5rem 3rem;
}

.user-container {
    max-width: 900px;
    margin: 0 auto;
}

.user-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.user-page-heading {
    font-size: 1.4rem;
    font-weight: normal;
    color: var(--gold-light);
    letter-spacing: 0.06em;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--parchment);
    opacity: 0.6;
    font-family: var(--font-ui);
    font-size: 0.95rem;
}

.empty-state p { margin-bottom: 0.5rem; }

.empty-state-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--gold-light);
    font-size: 0.9rem;
    text-decoration: underline;
}

/* ---------- Bookmarks ---------- */
.bmark-book {
    margin-bottom: 2.5rem;
}

.bmark-book-heading {
    font-family: var(--font-body);
    font-size: 1.3rem;
    color: var(--gold-light);
    letter-spacing: 0.08em;
    border-bottom: 1px solid rgba(201,168,76,0.35);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.bmark-book-ornament {
    color: var(--gold);
    font-size: 0.8rem;
}

.bmark-chapter {
    margin-bottom: 1.25rem;
    margin-left: 1rem;
}

.bmark-chapter-heading {
    margin-bottom: 0.5rem;
}

.bmark-chapter-link {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
}

.bmark-chapter-link:hover { color: #E07050; text-decoration: underline; }

.bmark-verse-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-left: 2px solid rgba(201,168,76,0.25);
    margin-bottom: 0.4rem;
    background: rgba(250,246,239,0.04);
    border-radius: 0 2px 2px 0;
}

.bmark-verse-row:hover {
    background: rgba(250,246,239,0.08);
    border-left-color: var(--gold);
}

.bmark-verse-body {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #D8CCBA;
}

.bmark-verse-num {
    font-family: var(--font-ui);
    font-size: 0.7em;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
}

.bmark-verse-text { flex: 1; color: #D8CCBA; }

.bmark-verse-label {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: #B8A88A;
    font-style: italic;
}

.bmark-verse-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.bmark-read-link {
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--ink-muted);
    transition: color 0.15s;
}

.bmark-read-link:hover { color: var(--gold); text-decoration: none; }

.bmark-delete-form { flex-shrink: 0; }

.bmark-delete-btn {
    background: transparent;
    border: 1px solid rgba(200,184,154,0.2);
    border-radius: 2px;
    color: var(--ink-muted);
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: color 0.15s, border-color 0.15s;
}

.bmark-delete-btn:hover { color: #CC4422; border-color: #CC4422; }

/* ---------- Studies ---------- */
.btn-create-study {
    padding: 0.55rem 1.2rem;
    background: var(--accent);
    color: #FAF0E0;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-create-study:hover { background: #8B3A1A; }

.create-study-form {
    background: rgba(250,246,239,0.07);
    border: 1px solid rgba(200,184,154,0.25);
    border-radius: 3px;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
}

.form-section-heading {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    color: var(--gold-light);
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.studies-list { display: flex; flex-direction: column; gap: 0.75rem; }

.study-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(250,246,239,0.06);
    border: 1px solid rgba(200,184,154,0.2);
    border-left: 3px solid var(--gold);
    border-radius: 2px;
    padding: 1rem 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.study-title {
    display: block;
    font-size: 1rem;
    color: var(--gold-light);
    font-family: var(--font-body);
    text-decoration: none;
    margin-bottom: 0.25rem;
}

.study-title:hover { color: #FFD980; text-decoration: underline; }

.study-desc {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--parchment);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.study-date {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-muted);
}

.study-card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.btn-view-study {
    padding: 0.4rem 0.9rem;
    background: var(--accent);
    color: #FAF0E0;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    border-radius: 2px;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-view-study:hover { background: #8B3A1A; text-decoration: none; }

.btn-delete-study {
    padding: 0.4rem 0.7rem;
    background: transparent;
    color: var(--ink-muted);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    border: 1px solid rgba(200,184,154,0.2);
    border-radius: 2px;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-delete-study:hover { color: #CC4422; border-color: #CC4422; }

/* ---------- Study View ---------- */
.study-container { }

.study-breadcrumb {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--ink-muted);
    margin-bottom: 1.25rem;
}

.study-breadcrumb a { color: var(--gold); text-decoration: none; }
.study-breadcrumb a:hover { text-decoration: underline; }

.study-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.study-view-title {
    font-size: 1.5rem;
    font-weight: normal;
    color: var(--gold-light);
    letter-spacing: 0.05em;
}

.study-view-desc {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--parchment);
    opacity: 0.7;
    margin-top: 0.35rem;
}

.btn-edit-study {
    padding: 0.45rem 1rem;
    background: transparent;
    color: var(--gold);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    border: 1px solid var(--gold);
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.btn-edit-study:hover { background: var(--gold); color: #1A0F06; }

.study-section-heading {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(200,184,154,0.2);
}

.study-body {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
}

.notes-list { display: flex; flex-direction: column; gap: 0.85rem; }

.note-card {
    background: rgba(250,246,239,0.07);
    border: 1px solid rgba(200,184,154,0.18);
    border-left: 3px solid var(--border);
    border-radius: 2px;
    padding: 0.85rem 1rem;
}

.note-ref a {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 0.4rem;
}

.note-ref a:hover { text-decoration: underline; }

.note-text {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--parchment);
}

.note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.6rem;
}

.note-date {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-muted);
}

.btn-delete-note {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0.2rem;
    transition: color 0.15s;
}

.btn-delete-note:hover { color: #CC4422; }

.add-note-panel {
    background: rgba(250,246,239,0.06);
    border: 1px solid rgba(200,184,154,0.2);
    border-radius: 3px;
    padding: 1.25rem;
    position: sticky;
    top: 1rem;
}

.add-note-panel .auth-btn { margin-top: 0.75rem; }

.ref-inputs {
    display: flex;
    gap: 0.4rem;
}

.ref-book { flex: 1; }
.ref-num  { width: 60px; flex-shrink: 0; }

.note-textarea { min-height: 120px; }

@media (max-width: 780px) {
    .study-body { grid-template-columns: 1fr; }
    .add-note-panel { position: static; }
}

/* ============================================================
   READER — BOOKMARK & NOTES ADDITIONS
   ============================================================ */
.verse-bmark-btn {
    display: inline-block;
    background: transparent;
    border: none;
    color: #A89060;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.35em 0 0;
    transition: color 0.15s, transform 0.1s;
    vertical-align: middle;
    line-height: inherit;
}

.verse-bmark-btn:hover {
    color: var(--gold);
    transform: scale(1.2);
}

.verse-bmark-btn.bookmarked {
    color: var(--gold);
}

.chapter-actions {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.chapter-bmark-btn,
.chapter-note-btn {
    padding: 0.4rem 0.9rem;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    background: rgba(250,246,239,0.08);
    color: var(--gold);
    border: 1px solid rgba(201,168,76,0.3);
}

.chapter-bmark-btn:hover,
.chapter-note-btn:hover {
    background: var(--gold);
    color: #1A0F06;
    border-color: var(--gold);
}

.chapter-bmark-btn.bookmarked {
    background: var(--gold);
    color: #1A0F06;
    border-color: var(--gold);
}

.sidebar-user-actions {
    margin-top: 1.25rem;
    border-top: 1px solid rgba(200,184,154,0.2);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sidebar-action-btn {
    display: block;
    padding: 0.4rem 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: #C8B89A;
    border-radius: 2px;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.sidebar-action-btn:hover {
    background: rgba(201,168,76,0.1);
    color: var(--gold-light);
    text-decoration: none;
}

/* ---------- Notes Panel ---------- */
.notes-panel {
    width: 300px;
    flex-shrink: 0;
    background: #150C04;
    border-left: 1px solid rgba(200,184,154,0.25);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    position: sticky;
    top: 0;
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

.notes-panel.open { transform: translateX(0); }

.notes-panel-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(200,184,154,0.2);
    gap: 0.5rem;
    flex-shrink: 0;
}

.notes-panel-title {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--gold-light);
    flex: 1;
}

.notes-panel-context {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--ink-muted);
}

.notes-panel-close {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    transition: color 0.15s;
    line-height: 1;
}

.notes-panel-close:hover { color: var(--parchment); }

.notes-panel-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.notes-label {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    margin-bottom: 0.3rem;
}

.notes-select { font-size: 0.82rem; padding: 0.4rem 0.6rem; }
.notes-textarea { min-height: 100px; font-size: 0.88rem; }

.notes-save-btn { margin-top: 0.25rem; }

.notes-feedback {
    margin-top: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    min-height: 1.2em;
}

.notes-feedback-ok    { color: #4A9A5C; }
.notes-feedback-error { color: #CC4422; }

.notes-links {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    border-top: 1px solid rgba(200,184,154,0.15);
    padding-top: 0.75rem;
}

.notes-link {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--gold);
    text-decoration: none;
}

.notes-link:hover { text-decoration: underline; }

.notes-empty {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: var(--ink-muted);
    font-style: italic;
}

/* ============================================================
   CHAT WIDGET
   ============================================================ */
#chat-widget {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9000;
}

#chat-toggle-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid rgba(201,168,76,0.4);
    color: #FAF0E0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: background 0.2s, transform 0.2s;
}

#chat-toggle-btn:hover { background: #8B3A1A; transform: scale(1.05); }

#chat-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #1A0F06;
    border: 1px solid rgba(201,168,76,0.35);
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    transform: scale(0.92) translateY(12px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

#chat-panel.open.expanded {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 50vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 6px 0 0 0;
    transform: none;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    background: #0D0703;
    border-bottom: 1px solid rgba(201,168,76,0.25);
    border-radius: 6px 6px 0 0;
    flex-shrink: 0;
}

.chat-header-left { display: flex; align-items: center; gap: 0.5rem; }
.chat-header-right { display: flex; gap: 0.25rem; }

.chat-header-icon { font-size: 0.95rem; }

.chat-title {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--gold-light);
}

.chat-status {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--ink-muted);
    font-style: italic;
    margin-left: 0.25rem;
}

.chat-ctrl-btn {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: 2px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.chat-ctrl-btn:hover { color: var(--parchment); background: rgba(255,255,255,0.06); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(200,184,154,0.2); border-radius: 2px; }

.chat-msg {
    max-width: 88%;
    padding: 0.55rem 0.8rem;
    border-radius: 4px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-wrap: break-word;
}

.chat-msg p { margin: 0 0 0.4em; }
.chat-msg p:last-child { margin-bottom: 0; }

.chat-msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: #FAF0E0;
    border-bottom-right-radius: 1px;
}

.chat-msg-assistant {
    align-self: flex-start;
    background: rgba(250,246,239,0.08);
    color: var(--parchment);
    border: 1px solid rgba(200,184,154,0.15);
    border-bottom-left-radius: 1px;
}

.chat-msg-system {
    align-self: center;
    color: var(--ink-muted);
    font-style: italic;
    font-size: 0.78rem;
    background: transparent;
    padding: 0.25rem;
    text-align: center;
    max-width: 100%;
}

.chat-msg-error {
    align-self: stretch;
    background: rgba(139,45,14,0.15);
    border: 1px solid rgba(139,45,14,0.3);
    color: #FFB09A;
    font-size: 0.8rem;
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.6rem 0.8rem;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--gold-light);
    border-radius: 50%;
    display: inline-block;
    animation: chatBounce 1.2s ease-in-out infinite;
    opacity: 0.6;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

.chat-input-area {
    display: flex;
    gap: 0;
    padding: 0.6rem;
    border-top: 1px solid rgba(200,184,154,0.15);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    background: rgba(250,246,239,0.06);
    color: var(--parchment);
    border: 1px solid rgba(200,184,154,0.2);
    border-right: none;
    border-radius: 3px 0 0 3px;
    outline: none;
    resize: none;
    line-height: 1.4;
    transition: border-color 0.15s;
}

.chat-input:focus { border-color: rgba(201,168,76,0.4); }
.chat-input::placeholder { color: var(--ink-muted); font-style: italic; }

.chat-send-btn {
    padding: 0 0.9rem;
    background: var(--accent);
    color: #FAF0E0;
    border: none;
    border-radius: 0 3px 3px 0;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover:not(:disabled) { background: #8B3A1A; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-context-bar {
    display: none;
    padding: 0.25rem 1rem;
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--ink-muted);
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(200,184,154,0.1);
    border-radius: 0 0 6px 6px;
    flex-shrink: 0;
    font-style: italic;
}

.chat-followups {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem 0.75rem;
}

.chat-followup-pill {
    background: rgba(201,168,76,0.12);
    border: 1px solid rgba(201,168,76,0.35);
    color: var(--gold-light);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.chat-followup-pill:hover {
    background: rgba(201,168,76,0.22);
    border-color: var(--gold-light);
}

@media (max-width: 500px) {
    #chat-panel { width: calc(100vw - 2rem); right: -0.5rem; }
    .notes-panel { width: 100%; position: fixed; bottom: 0; left: 0; z-index: 800; max-height: 70vh; }
}
