/* ============================================================
   BRAND WORDMARK — "Owl" rendered in gold ("Cite" inherits)
   Used in the nav logo, footer, and auth lockups.
   ============================================================ */
.brand-owl { color: var(--accent); }
/* Gold-gradient "Owl" for the large brand lockups (hero brand, auth). Falls back
   to flat gold where background-clip:text is unsupported. */
.brand-owl-grad {
    color: var(--accent);
    background: var(--grad-gold-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================================
   DROPDOWN MENUS (shared across sidebar + chat)
   ============================================================ */

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: var(--chrome-bg2);
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius);
    padding: 4px;
    z-index: var(--z-dropdown);
    max-height: 320px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

#doc-menu {
    min-width: 180px;
    left: 13px;
    right: 10px;
}
#thread-menu {
    min-width: 180px;
    left: 0;
    right: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--t2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
    min-width: 0;
}
.dropdown-item > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.dropdown-item:hover { background: var(--chrome-hover); color: var(--t1); }
.dropdown-item.active { color: var(--t1); background: var(--chrome-hover); }

.dropdown-item .dd-del {
    opacity: 0; background: none; border: none;
    color: var(--t3); cursor: pointer; font-size: 14px; padding: 0 2px;
}
.dropdown-item:hover .dd-del { opacity: 1; }
.dropdown-item .dd-del:hover { color: var(--red); }

.dropdown-divider {
    height: 1px;
    background: var(--chrome-border);
    margin: 4px 0;
}

.dropdown-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--t2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}
.dropdown-action:hover { background: var(--chrome-hover); color: var(--t1); }
.dropdown-action.danger { color: var(--red); }
.dropdown-action.danger:hover { background: var(--red-bg); color: var(--red); }
.dropdown-action svg { flex-shrink: 0; }
.dropdown-action.disabled { opacity: 0.55; pointer-events: none; }

/* ============================================================
   BUTTONS
   ============================================================ */

/* ---- Canonical button system — shared between landing AND the app ----
   `.landing-btn-primary` / `.btn-gold` / `.pricing-cta--primary` / `.nav-cta`
       The primary celebratory CTA: gold gradient pill with inset highlights
       and a soft halo. Used for Upgrade, Start writing, modal Confirm, hero.
   `.landing-btn-secondary` / `.btn-quiet`
       The secondary CTA: translucent glass pill with gold-tinted hover.
   Rules live here (not in landing.css) so the app's account modal, plan
   picker, and any future app surface can use the same canonical set. */
.landing-btn-primary,
.pricing-cta--primary,
.btn-gold,
.nav-cta {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--grad-gold-pill);
    color: var(--on-gold);
    padding: 13px 30px; border-radius: var(--radius-btn);
    font: 600 14px var(--sans); letter-spacing: -0.005em;
    text-decoration: none;
    border: none;
    cursor: pointer;
    position: relative;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -1px 0 rgba(0,0,0,0.18),
        0 1px 0 rgba(255,255,255,0.04),
        0 8px 28px -8px rgba(212,168,68,0.55);
    transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), filter 200ms var(--ease);
    white-space: nowrap;
}
/* Nav variant — same gradient, smaller padding to fit the pill nav. */
.nav-cta { padding: 8px 18px; font-size: 13px; }

.landing-btn-primary:hover,
.pricing-cta--primary:hover,
.btn-gold:hover,
.nav-cta:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.55),
        inset 0 -1px 0 rgba(0,0,0,0.18),
        0 1px 0 rgba(255,255,255,0.04),
        0 14px 36px -8px rgba(212,168,68,0.65);
}

/* Disabled + in-flight states — canonical home for the gold primary (was
 * duplicated in account.css and admin.css). */
.landing-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.landing-btn-primary.loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.landing-btn-secondary,
.btn-quiet,
.pricing-cta:not(.pricing-cta--primary) {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--grad-neutral-btn);
    color: var(--t1);
    padding: 13px 26px; border-radius: var(--radius-btn);
    font: 500 14px var(--sans); letter-spacing: -0.005em;
    text-decoration: none;
    border: 1px solid var(--chrome-border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 6px -3px rgba(0,0,0,0.5);
    transition: filter 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease);
}
.landing-btn-secondary:hover,
.btn-quiet:hover,
.pricing-cta:not(.pricing-cta--primary):hover {
    filter: brightness(1.12);
    border-color: var(--panel-border);
    transform: translateY(-1px);
}

