:root {
    --gold-accent: #d29a38;
    --gold-hover: #b8862f;
    --gold-glow: rgba(210, 154, 56, 0.15);
    --gold-glow-strong: rgba(210, 154, 56, 0.3);
    --surface: #1e1e1e;
    --surface-hover: #252525;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --font-serif: "Source Serif 4", ui-serif, Georgia, "Times New Roman", serif;
    --font-inter: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-open-sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-lato: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #c1c1c1;
    background-color: #121212;
    font-family: var(--font-serif);
    font-optical-sizing: auto;
}

body.font-inter { font-family: var(--font-inter); }
body.font-open-sans { font-family: var(--font-open-sans); }
body.font-lato { font-family: var(--font-lato); }

/* ── Nav bar ── */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    background-color: var(--surface);
    padding: 4px 16px;
    border-bottom: none;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    color: var(--gold-accent);
    font-weight: 600;
    letter-spacing: 0.03em;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}
.nav-bar > .sidebar-toggle { grid-column: auto; }  /* absolute-positioned; grid-column would re-anchor its containing block */
.nav-bar > .nav-title { grid-column: 2; justify-self: center; white-space: nowrap; }
.nav-bar > .nav-actions { grid-column: 3; justify-self: end; }

.nav-bar button {
    background-color: var(--surface);
    border: 1px solid rgba(147, 104, 30, 0.4);
    padding: 0px 6px 2px 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: rgba(147, 104, 30, 0.8);
    font-weight: 500;
}

.nav-bar button:hover {
    background-color: var(--gold-hover);
    box-shadow: 0 2px 8px var(--gold-glow-strong);
}

/* ── Book toolbar (sticky controls in content area) ── */
.book-toolbar {
    position: sticky;
    top: 0px;                 /* gap below the fixed navbar so it never tucks under */
    z-index: 10;
    background: #121212;
    padding-top: 6px;
    border-bottom: 1px solid rgba(210, 154, 56, 0.4);
    margin-top: -28px;
}


.book-title {
    font-weight: 600;
    color: var(--gold-accent);
    font-size: 0.82em;
    letter-spacing: 0.02em;
    white-space: nowrap;
    padding: 0 4px 0 8px;
}


/* ── Column headers (single-row toolbar) ── */
.column-headers {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px 0;
}

