/* The Remnant Thread - Enhanced Tufte-Inspired Typography */

:root {
    /* Core theme colors */
    --bg: #fffff8;
    --fg: #111;
    --accent: #8b4513;
    --muted: #666;
    --border: #d4c4b0;
    --quote-bg: #f9f7f3;
    --link: #5c4033;

    /* Interactive chips/pills - guaranteed contrast */
    --chip-bg: #e8e4dc;
    --chip-fg: #333;

    /* Semantic colors */
    --success: #2e7d32;
    --warning: #f57c00;
    --danger: #c62828;
    --gold: #ffd700;
    --dark-bg: #1a1a2e;
    --dark-bg-alt: #16213e;
    --modal-overlay: rgba(0,0,0,0.8);

    /* Layout */
    --max-width: 65ch;
    --sidenote-width: 25ch;

    /* Navbar */
    --navbar-height: 3rem;
    --navbar-height-mobile: 3.5rem;

    /* Border radius scale */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-round: 50%;

    /* Z-index hierarchy */
    --z-header: 100;
    --z-overlay: 500;
    --z-modal: 1000;
    --z-alert: 1100;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Spacing scale (for new code - existing code unchanged)
       Values: 0.25rem, 0.5rem, 0.75rem, 1rem, 1.5rem, 2rem, 3rem
       Common: 1rem (most used), 0.5rem, 1.5rem, 2rem */
    --space-xs: 0.25rem;   /* 4px - micro spacing */
    --space-sm: 0.5rem;    /* 8px - tight spacing */
    --space-md: 1rem;      /* 16px - default spacing */
    --space-lg: 1.5rem;    /* 24px - loose spacing */
    --space-xl: 2rem;      /* 32px - section spacing */
    --space-2xl: 3rem;     /* 48px - major sections */

    /* Visualization colors */
    --viz-fulfilled: #2a7d4c;
    --viz-present: #f59e0b;
    --viz-coming: #6b7280;
    --viz-entity: #3b82f6;
    --viz-event: #22c55e;
    --viz-verse: #eab308;
    --viz-quote: #a855f7;
    --viz-claim: #ef4444;
    --viz-compare-left: #2a7d4c;
    --viz-compare-right: #dc2626;

    /* Study/Status colors (Bootstrap palette used in studies) */
    --status-success: #28a745;      /* Sabbath, moral law, binding */
    --status-warning: #ffc107;      /* Mixed, ceremonial, transformed */
    --status-danger: #dc3545;       /* Sunday, fulfilled */
    --status-neutral: #6c757d;      /* Civil, ended, gray */
    --status-rome: #8b0000;         /* Dark red for Rome/martyr */

    /* Era colors (historical timeline) */
    --era-apostolic: #3498db;       /* Blue */
    --era-early: #9b59b6;           /* Purple */
    --era-medieval: #e67e22;        /* Orange */
    --era-reformation: #27ae60;     /* Green */
    --era-modern: #e74c3c;          /* Red */

    /* Accent highlights */
    --highlight-green: #90EE90;     /* Light green text */
    --highlight-red: #ff6b6b;       /* Martyr note text */
    --highlight-red-stroke: #ff4444; /* Martyr marker stroke */
    --source-primary: #b07020;      /* Primary source tags */

    /* Gradient backgrounds */
    --gradient-martyr-start: #4a0000;
    --gradient-martyr-end: #2a0000;
    --gradient-success-start: #1a4a1a;
    --gradient-success-end: #0a2a0a;

    /* Map/country fills */
    --map-country: #444;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a18;
        --fg: #e8e6e0;
        --accent: #d4a574;
        --muted: #999;
        --border: #3d3d35;
        --quote-bg: #252520;
        --link: #c9a87c;

        /* Interactive chips - high contrast for dark */
        --chip-bg: #3d3d35;
        --chip-fg: #e8e6e0;
        /* Semantic colors (adjusted for dark) */
        --success: #66bb6a;
        --warning: #ffb74d;
        --danger: #ef5350;
        --gold: #ffdd44;
        --modal-overlay: rgba(0,0,0,0.9);

        /* Visualization colors (brighter for dark bg) */
        --viz-fulfilled: #34d399;
        --viz-present: #fbbf24;
        --viz-coming: #9ca3af;
        --viz-entity: #60a5fa;
        --viz-event: #4ade80;
        --viz-verse: #facc15;
        --viz-quote: #c084fc;
        --viz-claim: #f87171;
        --viz-compare-left: #34d399;
        --viz-compare-right: #f87171;

        /* Study/Status colors (brighter for dark) */
        --status-success: #34d399;
        --status-warning: #fbbf24;
        --status-danger: #f87171;
        --status-neutral: #9ca3af;
        --status-rome: #dc2626;

        /* Era colors */
        --era-apostolic: #60a5fa;
        --era-early: #c084fc;
        --era-medieval: #fb923c;
        --era-reformation: #4ade80;
        --era-modern: #f87171;

        /* Accent highlights */
        --highlight-green: #86efac;
        --highlight-red: #fca5a5;
        --highlight-red-stroke: #f87171;
        --source-primary: #d4a574;

        /* Gradient backgrounds (softer for dark) */
        --gradient-martyr-start: #7f1d1d;
        --gradient-martyr-end: #450a0a;
        --gradient-success-start: #14532d;
        --gradient-success-end: #052e16;

        /* Map/country fills */
        --map-country: #666;
    }
}