/* Small modifier — in dense rows, modal footers, and in-panel CTAs the full
 * landing-hero pill (13×30, 14px) reads too tall. Same gradient and shape,
 * smaller proportions. Used by Modal's confirm button and the account
 * panel's in-row primaries. */
.landing-btn-primary.is-sm,
.acct-btn.is-sm,
.landing-btn-secondary.is-sm {
    padding: 7px 18px;
    font: var(--font-ui);
    font-weight: 500;
}

/* ---- Canonical pricing-card system — shared between landing AND the app ----
   Free + Pro share the canonical glass chrome; only the featured (Plus) tier
   earns the gold border + stele crown. Used on landing's pricing section AND
   on the in-app plan picker so both surfaces speak the same visual language. */
.pricing-card {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.005) 100%),
        rgba(var(--chrome-bg-rgb),0.6);
    backdrop-filter: blur(22px) saturate(1.2);
    -webkit-backdrop-filter: blur(22px) saturate(1.2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 34px 30px 22px;
    display: flex; flex-direction: column;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.04) inset,
        0 24px 60px -28px rgba(0,0,0,0.55);
}
/* Pricing cards aren't clickable targets (the CTA buttons inside are), so they
 * stay static — no hover lift or border brighten. */
.pricing-card--featured {
    border-color: rgba(212,168,68,0.22);
}
/* Featured cards get a gold divider above the features list (same
 * recipe as .why-card--us .why-card-head's gold-tinted bottom border). */
.pricing-card--featured .pricing-features {
    border-top-color: rgba(212,168,68,0.20);
}
.pricing-card--featured::before {
    content: '';
    position: absolute;
    top: 0; left: 24px; right: 24px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.7;
}

.pricing-card-header { margin-bottom: 22px; }
.pricing-tier-name {
    font: var(--font-eyebrow-sm); color: var(--t2);
    text-transform: uppercase; letter-spacing: var(--track-eyebrow);
    margin-bottom: 16px;
}
.pricing-price {
    font: 300 52px/1 var(--serif);
    color: var(--t1);
    letter-spacing: -0.035em;
    font-feature-settings: 'lnum' on, 'tnum' on;
}
.pricing-price span {
    font: 400 13px var(--sans);
    color: var(--t3);
    letter-spacing: 0;
    margin-left: 3px;   /* small breath between the amount and the /mo unit (not a full space — the slash would float) */
}
.pricing-desc {
    font: var(--font-ui); color: var(--t3);
    margin-top: 12px;
}

.pricing-features {
    list-style: none; padding: 0; margin: 0 0 32px;
    display: flex; flex-direction: column; gap: 12px;
    flex: 1;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 22px;
}
.pricing-features li {
    font: 400 14px/1.45 var(--sans); color: var(--t1);
    padding-left: 22px;
    position: relative;
}
.pricing-features li::before {
    /* Gold check mark — same SVG mask the .why-card--us list uses on
     * landing. Replaces the previous 12×1px dash so the feature lines
     * read as "yes, you get this" rather than just bullet ticks. */
    content: '';
    position: absolute;
    left: 0; top: 5px;
    width: 14px; height: 14px;
    background: var(--accent);
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path d='M3 7l3 3 5-6.5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path d='M3 7l3 3 5-6.5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

/* Pricing primaries reuse the base gold gradient button, but inside the glass
 * cards its full hero halo reads as excess (and two sit side by side),
 * so scope a softer gold drop here. The hero CTA keeps its full halo via
 * .landing-btn-primary. */
.pricing-cta--primary {
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -1px 0 rgba(0,0,0,0.18),
        0 1px 0 rgba(255,255,255,0.04),
        0 6px 16px -10px rgba(212,168,68,0.30);
}
.pricing-cta--primary:hover {
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.55),
        inset 0 -1px 0 rgba(0,0,0,0.18),
        0 1px 0 rgba(255,255,255,0.04),
        0 10px 22px -10px rgba(212,168,68,0.40);
}