.column-header {
    flex: 0 1 650px;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.column-select {
    background: transparent;
    color: #b0b0b0;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 5px 4px;
    border-radius: 0;
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    padding-right: 18px;
}

.column-select:hover {
    color: #e0e0e0;
    border-bottom-color: var(--gold-accent);
}

.column-select:focus {
    outline: none;
    color: #e0e0e0;
    border-bottom-color: var(--gold-accent);
    box-shadow: 0 1px 0 0 var(--gold-accent);
}

.column-select option {
    background: #1e1e1e;
    color: #c1c1c1;
}

.column-btn {
    background: transparent;
    color: #666;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.column-btn:hover {
    color: var(--gold-accent);
    background: rgba(210, 154, 56, 0.1);
}


/* ── Row groups (multi-column height sync) ── */
.row-group {
    display: flex;
    align-items: stretch;
    margin-bottom: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.row-group > .row-container {
    flex: 0 1 650px;
}

.row-group > .row-container + .row-container {
    border-left: 1px solid var(--border-subtle);
}

/* ── Per-row notes (inside row-group) ── */
.row-notes {
    display: none;
    flex: 0 1 650px;
    padding: 16px 12px;
    font-size: 13px;
    line-height: 1.55;
    color: #aaa;
    border-left: 1px solid var(--border-subtle);
}

.row-group.show-row-notes > .row-notes {
    display: block;
}

/* Per-row notes toggle — notebook icon, on/off states (above tabs) */
.row-notes-toggle {
    display: grid;
    place-items: center;
    width: 22px;
    height: 20px;
    padding: 0;
    margin: 0 0 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #888;
    transition: color 0.15s;
}
.row-notes-toggle svg { width: 15px; height: 15px; display: block; }
.row-notes-toggle:hover { color: var(--gold-accent); }
.row-notes-toggle.active { color: var(--gold-accent); }              /* ON */
.row-notes-toggle.active path:first-of-type { fill: color-mix(in srgb, var(--gold-accent) 16%, transparent); }

.row-notes .note-index {
    font-weight: 600;
    color: var(--gold-accent);
    margin-right: 6px;
    font-size: 12px;
}

/* ── Sidebar Style Section ── */
.sidebar-section {
    border-bottom: 1px solid var(--border-medium);
    margin-bottom: 12px;
    padding-bottom: 8px;
}

.section-toggle {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--gold-accent);
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    font-family: inherit;
}

.section-toggle:hover {
    color: var(--gold-hover);
}

.section-content.collapsed {
    display: none;
}

.style-group {
    margin-bottom: 10px;
}

.style-group label {
    display: block;
    font-size: 0.75em;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.theme-switcher,
.font-switcher {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.theme-btn,
.font-btn {
    background-color: transparent;
    border: 1px solid var(--border-medium);
    color: #888;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-btn:hover,
.font-btn:hover {
    border-color: var(--gold-accent);
    color: var(--gold-accent);
}

.theme-btn.active,
.font-btn.active {
    background-color: var(--gold-glow);
    border-color: var(--gold-accent);
    color: var(--gold-accent);
}

/* Font preview on each button */
.font-btn[data-font="serif"] { font-family: var(--font-serif); }
.font-btn[data-font="inter"] { font-family: var(--font-inter); }
.font-btn[data-font="open-sans"] { font-family: var(--font-open-sans); }
.font-btn[data-font="lato"] { font-family: var(--font-lato); }

/* ── Layout ── */
.container {
    display: flex;
    min-height: 100vh;
    padding-top: var(--nav-h, 50px);   /* matches the actual fixed navbar height (set by JS) */
    padding-left: 270px;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 50px;
    left: 0;
    width: 250px;
    background-color: var(--surface);
    padding: 20px;
    border-right: none;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    height: calc(100vh - 50px);
    z-index: 999;
}

.sidebarList {
    border-left: 1px solid rgba(147, 104, 30, 0.4);
}

.sidebar h2 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 0.85em;
    font-weight: 600;
    color: #c1c1c1;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar h2:first-of-type {
    margin-top: 12px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin-left: 5px;
}


.sidebar button {
    font-size: 1em;
    cursor: pointer;
    width: 100%;
    text-align: left;
    border: none;
    background-color: transparent;
    color: #c1c1c1;
    padding: 6px 8px;
    transition: all 0.2s ease;
}

.sidebar button:hover {
    color: var(--gold-accent);
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar button.active-item {
    color: var(--gold-accent);
    background-color: var(--gold-glow);
    border-left: 1px solid var(--gold-accent);
    padding-left: 8px;
}

/* Chapter chevron on active book/article with chapters */
.sidebar button.has-chapters::after {
    content: '▾';
    float: right;
    font-size: 0.75em;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.sidebar button.has-chapters.chapters-collapsed::after {
    content: '▸';
}

.chapter-button {
    font-size: 0.85em !important;
    color: #999 !important;
}

.chapter-button:hover {
    color: var(--gold-accent) !important;
}

/* Thought expand toggle (▸/▾) inside chapter buttons */
.thought-expand-toggle {
    display: inline-block;
    width: 14px;
    font-size: 0.75em;
    opacity: 0.5;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s ease;
}

.thought-expand-toggle:hover {
    opacity: 1;
}

/* Thought sub-list under each chapter */
.thought-list {
    margin-left: 14px;
    padding: 0;
    list-style: none;
}

.thought-list.collapsed {
    display: none;
}

.thought-button {
    font-size: 0.78em !important;
    color: #777 !important;
    padding: 2px 8px !important;
}

.thought-button:hover {
    color: var(--gold-accent) !important;
}

#wisdom-map-btn {
    border: 1px solid var(--gold-accent);
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--gold-accent);
    font-weight: 500;
    margin-bottom: 8px;
}

#wisdom-map-btn:hover {
    background-color: var(--gold-glow);
    box-shadow: 0 2px 8px var(--gold-glow-strong);
}

/* ── Main content ── */
.main-content {
    flex-grow: 1;
    padding: 0px 12px 12px 12px;
    position: relative;
    min-height: 500px;
}

.main-content h1 {
    margin-top: 0;
    font-size: 1.8em;
    color: #fff;
}

.content {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
    overflow-x: auto;
    overflow-y: clip;
    padding-bottom: 10px;
}

.content p {
    color: #f0f0f0;
}

.content p.error {
    color: #ff4d4d;
    font-weight: 500;
    text-align: center;
}

.content p.loading {
    color: #888;
    font-style: italic;
    text-align: center;
}

.doc-content {
    max-width: 650px;
    padding: 16px;
    font-size: 18px;
    line-height: 1.6;
    color: #f0f0f0;
}

.doc-content:has(.row-group) {
    max-width: none;
}

.doc-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.doc-content a {
    color: var(--gold-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.doc-content a:hover {
    color: var(--gold-hover);
    border-bottom-color: var(--gold-hover);
}

#banners {
    display: none !important;
}

/* ── Tabs ── */
.tab {
    border: 1px solid var(--border-medium);
    border-left: 0;
    padding: 2px 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
    font-size: 12px;
    transition: all 0.2s ease;
    color: #999;
    height: 14px;
}

.tab.active {
    border-color: rgba(147, 104, 30, 0.8);
    font-weight: 500;
}

.tab.search-match {
    background-color: rgba(56, 178, 210, 0.15);
    border-color: rgba(56, 178, 210, 0.6);
    color: #38b2d2;
}

.tab.search-match.active {
    background-color: rgba(56, 178, 210, 0.25);
}

.tab:hover {
    background-color: var(--surface-hover);
    border-color: var(--gold-accent);
    color: var(--gold-accent);
}

.content-body {
    flex-grow: 1;
    max-width: 650px;
    max-height: calc(100vh - var(--nav-h, 50px));   /* fit below the navbar so the page itself never scrolls */
    overflow-y: auto;
    scroll-padding-top: 38px;
}

.content-body:has(.row-group) {
    max-width: none;
}

/* ── Content Search Bar — one per column, each centered in its column slot ── */
.search-row { display: flex; align-items: flex-start; gap: 0; }
.search-slot { flex: 0 1 650px; min-width: 0; display: flex; justify-content: center; }
.content-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    width: 100%;
    max-width: 380px;
}
/* Export + edit-in-sheet icons — sit left of the book title, reveal on toolbar hover */
.fuall-line-actions { display: inline-flex; gap: 5px; margin-right: 4px; opacity: 0; transition: opacity 0.15s ease; }
.book-toolbar:hover .fuall-line-actions,
.fuall-line-actions:focus-within { opacity: 1; }
.fuall-line-btn {
    width: 26px; height: 26px; padding: 0;
    display: grid; place-items: center;
    background: transparent; border: 1px solid rgba(147, 104, 30, 0.45);
    border-radius: 6px; color: var(--gold-accent); cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.fuall-line-btn svg { width: 15px; height: 15px; }
.fuall-line-btn:hover { background: var(--gold-accent); color: #121212; }

/* Sticky when standalone (no book-toolbar parent) */
.content-body > .content-search-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #121212;
}

.content-search-input {
    background-color: var(--surface);
    border: 1px solid var(--border-medium);
    color: #e0e0e0;
    padding: 4px;
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font-serif);
    flex-grow: 1;
    transition: border-color 0.2s ease;
}

.content-search-input:focus {
    outline: none;
    border-color: var(--gold-accent);
}

.content-search-input::placeholder {
    color: #666;
}

.content-search-clear {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.content-search-clear:hover {
    color: var(--gold-accent);
}

.content-search-count {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.row-container.search-hidden,
.row-group.search-hidden,
.chapter-head.search-hidden {
    display: none;
}

.content-search-no-results {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 40px 20px;
    font-size: 14px;
}

.row-container {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
}

.chapter-head+.row-group {
    border-top: none;
    padding-top: 0;
}

.row-tabs {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 12px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    align-self: flex-start;
    z-index: 5;
}

.row-content {
    width: 650px;
    flex-shrink: 1;
    padding: 16px 14px;
    font-size: clamp(1.125rem, 1.05rem + 0.4vw, 1.25rem);  /* v2: 18 → 20px */
    line-height: 1.6;                                       /* v2 */
    color: #e0e0e0;                                         /* v2 (not pure #f0f0f0) */
    font-optical-sizing: auto;
    overflow-wrap: break-word;
    border-left: 1px solid rgba(147, 104, 30, 0.4);
    border-right: 1px solid rgba(147, 104, 30, 0.4);
}

.row-content p {
    margin: 0 0 0.6em 0;
    text-indent: 1.5em;          /* book-style indent (ported from v2) */
}
.row-content p:first-child {
    text-indent: 0;              /* first line of each passage sits flush */
}
.row-content p:last-child {
    margin-bottom: 0;
}

/* ── Tooltip styling ── */
/* Linked text (auto-matched annotation terms + inline cross-refs) reads in normal
   color with a dotted gold underline marking it as a link. */
.ref {
    color: inherit;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px dotted rgba(210, 154, 56, 0.6);   /* between section-dim and full gold */
}
.ref:hover { color: var(--gold-accent); border-bottom-color: var(--gold-accent); }

/* Custom tooltip (replaces Tippy.js) */
.custom-tooltip {
    position: fixed;
    display: none;
    background-color: #333232;
    color: #f0f0f0;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(147, 104, 30, 0.4);
    max-width: 320px;
    max-height: 350px;
    overflow-y: auto;
    overscroll-behavior: contain;
    word-wrap: break-word;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(210, 154, 56, 0.15);
    z-index: 1100;
    pointer-events: auto;
    font-size: 14px;
    line-height: 1.5;
}

/* Custom scrollbar for tooltip */
.custom-tooltip::-webkit-scrollbar {
    width: 8px;
}

.custom-tooltip::-webkit-scrollbar-track {
    background: #000;
    border-radius: 4px;
}

.custom-tooltip::-webkit-scrollbar-thumb {
    background: var(--gold-accent);
    border-radius: 4px;
}

.custom-tooltip::-webkit-scrollbar-thumb:hover {
    background: var(--gold-hover);
}

.custom-tooltip.visible {
    display: block;
}

.custom-tooltip a {
    color: var(--gold-accent);
}

/* ── Wisdom Map ── */
#wisdom-map {
    width: 100%;
    height: calc(100vh - 70px);
    border: 1px solid var(--border-subtle);
    background-color: #121212;
    display: none;
    position: relative;
}

.map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.map-controls button {
    background-color: var(--surface);
    border: 1px solid var(--border-medium);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    color: #c1c1c1;
    font-size: 12px;
    transition: all 0.2s ease;
}

.map-controls button.active {
    background-color: var(--gold-accent);
    color: #121212;
}

.map-controls button:hover {
    background-color: var(--surface-hover);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ── Map Filter Controls (top-left) ── */
.map-filter-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    background-color: rgba(30, 30, 30, 0.9);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
}

.map-search-input {
    background-color: var(--surface);
    border: 1px solid var(--border-medium);
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    width: 180px;
    transition: border-color 0.2s ease;
}

.map-search-input:focus {
    outline: none;
    border-color: var(--gold-accent);
}

.map-search-input::placeholder {
    color: #666;
}

.map-tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.map-filter-btn {
    background-color: transparent;
    border: 1px solid var(--border-medium);
    color: #999;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.map-filter-btn.active {
    background-color: var(--gold-glow);
    border-color: var(--gold-accent);
    color: var(--gold-accent);
}

#hover-preview {
    position: absolute;
    background-color: var(--surface);
    border: 1px solid var(--border-medium);
    padding: 10px 12px;
    max-width: 300px;
    max-height: 200px;
    overflow: auto;
    display: none;
    z-index: 999;
    pointer-events: none;
    color: #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ── Map Popup (draggable content viewer) ── */
.map-popup {
    position: absolute;
    display: flex;
    flex-direction: column;
    min-width: 350px;
    min-height: 300px;
    max-width: 600px;
    max-height: 80vh;
    background-color: var(--surface);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 1050;
    resize: both;
    overflow: hidden;
}

.map-popup-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--border-subtle);
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.map-popup-title {
    font-weight: 600;
    color: var(--gold-accent);
    flex-grow: 1;
    text-align: center;
}

.map-popup-type {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    margin-right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.map-popup-type:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--gold-accent);
}

.goto-arrow {
    font-size: 12px;
}

.map-popup-close {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.map-popup-close:hover {
    color: #fff;
}

.map-popup-body {
    padding: 12px;
    color: #c1c1c1;
    overflow: auto;
    flex-grow: 1;
}

.map-popup-body .doc-content {
    max-width: 100%;
    padding: 0;
}

/* ── Popover ── */
.popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--surface);
    border: 1px solid var(--border-medium);
    padding: 24px;
    max-width: 80%;
    max-height: 80%;
    overflow: auto;
    z-index: 1001;
    display: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: #e0e0e0;
}

#popover-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: transparent;
    color: #888;
    border: 1px solid var(--border-medium);
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
}

#popover-close:hover {
    color: var(--gold-accent);
    border-color: var(--gold-accent);
    background-color: var(--gold-glow);
}

/* ── Loading ── */
.inline-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #888;
}

.inline-loading .spinner {
    width: 28px;
    height: 28px;
    margin-bottom: 12px;
}