body.dark-mode {
    --bg: #1a1a18;
    --fg: #e8e6e0;
    --accent: #d4a574;
    --muted: #999;
    --border: #3d3d35;
    --quote-bg: #252520;
    --link: #c9a87c;

    /* Interactive chips - high contrast for dark */
    --chip-bg: #3d3d35;
    --chip-fg: #e8e6e0;
    /* Semantic colors (adjusted for dark) */
    --success: #66bb6a;
    --warning: #ffb74d;
    --danger: #ef5350;
    --gold: #ffdd44;
    --modal-overlay: rgba(0,0,0,0.9);

    /* Study/Status colors (brighter for dark) */
    --status-success: #34d399;
    --status-warning: #fbbf24;
    --status-danger: #f87171;
    --status-neutral: #9ca3af;
    --status-rome: #dc2626;

    /* Era colors */
    --era-apostolic: #60a5fa;
    --era-early: #c084fc;
    --era-medieval: #fb923c;
    --era-reformation: #4ade80;
    --era-modern: #f87171;

    /* Accent highlights */
    --highlight-green: #86efac;
    --highlight-red: #fca5a5;
    --highlight-red-stroke: #f87171;
    --source-primary: #d4a574;

    /* Gradient backgrounds (softer for dark) */
    --gradient-martyr-start: #7f1d1d;
    --gradient-martyr-end: #450a0a;
    --gradient-success-start: #14532d;
    --gradient-success-end: #052e16;

    /* Map/country fills */
    --map-country: #666;
}

/* Unified Site Header */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    box-sizing: border-box;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1.5rem;
    z-index: var(--z-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.site-header.hidden {
    transform: translateY(-100%);
    opacity: 0;
}

/* Main site nav - left side */
.site-nav {
    display: flex;
    gap: 0.15rem;
    font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
}

.site-nav a {
    font-size: 0.9rem;
    color: var(--muted);
    text-decoration: none;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.15s;
}

.site-nav a:hover {
    background: var(--quote-bg);
    color: var(--fg);
}

.site-nav a.active,
.site-nav a.has-saved-items {
    color: var(--accent);
    background: var(--quote-bg);
}

/* Nav icons - inline SVG */
.site-nav .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.site-nav .nav-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

.site-nav .nav-text {
    display: none; /* Icon-only nav for more space */
}


/* Chapter breadcrumb - center */
.chapter-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
}

.chapter-breadcrumb .crumb {
    color: var(--accent);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    text-decoration: none;
}

.chapter-breadcrumb .crumb:hover {
    background: var(--quote-bg);
}

.chapter-breadcrumb .sep {
    color: var(--muted);
    font-size: 0.75rem;
}

/* Chapter arrows - right side */
.chapter-arrows {
    display: flex;
    gap: 0.15rem;
}

.chapter-arrows a,
.chapter-arrows button {
    background: none;
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.chapter-arrows a:hover,
.chapter-arrows button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.chapter-arrows a.disabled,
.chapter-arrows button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Bookmark Modal */
.bookmark-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    z-index: var(--z-modal);
}

.bookmark-modal.visible {
    display: flex;
}

.bookmark-modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    max-height: 60vh;
    overflow-y: auto;
}

.bookmark-modal-content h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin: 0;
    border-bottom: 1px solid var(--border);
    font-size: 1rem;
}

.bookmark-modal-content .close-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.add-bookmark-btn {
    display: block;
    width: calc(100% - 2rem);
    margin: 1rem;
    padding: 0.75rem;
    background: var(--quote-bg);
    border: 1px dashed var(--border);
    border-radius: 4px;
    color: var(--fg);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.add-bookmark-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.bookmark-list {
    padding: 0 1rem 1rem;
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--quote-bg);
    border-radius: 4px;
    cursor: pointer;
}

.bookmark-item:hover {
    background: var(--border);
}

.bookmark-title {
    font-size: 0.9rem;
}

.bookmark-remove {
    color: var(--muted);
    font-size: 1.2rem;
    padding: 0 0.25rem;
}

.bookmark-remove:hover {
    color: var(--danger);
}

.bookmark-empty {
    color: var(--muted);
    text-align: center;
    font-size: 0.9rem;
    padding: 1rem;
}

/* TOC Modal */
.toc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5vh;
    z-index: var(--z-modal);
}

.toc-modal.visible {
    display: flex;
}

.toc-modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.toc-modal-content h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin: 0;
    border-bottom: 1px solid var(--border);
    font-size: 1rem;
    position: sticky;
    top: 0;
    background: var(--bg);
}

.toc-modal-content .close-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.toc-list {
    padding: 0.5rem 0;
}

.toc-section {
    margin-bottom: 0.5rem;
}

.toc-part {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
}

.toc-chapter {
    display: block;
    padding: 0.5rem 1rem 0.5rem 1.5rem;
    color: var(--fg);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 2px solid transparent;
}

.toc-chapter:hover {
    background: var(--quote-bg);
    color: var(--accent);
}

.toc-chapter.active {
    border-left-color: var(--accent);
    color: var(--accent);
    background: var(--quote-bg);
}

.toc-chapter.read {
    color: var(--muted);
}

.toc-chapter.read:hover {
    color: var(--accent);
}

.toc-check {
    color: var(--accent);
    margin-right: 0.35rem;
    font-size: 0.85em;
}

/* TOC Progress Line */
.toc-progress-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--quote-bg);
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.toc-progress-line:hover {
    background: var(--border);
}

.toc-progress-label {
    font-size: 0.9rem;
}

.toc-progress-stat {
    font-size: 0.8rem;
    color: var(--muted);
}

.toc-pct-badge {
    display: inline-block;
    background: var(--accent);
    color: var(--bg);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* Header button standard */
.header-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    min-height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.header-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.header-btn svg {
    width: 16px;
    height: 16px;
}

.header-btn.has-saved,
.header-btn.has-bookmarks,
.header-btn.has-favs {
    color: var(--accent);
    border-color: var(--accent);
}

.header-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Storage Warning */
.storage-warning {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    border: 2px solid var(--danger);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    max-width: 400px;
    width: 90%;
    z-index: var(--z-alert);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.storage-warning p {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
}

.storage-warning strong {
    color: var(--danger);
}

.storage-warning ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    font-size: 0.85rem;
}

.storage-warning li {
    margin-bottom: 0.25rem;
}

.storage-warning a {
    color: var(--accent);
}

.storage-warning button {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--quote-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--fg);
    cursor: pointer;
    font-family: inherit;
}

.storage-warning button:hover {
    background: var(--border);
}

/* Legacy support */
.site-header .site-title {
    font-size: 1rem;
    font-weight: 400;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.05em;
}

.site-header .site-title:hover {
    color: var(--fg);
}

.site-header nav {
    display: flex;
    gap: 1.5rem;
}

.site-header nav a {
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
}

.site-header nav a:hover {
    color: var(--accent);
}