.pricing-fineprint {
    margin-top: 22px;
    font: var(--font-ui); color: var(--t3);
    text-align: center;
    opacity: 0.8;
}

/* ---- "Why" card — glass panel with optional gold "winning" variant ----
   Used by landing's why-section (CiteOwl vs Generic AI comparison) AND by
   the account panel's Plan row, where .why-card--us signals "this is the
   recommended path" — the same role it plays on landing. */
.why-card {
    position: relative;
    padding: 36px 36px 32px;
    border-radius: 22px;
    display: flex; flex-direction: column;
    gap: 24px;
    border: 1px solid rgba(255,255,255,0.08);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.005) 100%),
        rgba(var(--chrome-bg-rgb),0.6);
    backdrop-filter: blur(22px) saturate(1.2);
    -webkit-backdrop-filter: blur(22px) saturate(1.2);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.04) inset,
        0 24px 60px -28px rgba(0,0,0,0.6);
}
.why-card--us {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.005) 100%),
        rgba(var(--chrome-bg-rgb),0.6);
    border-color: rgba(212,168,68,0.22);
}
.why-card--us::before {
    /* Stele crown — thin gold rule on the winning card */
    content: '';
    position: absolute;
    top: 0; left: 28%; right: 28%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.55;
}
.why-card-head {
    display: flex; flex-direction: column;
    gap: 8px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.why-card--us .why-card-head {
    border-bottom-color: rgba(212,168,68,0.20);
}
.why-card-label {
    font: 600 11px var(--sans);
    text-transform: uppercase;
    letter-spacing: var(--track-eyebrow);
    color: var(--t3);
}
.why-card--us .why-card-label { color: var(--accent); }
.why-card-tagline {
    font: 500 22px/1.25 var(--serif);
    color: var(--t1);
    letter-spacing: -0.012em;
}
/* Generic-AI card keeps its white tagline (base --t1) so the card isn't all
   grey — the "before" signal still comes from its grey eyebrow, muted list text,
   and × marks (vs CiteOwl's gold label, white list, gold checks). */

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    color: var(--t3);
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}
.btn-icon:hover { background: var(--chrome-hover); color: var(--t1); }

/* -- Shared button base -- */
.btn-ghost, .btn-primary, .btn-danger, .btn-accept, .btn-reject,
.btn-preview-restore, .btn-preview-close,
.btn-accept-bar, .btn-reject-bar {
    font: 500 12px var(--sans);
    padding: 6px 16px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    white-space: nowrap;
}

/* Full-size buttons for modals and primary actions */
.btn-ghost, .btn-primary, .btn-danger {
    font-size: 13px;
    padding: 8px 20px;
}

