/* ============================================================
   KJV Bible Reader — Dashboard
   ============================================================ */

*, *::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);
    --max-width:          860px;
}

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; }

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

.dash-heading {
    margin-bottom: 2.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.dash-title {
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.dash-date {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* ── Summary cards ────────────────────────────────────────── */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.dash-card {
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--color-text-muted);
}

.card-value {
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1.15;
    color: var(--color-text);
}
.card-value.due-nonzero    { color: var(--color-link); }
.card-value.streak-nonzero { color: var(--color-link); }

.card-sub {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    min-height: 1.25em;
}

.card-action { margin-top: 0.85rem; align-self: flex-start; }

/* ── Section ──────────────────────────────────────────────── */
.dash-section { margin-bottom: 2.5rem; }

.section-header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.section-title { font-size: 1.1rem; font-weight: 500; }

.section-badge {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.05rem 0.55rem;
}

/* ── Queue list ───────────────────────────────────────────── */
.queue-list { display: flex; flex-direction: column; }

.queue-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}
.queue-row:last-child { border-bottom: none; }

.queue-ref { font-size: 1rem; }

.queue-mastery {
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.queue-due {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 7rem;
    text-align: right;
}
.queue-due.is-due {
    color: var(--color-link);
    font-style: italic;
}

.queue-practice-btn {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    padding: 0.25rem 0.85rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 150ms ease, color 150ms ease;
}
.queue-practice-btn:hover { border-color: var(--color-link); color: var(--color-link); }

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

/* Shown when passages exist but none are due — the section still needs to say
   something rather than render blank. */
.queue-caught-up {
    padding: 0.9rem 0;
    color: var(--color-text-muted);
    font-style: italic;
}
.queue-caught-up[hidden] { display: none; }

.queue-empty kbd {
    font-family: var(--font-primary);
    font-size: 0.85em;
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 0.05em 0.35em;
}

/* ── Featured Passages ─────────────────────────────────────── */
.section-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.featured-list { display: flex; flex-direction: column; }

.featured-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}
.featured-row:last-child { border-bottom: none; }

.featured-title {
    font-size: 1rem;
    font-weight: 500;
}

.featured-ref {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.featured-add-btn {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    padding: 0.25rem 0.85rem;
    border-radius: 4px;
    border: 1px solid var(--color-link);
    background: transparent;
    color: var(--color-link);
    cursor: pointer;
    white-space: nowrap;
    transition: background 150ms ease, color 150ms ease;
    min-width: 5.5rem;
    text-align: center;
}
.featured-add-btn:hover:not(:disabled) {
    background: var(--color-accent-light, #f0ebe3);
}
.featured-add-btn.is-added,
.featured-add-btn:disabled {
    border-color: var(--color-border);
    color: var(--color-text-muted);
    cursor: default;
    background: transparent;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .dash-main { padding: 2rem 1.25rem 4rem; }
    .dash-nav  { padding: 0.75rem 1.25rem; }
    .dash-cards { grid-template-columns: 1fr; }

    .queue-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 0.4rem;
    }
    .queue-ref          { grid-column: 1; grid-row: 1; }
    .queue-practice-btn { grid-column: 2; grid-row: 1; }
    .queue-mastery      { grid-column: 1; grid-row: 2; }
    .queue-due          { grid-column: 2; grid-row: 2; text-align: right; }

    .featured-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 0.25rem;
    }
    .featured-title   { grid-column: 1; grid-row: 1; }
    .featured-add-btn { grid-column: 2; grid-row: 1; }
    .featured-ref     { grid-column: 1; grid-row: 2; }
}

/* ── Review History Dots ──────────────────────────────────────────────────── */

.queue-history {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-bottom: 0.35rem;
}

.hist-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.hist-good  { background: #5a9e6a; }   /* muted green  — Good / Easy */
.hist-hard  { background: #c8893a; }   /* muted orange — Hard        */
.hist-again { background: #b85050; }   /* muted red    — Again       */

/* ── Reading Plans ────────────────────────────────────────────────────────── */

.plans-list {
    display: flex;
    flex-direction: column;
}

.plan-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--color-border);
}

.plan-row:last-child {
    border-bottom: none;
}

.plan-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.plan-title {
    font-weight: 500;
    font-size: 1rem;
    color: var(--color-text);
}

.plan-progress {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.plan-progress.plan-unenrolled {
    font-style: italic;
}

.plan-progress.plan-finished {
    color: var(--color-accent);
    font-weight: 500;
}

.plan-progress-track {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.3rem;
}

.plan-progress-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.plan-day-label {
    font-size: 0.875rem;
    color: var(--color-link);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-day-label:hover {
    text-decoration: underline;
}

.plan-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Plans — Mobile (≤640px) ──────────────────────────────────────────────── */

@media (max-width: 640px) {
    .plan-row {
        grid-template-columns: 1fr;
        row-gap: 0.6rem;
    }

    .plan-actions {
        flex-wrap: wrap;
    }
}

/* ── Reading Rhythms ──────────────────────────────────────────────────────── */

#rhythms-section .section-header { gap: 0.75rem; }
#rhythm-new-btn { margin-left: auto; }

/* ── Section disclosures ──────────────────────────────────────────────────── */
/* Shared by "All lanes", "Add a featured passage", and the Activity heatmap:
   secondary content stays one click away instead of becoming the page's bulk. */

.rhythm-all-disclosure > summary,
.queue-later-disclosure > summary,
.featured-disclosure > summary {
    cursor: pointer;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 0.6rem 0;
    list-style-position: outside;
}
.rhythm-all-disclosure > summary:hover,
.queue-later-disclosure > summary:hover,
.featured-disclosure > summary:hover { color: var(--color-text); }

.featured-disclosure { margin-top: 0.75rem; }
.featured-disclosure[hidden] { display: none; }
.rhythm-all-disclosure[hidden] { display: none; }
.queue-later-disclosure[hidden] { display: none; }

/* The heatmap's summary carries the section heading itself. */
.section-summary {
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}
.section-summary:hover .section-title { color: var(--color-link); }
#activity-details[open] .section-summary { margin-bottom: 1rem; }

.rhythm-group-label {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 1rem 0 0.4rem;
}
.rhythm-group-label:first-child { margin-top: 0; }

.rhythm-none-today {
    text-transform: none;
    letter-spacing: 0;
    font-style: italic;
    font-size: 0.9rem;
}

/* Per-rhythm title bar — the visible home for Edit and Delete. */
.rhythm-group-head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.5rem 0 0.4rem;
    border-bottom: 1px solid var(--color-border);
    margin-top: 0.5rem;
}

.rhythm-group-title { font-weight: 500; font-size: 0.98rem; }
.rhythm-group-count { font-size: 0.8rem; color: var(--color-text-muted); }
.rhythm-group-head .rhythm-edit-btn { margin-left: auto; }
.rhythm-group-head .btn-secondary { padding: 0.2rem 0.6rem; font-size: 0.82rem; }

.rhythm-group-lanes { margin-bottom: 0.5rem; }

/* Quiet inline action — "Set position", "Delete", "Leave". Shared by plans and
   rhythms so a low-stakes or destructive action reads the same in both sections. */
.link-btn,
.rhythm-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.82rem;
    color: var(--color-link);
    padding: 0.2rem 0;
}
.link-btn:hover:not(:disabled),
.rhythm-link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled,
.rhythm-link-btn:disabled { opacity: 0.5; cursor: default; }

.rhythm-delete-btn,
.plan-leave-btn { color: #a33; }

/* Today's lane — the lead card */
.rhythm-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    border-radius: 6px;
    background: var(--color-header-bg);
}

/* Any other lane — same actions, quieter presentation */
.rhythm-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}
.rhythm-row:last-child { border-bottom: none; }

.rhythm-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.rhythm-lane-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    cursor: pointer;
}
.rhythm-lane-name { font-weight: 500; font-size: 1rem; }
.rhythm-lane-day,
.rhythm-lane-of {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
/* Separator sits on the rhythm title so it reads correctly whether or not the
   day chip is present (it is omitted when the lane is named after its day). */
.rhythm-lane-of::before { content: '· '; }

.rhythm-next {
    font-size: 0.95rem;
    color: var(--color-link);
}
.rhythm-next-empty {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--color-text-muted);
}
.rhythm-complete {
    font-size: 0.95rem;
    color: var(--color-accent);
    font-weight: 500;
}