.inline-loading .loading-phi {
    width: 28px;
    height: 28px;
    margin-bottom: 12px;
}

.inline-loading p {
    font-size: 14px;
    margin: 0;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60vh;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: var(--gold-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-phi,
.loading-phi-large {
    width: 48px;
    height: 48px;
    animation: phiGrow 2.5s ease-out infinite;
}

.content-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60vh;
}

@keyframes phiGrow {
    0% {
        transform: scale(0.3);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.4);
        opacity: 1;
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Utility ── */
.hidden {
    display: none;
}

.thought-label {
    font-style: italic;
    color: #ccc;
    display: block;
    margin-top: 10px;
}

.chapter-head {
    color: var(--gold-accent);
    font-size: 1.15em;
    font-weight: 600;
    margin-top: 40px;
    margin-bottom: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
    scroll-margin-top: 60px;
}

.sub-list {
    margin-left: 16px;
    margin-bottom: 8px;
}

.sub-list.collapsed {
    display: none;
}

/* ── Focus states for keyboard navigation ── */
*:focus-visible {
    outline: 2px solid var(--gold-accent);
    outline-offset: 2px;
}

/* ── Hamburger toggle — hidden on desktop ── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--gold-accent);
    font-size: 1.5em;
    cursor: pointer;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 10px;
}

/* ── Sidebar overlay for mobile ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Responsive: mobile layout ── */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }

    .nav-bar {
        padding-left: 48px;
        transition: transform 0.3s ease;
    }

    .nav-bar.hide-on-scroll {
        transform: translateY(-100%);
    }

    .nav-bar.hide-on-scroll ~ .container {
        padding-top: 0;
    }

    .book-toolbar {
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .book-toolbar.hide-on-scroll {
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
    }



    .column-btn {
        display: none;
    }

    .row-tabs {
        top: 50px;
    }

    .sidebar {
        left: -290px;
        transition: left 0.3s ease;
        z-index: 1001;
    }

    .sidebar.open {
        left: 0;
    }

    .container {
        padding-left: 0;
        transition: padding-top 0.3s ease;
    }

    .main-content {
        padding: 0;
    }

    .content-body {
        max-width: 100%;
    }

    .row-group {
        flex-direction: column;
    }

    .row-group > .row-container {
        flex-basis: auto;
        width: 100%;
    }

    .row-container {
        flex-direction: column-reverse;
    }

    .row-tabs {
        flex-direction: row;
        position: static;
        margin-top: 0;
        margin-bottom: 4px;
    }

    .row-content {
        width: 100%;
        padding: 12px 4px;
    }

    .doc-content {
        max-width: 100%;
        padding: 12px;
    }

    /* ── Mobile notes overlay ── */
    .row-group.show-row-notes > .row-notes {
        display: none;
    }

    .notes-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1200;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(3px);
        justify-content: center;
        align-items: center;
        padding: 24px;
    }

    .notes-overlay.active {
        display: flex;
    }

    .notes-overlay-content {
        background: var(--surface);
        color: #c1c1c1;
        border: 1px solid var(--border-medium);
        border-radius: 10px;
        padding: 24px 20px;
        max-width: 500px;
        width: 100%;
        max-height: 70vh;
        overflow-y: auto;
        font-size: 14px;
        line-height: 1.6;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    }

    .notes-overlay-content .note-index {
        font-weight: 600;
        color: var(--gold-accent);
        margin-right: 6px;
        font-size: 13px;
    }

    body.light-theme .notes-overlay {
        background: rgba(0, 0, 0, 0.35);
    }

    body.light-theme .notes-overlay-content {
        background: #ffffff;
        color: #424242;
        border-color: rgba(0, 0, 0, 0.1);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-accent);
}

/* Firefox */
html, body, .content-body, .main-content {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--surface);
}

/* ── Light Theme (inspired by LessWrong) ── */
body.light-theme {
    --surface: #ffffff;
    --surface-hover: #fafafa;
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-medium: rgba(0, 0, 0, 0.1);
    --gold-glow: rgba(210, 154, 56, 0.1);
    --gold-glow-strong: rgba(210, 154, 56, 0.2);
    color: rgba(0, 0, 0, 0.87);
    background-color: #ffffff;
}

/* ── Light: nav bar (frosted glass) ── */
body.light-theme .nav-bar {
    background-color: #f5f5f5;
    box-shadow: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--gold-accent);
}

body.light-theme .nav-bar button {
    color: #ffffff;
}

/* ── Light: sidebar ── */
body.light-theme .sidebar {
    background: #f5f5f5;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: none;
}