/* normal — raised charcoal */
.btn-ghost {
    background: var(--grad-neutral-btn);
    border: 1px solid var(--chrome-border);
    color: var(--t1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 6px -3px rgba(0,0,0,0.5);
}
.btn-ghost:hover { border-color: var(--panel-border); color: var(--t1); filter: brightness(1.12); }
.btn-ghost:active { transform: scale(0.98); }

/* gold — primary affirmative */
.btn-primary {
    background: var(--grad-gold-pill);
    border: none;
    color: var(--on-gold);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -1px 0 rgba(0,0,0,0.18),
        0 4px 14px -6px rgba(var(--accent-rgb),0.5);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }

/* red — destructive */
.btn-danger {
    background: var(--grad-red-pill);
    border: none;
    color: var(--btn-text);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 0 -1px 0 rgba(0,0,0,0.20),
        0 4px 12px -4px rgba(212,88,64,0.45);
}
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-danger:active { transform: scale(0.98); }

/* Gradient pill — same recipe family as .landing-btn-primary (gold).
   Used everywhere accept/reject appears: pending bar bulk, per-section
   inline change bars, source/figure change bars. Tops are tinted (not
   white-ish) so the buttons read as solid colored pills, not shiny chrome. */
.btn-accept,
.btn-accept-bar {
    background: var(--grad-green-pill);
    border: none;
    color: var(--btn-text);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 0 -1px 0 rgba(0,0,0,0.20),
        0 2px 8px -2px rgba(74,140,92,0.45);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn-accept:hover,
.btn-accept-bar:hover {
    transform: translateY(-0.5px);
    filter: brightness(1.08);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.24),
        inset 0 -1px 0 rgba(0,0,0,0.20),
        0 6px 16px -4px rgba(74,140,92,0.55);
}
.btn-accept:active,
.btn-accept-bar:active { transform: translateY(0); filter: brightness(0.96); }

.btn-reject,
.btn-reject-bar {
    background: var(--grad-red-pill);
    border: none;
    color: var(--btn-text);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 0 -1px 0 rgba(0,0,0,0.20),
        0 2px 8px -2px rgba(212,88,64,0.45);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn-reject:hover,
.btn-reject-bar:hover {
    transform: translateY(-0.5px);
    filter: brightness(1.08);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.24),
        inset 0 -1px 0 rgba(0,0,0,0.20),
        0 6px 16px -4px rgba(212,88,64,0.55);
}
.btn-reject:active,
.btn-reject-bar:active { transform: translateY(0); filter: brightness(0.96); }


/* ============================================================
   MODAL
   ============================================================ */

#modal-overlay {
    position: fixed; inset: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 22vh;
    /* Modal must render ABOVE the account overlay (which sits at --z-overlay
     * = 9999) so the plan picker, change-password, and delete-account modals
     * launched from inside Account aren't trapped underneath. */
    z-index: calc(var(--z-overlay) + 1);
    backdrop-filter: blur(2px);
}

#modal-box {
    /* Atelier dialog — one calm SOLID surface, matching the flat account
     * panel. The translucent glass recipe was dropped here: a flat
     * warm-charcoal box with a single hairline border reads quieter and
     * more decisive than a busy blurred panel. */
    background: var(--chrome-bg2);
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius-xl);
    padding: 24px 26px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 24px 64px -16px rgba(0,0,0,0.65);
}


/* Confirmation dialog — a restrained serif title sized for a 420px box
 * (the marketing-scale --font-title was too large here), with tighter body
 * copy. Destructive dialogs turn the title red so the stakes register
 * before the body is read. */
.modal-title {
    font: 500 22px var(--serif);
    color: var(--t1);
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}
#modal-box.modal-danger .modal-title { color: var(--red); }
.modal-body { font: 400 15px/1.55 var(--sans); color: var(--t2); margin-bottom: 22px; }

/* ---- Shared dialog body vocabulary ----
 * One small structural kit reused by every restructured confirm/info dialog
 * so they read consistently: a scannable list, a numeric stat block, and a
 * gold reassurance line ("your work is saved", "this can be undone"). */
.modal-body p + p { margin-top: 8px; }
.modal-body .dlg-list { margin: 8px 0 0; padding-left: 18px; }
.modal-body .dlg-list li { margin: 4px 0; color: var(--t2); }
.modal-body .dlg-list li strong { color: var(--t1); font-weight: 600; }
.modal-body .dlg-stats { display: flex; flex-wrap: wrap; gap: 14px 22px; margin: 14px 0 4px; }
.modal-body .dlg-stat { display: flex; flex-direction: column; gap: 1px; }
.modal-body .dlg-stat-v { font: 600 18px var(--sans); color: var(--t1); letter-spacing: -0.01em; }
.modal-body .dlg-stat-v.v-add { color: var(--green); }
.modal-body .dlg-stat-v.v-del { color: var(--red); }
.modal-body .dlg-stat-l { font: 400 12px var(--sans); color: var(--t3); }
/* Reassurance line — gold (an existing UI accent), the calm "you're safe" note. */
.modal-body .dlg-reassure { margin-top: 12px; color: var(--accent); font: 400 14px/1.5 var(--sans); }