/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    padding-top: var(--navbar-height);  /* Offset for fixed header */
    background: var(--bg);
    color: var(--fg);
    font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
    line-height: 1.8;
    transition: background 0.3s, color 0.3s;
}

/* Progress bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    z-index: var(--z-modal);
    transition: width 0.1s;
}

/* Main article container - centered by default */
article {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 2rem;
    position: relative;
    counter-reset: sidenote-counter;
}

/* Specific override for the Sabbath vs Sunday appendix to allow wider tables */
body.appendix-sabbath-vs-sunday article {
    max-width: 1200px; /* Allow more width for the comparison table */
}

/* When article has sidenotes, add left margin for them */
article:has(.sidenote) {
    max-width: calc(var(--max-width) + var(--sidenote-width) + 3rem);
    padding-left: calc(var(--sidenote-width) + 3rem);
}

@media (max-width: 1000px) {
    article,
    article:has(.sidenote) {
        max-width: var(--max-width);
        padding: 1.5rem 1rem;
    }
}

/* Typography */
h1 {
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin: 0 0 2rem 0;
    color: var(--accent);
    text-align: center;
}

/* Page title - centralized styling for special pages */
.page-title {
    text-align: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    margin: 0;
    color: var(--accent);
}

/* Article h1 - match .page-title h1 style for studies */
article > h1:first-child {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    margin: 0 auto 0.5rem auto;
    text-align: center !important;
}

/* Subtitle styling */
.subtitle {
    font-size: 1rem;
    color: var(--muted);
    margin: 0 auto 2rem auto;
    text-align: center !important;
}

article > p.subtitle {
    text-align: center !important;
}

h2 {
    font-size: 1.5rem;
    font-weight: 400;
    font-style: italic;
    margin: 3rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: var(--fg);
}

h4 {
    font-size: 1.1rem;
    font-weight: 600;
    font-style: italic;
    margin: 1.5rem 0 0.75rem;
    color: var(--accent);
}

p {
    margin: 1.4rem 0;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* Drop cap removed - was causing issues with J.E.P. and PART headings */

/* Links */
a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent);
}

/* Bold - accent color for emphasis */
strong {
    font-weight: 600;
    color: var(--accent);
}

/* Italic */
em {
    font-style: italic;
}

/* Scripture blockquotes */
blockquote {
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    background: var(--quote-bg);
    border-left: 4px solid var(--accent);
    border-radius: 0 4px 4px 0;
    font-style: italic;
    color: var(--fg);
}

blockquote p {
    margin: 0.75rem 0;
    text-align: left;
}

blockquote p:first-child {
    margin-top: 0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* Horizontal rules */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 3rem 0;
}

/* Lists */
ul, ol {
    margin: 1.5rem 0;
    padding-left: 1.5rem;
}

li {
    margin: 0.6rem 0;
    line-height: 1.6;
}

li strong {
    display: inline;
}

/* Sidenotes (Tufte-style) */
.sidenote-number {
    counter-increment: sidenote-counter;
}

.sidenote-number:after {
    content: counter(sidenote-counter);
    font-size: 0.7rem;
    vertical-align: super;
    color: var(--accent);
}

.sidenote {
    float: left;
    clear: left;
    margin-left: calc(-1 * var(--sidenote-width) - 3rem);
    width: var(--sidenote-width);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--muted);
    position: relative;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Hide hardcoded sup - use CSS counter instead */
.sidenote sup:first-child {
    display: none;
}

/* Show counter-based number (same counter as inline) */
.sidenote::before {
    content: counter(sidenote-counter);
    color: var(--accent);
    font-size: 0.7em;
    vertical-align: super;
    margin-right: 0.3rem;
}

/* Prevent long URLs from breaking sidenote layout */
.sidenote a {
    word-break: break-all;
    overflow-wrap: break-word;
}

input.margin-toggle {
    display: none;
}

@media (max-width: 1000px) {
    /* Hide inline sidenotes on mobile - JS popover handles display */
    .sidenote {
        display: none !important;
    }

    /* Tappable footnote numbers */
    .sidenote-number:after {
        cursor: pointer;
        text-decoration: underline;
        text-decoration-style: dotted;
        text-underline-offset: 2px;
    }

    /* Larger touch target for footnote numbers */
    label.sidenote-number {
        padding: 0.5rem 0.25rem;
        margin: -0.5rem -0.25rem;
        display: inline-block;
    }

    /* Hide global toggle on mobile - popover system handles it */
    .footnote-toggle {
        display: none !important;
    }
}

/* Code blocks - dynamic sizing handled by JS */
pre {
    margin: 1.5rem -2rem;
    padding: 1.5rem 2rem;
    background: var(--quote-bg);
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre;
    width: calc(100% + 4rem);
}

code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    background: var(--quote-bg);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

pre code {
    background: none;
    padding: 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9rem;
}

thead {
    background: var(--quote-bg);
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--accent);
    border-bottom: 2px solid var(--border);
}

tbody tr:hover {
    background: var(--quote-bg);
}

td em {
    color: var(--muted);
}

/* Diagrams */
.diagram {
    margin: 2rem 0;
    text-align: center;
}

.diagram img,
.diagram svg {
    max-width: 100%;
    height: auto;
}

.diagram-placeholder {
    padding: 2rem;
    background: var(--quote-bg);
    border: 2px dashed var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-style: italic;
}

/* Chapter navigation */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--max-width);
    margin: 3rem auto;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
}