.rhythm-progress {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.rhythm-track {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.3rem;
}
.rhythm-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.rhythm-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.rhythm-empty {
    padding: 1.25rem 0;
    color: var(--color-text-muted);
}
.rhythm-empty-sub {
    font-size: 0.9rem;
    max-width: 46ch;
    margin: 0.4rem 0 0.9rem;
}

/* ── Rhythm Builder ───────────────────────────────────────────────────────── */

.rhythm-builder-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;
}
.rhythm-builder-overlay[hidden] { display: none; }

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

.rhythm-builder-header,
.rhythm-builder-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
}
.rhythm-builder-header { justify-content: space-between; border-bottom: 1px solid var(--color-border); }
.rhythm-builder-footer { border-top: 1px solid var(--color-border); }
.rhythm-builder-header h2 { font-size: 1.1rem; font-weight: 500; }
.rb-spacer { flex: 1; }

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

#rhythm-delete-btn { color: #a33; border-color: #d9b5b5; }

.rhythm-builder-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
}

.rb-field { display: block; margin-bottom: 1rem; }
.rb-label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 0.3rem;
}
#rhythm-title-input {
    width: 100%;
    font-family: var(--font-primary);
    font-size: 1.05rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: #fff;
    color: var(--color-text);
}
#rhythm-title-input:focus { outline: none; border-color: var(--color-link); }