/* Modal inputs — glass treatment matching .acct-field-input app-wide. */
.modal-input,
.modal-field textarea,
.modal-field input[type="text"] {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    color: var(--t1);
    font: 13px var(--sans);
    padding: 10px 14px;
    outline: none;
    transition: border-color var(--dur), background var(--dur);
}
.modal-input { margin-bottom: 14px; }
.modal-field textarea,
.modal-field input[type="text"] { padding: 8px 12px; resize: vertical; }
.modal-input::placeholder,
.modal-field textarea::placeholder,
.modal-field input[type="text"]::placeholder { color: rgba(232,228,212,0.35); }
.modal-input:hover,
.modal-field textarea:hover,
.modal-field input[type="text"]:hover { border-color: rgba(255,255,255,0.18); }
.modal-input:focus,
.modal-field textarea:focus,
.modal-field input[type="text"]:focus {
    border-color: transparent;
    background: rgba(255,255,255,0.06);
}

.modal-field { margin-bottom: 12px; }
.modal-field:last-child { margin-bottom: 0; }
.modal-field label { display: block; font: var(--font-meta); color: var(--t3); margin-bottom: 5px; letter-spacing: 0.02em; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ============================================================
   MODAL — Panel variant (account-panel style)
   ============================================================ */

/* Overlay in panel mode — stronger blur, positioned over document */
#modal-overlay.modal-panel-mode {
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: flex-start;
    padding-top: 0;
}

/* Box in panel mode — wider, flex layout, centered on document area */
#modal-overlay.modal-panel-mode #modal-box {
    max-width: 620px;
    padding: 0;
    height: min(480px, calc(100vh - 80px));
    display: flex;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    /* --panel-left is set by JS to center the main content area over #center-column */
    position: absolute;
    left: var(--panel-left, 50%);
    top: 50%;
    transform: translate(-50%, -50%);
}

/* ---- Sidebar ---- */
.modal-panel-sidebar {
    width: 160px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 8px;
    border-right: 1px solid var(--chrome-border);
    background: var(--chrome-bg);
}
.modal-panel-sidebar-title {
    font: 500 13px var(--sans);
    color: var(--t1);
    padding: 4px 10px 14px;
}
.modal-panel-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.modal-panel-nav-item {
    display: block;
    width: 100%;
    padding: 6px 10px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font: 400 13px var(--sans);
    color: var(--t2);
    text-align: left;
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}
.modal-panel-nav-item:hover {
    background: var(--chrome-hover);
    color: var(--t1);
}
.modal-panel-nav-item.active {
    background: var(--chrome-surface);
    color: var(--t1);
}
.modal-panel-nav-item.disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

/* ---- Main area ---- */
.modal-panel-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.modal-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    flex-shrink: 0;
}
.modal-panel-title {
    font: 500 15px var(--sans);
    color: var(--t1);
}
.modal-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--t3);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur), color var(--dur);
}
.modal-panel-close:hover {
    background: var(--chrome-hover);
    color: var(--t1);
}

/* ---- Scrollable content (fills available height) ---- */
.modal-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
}
/* Panes fill the content area */
.modal-panel-content [data-pane] {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ---- Footer (caption + actions pinned at bottom) ---- */
.modal-panel-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--chrome-border);
}
/* Modal panel caption — visual from FIELDS block below */
.modal-panel-caption { flex: 1; min-width: 0; }
.modal-panel-footer-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ============================================================
   SCROLLBAR — .scrollable class
   ============================================================ */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: var(--radius-xs); transition: background 0.2s; }

.scrollable::-webkit-scrollbar-thumb,
#chat-messages::-webkit-scrollbar-thumb,
#toc-section::-webkit-scrollbar-thumb,
#revision-list::-webkit-scrollbar-thumb,
.tool-result::-webkit-scrollbar-thumb,
.source-quote-box::-webkit-scrollbar-thumb,
.dropdown-list::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
#document-scroll::-webkit-scrollbar { width: 8px; }
#document-scroll::-webkit-scrollbar-thumb { background: var(--scroll-thumb-hover); border-radius: var(--radius-xs); }
#document-scroll::-webkit-scrollbar-thumb:hover { background: rgba(140,115,65,0.7); }

.scrollable:hover::-webkit-scrollbar-thumb,
#chat-messages:hover::-webkit-scrollbar-thumb,
#toc-section:hover::-webkit-scrollbar-thumb,
#revision-list:hover::-webkit-scrollbar-thumb,
.tool-result:hover::-webkit-scrollbar-thumb,
.source-quote-box:hover::-webkit-scrollbar-thumb,
.dropdown-list:hover::-webkit-scrollbar-thumb { background: var(--scroll-thumb-hover); }