.chapter-nav a {
    color: var(--link);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.chapter-nav a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.nav-prev {
    text-align: left;
}

.nav-next {
    text-align: right;
}

.nav-toc {
    font-weight: 600;
}

/* Table of Contents */
.toc {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

.toc li {
    margin: 0.75rem 0;
    padding-left: 0;
}

.toc a {
    color: var(--fg);
    text-decoration: none;
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px dotted var(--border);
    transition: color 0.2s, border-color 0.2s;
}

.toc a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Title Page Styling */
.title-page article {
    max-width: var(--max-width);
    padding: 0 2rem;
    margin: 0 auto;
}

.title-page article > h1:first-of-type {
    font-size: clamp(1.8rem, 8vw, 3.5rem);
    letter-spacing: 0.15em;
    margin: 15vh 0 1.5rem 0;
    text-align: center;
    font-weight: 300;
    text-transform: uppercase;
}

.title-page article > h2:first-of-type {
    font-size: 1.3rem;
    font-weight: 300;
    font-style: italic;
    margin: 0 0 2rem 0;
    padding: 0;
    border: none;
    text-align: center;
    color: var(--muted);
}

.title-page article > p:first-of-type {
    text-align: center;
    font-size: 1rem;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin: 2rem 0;
}

.title-page article > p:first-of-type strong {
    font-weight: 400;
}

.title-page hr {
    border: none;
    text-align: center;
    margin: 2.5rem auto;
    max-width: 200px;
}

.title-page hr::before {
    content: "✦  ✦  ✦";
    color: var(--accent);
    font-size: 0.8rem;
    letter-spacing: 0.5em;
}

.title-page blockquote {
    max-width: 500px;
    margin: 3rem auto;
    padding: 1.5rem 2rem;
    text-align: center;
    font-size: 0.95rem;
    border-left: none;
    border-radius: 0;
    background: transparent;
}

.title-page blockquote p {
    text-align: center;
}

/* Footer */
footer {
    padding: 2rem 1.5rem 4rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

footer p {
    text-align: center;
    margin: 0.25rem 0;
}

footer a {
    color: var(--accent);
}

footer .version {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    color: var(--muted);
}

/* Focus mode */
body.focus-mode article p:not(.active),
body.focus-mode article li:not(.active) {
    opacity: 0.25;
    transition: opacity 0.3s;
}

body.focus-mode article p.active,
body.focus-mode article li.active {
    opacity: 1;
}

/* Keyboard help tooltip */
.keyboard-help {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--fg);
    color: var(--bg);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.6;
    display: none;
    z-index: var(--z-modal);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.keyboard-help.visible {
    display: block;
}

.keyboard-help kbd {
    display: inline-block;
    background: var(--bg);
    color: var(--fg);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
    margin-right: 0.5rem;
}

/* Icon-only nav for tablets and below */
@media (max-width: 1100px) {
    /* Hide text labels, show only icons */
    .site-nav .nav-text {
        display: none;
    }

    .site-nav .nav-icon {
        width: 20px;
        height: 20px;
    }
}

/* Mobile responsive */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    body {
        padding-top: var(--navbar-height-mobile);
    }

    article {
        padding: 2rem 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    blockquote {
        padding: 1rem;
        margin-left: 0;
        margin-right: 0;
    }

    .chapter-nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .chapter-nav a {
        text-align: center;
    }

    /* Mobile navbar polish - larger touch targets */
    .site-header {
        padding: 0.5rem 0.5rem 0.5rem 1rem;  /* TRBL: reduced right to prevent overflow */
    }

    .site-nav {
        gap: 0;  /* Zero gap for 5-icon nav */
    }

    .site-nav a {
        padding: 0.2rem;  /* Tighter than desktop for mobile */
        font-size: 0.85rem;
    }

    .site-nav .nav-icon {
        width: 16px;
        height: 16px;
    }

    .header-actions {
        gap: 0.25rem;
    }

    .header-btn {
        padding: 0.3rem 0.4rem;
        min-height: unset;
    }

    /* Bookmark button - shorter text on mobile */
    .bookmark-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
    }

}

/* ==========================================================================
   PARTS PAGE NAVIGATION - Section dividers with CTA buttons
   ========================================================================== */

.part-divider {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2rem 0;
    opacity: 0.6;
}

.part-cta-button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--link);
    color: var(--bg);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: bold;
    font-size: 0.95rem;
    transition: background var(--transition-fast);
}

.part-cta-button:hover {
    background: var(--accent);
    color: var(--bg);
}

/* Print styles */
@media print {
    @page {
        size: 6in 9in;
        margin: 0.55in 0.6in 0.6in 0.6in;
    }

    @page :first {
        margin-top: 0.75in;
    }

    body {
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    .progress-bar,
    .chapter-nav,
    .site-footer,
    .keyboard-help,
    .part-divider,
    .part-cta-button {
        display: none;
    }

    article {
        max-width: none;
        padding: 0;
    }

    h1 {
        page-break-before: always;
        page-break-after: avoid;
        font-size: 24pt;
        margin-top: 0;
        color: #000;
    }

    h2, h3, h4 {
        page-break-after: avoid;
        color: #000;
    }

    blockquote {
        page-break-inside: avoid;
        border-left: 2px solid #000;
        background: none;
    }

    p {
        orphans: 3;
        widows: 3;
    }

    .sidenote {
        float: none;
        display: block;
        margin: 0.5rem 0;
        padding: 0.5rem;
        background: #f5f5f5;
        width: auto;
        font-size: 9pt;
    }

    a {
        color: #000;
        text-decoration: none;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    a[href^="#"]:after,
    a[href^="javascript"]:after {
        content: "";
    }
}

/* ==========================================================================
   TRACT PRINT STYLES - Optimized for single-issue shareable pages
   ========================================================================== */

/* Tract-specific print styles */
@media print {
    .tract-page .site-header,
    .tract-page .print-btn,
    .tract-page .no-print,
    .tract-page .site-footer {
        display: none !important;
    }

    .tract-page {
        padding-top: 0 !important;
    }

    .tract-page article {
        max-width: none;
        padding: 0.35rem 0.85rem 1.1rem;
        margin: 0;
    }

    .tract-page .tract-header,
    .tract-page .tract-hero {
        text-align: center;
        margin-bottom: 1rem;
        padding-bottom: 0.6rem;
        border-bottom: 2px solid #000;
    }

    .tract-page .tract-header h1,
    .tract-page .tract-hero h1 {
        font-size: 18pt;
        margin: 0 0 0.2rem;
        page-break-before: avoid !important;
        page-break-after: avoid;
    }

    .tract-page .tract-header .tagline,
    .tract-page .tract-hero .tract-tagline {
        font-size: 11pt;
        color: #555;
        margin: 0 auto;
        max-width: none;
        text-align: center;
    }

    .tract-page .tract-content,
    .tract-page .tract-body {
        font-size: 11pt;
        line-height: 1.5;
    }

    .tract-page .tract-content h2,
    .tract-page .tract-body h2 {
        font-size: 12pt;
        margin: 0.85rem 0 0.5rem;
        page-break-after: avoid;
    }

    .tract-page .tract-content p,
    .tract-page .tract-body p {
        margin: 0.45rem 0;
        text-align: justify;
    }

    .tract-page .tract-content blockquote,
    .tract-page .tract-body blockquote {
        margin: 0.65rem 0;
        padding: 0.4rem 0.65rem;
        border-left: 2px solid #000;
        background: #f5f5f5;
        font-size: 9pt;
    }
    
    .tract-page hr {
        border: none;
        border-top: 1px solid #000;
        margin: 0.55rem 0;
    }

    .tract-page .tract-footer {
        margin-top: 1.1rem;
        padding-top: 0.65rem;
        border-top: 1px solid #000;
        text-align: center;
        font-size: 9pt;
    }

    .tract-page .tract-footer .qr-print,
    .tract-page .tract-footer .tract-qr {
        display: block !important;
        margin: 0.55rem auto 0.4rem;
    }

    .tract-page .tract-footer .url {
        font-family: monospace;
        font-size: 10pt;
    }

    @page {
        size: letter;
        margin: 0.55in 0.6in 0.55in 0.6in;
    }
}

/* Footnote toggle button - icon-only circular design */
.footnote-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-round);
    cursor: pointer;
    z-index: var(--z-header);
    opacity: 0.6;
    transition: opacity var(--transition-slow), border-color var(--transition-fast), transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.footnote-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--fg);
    fill: none;
    transition: stroke var(--transition-fast);
}