.rb-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.rb-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
    margin: 0.7rem 0 1rem;
    max-width: 58ch;
}

.rb-error {
    margin-top: 0.9rem;
    font-size: 0.9rem;
    color: #a33;
}

.rb-lane {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.8rem 0.9rem;
    margin-bottom: 0.8rem;
    background: var(--color-header-bg);
}

/* The lane arrived at via "Set position" — marked so it is obvious which one to edit. */
.rb-lane-focused {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-light);
}
.rb-lane-focused .rb-lane-position {
    color: var(--color-text);
    font-weight: 500;
}

.rb-lane-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.rb-lane-name,
.rb-lane-day,
.rb-position-book,
.rb-position-chapter {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: #fff;
    color: var(--color-text);
}
.rb-lane-name { flex: 1; min-width: 0; }
.rb-position-chapter { width: 5rem; }

.rb-icon {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.35rem 0.45rem;
}
.rb-icon:hover:not(:disabled) { color: var(--color-text); background: #fff; }
.rb-icon:disabled { opacity: 0.35; cursor: default; }

.rb-lane-books {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
}
.rb-empty { font-size: 0.85rem; font-style: italic; color: var(--color-text-muted); }

.rb-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.15rem 0.3rem 0.15rem 0.6rem;
    font-size: 0.82rem;
}
.rb-chip-name { margin-right: 0.15rem; }
.rb-chip-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    line-height: 1;
    padding: 0.1rem 0.2rem;
}
.rb-chip-btn:hover:not(:disabled) { color: var(--color-text); }
.rb-chip-btn:disabled { opacity: 0.3; cursor: default; }

.rb-lane-position {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.rb-picker > summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-link);
}
.rb-picker-body {
    margin-top: 0.6rem;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 0.4rem;
}

.rb-category { margin-bottom: 0.7rem; }
.rb-category-head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.2rem;
}
.rb-category-name {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}
.rb-category-all {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.78rem;
    color: var(--color-link);
    padding: 0;
}
.rb-category-all:hover { text-decoration: underline; }

.rb-category-books {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.1rem 0.6rem;
}
.rb-book {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ── Rhythms — Mobile (≤640px) ────────────────────────────────────────────── */

@media (max-width: 640px) {
    .rhythm-card,
    .rhythm-row {
        grid-template-columns: 1fr;
        row-gap: 0.6rem;
    }
    .rhythm-actions { flex-wrap: wrap; }
    .rb-lane-head { flex-wrap: wrap; }
    .rb-lane-name { flex-basis: 100%; }
    .rb-category-books { grid-template-columns: 1fr 1fr; }
}

/* ── Activity Heatmap ─────────────────────────────────────────────────────── */

.heatmap-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

/* Month labels row */
.heatmap-months {
    position: relative;
    height: 1.25rem;
    margin-left: 2.5rem; /* align with grid (matches .heatmap-days width) */
    margin-bottom: 0.2rem;
}

.heatmap-month-label {
    position: absolute;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Grid row: day labels + cell grid side by side */
.heatmap-body {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}

/* Day-of-week labels (Sun–Sat) */
.heatmap-days {
    display: grid;
    grid-template-rows: repeat(7, 11px);
    gap: 2px;
    flex-shrink: 0;
    width: 2.2rem;
}

.heatmap-days span {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    line-height: 11px;
    text-align: right;
}

/* Cell grid */
.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 11px);
    grid-auto-flow: column;
    gap: 2px;
}

/* Individual cells */
.heat-cell {
    width: 11px;
    height: 11px;
    border-radius: 2px;
}

.heat-future { background: transparent; }
.heat-0 { background: var(--color-border); }
.heat-1 { background: color-mix(in srgb, var(--color-accent) 30%, var(--color-border)); }
.heat-2 { background: color-mix(in srgb, var(--color-accent) 55%, var(--color-border)); }
.heat-3 { background: color-mix(in srgb, var(--color-accent) 78%, var(--color-border)); }
.heat-4 { background: var(--color-accent); }

/* Legend */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 0.6rem;
    margin-left: 2.5rem;
}

.heatmap-legend span {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin: 0 0.15rem;
}

/* Mobile: allow horizontal scroll, hide day labels to save space */
@media (max-width: 640px) {
    .heatmap-days { display: none; }
    .heatmap-months { margin-left: 0; }
    .heatmap-legend { margin-left: 0; }
}

/* ── 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;
}

a.sermon-note-row {
    text-decoration: none;
    color: inherit;
}
a.sermon-note-row:hover { text-decoration: none; }

.sermon-notes-more {
    display: inline-block;
    margin-top: 0.85rem;
    font-size: 0.9rem;
    color: var(--color-link);
}

.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);
}