body.light-theme .sidebar h2 {
    color: #424242;
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .sidebar .sidebarList button {
    color: rgba(0, 0, 0, 0.6);
}

body.light-theme .sidebar .sidebarList button:hover {
    color: rgba(0, 0, 0, 0.87);
    background-color: rgba(0, 0, 0, 0.03);
}

body.light-theme .sidebar .sidebarList button.active-item {
    color: var(--gold-accent);
    background-color: rgba(210, 154, 56, 0.06);
}

body.light-theme .sidebarList {
    border-left-color: rgba(210, 154, 56, 0.25);
}

body.light-theme .chapter-button {
    color: #757575 !important;
}

body.light-theme .chapter-button:hover {
    color: var(--gold-accent) !important;
}

body.light-theme .section-toggle {
    color: var(--gold-accent);
}

body.light-theme .style-group label {
    color: #9e9e9e;
}

body.light-theme .theme-btn,
body.light-theme .font-btn {
    color: #757575;
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .theme-btn.active,
body.light-theme .font-btn.active {
    color: var(--gold-accent);
    border-color: var(--gold-accent);
}

body.light-theme .sidebar-overlay {
    background: rgba(0, 0, 0, 0.15);
}

/* ── Light: content area ── */
body.light-theme .content-body {
    color: rgba(0, 0, 0, 0.87);
    background-color: #ffffff;
}

body.light-theme .content-body > .content-search-bar {
    background-color: #ffffff;
}

body.light-theme .content-body h1,
body.light-theme .content-body h2,
body.light-theme .content-body h3 {
    color: #424242;
}

body.light-theme .main-content h1 {
    color: #424242;
}

body.light-theme .content p {
    color: rgba(0, 0, 0, 0.87);
}

body.light-theme .doc-content {
    color: rgba(0, 0, 0, 0.87);
}

body.light-theme .doc-content a {
    color: var(--gold-accent);
}

body.light-theme .row-content {
    color: rgba(0, 0, 0, 0.87);
    background-color: #f5f5f5;
    border-left-color: rgba(210, 154, 56, 0.25);
    border-right-color: rgba(210, 154, 56, 0.25);
    border-radius: 8px;
}

body.light-theme .row-group {
    border-top-color: rgba(210, 154, 56, 0.25);
}

body.light-theme .chapter-head {
    border-top-color: rgba(210, 154, 56, 0.3);
}

body.light-theme .thought-label {
    color: #757575;
}

body.light-theme .ref {
    color: var(--gold-accent);
}

/* ── Light: book toolbar ── */
body.light-theme .book-toolbar {
    background: #f5f5f5;
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .column-btn {
    background: transparent;
    color: #9e9e9e;
}

body.light-theme .column-btn:hover {
    color: var(--gold-accent);
    background: rgba(210, 154, 56, 0.08);
}

body.light-theme .column-select {
    background: transparent;
    color: #757575;
    border-bottom-color: rgba(0, 0, 0, 0.08);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239e9e9e'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
}

body.light-theme .column-select:hover,
body.light-theme .column-select:focus {
    color: #424242;
    border-bottom-color: var(--gold-accent);
}

body.light-theme .column-select option {
    background: #ffffff;
    color: #424242;
}

/* ── Light: tabs ── */
body.light-theme .tab {
    color: #757575;
    border-color: rgba(0, 0, 0, 0.1);
    background-color: #f5f5f5;
}

body.light-theme .tab.active {
    border-color: rgba(210, 154, 56, 0.6);
    color: var(--gold-accent);
}

body.light-theme .tab:hover {
    background-color: #fafafa;
    border-color: var(--gold-accent);
    color: var(--gold-accent);
}

/* ── Light: row notes ── */
body.light-theme .row-notes {
    color: #757575;
    border-left-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .row-notes-toggle {
    color: #9e9e9e;
}

/* ── Light: tooltips (dark, LessWrong signature) ── */
body.light-theme .custom-tooltip {
    background-color: rgba(75, 75, 75, 0.94);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 3px;
}

body.light-theme .custom-tooltip a {
    color: #f0c060;
}

body.light-theme .custom-tooltip::-webkit-scrollbar-track {
    background: rgba(60, 60, 60, 0.9);
}

body.light-theme .custom-tooltip::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

body.light-theme .custom-tooltip::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ── Light: popovers and overlays ── */
body.light-theme .popover {
    background-color: #ffffff;
    color: rgba(0, 0, 0, 0.87);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.025), 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-theme #popover-close {
    color: #9e9e9e;
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme #popover-close:hover {
    color: var(--gold-accent);
    border-color: var(--gold-accent);
    background-color: var(--gold-glow);
}

/* ── Light: map ── */
body.light-theme #wisdom-map {
    background-color: #fafafa;
    border-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .map-controls button {
    background-color: #ffffff;
    color: rgba(0, 0, 0, 0.7);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .map-controls button.active {
    background-color: var(--gold-accent);
    color: #ffffff;
}

body.light-theme .map-controls button:hover {
    background-color: #fafafa;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.025);
}

body.light-theme .map-filter-controls {
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.025);
}

body.light-theme .map-search-input {
    background-color: #ffffff;
    color: rgba(0, 0, 0, 0.87);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .map-search-input::placeholder {
    color: #9e9e9e;
}

body.light-theme .map-filter-btn {
    color: #757575;
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .map-filter-btn.active {
    color: var(--gold-accent);
    border-color: var(--gold-accent);
}

body.light-theme #hover-preview {
    background-color: #ffffff;
    color: rgba(0, 0, 0, 0.87);
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.025), 0 4px 12px rgba(0, 0, 0, 0.08);
}

body.light-theme .map-popup {
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.025), 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-theme .map-popup-header {
    background-color: #fafafa;
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .map-popup-body {
    color: rgba(0, 0, 0, 0.87);
}

body.light-theme .map-popup-close {
    color: #9e9e9e;
}

body.light-theme .map-popup-close:hover {
    color: rgba(0, 0, 0, 0.87);
}

body.light-theme .map-popup-type {
    color: #757575;
}

body.light-theme .map-popup-type:hover {
    color: var(--gold-accent);
    background-color: rgba(0, 0, 0, 0.03);
}

/* ── Light: scrollbars ── */
body.light-theme ::-webkit-scrollbar-track {
    background: #ffffff;
}

body.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ── Light: loading states ── */
body.light-theme .loading-indicator {
    background-color: #ffffff;
}

body.light-theme .spinner {
    border-color: rgba(0, 0, 0, 0.08);
    border-top-color: var(--gold-accent);
}

body.light-theme .inline-loading {
    color: #757575;
}

body.light-theme .content p.loading {
    color: #9e9e9e;
}

body.light-theme .content p.error {
    color: #d32f2f;
}

/* ── Agora (discussion notes) ── */
.agora-doc {
    max-width: 780px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    line-height: 1.6;
    color: #d0d0d0;
}

.agora-header {
    border-bottom: 1px solid rgba(210, 154, 56, 0.3);
    padding-bottom: 16px;
    margin-bottom: 28px;
}

.agora-title {
    font-family: var(--font-serif);
    font-size: 1.8em;
    font-weight: 600;
    color: var(--gold-accent);
    margin: 0 0 10px;
    letter-spacing: 0.01em;
}

.agora-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.92em;
}

.agora-meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
}

.agora-meta-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72em;
    color: #888;
    min-width: 90px;
    font-weight: 600;
}

.agora-meta-value {
    color: #c1c1c1;
    flex: 1;
    min-width: 0;
}

.agora-section {
    margin-bottom: 28px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.015);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.agora-section.is-collapsible:not(.collapsed) {
    background: rgba(255, 255, 255, 0.025);
    border-color: rgba(210, 154, 56, 0.22);
}

.agora-section-title {
    font-family: var(--font-serif);
    font-size: 1.35em;
    font-weight: 600;
    color: #e8e8e8;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.agora-section.is-collapsible > .agora-section-title {
    cursor: pointer;
    transition: color 0.15s ease;
}

.agora-section.is-collapsible > .agora-section-title .agora-chev {
    cursor: pointer;
}

.agora-section-label {
    cursor: text;
    user-select: text;
}

.agora-section-label.is-claim {
    font-weight: 600;
    line-height: 1.4;
    font-size: 0.76em;
}

.agora-section.is-collapsible > .agora-section-title:hover {
    color: var(--gold-accent);
}

.agora-section.is-collapsible > .agora-section-title:focus-visible {
    outline: 1px dashed var(--gold-accent);
    outline-offset: 3px;
}

.agora-section.is-collapsible.collapsed > .agora-section-body {
    display: none;
}

.agora-section-body {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dotted var(--border-subtle);
}

.agora-section-label {
    flex: 1;
    min-width: 0;
}

/* Subsection summary — always visible (sits inside the subsection card) */
.agora-subsection-summary {
    margin: 0;
    color: #b8b8b8;
    font-size: 0.94em;
    line-height: 1.55;
}

.agora-subsection-summary.is-toggle {
    cursor: pointer;
    transition: color 0.15s ease;
}

.agora-subsection-summary.is-toggle:hover {
    color: #d0d0d0;
}

/* "Justifications" label inside the collapsed body */
.agora-justifications-label {
    font-size: 0.66em;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #888;
    font-weight: 600;
    margin: 4px 0 10px;
    font-family: var(--font-inter), -apple-system, sans-serif;
    padding-bottom: 4px;
    border-bottom: 1px dotted var(--border-subtle);
}

/* Justification block: mixed prose + bullets */
.agora-justification-prose {
    margin: 0 0 10px;
    color: #c5c5c5;
    font-size: 0.98em;
    line-height: 1.65;
}

.agora-justification-prose:last-child {
    margin-bottom: 0;
}

.agora-justification-bullets {
    list-style: none;
    margin: 0 0 12px;
    padding: 0 0 0 4px;
}

.agora-justification-bullets li {
    position: relative;
    padding: 3px 0 3px 18px;
    color: #d0d0d0;
    font-size: 0.96em;
    line-height: 1.55;
}

.agora-justification-bullets li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 0.78em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--gold-accent);
    opacity: 0.7;
}

.agora-section-summary {
    color: #b8b8b8;
    font-style: italic;
    margin: 0 0 22px;
    font-size: 0.98em;
    line-height: 1.6;
}

.agora-subsection {
    margin: 0 0 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.018);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.agora-subsection.is-collapsible:not(.collapsed),
.agora-subsection.is-flat {
    background: rgba(210, 154, 56, 0.03);
    border-color: rgba(210, 154, 56, 0.22);
}

/* Flat subsection: fact bullets with inline source link */
.agora-subsection-points {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}

.agora-subsection-points li {
    position: relative;
    padding: 8px 0 8px 18px;
    line-height: 1.55;
    color: #d0d0d0;
    font-size: 0.95em;
    border-bottom: 1px solid var(--border-subtle);
}

.agora-subsection-points li:last-child {
    border-bottom: none;
}

.agora-subsection-points li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 0.95em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--gold-accent);
    opacity: 0.55;
}

.agora-point-source {
    display: inline;
    font-size: 0.88em;
    color: #8a8a8a;
    white-space: nowrap;
    margin-left: 2px;
}

.agora-doc .agora-subsection-points .agora-link {
    color: #a8a8a8;
    text-decoration: underline;
    text-decoration-color: rgba(210, 154, 56, 0.45);
    font-weight: 500;
    border-bottom: none;
}

.agora-doc .agora-subsection-points .agora-link:hover,
.agora-doc .agora-subsection-points .agora-link:focus-visible {
    color: var(--gold-accent);
    text-decoration-color: var(--gold-accent);
    border-bottom: none;
}