.footnote-toggle.faded {
    opacity: 0.2;
}

.footnote-toggle:hover {
    opacity: 1;
    border-color: var(--accent);
    transform: scale(1.05);
}

.footnote-toggle:hover svg {
    stroke: var(--accent);
}

/* Active state when notes visible */
.footnote-toggle.notes-visible {
    background: var(--accent);
    border-color: var(--accent);
}

.footnote-toggle.notes-visible svg {
    stroke: var(--bg);
}

.footnote-toggle.notes-visible:hover {
    background: var(--link);
    border-color: var(--link);
}

/* Tooltip on hover */
.footnote-toggle::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--fg);
    color: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.footnote-toggle:hover::after {
    opacity: 1;
}

/* Hide sidenotes - fade instead of display:none to prevent layout jump */
body.hide-sidenotes .sidenote {
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

body.hide-sidenotes .sidenote-number:after {
    opacity: 0.3;
}

/* When sidenotes hidden, center the article by removing the margin offset (desktop only) */
@media (min-width: 1001px) {
    body.hide-sidenotes article:has(.sidenote) {
        max-width: var(--max-width);
        padding-left: 2rem;
        transition: padding-left var(--transition-normal), max-width var(--transition-normal);
    }

    /* Default transition for when sidenotes are shown */
    article:has(.sidenote) {
        transition: padding-left var(--transition-normal), max-width var(--transition-normal);
    }
}

/* Reading time indicator - super subtle */
.reading-time-indicator {
    text-align: center;
    margin: 0.25rem 0 1.5rem 0;
    opacity: 0.4;
}

.reading-time-indicator span {
    font-size: 0.75rem;
    color: var(--fg);
    letter-spacing: 0.03em;
}

/* Selection highlight */
::selection {
    background: rgba(139, 69, 19, 0.2);
}

/* ==========================================================================
   VISUALIZATION INDICATORS - Margin links to D3 visualizations
   ========================================================================== */

/* ==========================================================================
   DIAGRAM STYLES - Modern HTML/CSS replacements for ASCII art
   ========================================================================== */

/* Base diagram container */
.diagram {
    margin: 2rem auto;
    max-width: 100%;
    overflow-x: auto;
}

/* Responsive diagram grids - always stack in narrow article column */
.diagram-grid-2col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
    max-width: 100%;
}