.scrollable::-webkit-scrollbar-thumb:hover,
#document-scroll::-webkit-scrollbar-thumb:hover,
#chat-messages::-webkit-scrollbar-thumb:hover,
#toc-section::-webkit-scrollbar-thumb:hover,
#revision-list::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-active); }

/* ============================================================
   UTILITY
   ============================================================ */

.hidden { display: none !important; }

/* ============================================================
   ANIMATIONS — shared keyframes
   ============================================================ */

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

/* ============================================================
   FIELDS — canonical input primitives. Four archetypes:
   (A) Doc field — borderless serif on papyrus. 10 classes share this base.
   (B) Doc bordered field — small bordered input inside the doc.
   (C) Chrome field — sans, chrome-surface, chrome-border. For modals/sidebars.
   (D) Underline field — border-bottom only (account, inline captions).
   Per-file CSS only adds non-visual specifics: text-align, min-height, etc.
   ============================================================ */

/* ── (A) Doc field — borderless serif, brick caret ────────────────── */
.doc-title-edit,
.section-title-input,
.src-title-input,
.doc-desc-edit,
.section-body-input,
.section-body,
.meta-summary-input,
.src-desc-input,
.src-meta-input,
.src-url-input {
    background: none;
    border: none;
    outline: none;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    /* Brick caret, not gold: this is the papyrus document surface, whose accent
       is brick (--doc-accent). Gold is the chrome accent — low-contrast and
       off-palette on the light page. Chrome fields (group C) keep gold. */
    caret-color: var(--doc-accent);
    font-family: var(--serif);
    color: var(--td2b);
}
/* textareas with autogrow */
.doc-title-edit,
.doc-desc-edit,
.section-title-input,
.section-body-input,
.meta-summary-input,
.src-desc-input { resize: none; overflow: hidden; }

/* Title sizes */
.doc-title-edit { font: 300 36px/1.2 var(--serif); color: var(--td1); letter-spacing: -0.5px; }
.section-title-input[data-level="1"] { font: 300 26px/1.25 var(--serif); color: var(--td1); letter-spacing: -0.3px; }
.section-title-input[data-level="2"] { font: 300 23px/1.3 var(--serif); color: var(--td1); }
.section-title-input[data-level="3"] { font: 300 20px/1.35 var(--serif); color: var(--td1); }
.src-title-input { font: 500 17px/1.4 var(--serif); color: var(--td1); }

/* Body */
.doc-desc-edit,
.section-body-input,
.section-body { font: 400 16px/1.82 var(--serif); color: var(--td2b); }

/* Italic metadata — section summary, source description, source meta fields */
.meta-summary-input,
.src-desc-input,
.src-meta-input { font: italic 14px/1.7 var(--serif); color: var(--td3); }

/* URL — like body but doc-accent + underline */
.src-url-input {
    font: 400 14px/1.5 var(--serif);
    color: var(--doc-accent);
    text-decoration: underline;
    text-decoration-color: rgba(139,58,42,0.25);
    text-underline-offset: 2px;
    transition: text-decoration-color var(--dur);
}
.src-url-input:hover,
.src-url-input:focus { text-decoration-color: var(--doc-accent); }

/* Placeholders */
.doc-title-edit::placeholder,
.section-title-input::placeholder,
.src-title-input::placeholder,
.doc-desc-edit::placeholder,
.section-body-input::placeholder { color: var(--td3); opacity: 0.5; }
.meta-summary-input::placeholder,
.src-desc-input::placeholder,
.src-meta-input::placeholder { color: var(--td3); opacity: 0.6; font-style: italic; }
.src-url-input::placeholder { color: var(--td3); opacity: 0.6; font-style: italic; text-decoration: none; }

/* Focus — color shift only (no border or outline change) */
.doc-title-edit:focus,
.section-title-input:focus,
.src-title-input:focus { color: var(--td1); }
.doc-desc-edit:focus,
.section-body-input:focus,
.section-body.editing { color: var(--td2); }
.meta-summary-input:focus,
.src-desc-input:focus,
.src-meta-input:focus { color: var(--td2); }