.agora-subsection-title {
    font-family: var(--font-serif);
    font-size: 1.02em;
    font-weight: 600;
    color: #e8e8e8;
    margin: 0 0 8px;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.agora-subsection-label {
    flex: 1;
    min-width: 0;
    cursor: text;
    user-select: text;
}

.agora-subsection.is-collapsible > .agora-subsection-title {
    cursor: pointer;
    padding: 0;
    margin: 0 0 8px;
    transition: color 0.15s ease;
}

.agora-subsection.is-collapsible > .agora-subsection-title:hover {
    color: var(--gold-accent);
}

.agora-subsection.is-collapsible > .agora-subsection-title:focus-visible {
    outline: 1px dashed var(--gold-accent);
    outline-offset: 2px;
}

/* CSS-drawn chevron (right-aligned in flex header) */
.agora-chev {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    opacity: 0.7;
    margin-right: 4px;
    margin-bottom: 3px;
}

.agora-section.is-collapsible:not(.collapsed) > .agora-section-title .agora-chev,
.agora-subsection.is-collapsible:not(.collapsed) > .agora-subsection-title .agora-chev {
    transform: rotate(45deg);
    margin-bottom: 0;
    margin-top: -3px;
}

.agora-subsection.is-collapsible > .agora-subsection-body {
    display: none;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dotted var(--border-subtle);
}

.agora-subsection.is-collapsible:not(.collapsed) > .agora-subsection-body {
    display: block;
}

/* ── Claim / Verdict / Justification ── */
.agora-claim {
    margin: 0 0 14px;
    padding: 14px 18px;
    background: rgba(210, 154, 56, 0.06);
    border-left: 3px solid var(--gold-accent);
    border-radius: 0 4px 4px 0;
}

.agora-claim-label {
    display: block;
    font-size: 0.68em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gold-accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.agora-claim-text {
    margin: 0;
    font-size: 1.08em;
    line-height: 1.45;
    color: #f0f0f0;
    font-weight: 500;
}

.agora-assessment {
    margin: 0 0 24px;
    padding: 14px 16px 10px;
    border: 1px solid rgba(140, 180, 230, 0.18);
    border-radius: 4px;
    background: rgba(140, 180, 230, 0.03);
    position: relative;
}

.agora-assessment-byline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #7ba7d6;
    margin-bottom: 10px;
    font-weight: 600;
    font-family: var(--font-inter), -apple-system, sans-serif;
}

.agora-assessment-icon {
    font-size: 1em;
    color: #7ba7d6;
    line-height: 1;
    opacity: 0.9;
}

.agora-verdict {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 12px;
    flex-wrap: wrap;
    padding: 0;
}

.agora-verdict-label {
    font-size: 0.68em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #888;
    font-weight: 600;
    flex-shrink: 0;
}

.agora-verdict-text {
    color: #d8d8d8;
    font-size: 0.98em;
    font-style: italic;
    flex: 1;
    min-width: 0;
}

.agora-justification {
    margin: 0;
    color: #c5c5c5;
    font-size: 0.98em;
    line-height: 1.65;
}

.agora-assessment .agora-justification {
    margin: 0;
}

.agora-subsection-note {
    color: #a8a8a8;
    font-size: 0.92em;
    margin: 0 0 10px;
    padding-left: 10px;
    border-left: 2px solid var(--border-subtle);
}

.agora-author-note {
    margin: 0 0 24px;
    padding: 12px 16px;
    border-left: 2px solid var(--gold-accent);
    background: rgba(210, 154, 56, 0.05);
    color: #c5c5c5;
    font-size: 0.96em;
    line-height: 1.6;
    border-radius: 0 4px 4px 0;
}

/* Bullet group heading inside a flat-format subsection */
.agora-bullet-heading {
    font-family: var(--font-inter), -apple-system, sans-serif;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gold-accent);
    font-weight: 600;
    margin: 14px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px dotted var(--border-subtle);
}

.agora-bullet-heading:first-child {
    margin-top: 0;
}

body.light-theme .agora-bullet-heading {
    color: var(--gold-accent);
}

/* Claude's assessment — now collapsible */
.agora-assessment.is-collapsible > .agora-assessment-byline {
    cursor: pointer;
    margin-bottom: 0;
    user-select: none;
    transition: color 0.15s ease;
}

.agora-assessment.is-collapsible > .agora-assessment-byline:hover {
    color: #a8c5e8;
}

.agora-assessment.is-collapsible > .agora-assessment-byline:focus-visible {
    outline: 1px dashed #7ba7d6;
    outline-offset: 3px;
}

.agora-assessment.is-collapsible > .agora-assessment-byline .agora-chev {
    margin-left: auto;
    color: #7ba7d6;
}

.agora-assessment.is-collapsible:not(.collapsed) > .agora-assessment-byline {
    margin-bottom: 10px;
}

.agora-assessment.is-collapsible:not(.collapsed) > .agora-assessment-byline .agora-chev {
    transform: rotate(45deg);
    margin-bottom: 0;
    margin-top: -3px;
}

.agora-assessment.is-collapsible.collapsed > .agora-assessment-body {
    display: none;
}

.agora-assessment-body {
    /* No extra spacing — verdict/justification carry their own margins */
}

/* "Justifications for claim" — collapsible wrapper around author note + subsections */
.agora-justifications-wrap {
    margin: 0 0 24px;
}

.agora-justifications-wrap.is-collapsible > .agora-justifications-title {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
    font-family: var(--font-inter), -apple-system, sans-serif;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #b8b8b8;
    font-weight: 600;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.agora-justifications-wrap.is-collapsible > .agora-justifications-title:hover {
    color: var(--gold-accent);
    border-color: rgba(210, 154, 56, 0.35);
}

.agora-justifications-wrap.is-collapsible > .agora-justifications-title:focus-visible {
    outline: 1px dashed var(--gold-accent);
    outline-offset: 3px;
}

.agora-justifications-title-text {
    flex: 1;
}

.agora-justifications-wrap.is-collapsible > .agora-justifications-title .agora-chev {
    margin-left: auto;
}

.agora-justifications-wrap.is-collapsible:not(.collapsed) > .agora-justifications-title {
    margin-bottom: 16px;
    border-color: rgba(210, 154, 56, 0.22);
    color: var(--gold-accent);
}

.agora-justifications-wrap.is-collapsible:not(.collapsed) > .agora-justifications-title .agora-chev {
    transform: rotate(45deg);
    margin-bottom: 0;
    margin-top: -3px;
}

.agora-justifications-wrap.is-collapsible.collapsed > .agora-justifications-body {
    display: none;
}

body.light-theme .agora-justifications-wrap.is-collapsible > .agora-justifications-title {
    background: rgba(0, 0, 0, 0.02);
    color: #555;
}

body.light-theme .agora-justifications-wrap.is-collapsible:not(.collapsed) > .agora-justifications-title {
    color: var(--gold-accent);
}

.agora-author-note-label {
    display: inline;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold-accent);
    font-weight: 600;
    font-family: var(--font-inter), -apple-system, sans-serif;
    margin-right: 8px;
}

.agora-author-note-label::after {
    content: ' \2014';
    color: var(--gold-accent);
    opacity: 0.7;
}

.agora-author-note-text {
    color: #c5c5c5;
}

p.agora-author-note-text {
    margin: 8px 0 0;
}

body.light-theme .agora-author-note {
    background: rgba(210, 154, 56, 0.08);
    color: #2a2a2a;
}

body.light-theme .agora-author-note-text {
    color: #2a2a2a;
}

.agora-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.agora-link-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    line-height: 1.55;
    font-size: 0.95em;
    display: grid;
    grid-template-columns: 90px 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 4px;
    align-items: baseline;
}

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

.agora-link-item:not(.relation-supports):not(.relation-qualifies):not(.relation-context) {
    grid-template-columns: 1fr;
}

.agora-link-head {
    grid-column: 2;
    grid-row: 1;
}

.agora-link-item:not(.relation-supports):not(.relation-qualifies):not(.relation-context) .agora-link-head {
    grid-column: 1;
}

.agora-doc .agora-link {
    color: #e4e4e4;
    font-weight: 500;
    word-break: break-word;
    text-decoration: underline;
    text-decoration-color: rgba(210, 154, 56, 0.55);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    border-bottom: none;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.agora-doc .agora-link:hover,
.agora-doc .agora-link:focus-visible {
    color: var(--gold-accent);
    text-decoration-color: var(--gold-accent);
    border-bottom: none;
}

.agora-link-note {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    color: #a8a8a8;
    font-size: 0.93em;
    line-height: 1.55;
}

.agora-link-item:not(.relation-supports):not(.relation-qualifies):not(.relation-context) .agora-link-note {
    grid-column: 1;
}

/* Relation tags (Supports / Qualifies / Context) */
.agora-relation {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: baseline;
    font-size: 0.64em;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 3px 7px;
    border-radius: 3px;
    border: 1px solid;
    line-height: 1.3;
    white-space: nowrap;
    font-family: var(--font-inter), -apple-system, sans-serif;
}

.agora-relation.agora-relation-inline {
    grid-column: auto;
    grid-row: auto;
    justify-self: auto;
    align-self: center;
    margin-left: auto;
    margin-right: 10px;
    flex-shrink: 0;
}

.agora-relation.relation-supports {
    color: #8fbf6f;
    border-color: rgba(143, 191, 111, 0.4);
    background: rgba(143, 191, 111, 0.08);
}

.agora-relation.relation-qualifies {
    color: #d29a38;
    border-color: rgba(210, 154, 56, 0.4);
    background: rgba(210, 154, 56, 0.08);
}

.agora-relation.relation-context {
    color: #8a8a8a;
    border-color: rgba(138, 138, 138, 0.35);
    background: rgba(138, 138, 138, 0.06);
}

.agora-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 14px 0 4px;
    border-radius: 6px;
    background: #000;
    border: 1px solid var(--border-medium);
}

.agora-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