.diagram-grid-2col-tight {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.diagram-grid-2col .arch-diagram,
.diagram-grid-2col .phase-box {
    max-width: 100%;
}

.diagram-title {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.diagram-subtitle {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

/* Equation Box - dramatic mathematical presentation */
.equation-box {
    background: var(--quote-bg);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    max-width: 320px;
    margin: 2rem auto;
    text-align: center;
}

.equation-box .line {
    font-size: 1.1rem;
    margin: 0.5rem 0;
    font-family: 'Palatino Linotype', Palatino, Georgia, serif;
}

.equation-box .operator {
    font-size: 1.3rem;
    color: var(--accent);
    font-weight: bold;
}

.equation-box .result {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent);
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
}

/* Comparison Table - claim vs reality */
    margin-bottom: 1.5em;
}

.comparison-table {
    width: 100%;
    max-width: 450px;
    margin: 2rem auto;
    border-collapse: collapse;
    background: var(--quote-bg);
    border-radius: 8px;
    overflow: hidden;
}

.comparison-table th {
    background: var(--accent);
    color: var(--bg);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.comparison-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.comparison-table tr:last-child td {
    border-bottom: none;
}

.comparison-table .claim {
    font-weight: 600;
}

.comparison-table .reality {
    color: var(--muted);
}

/* Full-width comparison table (for Appendix) */
.comparison-table-wrapper {
    overflow-x: auto;
    margin: 2rem 0;
}

.comparison-table.full-width {
    max-width: 100%;
    min-width: 700px;
}

.comparison-table.full-width th:first-child,
.comparison-table.full-width td:first-child {
    width: 15%;
    font-weight: 600;
}

.comparison-table.full-width th:nth-child(2),
.comparison-table.full-width td:nth-child(2),
.comparison-table.full-width th:nth-child(3),
.comparison-table.full-width td:nth-child(3) {
    width: 42.5%;
}

.comparison-table.full-width td {
    vertical-align: top;
    line-height: 1.5;
}

/* Table note cells */
.comparison-table .table-note {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Timeline table variant */
.comparison-table.timeline-table {
    max-width: 100%;
    min-width: 320px;
}

.comparison-table.timeline-table th {
    text-align: center;
}

.comparison-table.timeline-table .timeline-year {
    width: 70px;
    font-weight: 600;
    white-space: nowrap;
}

.comparison-table.timeline-table tr.highlight td {
    background: rgba(139, 69, 19, 0.1);
    color: var(--accent);
}

/* Summary Box */
.summary-box {
    background: var(--quote-bg);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.summary-box h3 {
    margin: 0 0 1rem 0;
    text-align: center;
    color: var(--accent);
}

.summary-columns {
    display: flex;
    gap: 2rem;
}

.summary-column {
    flex: 1;
}

.summary-column h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.summary-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.summary-column li {
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .summary-columns {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Bibliography / Works Cited */
.bibliography {
    font-size: 0.9rem;
    line-height: 1.6;
}

.bibliography p {
    padding-left: 2rem;
    text-indent: -2rem;
    margin-bottom: 0.75rem;
}

.bibliography a {
    word-break: break-word;
}

/* Timeline - historical progression */
.timeline {
    position: relative;
    margin: 2rem auto;
    max-width: 700px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 100%;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding: 1rem 0;
    display: flex;
    align-items: flex-start;
}

.timeline-item:nth-child(odd) {
    flex-direction: row;
}

.timeline-item:nth-child(even) {
    flex-direction: row-reverse;
}

.timeline-date {
    flex: 0 0 45%;
    text-align: right;
    padding-right: 2rem;
    font-weight: 600;
    color: var(--accent);
}

.timeline-item:nth-child(even) .timeline-date {
    text-align: left;
    padding-right: 0;
    padding-left: 2rem;
}

.timeline-marker {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    border: 3px solid var(--bg);
}

.timeline-content {
    flex: 0 0 45%;
    padding-left: 2rem;
    background: var(--quote-bg);
    padding: 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}

.timeline-item:nth-child(even) .timeline-content {
    padding-left: 1rem;
    padding-right: 2rem;
    border-left: none;
    border-right: 3px solid var(--accent);
}

.timeline-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    color: var(--fg);
}

.timeline-content p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Timeline item states */
.timeline-item.highlight .timeline-content {
    background: rgba(139, 69, 19, 0.1);
    border-color: var(--accent);
}

.timeline-item.highlight .timeline-marker {
    width: 16px;
    height: 16px;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.3);
}

.timeline-item.future .timeline-content {
    background: transparent;
    border-style: dashed;
}

.timeline-item.future .timeline-marker {
    background: transparent;
    border: 3px dashed var(--accent);
}

.timeline-item.future .timeline-date {
    font-style: italic;
}

/* Architecture Box - nested structures like Ark */
.arch-diagram {
    background: var(--quote-bg);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem auto;
    max-width: 600px;
}

.arch-box {
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin: 0.75rem 0;
    background: var(--bg);
}

.arch-box.outer {
    border-color: var(--accent);
    background: var(--quote-bg);
}

.arch-box.inner {
    border-style: dashed;
}

.arch-box.sacred {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--quote-bg) 0%, rgba(139, 69, 19, 0.1) 100%);
}

.arch-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.arch-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.arch-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
}

.arch-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.arch-list li {
    padding: 0.25rem 0;
}

/* Phase Diagram - multi-stage progression */
.phase-diagram {
    margin: 2rem auto;
    max-width: 650px;
}

.phase-start {
    text-align: center;
    padding: 1rem;
    background: var(--accent);
    color: var(--bg);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.phase-arrow {
    text-align: center;
    font-size: 2rem;
    color: var(--accent);
    margin: 0.5rem 0;
}

.phase-box {
    background: var(--quote-bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.phase-box.current {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--quote-bg) 0%, rgba(139, 69, 19, 0.05) 100%);
}

.phase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.phase-number {
    background: var(--accent);
    color: var(--bg);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.phase-status {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    background: rgba(139, 69, 19, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
}

.phase-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--accent);
}

.phase-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.phase-column h5 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.phase-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
}

.phase-column li {
    padding: 0.25rem 0;
    padding-left: 1rem;
    position: relative;
}

.phase-column li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* Tree Diagram - hierarchical structures */
.tree-diagram {
    margin: 2rem auto;
    overflow-x: auto;
    padding: 1rem;
}

.tree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tree-label {
    background: var(--quote-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    margin: 0.25rem;
    min-width: 100px;
}

.tree-label.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
}

.tree-label.highlight {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--quote-bg) 0%, rgba(139, 69, 19, 0.1) 100%);
}

.tree-children {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    position: relative;
}

.tree-children::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    left: 50%;
    width: 1px;
    height: 0.5rem;
    background: var(--border);
}

/* Responsive diagrams */
@media (max-width: 768px) {
    .timeline::before {
        left: 20px;
    }

    .timeline-item,
    .timeline-item:nth-child(even) {
        flex-direction: column;
        padding-left: 50px;
    }

    .timeline-date,
    .timeline-item:nth-child(even) .timeline-date {
        text-align: left;
        padding: 0 0 0.5rem 0;
        flex: none;
    }

    .timeline-marker {
        left: 20px;
    }

    .timeline-content,
    .timeline-item:nth-child(even) .timeline-content {
        padding: 1rem;
        border-left: 3px solid var(--accent);
        border-right: none;
    }

    .phase-columns {
        grid-template-columns: 1fr;
    }

    .arch-list {
        grid-template-columns: 1fr;
    }

    .comparison-table {
        font-size: 0.85rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem 0.75rem;
    }
}

/* Horizontal Timeline - historical progression in a row */
.timeline-horizontal {
    margin: 2rem auto;
    max-width: 100%;
    overflow-x: auto;
    padding: 1rem 0;
}

.timeline-events {
    display: flex;
    gap: 0;
    min-width: max-content;
    padding: 0 1rem;
}

.timeline-event {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    position: relative;
}

.timeline-event::after {
    content: '→';
    position: absolute;
    right: -0.5rem;
    top: 2.5rem;
    color: var(--accent);
    font-size: 1.2rem;
}

.timeline-event:last-child::after {
    display: none;
}