/* ── (B) Doc bordered field — small bordered inputs inside the doc ── */
.doc-author-input,
.fig-ie-field {
    background: transparent;
    color: var(--td2);
    border: 1px solid var(--doc-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    outline: none;
    caret-color: var(--doc-accent);
    font: 400 14px/1.6 var(--serif);
    transition: border-color var(--dur);
}
.doc-author-input::placeholder,
.fig-ie-field::placeholder { color: var(--td3); opacity: 0.6; }
.doc-author-input:focus,
.fig-ie-field:focus { color: var(--td1); border-color: transparent; }

/* ── (C) Chrome field — sans, chrome surface, chrome border ────────── */
.modal-panel-caption,
.fig-section-select,
.export-row-input,
.export-textarea,
#doc-search-input {
    background: var(--chrome-surface);
    color: var(--t1);
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius-sm);
    font: var(--font-ui);
    padding: 6px 10px;
    outline: none;
    caret-color: var(--accent);
    transition: border-color var(--dur);
}
.modal-panel-caption::placeholder,
.export-row-input::placeholder,
.export-textarea::placeholder,
#doc-search-input::placeholder { color: var(--t3); opacity: 0.5; }
.modal-panel-caption:hover,
.export-row-input:hover,
.export-textarea:hover,
#doc-search-input:hover { border-color: var(--panel-border); }
.modal-panel-caption:focus,
.fig-section-select:focus,
.export-row-input:focus,
.export-textarea:focus,
#doc-search-input:focus { border-color: transparent; }

/* ============================================================
   COLLAPSIBLE PANELS — shared max-height transition.
   Each panel adds only its own max-height (which caps the open size).
   Used by: section meta panel, source expand panel, figure meta panel,
   document meta panel.
   ============================================================ */
.section-meta-panel,
.src-expand-panel,
.fig-meta-panel,
.doc-meta-panel {
    overflow: hidden;
    opacity: 1;
    transition: max-height 220ms var(--ease),
                opacity 180ms var(--ease),
                padding 220ms var(--ease),
                margin 220ms var(--ease);
}
.section-meta-panel.collapsed,
.src-expand-panel.collapsed,
.fig-meta-panel.collapsed,
.doc-meta-panel.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    pointer-events: none;
}

/* ============================================================
   DOC DIVIDER — 2px ochre-dim accent rule used inside doc panels.
   ============================================================ */
.meta-divider,
.src-panel-divider {
    height: 2px;
    background: var(--doc-ochre-dim);
    margin: 10px 0 4px;
}

/* ============================================================
   DOC ICON BUTTON — square icon button for the document context.
   Used for: ⋯ menus, ↗ open, × delete, ↔ scroll, link buttons.
   Sentinel classes (.meta-toggle-btn, .src-toggle-btn, .fig-menu-btn,
   .src-claim-link, .src-claim-delete, .doc-author-remove, .open-link-btn)
   exist only as JS hooks; all visual lives here.
   ============================================================ */

.doc-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--td2);
    border-radius: var(--radius-xs);
    cursor: pointer;
    text-decoration: none;
    font-size: 10px;
    line-height: 1;
    transition: background var(--dur), color var(--dur), opacity var(--dur);
}
.doc-icon-btn:hover { background: var(--doc-hover); color: var(--td1); }
.doc-icon-btn:focus-visible {
    outline: 2px solid var(--doc-ochre);
    outline-offset: -2px;
}
.doc-icon-btn--lg { width: 28px; height: 28px; }

/* "Subtle" variant — affordance is visible always at moderate opacity,
   full opacity when the parent (section/source/figure/header/claim) is
   hovered or focus-within. Replaces the old opacity:0-until-hover
   pattern that hid affordances from keyboard + touch users. */