@media (max-width: 768px) {
    .agora-doc {
        padding: 16px 14px 48px;
        font-size: 0.98em;
    }

    .agora-title {
        font-size: 1.4em;
    }

    .agora-meta-label {
        min-width: 0;
        flex-basis: 100%;
    }

    .agora-meta-value {
        flex-basis: 100%;
    }

    .agora-section-title {
        font-size: 1.15em;
    }

    .agora-link-item {
        grid-template-columns: 1fr;
        row-gap: 6px;
        padding: 12px 0;
    }

    .agora-link-item .agora-relation {
        grid-column: 1;
        grid-row: 1;
    }

    .agora-link-item .agora-link-head {
        grid-column: 1;
        grid-row: 2;
    }

    .agora-link-item .agora-link-note {
        grid-column: 1;
        grid-row: 3;
        font-size: 0.92em;
    }

    .agora-claim {
        padding: 12px 14px;
    }

    .agora-claim-text {
        font-size: 1em;
    }

    .agora-subsection.is-collapsible > .agora-subsection-body {
        padding-left: 14px;
    }
}

body.light-theme .agora-claim {
    background: rgba(210, 154, 56, 0.1);
}

body.light-theme .agora-claim-text {
    color: #1a1a1a;
}

body.light-theme .agora-verdict-text {
    color: #333;
}

body.light-theme .agora-justification {
    color: #424242;
}

body.light-theme .agora-assessment {
    background: rgba(30, 100, 170, 0.04);
    border-color: rgba(30, 100, 170, 0.2);
}

body.light-theme .agora-assessment-byline,
body.light-theme .agora-assessment-icon {
    color: #3b74a8;
}