.timeline-year {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.timeline-card {
    background: var(--quote-bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
    width: 110px;
}

.timeline-card.highlight {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--quote-bg) 0%, rgba(139, 69, 19, 0.1) 100%);
}

.timeline-card.future {
    border-style: dashed;
    border-color: var(--accent);
}

.timeline-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
    color: var(--fg);
}

.timeline-card p {
    margin: 0;
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.3;
}

.timeline-result {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.timeline-result-box {
    background: var(--quote-bg);
    border: 2px dashed var(--accent);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    text-align: center;
    max-width: 300px;
}

.timeline-result-box h4 {
    margin: 0 0 0.5rem 0;
    color: var(--accent);
    font-size: 0.9rem;
}

.timeline-result-box p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.timeline-pattern {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--quote-bg);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}

.timeline-pattern p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
}

.timeline-pattern strong {
    color: var(--accent);
}

@media (max-width: 768px) {
    .timeline-events {
        flex-direction: column;
        min-width: unset;
        gap: 1rem;
    }

    .timeline-event {
        flex-direction: row;
        min-width: unset;
        width: 100%;
    }

    .timeline-event::after {
        content: '↓';
        position: static;
        margin-left: 1rem;
        align-self: center;
    }

    .timeline-year {
        min-width: 70px;
        margin-bottom: 0;
        margin-right: 0.5rem;
    }

    .timeline-card {
        width: auto;
        flex: 1;
        text-align: left;
    }
}

/* ==========================================================================
   SHARED COMPONENT LIBRARY - Reusable patterns across all pages
   ========================================================================== */

/* Button System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: none;
    color: var(--fg);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn:active {
    background: var(--accent);
    color: var(--bg);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.btn.primary:hover {
    background: var(--link);
    border-color: var(--link);
    color: var(--bg);
}

.btn.large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Stat Card System */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: var(--quote-bg);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.2;
}

.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* Tab System */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    gap: 0;
}

.tab {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--fg);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Streak Display (text-based, no emoji) */
.streak-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: var(--quote-bg);
    border-radius: 4px;
    font-size: 0.85rem;
}

.streak-count {
    font-weight: 600;
    color: var(--accent);
}

.streak-label {
    color: var(--muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}

.empty-state p {
    margin: 0.5rem 0;
    text-align: center;
}

/* Card Component */
.card {
    background: var(--quote-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s;
}

.card:hover {
    border-color: var(--accent);
}

.card.clickable {
    cursor: pointer;
}

.card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* Tool List (from download.html) */
.tool-list {
    display: flex;
    flex-direction: column;
}

.tool-item {
    display: flex;
    align-items: baseline;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    gap: 0.75rem;
}

.tool-item:last-child {
    border-bottom: none;
}

.tool-item:hover {
    background: var(--quote-bg);
    margin: 0 -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    border-radius: 4px;
}

.tool-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-name {
    font-weight: 500;
    min-width: 140px;
    flex-shrink: 0;
}

.tool-desc {
    color: var(--muted);
    font-size: 0.9rem;
    flex: 1;
}

.tool-action {
    color: var(--muted);
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-left: auto;
}

@media (max-width: 600px) {
    .tool-name {
        min-width: 100px;
    }
    .tool-desc {
        font-size: 0.85rem;
    }
}

/* ============================================
   SHARED DEVOTIONAL PAGE PATTERN
   Used by: Prayer, Memorize, Book, Bible
   ============================================ */

/* Page Container */
.devotional-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
    min-height: calc(100vh - var(--navbar-height));
}

/* Page Header */
.devotional-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.devotional-header h1 {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    margin: 0;
    color: var(--accent);
}

.devotional-subtitle {
    color: var(--muted);
    font-style: italic;
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

/* Study page subtitles */
.subtitle {
    font-size: 0.95rem;
    color: var(--muted);
    text-align: center;
    margin-bottom: 2rem;
    font-style: italic;
}

/* Hero Card (Featured Item) */
.devotional-hero {
    background: linear-gradient(135deg, var(--quote-bg) 0%, var(--bg) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.devotional-hero:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.devotional-hero-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.devotional-hero-title {
    font-size: 1.3rem;
    font-weight: 500;
    margin: 0 0 0.5rem;
    color: var(--fg);
}

.devotional-hero-ref {
    font-size: 0.85rem;
    color: var(--link);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 0.75rem;
}

.devotional-hero-ref:hover {
    text-decoration: underline;
}

.devotional-hero-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--muted);
    font-style: italic;
    margin: 0;
}

.devotional-hero-cta {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    margin-top: 0.75rem;
    opacity: 0.7;
}

/* Week Indicator (Sunday through Sabbath) */
.week-indicator {
    margin: 1rem 0;
    padding: 0.75rem 0;
}

.week-days {
    display: flex;
    justify-content: space-between;
    gap: 0.25rem;
}

.week-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.week-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.week-dot {
    font-size: 0.9rem;
    color: var(--muted);
    opacity: 0.4;
}

.week-dot.prayed,
.week-dot.active {
    color: var(--accent);
    opacity: 1;
}

.week-day.today .week-label {
    color: var(--fg);
    font-weight: 600;
}

.week-day.today .week-dot {
    opacity: 0.7;
}

/* Sabbath - the seventh day - emphasized */
.week-day.sabbath .week-label {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.6rem;
}

.week-day.sabbath .week-dot.prayed,
.week-day.sabbath .week-dot.active {
    color: var(--accent);
    font-size: 1.1rem;
}

/* Stats Bar (Horizontal) */
.devotional-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
    margin-bottom: 1rem;
    background: var(--quote-bg);
    border-radius: 8px;
}

.devotional-stat {
    text-align: center;
}

.devotional-stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1;
}

.devotional-stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-top: 0.25rem;
    display: block;
}

.devotional-stat-divider {
    width: 1px;
    height: 30px;
    background: var(--border);
}

/* Progress Bar */
.devotional-progress {
    margin-bottom: 1.5rem;
}

.devotional-progress-bar {
    background: var(--quote-bg);
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
}

.devotional-progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.devotional-progress-text {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* Primary Action Buttons */
.devotional-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 300px;
    margin: 1.5rem auto;
}