.doc-icon-btn--subtle { opacity: 0.85; }
.section-block:hover    .doc-icon-btn--subtle,
.section-block:focus-within .doc-icon-btn--subtle,
.section-block.meta-open .doc-icon-btn--subtle,
.src-card:hover         .doc-icon-btn--subtle,
.src-card:focus-within  .doc-icon-btn--subtle,
.src-card.src-open      .doc-icon-btn--subtle,
.src-claim:hover        .doc-icon-btn--subtle,
.src-claim:focus-within .doc-icon-btn--subtle,
.figure-block:hover     .doc-icon-btn--subtle,
.figure-block:focus-within .doc-icon-btn--subtle,
#doc-header:hover       .doc-icon-btn--subtle,
#doc-header:focus-within .doc-icon-btn--subtle,
#doc-header.doc-meta-open .doc-icon-btn--subtle,
.doc-author-row:hover   .doc-icon-btn--subtle,
.doc-author-row:focus-within .doc-icon-btn--subtle { opacity: 1; }

/* ============================================================
   EMPTY STATE — shared primitive
   ============================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    gap: 10px;
    color: var(--t3);
}
.empty-state-icon {
    color: var(--t3);
    opacity: 0.55;
    margin-bottom: 4px;
}
.empty-state-title {
    font: 500 14px var(--sans);
    color: var(--t1);
    line-height: 1.4;
}
.empty-state-desc {
    font: 400 12px/1.55 var(--sans);
    color: var(--t3);
    max-width: 320px;
}
.empty-state-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.empty-state-actions button {
    font: 500 12px var(--sans);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    border: 1px solid var(--chrome-border);
    color: var(--t2);
    transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.empty-state-actions button:hover {
    background: var(--chrome-hover);
    color: var(--t1);
    border-color: var(--t3);
}

/* Document-context variant — used inside the papyrus surface.
   Switches to serif fonts so the copy reads as part of the document
   (matches abstract/title typography) instead of as chrome UI. */
.empty-state.empty-state--doc { color: var(--td3); }
.empty-state.empty-state--doc .empty-state-icon { color: var(--td3); }
.empty-state.empty-state--doc .empty-state-title {
    color: var(--td1);
    font: 500 20px/1.3 var(--serif);
}
.empty-state.empty-state--doc .empty-state-desc {
    color: var(--td2);
    font: 400 16px/1.65 var(--serif);
    max-width: 42ch;
}
.empty-state.empty-state--doc .empty-state-actions button {
    border-color: var(--doc-border-strong);
    color: var(--td2);
    background: none;
}
.empty-state.empty-state--doc .empty-state-actions button:hover {
    border-color: var(--doc-ochre);
    color: var(--doc-ochre);
    background: var(--doc-hover-subtle);
}

/* ============================================================
   CONTEXT MENU (document actions)
   ============================================================ */

.context-menu {
    position: fixed;
    background: var(--chrome-bg2);
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius);
    padding: 4px;
    z-index: var(--z-dropdown);
    min-width: 160px;
    box-shadow: var(--shadow-sm);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    font-size: 12px;
    color: var(--t2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.context-menu-item:hover { background: var(--chrome-hover); color: var(--t1); }
.context-menu-item.danger { color: var(--red); }
.context-menu-item.danger:hover { background: var(--red-bg); }

/* ============================================================
   DRAG-AND-DROP OVERLAY
   ============================================================ */

#drop-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 72px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    background: var(--accent-subtle);
    color: var(--accent);
    transition: background var(--dur);
}
.drop-label {
    font: 500 16px var(--sans);
    color: var(--accent);
}
.drop-formats {
    font: 400 12px var(--sans);
    color: var(--t3);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

#toast-container {
    position: fixed;
    bottom: var(--space-12);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-4);
    pointer-events: none;
}
.toast {
    padding: var(--space-4) var(--space-8);
    border-radius: var(--radius);
    font: 500 13px/1.4 var(--sans);
    max-width: 420px;
    text-align: center;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-error   { background: var(--red); color: var(--btn-text); }
.toast-success { background: var(--green); color: var(--btn-text); }
.toast-info    { background: var(--chrome-surface); color: var(--t1); border: 1px solid var(--chrome-border); }

/* ============================================================
   SAVE INDICATOR
   ============================================================ */

.save-indicator {
    position: fixed;
    top: var(--space-4);
    right: var(--space-8);
    font: 400 11px var(--sans);
    color: var(--t3);
    opacity: 0;
    transition: opacity var(--dur);
    z-index: var(--z-sticky);
    pointer-events: none;
}
.save-indicator.visible { opacity: 1; }