body.light-theme .agora-section {
    background: rgba(0, 0, 0, 0.015);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .agora-section.is-collapsible:not(.collapsed) {
    background: rgba(210, 154, 56, 0.04);
    border-color: rgba(210, 154, 56, 0.25);
}

body.light-theme .agora-subsection {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .agora-subsection.is-collapsible:not(.collapsed),
body.light-theme .agora-subsection.is-flat {
    background: rgba(210, 154, 56, 0.05);
    border-color: rgba(210, 154, 56, 0.3);
}

body.light-theme .agora-subsection-points li {
    color: #333;
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-theme .agora-point-source {
    color: #666;
}

body.light-theme .agora-doc .agora-subsection-points .agora-link {
    color: #555;
}

body.light-theme .agora-subsection-title {
    color: #1a1a1a;
}

body.light-theme .agora-subsection-summary {
    color: #555;
}

body.light-theme .agora-subsection-summary.is-toggle:hover {
    color: #2a2a2a;
}

body.light-theme .agora-justifications-label {
    color: #777;
}

body.light-theme .agora-justification-prose,
body.light-theme .agora-justification-bullets li {
    color: #424242;
}

body.light-theme .agora-doc .agora-link {
    color: #1a1a1a;
}

body.light-theme .agora-doc .agora-link:hover,
body.light-theme .agora-doc .agora-link:focus-visible {
    color: var(--gold-hover);
}

body.light-theme .agora-relation.relation-supports {
    color: #5a8a3d;
    background: rgba(90, 138, 61, 0.08);
}

body.light-theme .agora-doc {
    color: #333;
}

body.light-theme .agora-section-title {
    color: #1a1a1a;
}

body.light-theme .agora-section-summary,
body.light-theme .agora-subsection-note,
body.light-theme .agora-link-note {
    color: #555;
}

body.light-theme .agora-meta-value {
    color: #333;
}

body.light-theme .agora-meta-label {
    color: #888;
}

body.light-theme .agora-embed {
    background: #f0f0f0;
    border-color: rgba(0, 0, 0, 0.1);
}

/* ---------------------------------------------------------------- Editor (editor.js) */

.nav-bar .nav-title { /* keep title from being pushed by actions */ }

.nav-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fuall-btn {
    font: inherit;
    font-size: 0.82rem;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--gold-accent, #d29a38);
    background: transparent;
    color: var(--gold-accent, #d29a38);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.fuall-btn:hover { background: var(--gold-accent, #d29a38); color: #121212; }
.fuall-btn-edit.active { background: var(--gold-accent, #d29a38); color: #121212; }
.fuall-btn-ghost { border-color: rgba(193,193,193,0.4); color: #c1c1c1; }
.fuall-btn-ghost:hover { background: rgba(193,193,193,0.15); color: #e0e0e0; }

.fuall-user {
    font-size: 0.8rem;
    color: #9a9a9a;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fuall-gbtn { display: inline-flex; }

body.light-theme .fuall-user { color: #666; }

/* Password unlock modal */
.fuall-pw-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.fuall-pw-box {
    background: #181818;
    border: 1px solid rgba(210,154,56,0.4);
    border-radius: 10px;
    padding: 22px;
    width: 280px;
    max-width: calc(100vw - 40px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.fuall-pw-title {
    font-size: 0.95rem;
    color: #e0e0e0;
    margin-bottom: 12px;
}
.fuall-pw-input {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 0.95rem;
    padding: 9px 11px;
    border-radius: 6px;
    border: 1px solid rgba(193,193,193,0.3);
    background: #121212;
    color: #e0e0e0;
}
.fuall-pw-input:focus { outline: none; border-color: var(--gold-accent, #d29a38); }
.fuall-pw-error { color: #d96a6a; font-size: 0.8rem; min-height: 1em; margin: 6px 2px; }
.fuall-pw-bar { display: flex; gap: 8px; justify-content: flex-end; }
body.light-theme .fuall-pw-box { background: #fff; }
body.light-theme .fuall-pw-input { background: #fafafa; color: #222; }
body.light-theme .fuall-pw-title { color: #222; }

/* ── Category-icon version tabs ── */
.tab svg { width: 12px; height: 12px; display: block; }
.tab .tab-lang, .tab .tab-glyph { font-size: 12px; font-weight: 600; line-height: 1; }
.tab.active { color: var(--gold-accent); }   /* lit gold icon on the selected version */

/* ── Quill editor theming for Classic (ported from Reader v2) ── */
.ql-toolbar.ql-snow { background: var(--surface); border-color: var(--border-medium) !important; border-radius: 6px 6px 0 0; }
.ql-container.ql-snow { border-color: var(--border-medium) !important; border-radius: 0 0 6px 6px; font-family: var(--font-serif); font-size: 1rem; }
.ql-editor { color: #e0e0e0; min-height: 4.5em; line-height: 1.6; }
.ql-editor.ql-blank::before { color: #777; font-style: normal; }
.ql-snow .ql-stroke { stroke: #b0b0b0; }
.ql-snow .ql-fill { fill: #b0b0b0; }
.ql-snow .ql-picker { color: #b0b0b0; }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--gold-accent); }
.ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--gold-accent); }
body.light-theme .ql-toolbar.ql-snow { background: #f4f4f4; }
body.light-theme .ql-editor { color: #222; }
body.light-theme .ql-snow .ql-stroke { stroke: #555; }

/* ── Sheet editor (Google-Sheets-style grid) ── */
.fuall-sheet {
    position: fixed; inset: 0; z-index: 3000;
    background: var(--background, #121212);
    display: flex; flex-direction: column;
}
.fuall-sheet-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; border-bottom: 1px solid var(--border-medium);
}
.fuall-sheet-title { font-weight: 600; color: var(--gold-accent); margin-right: auto; }
.fuall-sheet-status { color: #8ab38a; font-size: 0.85rem; }
.fuall-sheet-scroll { flex: 1; overflow: auto; }
.fuall-sheet-table { border-collapse: collapse; width: max-content; font-size: 0.86rem; }
.fuall-sheet-table th, .fuall-sheet-table td { border: 1px solid var(--border-medium); vertical-align: top; }
.fuall-sheet-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface); color: var(--gold-accent);
    padding: 7px 10px; text-align: left; white-space: nowrap; font-weight: 600;
}
.fuall-sheet-table thead th:first-child { left: 0; z-index: 3; }
.fuall-cell-idx {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface); color: #999;
    padding: 6px 9px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.fuall-cell {
    padding: 0; min-width: 240px; max-width: 420px;
    cursor: text; color: #d4d4d4; font-family: var(--font-serif);
}
.fuall-cell:hover { background: rgba(255,255,255,0.035); }
.fuall-cell.dirty { box-shadow: inset 0 0 0 2px var(--gold-accent); }
.fuall-cell-view { padding: 6px 10px; }          /* full content — no clipping */
.fuall-cell-view p { margin: 0 0 0.4em; }
.fuall-cell-view p:last-child { margin-bottom: 0; }
.fuall-cell.editing { box-shadow: inset 0 0 0 2px var(--gold-accent); }
.fuall-cell .ql-toolbar.ql-snow { border: 0 !important; border-bottom: 1px solid var(--border-medium) !important; border-radius: 0; padding: 3px 6px; }
.fuall-cell .ql-container.ql-snow { border: 0 !important; font-family: var(--font-serif); font-size: 0.92rem; }
.fuall-cell .ql-editor { padding: 6px 10px; }

/* actions column (stacked icons) + numbering + column headers */
.fuall-acts-h, .fuall-num-h { position: sticky; z-index: 3; background: var(--surface); }
.fuall-acts-h, .fuall-acts { width: 26px; min-width: 26px; }
.fuall-acts {
    position: sticky; left: 0; z-index: 1; background: var(--surface);
    padding: 3px 2px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.fuall-cell-idx { left: 26px; }                  /* number column sits right of the actions column */
.fuall-sheet-table thead .fuall-num-h { left: 26px; }
.fuall-mini {
    font-family: var(--font-inter, sans-serif); font-size: 12px; line-height: 1;
    width: 18px; height: 18px; padding: 0;
    display: inline-grid; place-items: center; vertical-align: middle;
    border: 1px solid var(--border-medium); border-radius: 3px;
    background: transparent; color: #999; cursor: pointer;
}
.fuall-mini:hover { color: var(--gold-accent); border-color: var(--gold-accent); }
.fuall-mini.on { color: var(--gold-accent); border-color: var(--gold-accent); background: rgba(210,154,56,0.18); }
.fuall-colh { white-space: nowrap; }
.fuall-colh-lab { margin-right: 6px; cursor: grab; user-select: none; }
.fuall-colh.drop-target { outline: 2px solid var(--gold-accent); outline-offset: -2px; }
.fuall-colh-input {
    font: inherit; font-size: 0.86rem; width: 9em;
    background: var(--background, #121212); color: var(--gold-accent);
    border: 1px solid var(--gold-accent); border-radius: 3px; padding: 2px 5px;
}

body.light-theme .fuall-sheet { background: #ffffff; }
body.light-theme .fuall-cell { color: #222; }
body.light-theme .fuall-cell-view { color: #222; }
body.light-theme .fuall-colh-input { background: #fff; color: #9a6f1f; }

/* column header: category icon + type selector */
.fuall-colh-icon { color: var(--gold-accent); margin-right: 5px; vertical-align: middle; display: inline-flex; }
.fuall-colh-icon svg { width: 13px; height: 13px; }
.fuall-type-sel {
    font-family: var(--font-inter, sans-serif); font-size: 11px;
    margin: 0 6px; padding: 1px 3px;
    background: var(--background, #121212); color: #aaa;
    border: 1px solid var(--border-medium); border-radius: 3px; cursor: pointer;
}
body.light-theme .fuall-type-sel { background: #fff; color: #555; }

/* section number (row Index) in the rail + click-to-cycle cursor */
.row-num {
    font-family: var(--font-inter, sans-serif);
    font-size: 0.6rem; line-height: 1;
    color: #777; text-align: center;
    margin-bottom: 5px; padding-top: 2px;
    font-variant-numeric: tabular-nums; user-select: none;
    transition: color 0.15s;
}
.row-group:hover .row-num { color: var(--gold-accent); }
.row-content.cyclable { cursor: pointer; }
body.light-theme .row-num { color: #999; }

/* ── Segment cross-reference chips + hover preview ── */
.row-xrefs { flex-basis: 100%; order: 5; display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; max-width: 650px; }
.xref-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--font-inter, sans-serif); font-size: 0.72rem;
    color: var(--gold-accent); text-decoration: none;
    border: 1px solid rgba(210,154,56,0.35); border-radius: 999px;
    padding: 2px 10px 2px 7px; background: rgba(210,154,56,0.06);
    transition: background 0.15s, border-color 0.15s;
}
.xref-chip svg { width: 13px; height: 13px; flex-shrink: 0; }
.xref-chip:hover { background: rgba(210,154,56,0.16); border-color: var(--gold-accent); }
.xref-flash { animation: xrefFlash 1.6s ease; }
@keyframes xrefFlash { 0%,100% { background: transparent; } 22% { background: rgba(210,154,56,0.14); } }

/* #id selector to beat the base `#hover-preview { display:none; position:absolute }` */
#hover-preview.xref-preview {
    display: block; position: fixed; z-index: 4000;
    width: auto; max-width: 440px; min-width: 220px; max-height: 320px; overflow: auto;
    pointer-events: auto;
    /* glassmorphism — frosted translucent panel */
    background: rgba(12, 12, 14, 0.68);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid rgba(210, 154, 56, 0.22);
    border-radius: 5px; padding: 12px 15px;
    box-shadow: 0 16px 44px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.14);
}
.hover-preview.hidden { display: none; }
.xref-prev-head { font-family: var(--font-inter, sans-serif); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-accent); margin-bottom: 7px; }
.xref-prev-ver { opacity: 0.55; }
.xref-prev-body { font-family: var(--font-serif); font-size: 0.95rem; line-height: 1.55; color: #d8d8d8; }
.xref-prev-body p { margin: 0 0 0.5em; }
.xref-prev-body p:last-child { margin-bottom: 0; }
body.light-theme #hover-preview.xref-preview { background: rgba(255,255,255,0.6); border-color: rgba(147,104,30,0.3); }
body.light-theme .xref-prev-body { color: #333; }

/* cross-reference editor modal */
.fuall-xr-back { position: fixed; inset: 0; z-index: 3500; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; }
.fuall-xr-panel {
    background: rgba(12, 12, 14, 0.72);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid rgba(210, 154, 56, 0.25);
    border-radius: 5px; padding: 18px 20px; width: min(540px, 92vw); max-height: 80vh; overflow: auto;
    box-shadow: 0 20px 52px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.14);
}
body.light-theme .fuall-xr-panel { background: rgba(255,255,255,0.7); border-color: rgba(147,104,30,0.3); }
.fuall-xr-head { font-weight: 600; color: var(--gold-accent); margin-bottom: 12px; }
.fuall-xr-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fuall-xr-empty { color: #888; font-size: 0.85rem; font-style: italic; }
.fuall-xr-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border: 1px solid var(--border-subtle); border-radius: 6px; font-size: 0.85rem; color: #ddd; }
.fuall-xr-item b { color: var(--gold-accent); font-weight: 600; }
.fuall-xr-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.fuall-xr-form select, .fuall-xr-seg { font: inherit; font-size: 0.85rem; padding: 5px 8px; background: var(--background, #121212); color: #e0e0e0; border: 1px solid var(--border-medium); border-radius: 6px; }
.fuall-xr-seg { width: 130px; }
body.light-theme .fuall-xr-panel { background: #fff; }
body.light-theme .fuall-xr-form select, body.light-theme .fuall-xr-seg { background: #fff; color: #222; }

/* per-cell revision history */
.fuall-cell { position: relative; }
.fuall-cell-hist {
    position: absolute; top: 3px; right: 3px; z-index: 2;
    width: 20px; height: 20px; padding: 0; display: grid; place-items: center;
    background: var(--surface, #1e1e1e); color: #888;
    border: 1px solid var(--border-medium); border-radius: 4px;
    cursor: pointer; opacity: 0; transition: opacity 0.12s, color 0.12s;
}
.fuall-cell:hover .fuall-cell-hist { opacity: 1; }
.fuall-cell-hist:hover { color: var(--gold-accent); border-color: var(--gold-accent); }
.fuall-cell-hist svg { width: 13px; height: 13px; }
.fuall-hist-panel { width: min(560px, 94vw); }
.fuall-hist-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; }
.fuall-hist-card { border: 1px solid var(--border-subtle); border-radius: 8px; padding: 10px 12px; position: relative; }
.fuall-hist-meta { display: flex; justify-content: space-between; gap: 10px; font-family: var(--font-inter, sans-serif); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gold-accent); margin-bottom: 6px; }
.fuall-hist-who { color: #888; text-transform: none; letter-spacing: 0; }
.fuall-hist-val { font-family: var(--font-serif); font-size: 0.9rem; line-height: 1.5; color: #d6d6d6; max-height: 130px; overflow: auto; }
.fuall-hist-val p { margin: 0 0 0.4em; }
.fuall-hist-restore { margin-top: 8px; font-size: 0.74rem; padding: 3px 10px; }
body.light-theme .fuall-cell-hist { background: #fff; }
body.light-theme .fuall-hist-val { color: #333; }

/* ── Inline cross-reference links ([[Work#segment]]) + pinned card ── */
/* Same treatment as .ref: normal text with a dotted gold underline. */
.xref-inline {
    text-decoration: none;
    cursor: pointer;
}
.doc-content a.xref-inline,
.xref-inline { color: inherit; border-bottom: 1px dotted rgba(210, 154, 56, 0.6); }
.doc-content a.xref-inline:hover,
.xref-inline:hover { color: var(--gold-accent); border-bottom-color: var(--gold-accent); }

.xref-pinned {
    position: fixed; z-index: 4100; max-width: 460px; max-height: 360px; overflow: auto;
    /* glassmorphism — frosted translucent panel */
    background: rgba(12, 12, 14, 0.72);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid rgba(210, 154, 56, 0.28);
    border-radius: 5px; padding: 12px 15px;
    box-shadow: 0 20px 52px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.16);
}
.xref-pinned .xref-prev-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.xref-head-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xref-head-actions { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.xref-pin-close { background: none; border: none; color: #999; font-size: 1.15rem; cursor: pointer; line-height: 1; padding: 0 2px; }
.xref-pin-close:hover { color: var(--gold-accent); }
/* go-to: an inline icon in the header, next to close */
.xref-goto { background: none; border: none; color: #999; cursor: pointer; padding: 0; display: inline-flex; align-items: center; }
.xref-goto svg { width: 15px; height: 15px; }
.xref-goto:hover { color: var(--gold-accent); }
body.light-theme .xref-pinned { background: rgba(255,255,255,0.65); border-color: rgba(147,104,30,0.35); }

/* editor help button + panel */
.fuall-help-btn { width: 30px; padding: 5px 0; border-radius: 50%; font-weight: 700; }
.fuall-help-panel { width: min(560px, 94vw); }
.fuall-help-body { font-size: 0.88rem; line-height: 1.55; color: #d4d4d4; margin-bottom: 14px; }
.fuall-help-body h4 { color: var(--gold-accent); margin: 16px 0 6px; font-size: 0.95rem; }
.fuall-help-body h4:first-child { margin-top: 4px; }
.fuall-help-body ul { margin: 4px 0 8px; padding-left: 20px; }
.fuall-help-body li { margin: 3px 0; }
.fuall-help-body code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; background: rgba(210,154,56,0.12); color: var(--gold-accent); padding: 1px 5px; border-radius: 4px; }
.fuall-help-body b { color: #ececec; }
.fuall-help-note { background: rgba(210,154,56,0.07); border-left: 2px solid rgba(210,154,56,0.5); padding: 7px 11px; border-radius: 0 6px 6px 0; }
body.light-theme .fuall-help-body { color: #333; }
body.light-theme .fuall-help-body b { color: #111; }

/* ── Layered typed notes ── */
.typed-note { border-left: 2px solid transparent; padding-left: 9px; margin-bottom: 11px; }
.typed-note:last-child { margin-bottom: 0; }
.note-type {
    display: inline-block; font-family: var(--font-inter, sans-serif);
    font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
    padding: 1px 8px; border-radius: 999px; margin-bottom: 5px;
}
.note-body p { margin: 0 0 0.45em; }
.note-body p:last-child { margin-bottom: 0; }
.note-commentary    { border-left-color: rgba(210,154,56,0.55); }
.note-commentary    .note-type { color: var(--gold-accent); background: rgba(210,154,56,0.14); }
.note-deeper        { border-left-color: rgba(111,168,220,0.55); }
.note-deeper        .note-type { color: #6fa8dc; background: rgba(111,168,220,0.15); }
.note-justification { border-left-color: rgba(138,179,138,0.55); }
.note-justification .note-type { color: #8ab38a; background: rgba(138,179,138,0.15); }
.note-citation      { border-left-color: rgba(176,176,176,0.45); }
.note-citation      .note-type { color: #b0b0b0; background: rgba(176,176,176,0.12); }

/* annotations: entry key as a heading (reference works) */
.annotations-key { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; color: var(--gold-accent); margin: 20px 0 0; padding-top: 42px; border-top: 1px solid var(--border-subtle); }
.annotations-key:first-of-type { border-top: none; padding-top: 0; }
/* sheet: editable Key column (reference works) */
.fuall-key-h { left: 26px; min-width: 150px; }
.fuall-key-cell { min-width: 150px; max-width: 240px; white-space: normal; color: var(--gold-accent); cursor: text; font-family: var(--font-serif); padding: 6px 9px; font-variant-numeric: normal; }
.fuall-key-input { width: 100%; font: inherit; font-family: var(--font-serif); background: var(--background, #121212); color: var(--gold-accent); border: 1px solid var(--gold-accent); border-radius: 3px; padding: 4px 6px; box-sizing: border-box; }
body.light-theme .fuall-key-input { background: #fff; color: #9a6f1f; }

/* sheet: links gold, not default blue */
.fuall-cell-view a, .fuall-cell .ql-editor a, .fuall-usedby a { color: var(--gold-accent); text-decoration: none; border-bottom: 1px solid rgba(210,154,56,0.35); }
.fuall-cell-view a:hover { border-bottom-color: var(--gold-accent); }
/* sheet filter input */
.fuall-sheet-filter {
    font: inherit; font-size: 0.85rem; padding: 5px 10px; width: 200px;
    background: var(--background, #121212); color: #e0e0e0;
    border: 1px solid var(--border-medium); border-radius: 6px;
}
.fuall-sheet-filter:focus { outline: none; border-color: var(--gold-accent); }
body.light-theme .fuall-sheet-filter { background: #fff; color: #222; }
/* used-by column (read-only) */
.fuall-usedby { padding: 7px 9px; white-space: normal; vertical-align: top; }
.fuall-usedby-chip { display: inline-block; font-family: var(--font-inter, sans-serif); font-size: 0.72rem; color: var(--gold-accent); background: rgba(210,154,56,0.1); border: 1px solid rgba(210,154,56,0.3); border-radius: 999px; padding: 1px 8px; margin: 0 4px 4px 0; }
.fuall-usedby-none { color: #666; }

/* "referenced by" rail button + popover */
.row-backlink-btn {
    display: inline-flex; align-items: center; gap: 2px;
    background: transparent; border: none; color: #777; cursor: pointer;
    padding: 2px; transition: color 0.15s;
}
.row-backlink-btn svg { width: 15px; height: 15px; }
.row-backlink-count { font-family: var(--font-inter, sans-serif); font-size: 0.6rem; font-weight: 600; }
.row-backlink-btn:hover { color: var(--gold-accent); }
.backlinks-pop { max-width: 360px; }
.backlinks-list { display: flex; flex-direction: column; gap: 3px; }
.backlink-item { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-accent); text-decoration: none; font-size: 0.86rem; padding: 4px 7px; border-radius: 5px; }
.backlink-item svg { width: 13px; height: 13px; flex-shrink: 0; }
.backlink-item:hover { background: rgba(210,154,56,0.12); }

/* link autocomplete (inside sheet cell editor) */
.fuall-ac {
    position: fixed; z-index: 5000; min-width: 200px; max-width: 280px; max-height: 240px; overflow: auto;
    background: rgba(12, 12, 14, 0.72);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid rgba(210, 154, 56, 0.25);
    border-radius: 5px;
    box-shadow: 0 14px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.14);
    padding: 4px;
}
.fuall-ac-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 5px 9px; border-radius: 5px; cursor: pointer;
    font-family: var(--font-serif); font-size: 0.88rem; color: #e0e0e0;
}
.fuall-ac-item.sel, .fuall-ac-item:hover { background: rgba(210,154,56,0.18); color: #fff; }
.fuall-ac-tag { font-family: var(--font-inter, sans-serif); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; color: #888; }
body.light-theme .fuall-ac { background: #fff; }
body.light-theme .fuall-ac-item { color: #222; }

/* inline reference shown as a chip in sheet cells */
.fuall-ref-chip {
    display: inline-block; font-family: var(--font-inter, sans-serif); font-size: 0.72rem;
    color: var(--gold-accent); background: rgba(210,154,56,0.1);
    border: 1px solid rgba(210,154,56,0.35); border-radius: 999px;
    padding: 0 7px; margin: 0 1px; vertical-align: baseline; white-space: nowrap;
}
body.light-theme .fuall-ref-chip { color: #9a6f1f; }
/* row number that has an abstract preview on hover/click */
.row-num-abstract { cursor: pointer; }
.row-num-abstract:hover { color: var(--gold-accent); }

/* reference brackets shown gold in sheet cells */
.fuall-ref-bracket { color: var(--gold-accent); font-weight: 700; }
body.light-theme .fuall-ref-bracket { color: #9a6f1f; }

/* Canon column (editable scholarly reference) + reader rail display */
.fuall-canon-cell { cursor: text; color: #b59a6a; min-width: 60px; }
.fuall-canon-cell:hover { background: rgba(255,255,255,0.04); }
.fuall-canon-h { color: var(--gold-accent); }
.row-num-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; }
.row-canon { font-family: var(--font-inter, sans-serif); font-size: 0.6rem; color: rgba(147,104,30,0.9); letter-spacing: 0.02em; white-space: nowrap; }
body.light-theme .row-canon { color: rgba(147,104,30,0.95); }