.devotional-primary-btn {
    background: var(--accent);
    color: var(--bg);
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.devotional-primary-btn:hover {
    filter: brightness(1.1);
}

.devotional-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.devotional-secondary-btn {
    background: none;
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.devotional-secondary-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Section Divider */
.devotional-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Quick Access Pills */
.devotional-pills {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.devotional-pills::-webkit-scrollbar {
    display: none;
}

.devotional-pill {
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
    color: var(--fg);
    cursor: pointer;
    transition: all 0.2s;
}

.devotional-pill:hover {
    border-color: var(--accent);
    background: var(--quote-bg);
}

.devotional-pill.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

/* Collection Section */
.devotional-section {
    margin-bottom: 1.5rem;
}

.devotional-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.devotional-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    margin: 0;
    font-weight: 400;
}

.devotional-section-action {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.devotional-section-action:hover {
    opacity: 0.9;
}

/* Collection Card */
.devotional-collection {
    background: var(--quote-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.devotional-collection:hover {
    border-color: var(--accent);
}

.devotional-collection-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.devotional-collection-item:last-child {
    border-bottom: none;
}

.devotional-collection-name {
    font-size: 0.9rem;
    color: var(--fg);
}

.devotional-collection-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.devotional-see-all {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0.75rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--link);
    cursor: pointer;
}

.devotional-see-all:hover {
    color: var(--accent);
}

/* Browse Grid */
.devotional-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (max-width: 450px) {
    .devotional-grid {
        grid-template-columns: 1fr;
    }
}

.devotional-card {
    background: var(--quote-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.devotional-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.devotional-card-name {
    font-weight: 500;
    color: var(--fg);
    margin-bottom: 0.25rem;
}

.devotional-card-count {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Empty State */
.devotional-empty {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--quote-bg);
    border-radius: 10px;
    border: 1px dashed var(--border);
}

.devotional-empty-icon {
    font-size: 2rem;
    color: var(--muted);
    opacity: 0.5;
    margin-bottom: 0.75rem;
}

.devotional-empty-text {
    font-size: 0.9rem;
    color: var(--fg);
    margin: 0 0 0.25rem;
}

.devotional-empty-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.remnant-toast-container {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-alert);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.remnant-toast {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    max-width: 400px;
    width: max-content;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: toastSlideUp var(--transition-normal);
    border-left: 4px solid var(--accent);
}

.remnant-toast.success { border-left-color: var(--success); }
.remnant-toast.warning { border-left-color: var(--warning); }
.remnant-toast.danger { border-left-color: var(--danger); }

.remnant-toast.dismissing {
    animation: toastSlideDown var(--transition-fast);
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--fg);
}

.toast-dismiss {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color var(--transition-fast);
}

.toast-dismiss:hover {
    color: var(--fg);
}

.toast-action {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.toast-action:hover {
    opacity: 0.9;
}

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

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

@media (max-width: 600px) {
    .remnant-toast-container {
        left: 1rem;
        right: 1rem;
        transform: none;
    }

    .remnant-toast {
        max-width: none;
        width: auto;
    }
}

/* ==========================================================================
   Specialized Page Header Overrides
   Used by bible.html, memorize.html, prayer.html
   ========================================================================== */

.page-bible .site-header,
.page-memorize .site-header,
.page-prayer .site-header,
.page-share .site-header,
.page-index .site-header,
.page-chapter .site-header,
.page-progress .site-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding-right: 0.5rem;
}

.page-bible .site-nav,
.page-memorize .site-nav,
.page-prayer .site-nav,
.page-share .site-nav,
.page-index .site-nav,
.page-chapter .site-nav,
.page-progress .site-nav {
    justify-self: start;
}

.page-bible .header-actions,
.page-memorize .header-actions,
.page-prayer .header-actions,
.page-share .header-actions,
.page-index .header-actions,
.page-chapter .header-actions,
.page-progress .header-actions {
    grid-column: 3;
    justify-self: end;
}

@media (max-width: 600px) {
    .page-bible .site-header,
    .page-memorize .site-header,
    .page-prayer .site-header,
    .page-share .site-header,
    .page-index .site-header,
    .page-chapter .site-header,
    .page-progress .site-header {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0.5rem 0.5rem 0.5rem 1rem;
    }

    .page-bible .site-nav,
    .page-memorize .site-nav,
    .page-prayer .site-nav,
    .page-share .site-nav,
    .page-index .site-nav,
    .page-chapter .site-nav,
    .page-progress .site-nav {
        grid-column: 1;
    }

    .page-bible .header-actions,
    .page-memorize .header-actions,
    .page-prayer .header-actions,
    .page-share .header-actions,
    .page-index .header-actions,
    .page-chapter .header-actions,
    .page-progress .header-actions {
        grid-column: 2;
    }
}

/* ==========================================================================
   MOBILE SIDENOTE POPOVER
   ========================================================================== */

.sidenote-popover {
    position: fixed;
    z-index: var(--z-modal);
    max-width: calc(100vw - 2rem);
    width: 320px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--fg);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    pointer-events: none;
}

.sidenote-popover.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sidenote-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.sidenote-popover-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

.sidenote-popover-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    font-size: 1.25rem;
}

.sidenote-popover-close:hover {
    color: var(--fg);
}

.sidenote-popover-content {
    color: var(--muted);
}

.sidenote-popover-content a {
    word-break: break-all;
}

/* Arrow pointing to sidenote number */
.sidenote-popover::before {
    content: '';
    position: absolute;
    top: -6px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--border);
}

.sidenote-popover::after {
    content: '';
    position: absolute;
    top: -5px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--bg);
}

/* Arrow below when popover is above tap */
.sidenote-popover.arrow-bottom::before {
    top: auto;
    bottom: -6px;
    border-bottom-color: transparent;
    border-top-color: var(--border);
}

.sidenote-popover.arrow-bottom::after {
    top: auto;
    bottom: -5px;
    border-bottom-color: transparent;
    border-top-color: var(--bg);
}

/* Backdrop for dismissal */
.sidenote-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) - 1);
    background: transparent;
    display: none;
}

.sidenote-backdrop.visible {
    display: block;
}
