/* ═══════════════════════════════════════════════════════════
   VeraNex by Veraflow — Professional Legal UI v5
   Palette: teal-copper · charcoal · steel grey
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens ───────────────────────────────────────── */

:root {
    --bg:              #ECEEF1;                    /* off-white page bg */
    --surface:         rgba(255, 255, 255, 0.90);  /* white card surface */
    --surface-2:       rgba(248, 249, 251, 0.98);
    --border:          rgba(42, 47, 54, 0.10);     /* #2A2F36 @ 10% */
    --border-2:        rgba(42, 47, 54, 0.20);     /* #2A2F36 @ 20% */
    --navy:            #001117;                    /* primary dark */
    --navy-2:          #2A2F36;                    /* secondary dark */
    --blue:            #C98A4C;                    /* copper — primary interactive */
    --blue-2:          #D9A070;                    /* lighter copper tint */
    --blue-bg:         rgba(201, 138, 76, 0.08);
    --vf-orange:       #C98A4C;
    --vf-orange-2:     #D9A070;
    --vf-orange-soft:  rgba(201, 138, 76, 0.16);
    --text:            #001117;
    --text-2:          #2A2F36;
    --text-3:          #88929A;
    --ok:              #1F7A52;
    --ok-bg:           rgba(31, 122, 82, 0.09);
    --ok-bdr:          rgba(31, 122, 82, 0.22);
    --warn:            #8C6020;                    /* distinct dark amber */
    --warn-bg:         rgba(140, 96, 32, 0.09);
    --warn-bdr:        rgba(140, 96, 32, 0.22);
    --err:             #B02020;
    --err-bg:          rgba(176, 32, 32, 0.09);
    --err-bdr:         rgba(176, 32, 32, 0.22);
    --shadow-sm:       0 1px 4px rgba(0, 17, 23, 0.08);
    --shadow-md:       0 4px 16px rgba(0, 17, 23, 0.11);
    --r:               9px;
    --r-sm:            5px;
    --legal-measure:   86ch;
    --sidebar-w:       420px;
    --conv-w:          210px;
    --ask-bar-h:       140px;
    --ask-input-fill:  rgba(255, 255, 255, 0.95);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

/* No overflow on html/body — both default to visible so the page scrolls
   naturally. Horizontal overflow is clipped at the .app-main level instead,
   avoiding the browser quirk where html overflow-x:hidden forces body
   overflow-y to hidden and prevents settings page scroll. */

/* ── Body ────────────────────────────────────────────────── */

body {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-width: 320px;
    color: var(--text);
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 8%  0%,  rgba(201, 138, 76, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 92% 100%, rgba(201, 138, 76, 0.05) 0%, transparent 50%),
        linear-gradient(160deg, #ECEEF1 0%, #E8EAED 55%, #E4E7EA 100%);
    background-attachment: fixed;
    transition: background 0.3s, color 0.3s;
}

/* ── Header ──────────────────────────────────────────────── */

header {
    background: linear-gradient(135deg, #001117 0%, #2A2F36 60%, #141B22 100%);
    border-bottom: 1px solid rgba(100, 149, 237, 0.14);
    color: #FFFFFF;
    padding: 0 24px;
    box-shadow: 0 2px 14px rgba(0, 17, 23, 0.22);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 0 auto;
    padding: 17px 0;
    flex-wrap: wrap;
}

/* backward-compat for library / generate pages — same layout as header-inner */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 0 auto;
    flex-wrap: wrap;
    padding: 17px 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s;
}
.header-brand:hover {
    opacity: 0.85;
}

.header-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-brand h1, .header-top h1, header h1 {
    margin: 0;
    font-size: clamp(1.0rem, 2.5vw, 1.22rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #FFFFFF;
}

.header-sub, .header-top p, header p {
    margin: 2px 0 0;
    font-size: 0.76rem;
    color: rgba(200, 218, 255, 0.60);
}

.brand-by {
    font-size: 0.42em;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: rgba(200, 218, 255, 0.38);
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 0.5em;
}

/* ── Ask bar error banner ────────────────────────────────── */

.stream-error-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin: 0;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    background: var(--ask-input-fill, var(--blue-bg));
    border: 1px solid rgba(201, 138, 76, 0.2);
    color: var(--text-2);
    font-size: 0.68rem;
    line-height: 1.35;
    animation: fadeIn 0.18s ease;
    max-width: none;
}

.stream-error-banner:not([hidden]) {
    display: inline-flex;
}

.stream-error-banner-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stream-error-banner-close {
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.stream-error-banner:hover .stream-error-banner-close {
    opacity: 1;
}

.stream-error-banner-close:hover {
    color: var(--err) !important;
    background: var(--err-bg) !important;
}

.stream-error-banner-close:focus-visible {
    opacity: 1;
}

/* ── Ask bar credit line ─────────────────────────────────── */

.ask-bar-credit {
    text-align: center;
    font-size: 0.58rem;
    color: rgba(90, 110, 140, 0.45);
    margin: 3px 0 0;
    letter-spacing: 0.02em;
    user-select: none;
}

.header-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

.header-nav a {
    color: rgba(200, 218, 255, 0.85);
    text-decoration: none;
    padding: 6px 13px;
    border-radius: var(--r-sm);
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.header-nav a:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.14);
}

.nav-active {
    background: rgba(255, 255, 255, 0.16) !important;
    border-color: rgba(255, 255, 255, 0.22) !important;
    color: #fff !important;
}

/* ── Page layout ─────────────────────────────────────────── */

.app-layout, .app-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 18px 18px 148px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* The chat page only — its left/right sidebars are fixed-width
   (--conv-w/--sidebar-w) and the middle "1fr" column in .home-grid absorbs
   all remaining space, so removing the cap here lets all three panels span
   the full viewport on wide screens instead of floating in a centered
   column. Other pages (settings/library/manual) keep the 1440px cap above —
   their single/two-column content would look odd stretched edge to edge. */
.app-main--chat {
    max-width: none;
}

main { margin-top: 0; }

.main-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Home 3-column grid ──────────────────────────────────── */

.home-grid {
    display: grid;
    grid-template-columns: var(--conv-w) 1fr var(--sidebar-w);
    gap: 14px;
    align-items: start;
    /* As a flex item of .app-main (column direction), a grid container
       defaults to a content-based minimum width unless told otherwise —
       on narrow screens that silently forces the whole page (and anything
       sharing its containing block, like the fixed header/ask-bar) wider
       than the viewport. */
    min-width: 0;
}

.home-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.home-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 14px;
    height: calc(100vh - 76px);
    overflow: hidden;
    overflow-x: hidden;
}

/* Documents card — compact, constrained so refs are always visible */
.home-sidebar .upload-card {
    flex-shrink: 0;
}

.home-sidebar .upload-card .uploaded-list {
    max-height: 130px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

.home-sidebar .upload-card .uploaded-list::-webkit-scrollbar { width: 4px; }
.home-sidebar .upload-card .uploaded-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* Slaagkans widget — compact, never grows */
#slaagkans-card { flex-shrink: 0; }

/* References card fills remaining sidebar height and scrolls internally */
#references-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#references-card h2 { flex-shrink: 0; }

#references-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

/* Always show references card when it has content */
#references-card:not(:empty) {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
}

#references-content::-webkit-scrollbar { width: 5px; }
#references-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
#references-content::-webkit-scrollbar-track { background: transparent; }

/* ── Card ────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.card h2,
.card h1 {
    margin: 0 0 16px;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.login-card {
    width: min(420px, 100%);
    max-width: 420px;
    border-radius: calc(var(--r) + 2px);
    padding: 26px 24px;
}

@media (max-width: 560px) {
    .login-page {
        min-height: 100vh;
        min-height: 100dvh;
        padding: 16px 12px;
        align-items: center;
    }

    .login-card {
        width: 100%;
        max-width: 360px;
        padding: 20px 16px;
    }

    .login-card h1 {
        margin-bottom: 12px;
        font-size: 0.98rem;
    }

    .login-form {
        gap: 10px;
    }

    .login-hint {
        margin-top: 14px;
        font-size: 0.84rem;
    }
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-hint {
    margin-top: 18px;
    font-size: 0.9rem;
    color: #5B6570;
    line-height: 1.5;
}

.login-hint a,
.login-hint .link-button {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(201, 138, 76, 0.22);
}

.login-hint a:hover,
.login-hint .link-button:hover {
    color: var(--blue-2);
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.link-button:focus-visible {
    outline: 2px solid var(--blue-2);
    outline-offset: 2px;
}

.login-card code {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    background: rgba(248, 251, 255, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    color: var(--text-2);
    overflow-x: auto;
}

/* ── Page banners ────────────────────────────────────────── */

.page-message, .page-banner {
    padding: 9px 15px;
    border-radius: var(--r-sm);
    font-size: 0.86rem;
    font-weight: 500;
}

.page-message-success, .page-banner--success {
    background: var(--ok-bg); border: 1px solid var(--ok-bdr); color: var(--ok);
}
.page-message-error, .page-banner--error {
    background: var(--err-bg); border: 1px solid var(--err-bdr); color: var(--err);
}
.page-message-warning, .page-banner--warn {
    background: var(--warn-bg); border: 1px solid var(--warn-bdr); color: var(--warn);
}
.page-message-info, .page-banner--info {
    background: var(--blue-bg); border: 1px solid rgba(201, 138, 76,0.18); color: var(--blue);
}

/* ── Form controls ───────────────────────────────────────── */

input[type="text"],
input[type="number"],
input[type="url"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.90);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color 0.14s, box-shadow 0.14s;
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    border-color: var(--blue-2);
    box-shadow: 0 0 0 3px rgba(201, 138, 76, 0.11);
}

textarea { resize: vertical; line-height: 1.55; }

label {
    display: block;
    font-size: 0.81rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 5px;
}

form { display: flex; flex-direction: column; gap: 9px; }

/* ── Shared layout primitives ───────────────────────────── */

.nav-inline-form { margin: 0; }

.audit-inline-title { display: inline; }

.manual-hero-title {
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.manual-status-ok { color: var(--ok); }
.manual-status-warn { color: var(--warn); }
.manual-status-err { color: var(--err); }

/* ── Auth pages (login/request/reset family) ────────────── */

.auth-page,
.auth-page * {
    box-sizing: border-box;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding: 24px;
}

.auth-page .login-card {
    width: 360px;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 17, 23, 0.10), 0 1px 4px rgba(0, 17, 23, 0.06);
    overflow: hidden;
    background: #fff;
    max-width: 100%;
    padding: 0;
}

.auth-page .login-card.login-card--wide {
    width: 400px;
}

.auth-page .login-card.login-card--verify {
    width: 380px;
}

.auth-page .setup-card {
    width: 420px;
    max-width: 100%;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 17, 23, 0.10), 0 1px 4px rgba(0, 17, 23, 0.06);
    overflow: hidden;
    background: #fff;
}

.auth-page .setup-card__header {
    background: linear-gradient(135deg, #001117 0%, #2A2F36 100%);
    padding: 28px 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.auth-page .setup-card__header,
.auth-page .exp-card__header,
.auth-page .login-card__header {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.auth-page .setup-card__mark {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.auth-page .setup-card__brand-name {
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.auth-page .setup-card__brand-tagline {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.auth-page .setup-card__body {
    padding: 24px 32px 32px;
}

.auth-page .setup-card__footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 20px;
}

.auth-page .setup-card__body h2 {
    font-size: 15px;
    font-weight: 600;
    color: #001117;
    margin-bottom: 6px;
}

.auth-page p.desc {
    font-size: 13px;
    color: #88929A;
    margin-bottom: 18px;
    line-height: 1.5;
}

.auth-page .steps {
    margin-bottom: 18px;
}

.auth-page .step {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: flex-start;
}

.auth-page .step-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: #001117;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-page .step-text {
    font-size: 13px;
    color: #2A2F36;
    line-height: 1.5;
}

.auth-page .qr-wrap {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}

.auth-page .qr-wrap svg {
    width: 160px;
    height: 160px;
    border-radius: 8px;
}

.auth-page .secret-box {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 14px;
    font-family: monospace;
    font-size: 14px;
    letter-spacing: 0.12em;
    text-align: center;
    color: #111827;
    word-break: break-all;
    margin-bottom: 18px;
}

.auth-page .code-input {
    font-size: 22px;
    letter-spacing: 0.18em;
    text-align: center;
    font-family: monospace;
}

.auth-page .btn-primary {
    display: block;
    margin-top: 8px;
    width: 100%;
    padding: 11px;
    background: #001117;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    text-align: center;
}

.auth-page .btn-primary:hover {
    background: #2A2F36;
}

.auth-page .btn-secondary-link {
    display: block;
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: #88929A;
}

.auth-page .btn-secondary-link a {
    color: #2A2F36;
}

.auth-page .toggle-section {
    display: none;
}

.auth-page .toggle-section.visible {
    display: block;
}

.auth-page .backup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}

.auth-page .backup-code-item {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: monospace;
    font-size: 14px;
    letter-spacing: 0.1em;
    text-align: center;
    color: #111827;
}

.auth-page .backup-grid-wrap {
    position: relative;
    margin: 16px 0;
}
.auth-page .backup-grid-wrap .backup-grid {
    margin: 0;
}
.auth-page .backup-copy-btn {
    position: absolute;
    top: -28px;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f3f4f6;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    color: #88929A;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    padding: 0;
}
.auth-page .backup-copy-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #2A2F36;
}
.auth-page .backup-copy-btn--done {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

.auth-page .backup-notice {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.auth-page .exp-card {
    width: 100%;
    max-width: 560px;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 17, 23, 0.10), 0 1px 4px rgba(0, 17, 23, 0.06);
    overflow: hidden;
    background: #fff;
}

.auth-page .exp-card__header {
    background: linear-gradient(135deg, #001117 0%, #2A2F36 100%);
    padding: 32px 32px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.auth-page .exp-card__mark {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.auth-page .exp-card__brand-name {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.auth-page .exp-card__brand-tagline {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    letter-spacing: 0.06em;
    margin-top: 3px;
}

.auth-page .exp-card__body {
    padding: 32px;
}

.auth-page .exp-card__body h2 {
    font-size: 17px;
    font-weight: 700;
    color: #001117;
    margin-bottom: 10px;
}

.auth-page .exp-card__body p {
    font-size: 14px;
    color: #2A2F36;
    line-height: 1.6;
    margin-bottom: 28px;
}

.auth-page .exp-card__body p strong {
    color: #001117;
}

.auth-page .plans {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.auth-page .plan-card {
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-page .plan-card:hover {
    border-color: #2A2F36;
}

.auth-page .plan-card__name {
    font-size: 15px;
    font-weight: 700;
    color: #001117;
}

.auth-page .plan-card__desc {
    font-size: 12px;
    color: #88929A;
    line-height: 1.5;
    flex: 1;
}

.auth-page .plan-card__pricing {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.auth-page .plan-card__btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    background: #001117;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: block;
    text-align: center;
    transition: background 0.15s;
}

.auth-page .plan-card__btn:hover {
    background: #2A2F36;
}

.auth-page .plan-card--team .plan-card__btn {
    background: #2A2F36;
}

.auth-page .plan-card--team .plan-card__btn:hover {
    background: #001117;
}

.auth-page .exp-card__footer {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    padding-bottom: 28px;
}

.auth-page .exp-card__footer a {
    color: #2A2F36;
}

.auth-page .grace-banner {
    background: #fef9c3;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #854d0e;
    margin-bottom: 20px;
}

@media (max-width: 480px) {
    .auth-page .plans {
        grid-template-columns: 1fr;
    }
}

/* ── Pricing page ─────────────────────────────────────────────────────────── */

.auth-page .pricing-wrap {
    width: 100%;
    max-width: 760px;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 17, 23, 0.10), 0 1px 4px rgba(0, 17, 23, 0.06);
    overflow: hidden;
    background: #fff;
}

.auth-page .pricing-header {
    background: linear-gradient(135deg, #001117 0%, #2A2F36 100%);
    padding: 28px 36px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.auth-page .pricing-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.auth-page .pricing-brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.auth-page .pricing-tagline {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    letter-spacing: 0.06em;
    margin-top: 3px;
}

.auth-page .pricing-body {
    padding: 36px;
}

.auth-page .pricing-body h2 {
    font-size: 20px;
    font-weight: 700;
    color: #001117;
    margin-bottom: 8px;
}

.auth-page .pricing-intro {
    font-size: 14px;
    color: #2A2F36;
    line-height: 1.6;
    margin-bottom: 24px;
}

.pricing-toggle {
    display: inline-flex;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 24px;
}

.pricing-toggle-btn {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #88929A;
    background: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pricing-toggle-btn--active {
    background: #001117;
    color: #fff;
}

.pricing-discount-badge {
    display: inline-block;
    background: #dcfce7;
    color: #15803d;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.pricing-toggle-btn--active .pricing-discount-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.pricing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.pricing-grid--settings {
    margin-bottom: 0;
}

.pricing-card {
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: border-color 0.15s;
}

.pricing-card:hover {
    border-color: #2A2F36;
}

.pricing-card--featured {
    border-color: #2A2F36;
    background: #f8faff;
}

.pricing-card__badge {
    display: inline-block;
    background: #2A2F36;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    align-self: flex-start;
}

.pricing-card__name {
    font-size: 17px;
    font-weight: 700;
    color: #001117;
    margin-bottom: 8px;
}

.pricing-card__desc {
    font-size: 13px;
    color: #88929A;
    line-height: 1.5;
    margin-bottom: 18px;
}

.pricing-card__desc strong {
    color: #001117;
}

.pricing-card__price-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 6px;
}

.pricing-card__amount {
    font-size: 32px;
    font-weight: 800;
    color: #001117;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.pricing-card__period {
    font-size: 12px;
    color: #9ca3af;
}

.pricing-card__billing-note {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 18px;
}

.pricing-team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

.pricing-team-label {
    font-size: 12px;
    font-weight: 600;
    color: #2A2F36;
}

.pricing-stepper {
    display: flex;
    align-items: center;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.pricing-stepper-btn {
    width: 32px;
    height: 32px;
    background: #f9fafb;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #2A2F36;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
    flex-shrink: 0;
    line-height: 1;
}

.pricing-stepper-btn:hover {
    background: #f3f4f6;
}

.pricing-stepper-input {
    width: 52px;
    text-align: center;
    border: none;
    border-left: 1.5px solid #e5e7eb;
    border-right: 1.5px solid #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    color: #001117;
    outline: none;
    padding: 6px 0;
    -moz-appearance: textfield;
}

.pricing-stepper-input:focus-visible {
    outline: 2px solid var(--blue-2);
    outline-offset: -2px;
}

.pricing-stepper-input::-webkit-outer-spin-button,
.pricing-stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pricing-stepper--sm .pricing-stepper-input {
    width: 40px;
    font-size: 13px;
    padding: 4px 0;
}

.pricing-stepper--sm .pricing-stepper-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
}

.pricing-card__features {
    list-style: none;
    padding: 0;
    margin: 0 0 22px 0;
    flex: 1;
}

.pricing-card__features li {
    font-size: 13px;
    color: #2A2F36;
    padding: 5px 0 5px 22px;
    position: relative;
    line-height: 1.4;
}

.pricing-card__features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #2A2F36;
    font-weight: 700;
}

.pricing-card__btn {
    margin-top: auto;
    padding: 11px 16px;
    background: #001117;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: block;
    text-align: center;
    transition: background 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.pricing-card__btn:hover {
    background: #2A2F36;
}

.pricing-card__btn--featured {
    background: #2A2F36;
}

.pricing-card__btn--featured:hover {
    background: #001117;
}

.auth-page .pricing-footer {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    padding-bottom: 4px;
}

.pricing-vat-note {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
}

.auth-page .pricing-footer a {
    color: #2A2F36;
}

@media (max-width: 640px) {
    .pricing-grid {
        grid-template-columns: 1fr;
    }
    .auth-page .pricing-body {
        padding: 20px;
    }
    .auth-page .pricing-wrap {
        border-radius: 12px;
    }
}

.auth-page .login-card__header {
    background: linear-gradient(135deg, #001117 0%, #2A2F36 100%);
    padding: 32px 32px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.auth-page .login-card__mark {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.auth-page .login-card__mark.login-card__mark--lg {
    width: 72px;
    height: 72px;
}

.auth-brand-center {
    text-align: center;
}

.auth-page .login-card__brand-name {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
}

.auth-page .login-card__brand-name span {
    font-variant: small-caps;
    font-size: 0.72em;
    font-weight: 400;
    opacity: 0.70;
    letter-spacing: 0.08em;
}

.auth-page .login-card__brand-tagline {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    letter-spacing: 0.06em;
    margin-top: 3px;
    text-align: center;
}

.auth-page .login-card__body {
    padding: 28px 32px 32px;
}

.auth-page .login-card__body h2 {
    font-size: 15px;
    font-weight: 600;
    color: #001117;
    margin-bottom: 18px;
}

.auth-page .login-card__body p {
    font-size: 13px;
    color: #88929A;
    margin-bottom: 18px;
    line-height: 1.5;
}

.auth-page .login-banner {
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-page .login-banner--error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.auth-page .login-banner--success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.auth-page .login-banner--warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.auth-page .login-banner--info { background: rgba(201, 138, 76, 0.06); border: 1px solid rgba(201, 138, 76, 0.28); color: #C98A4C; }
.auth-page .login-banner--info code {
    background: rgba(201, 138, 76, 0.10);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

.auth-page .login-banner--info p {
    margin-top: 6px;
    font-size: 12px;
}

.auth-page .login-field {
    margin-bottom: 14px;
}

.auth-page label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #2A2F36;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.auth-page input[type="text"],
.auth-page input[type="password"],
.auth-page input[type="email"],
.auth-page textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.auth-page input[type="text"]:focus,
.auth-page input[type="password"]:focus,
.auth-page input[type="email"]:focus,
.auth-page textarea:focus {
    border-color: #2A2F36;
}

.auth-page textarea {
    resize: vertical;
    min-height: 88px;
}

.auth-page button[type="submit"] {
    margin-top: 8px;
    width: 100%;
    padding: 11px;
    background: #001117;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.auth-page button[type="submit"]:hover {
    background: #2A2F36;
}

.auth-page .login-hint {
    margin-top: 16px;
    font-size: 12px;
    color: #5B6570;
    text-align: center;
    line-height: 1.5;
}

.auth-page .login-hint a,
.auth-page .login-hint .link-button {
    color: #2A2F36;
}

.auth-page .login-card__footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 20px;
}

.page-main-narrow {
    max-width: 1020px;
    margin: 28px auto;
    padding: 0 18px 48px;
}

.card-block { margin-bottom: 20px; }

.form-field--full { grid-column: 1 / -1; }

.settings-hint--tight { margin-top: 0; }
.settings-hint--inline { margin: 0; }
.settings-hint--spaced { margin-top: 8px; }

.inline-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.export-form-inline { margin-top: 20px; }

.sidebar-kicker {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
}

.refs-turn-label {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-3);
    margin-left: 0.5rem;
    vertical-align: middle;
    white-space: normal;
}

.panel-head-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.panel-head-title {
    margin: 0;
}

.panel-head-sub {
    font-size: 0.74rem;
    color: var(--text-3);
}

.lib-add-link--mt { margin-top: 8px; }

.pin-picker-list {
    padding: 6px 0 2px;
}

.pin-empty {
    font-size: 0.8rem;
    color: var(--text-3);
    font-style: italic;
    margin: 2px 0 4px;
}

.pin-empty--inline {
    margin: 2px 0 8px;
}

.pin-section {
    margin-bottom: 8px;
}

.pin-section-title {
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 6px 0 4px;
}

.pin-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}

.pin-row .remove-cross {
    opacity: 1;
}

.pin-row--lined {
    border-bottom: 1px solid var(--border);
}

.pin-name {
    flex: 1;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.pin-add-btn {
    font-size: 0.78rem !important;
    padding: 2px 8px !important;
}

.pin-source-badge {
    flex-shrink: 0;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 7px;
}

.main-content--flex {
    flex: 1;
}

.ls-load-btn {
    flex-shrink: 0;
}

.delete-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    background: rgba(30, 20, 10, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #f5ede4;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* ── Dashboard page ─────────────────────────────────────── */

.dash-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.dash-stat-card {
    flex: 1;
    min-width: 150px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
    text-align: center;
}

.dash-stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1;
}

.dash-stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-2);
    margin-top: 4px;
}

.dash-section {
    margin-bottom: 32px;
}

.dash-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.guardrail-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
}

.guardrail-badge--green {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid var(--ok-bdr);
}

.guardrail-badge--amber {
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid var(--warn-bdr);
}

.guardrail-badge--red {
    background: var(--err-bg);
    color: var(--err);
    border: 1px solid var(--err-bdr);
}

.rep-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.rep-table th {
    text-align: left;
    padding: 6px 10px;
    font-weight: 600;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
}

.rep-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.rep-bar-wrap {
    width: 120px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
    height: 8px;
    display: inline-block;
    vertical-align: middle;
}

.rep-bar {
    height: 8px;
    border-radius: 4px;
}

.rep-bar--good { background: var(--ok); }
.rep-bar--warn { background: var(--warn); }
.rep-bar--bad { background: var(--err); }

.flag-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    margin-top: 8px;
}

.flag-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.flag-bar-fill {
    width: 20px;
    background: var(--blue);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}

.flag-bar-day {
    font-size: 0.6rem;
    color: var(--text-3);
    white-space: nowrap;
    transform: rotate(-45deg);
    margin-top: 2px;
}

.corrections-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.corrections-table th {
    text-align: left;
    padding: 6px 8px;
    font-weight: 600;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
}

.corrections-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: break-word;
    max-width: 200px;
}

.export-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text);
    text-decoration: none;
}

.export-btn:hover {
    background: var(--surface-2);
    border-color: var(--blue);
    color: var(--blue);
}

.dash-section details > summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    padding: 4px 0;
    user-select: none;
}

.dash-section details[open] > summary {
    color: var(--blue);
}

.dash-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    margin-bottom: 32px;
}

.dash-two-col .dash-section {
    margin-bottom: 0;
}

.corrections-scroll {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
    margin-top: 10px;
}

.dash-inline-summary {
    font-size: 0.75rem;
    color: var(--text-2);
    cursor: pointer;
}

.dash-inline-excerpt {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: var(--text-2);
    font-style: italic;
    white-space: pre-wrap;
}

.dash-empty-note {
    color: var(--text-2);
    font-size: 0.82rem;
    margin-top: 8px;
}

@media (max-width: 680px) {
    .dash-two-col {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .dash-two-col .dash-section {
        margin-bottom: 24px;
    }
}

/* ── Buttons ─────────────────────────────────────────────── */

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
}

button[type="submit"],
button[type="button"]:not(.remove-cross):not(.lib-source-tab):not(.corpus-filter-toggle):not(.nav-mode-btn):not(.btn-danger-sm):not(.add-doc-btn):not(.conv-drawer-toggle):not(.ref-drawer-toggle):not(.pinned-drawer-toggle):not(.app-modal-btn):not(.home-sidebar-close):not(.approve-trigger-btn):not(.nav-icon-btn):not(.nav-avatar-btn):not(.ask-send-btn):not(.password-modal-close):not(.lib-chip):not(.lib-jur-pill):not(.lib-doc-star-btn):not(.lib-doc-refresh-btn):not(.lib-export-btn):not(.lib-banner-close):not(.lib-bulk-load-btn):not(.lib-cm-del):not(.lib-idx-btn):not(.conv-search-menu-btn):not(.doc-expand-btn):not(.conv-turn-toggle) {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--navy);
    border: 1.5px solid rgba(0, 17, 23, 0.30);
    font-size: 0.86rem;
    font-weight: 600;
    transition: background 0.14s, color 0.14s, border-color 0.14s, box-shadow 0.14s;
    box-shadow: none;
}

button[type="submit"]:hover,
button[type="button"]:not(.remove-cross):not(.lib-source-tab):not(.corpus-filter-toggle):not(.nav-mode-btn):not(.btn-danger-sm):not(.add-doc-btn):not(.conv-drawer-toggle):not(.ref-drawer-toggle):not(.pinned-drawer-toggle):not(.app-modal-btn):not(.home-sidebar-close):not(.approve-trigger-btn):not(.nav-icon-btn):not(.nav-avatar-btn):not(.ask-send-btn):not(.password-modal-close):not(.lib-chip):not(.lib-jur-pill):not(.lib-doc-star-btn):not(.lib-doc-refresh-btn):not(.lib-export-btn):not(.lib-banner-close):not(.lib-bulk-load-btn):not(.lib-cm-del):not(.lib-idx-btn):not(.conv-search-menu-btn):not(.doc-expand-btn):not(.conv-turn-toggle):hover {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
    box-shadow: var(--shadow-sm);
}

/* Chat send button — keep prominent dark style */
.ask-send-btn {
    background: var(--navy) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: var(--shadow-sm) !important;
}
.ask-send-btn:hover { background: #2A2F36 !important; }

button[type="submit"]:disabled { opacity: 0.50; cursor: not-allowed; }

.btn-secondary, .json-button {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--r-sm);
    font-size: 0.86rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s;
    background: transparent !important;
    color: var(--blue) !important;
    border: 1px solid var(--border-2) !important;
    box-shadow: none !important;
}

.btn-secondary:hover, .json-button:hover {
    background: var(--blue-bg) !important;
    border-color: rgba(201, 138, 76, 0.28) !important;
}

/* ── Dropzone ────────────────────────────────────────────── */

.dropzone {
    border: 1.5px dashed var(--border-2);
    border-radius: var(--r);
    padding: 22px 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.14s, background 0.14s;
    background: rgba(255, 255, 255, 0.50);
    user-select: none;
}

.dropzone:hover, .dropzone-active {
    border-color: var(--blue-2);
    background: rgba(201, 138, 76, 0.04);
}

.dropzone-label { pointer-events: none; }

.dropzone-title {
    margin: 0 0 4px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-2);
}

.dropzone-hint {
    font-size: 0.73rem;
    color: var(--text-3);
    letter-spacing: 0.02em;
}

#file-input, .file-preview { display: none !important; }

/* ── Upload status ───────────────────────────────────────── */

.upload-status {
    font-size: 0.81rem;
    padding: 5px 10px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
}

.upload-status-active  { background: var(--ok-bg);   border-color: var(--ok-bdr);   color: var(--ok);   }
.upload-status-error   { background: var(--err-bg);  border-color: var(--err-bdr);  color: var(--err);  }
.upload-status-warning { background: var(--warn-bg); border-color: var(--warn-bdr); color: var(--warn); }


/* ── Document list ───────────────────────────────────────── */

.uploaded-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}
.uploaded-list::-webkit-scrollbar { width: 4px; }
.uploaded-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* Mirrors .conv-item exactly */
.doc-item {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 5px;
    padding: 6px 9px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    cursor: default;
    align-items: center;
}

.doc-item:hover {
    background: rgba(255, 255, 255, 0.70);
    border-color: var(--border);
}
.doc-item:hover .remove-cross { opacity: 1; }

.doc-expand-btn {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--vf-orange);
    border-radius: 999px;
    transition: color 0.14s, opacity 0.14s;
    opacity: 0.85;
}
.doc-expand-btn:hover {
    color: var(--vf-orange-2);
    opacity: 1;
}
.doc-expand-btn:focus-visible {
    opacity: 1;
    outline: none;
}
.doc-expand-chevron { transition: transform 0.15s ease; }

.doc-view-btn {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-3);
    border-radius: 3px;
    transition: color 0.12s, background 0.12s;
}
.doc-view-btn:hover { color: var(--blue); background: var(--blue-bg); }

.doc-name {
    grid-column: 2;
    grid-row: 1 / span 2;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
    overflow: hidden;
}

.doc-format-badge {
    flex-shrink: 0;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-3);
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 3px;
    padding: 0 3px;
    line-height: 1.5;
}

.doc-date {
    flex-shrink: 0;
    font-size: 0.63rem;
    color: var(--text-3);
}

.doc-indexing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.inline-remove {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
    display: flex;
    align-items: center;
}

.remove-cross {
    background: none !important;
    border: none !important;
    color: var(--text-3) !important;
    opacity: 0;
    cursor: pointer;
    padding: 3px 4px !important;
    border-radius: 3px !important;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
    box-shadow: none !important;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-cross:hover {
    color: var(--err) !important;
    background: var(--err-bg) !important;
    opacity: 1;
}

/* ── Document text preview panel ─────────────────────────── */

.doc-preview {
    margin: 0 0 4px 30px;
    border-left: 2px solid var(--border-2);
    padding: 8px 12px;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--surface-2);
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

.doc-preview__text {
    font-size: 0.72rem;
    color: var(--text-2);
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    margin: 0;
}

.doc-preview__loading {
    font-size: 0.72rem;
    color: var(--text-3);
    font-style: italic;
    margin: 0;
}

[data-theme="dark"] .doc-preview {
    background: rgba(255,255,255,0.04);
    border-left-color: var(--border);
}

/* ── Answer card ─────────────────────────────────────────── */

.answer-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: clamp(380px, calc(100dvh - 300px), 760px);
    /* Use surface background to match main app */
    background: var(--surface);
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
}

.answer-content-stack {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border: none;
    border-radius: 0;
    background: var(--surface);
    overflow: visible;
}

.answer-content-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 2px 6px;
    border-bottom: none;
    background: transparent;
}

.answer-content-summary::-webkit-details-marker {
    display: none;
}

.answer-content-summary::after {
    content: '▾';
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--vf-orange) 72%, var(--text-3));
}

.answer-content-stack[open] .answer-content-summary::after {
    content: '▴';
}

.answer-content-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 2px;
    background: var(--surface);
}

.answer-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.reading-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-dropdown-reading {
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--border);
}

.nav-dropdown-reading-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}

.reading-group {
    display: inline-flex;
    gap: 4px;
}

.reading-chip {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 2px 7px;
    cursor: pointer;
}

.reading-chip--active {
    border-color: rgba(201, 138, 76, 0.34);
    color: var(--blue);
    background: var(--blue-bg);
}

.answer-story-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: visible;
    padding: 2px 2px 2px 0;
    scroll-behavior: smooth;
    /* Ensure background is consistent with main app */
    background: var(--surface);
}

.answer-busy-placeholder {
    color: var(--text-3) !important;
    font-style: italic;
    animation: answer-busy-pulse 1.2s ease-in-out infinite;
}

@keyframes answer-busy-pulse {
    0%, 100% { opacity: 0.58; }
    50% { opacity: 1; }
}

.answer-current-question {
    margin: 0 0 12px 0;
    max-width: min(82%, 62ch);
    padding: 9px 12px;
    border-radius: 14px 14px 4px 14px;
    border: 1px solid rgba(201, 138, 76, 0.2);
    background: rgba(201, 138, 76, 0.1);
    color: var(--text-2);
    font-size: 0.8rem;
    line-height: 1.5;
    font-weight: 500;
    overflow-wrap: anywhere;
    text-align: left;
    align-self: flex-start;
    clear: both;
}

.answer-current-question--busy {
    position: relative;
    padding-left: 30px;
}

.answer-current-question--busy::after {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #c98a4c;
    transform: translateY(-50%);
    animation: question-busy-breath 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(201, 138, 76, 0.34);
}

@keyframes question-busy-breath {
    0%,
    100% {
        transform: translateY(-50%) scale(0.9);
        opacity: 0.75;
        box-shadow: 0 0 0 0 rgba(201, 138, 76, 0.34);
    }
    50% {
        transform: translateY(-50%) scale(1.15);
        opacity: 1;
        box-shadow: 0 0 0 7px rgba(201, 138, 76, 0);
    }
}

.answer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.answer-meta-chip {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-3);
    background: var(--surface-3, rgba(255,255,255,0.06));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 8px;
}

.citation-first-box {
    margin: 0 0 10px;
    padding: 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.citation-first-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.citation-first-head-main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.citation-first-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    -webkit-appearance: none;
    font-size: 0;
    font-weight: 700;
    letter-spacing: 0.03em;
    border-radius: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.74);
    color: var(--text-2);
    line-height: 1;
    cursor: pointer;
}

.citation-first-toggle::before {
    content: '▾';
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--vf-orange) 72%, var(--text-3));
}

.citation-first-toggle[aria-expanded="true"]::before {
    content: '▴';
}

.citation-first-toggle:hover {
    border-color: var(--vf-orange);
    color: var(--vf-orange);
}

.citation-first-body {
    margin-top: 7px;
}

.citation-first-body-title {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}

.citation-first-body[hidden] {
    display: none !important;
}

.citation-first-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
}

.citation-first-verdict {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.75);
}

.citation-first-verdict--ok {
    border-color: var(--ok-bdr);
    background: var(--ok-bg);
}

.citation-first-verdict--warn {
    border-color: var(--warn-bdr);
    background: var(--warn-bg);
}

.citation-first-verdict--err {
    border-color: var(--err-bdr);
    background: var(--err-bg);
}

.citation-first-verdict-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--text-3);
    flex-shrink: 0;
}

.citation-first-verdict-dot--ok { background: var(--ok); }
.citation-first-verdict-dot--warn { background: var(--warn); }
.citation-first-verdict-dot--err { background: var(--err); }

.citation-first-verdict-label {
    min-width: 0;
    flex: 1;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
}

.citation-first-verdict-score {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 7px;
    background: rgba(255, 255, 255, 0.72);
}

.citation-first-points {
    display: grid;
    gap: 5px;
    margin-top: 8px;
}

.citation-first-point {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.68);
}

.citation-first-point--empty {
    font-size: 0.70rem;
    color: var(--text-2);
    line-height: 1.45;
}

.citation-first-point-icon {
    width: 16px;
    text-align: center;
    font-size: 0.76rem;
    line-height: 1.3;
    color: var(--blue);
    flex-shrink: 0;
}

.citation-first-point-body {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.citation-first-point-label {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
}

.citation-first-point-text {
    font-size: 0.70rem;
    line-height: 1.42;
    color: var(--text-1);
}

.citation-first-status {
    display: inline-flex;
    margin-top: 8px;
    font-size: 0.70rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid transparent;
    white-space: normal;
    line-height: 1.35;
}

.citation-first-status--ok {
    color: var(--ok);
    background: var(--ok-bg);
    border-color: var(--ok-bdr);
}

.citation-first-status--warn {
    color: var(--warn);
    background: var(--warn-bg);
    border-color: var(--warn-bdr);
}

.citation-first-status--err {
    color: var(--err);
    background: var(--err-bg);
    border-color: var(--err-bdr);
}

.citation-first-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.citation-first-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 6px 7px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.68);
}

.citation-first-jump {
    flex-shrink: 0;
    min-width: 30px;
    height: 22px;
    border-radius: 5px !important;
    border: 1px solid rgba(201, 138, 76, 0.24) !important;
    background: var(--blue-bg) !important;
    color: var(--blue-2) !important;
    font-size: 0.71rem !important;
    font-weight: 700 !important;
    padding: 0 7px !important;
    box-shadow: none !important;
}

.citation-first-jump:hover {
    border-color: var(--blue-2) !important;
    background: rgba(201, 138, 76, 0.15) !important;
}

.citation-first-text {
    min-width: 0;
    flex: 1;
}

.citation-first-top {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.citation-first-pill {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 4px;
    padding: 1px 5px;
    border: 1px solid rgba(201, 138, 76, 0.20);
    color: var(--blue);
    background: var(--blue-bg);
}

.citation-first-meta {
    font-size: 0.66rem;
    color: var(--text-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.7);
}

.citation-first-authority {
    font-size: 0.66rem;
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 600;
    border: 1px solid transparent;
}

.citation-first-authority--high {
    color: var(--ok);
    border-color: var(--ok-bdr);
    background: var(--ok-bg);
}

.citation-first-authority--mid {
    color: var(--blue);
    border-color: rgba(201, 138, 76, 0.24);
    background: var(--blue-bg);
}

.citation-first-authority--base {
    color: var(--text-2);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.65);
}

.citation-first-source {
    font-size: 0.71rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.citation-first-note {
    margin-top: 7px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.70rem;
    line-height: 1.45;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.citation-first-note-text {
    min-width: 0;
}

.citation-first-why {
    flex-shrink: 0;
    font-size: 0.64rem;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid currentColor;
    padding: 1px 7px;
    cursor: help;
    opacity: 0.9;
}

.citation-first-note--ok {
    color: var(--ok);
    background: var(--ok-bg);
    border-color: var(--ok-bdr);
}

.citation-first-note--warn {
    color: var(--warn);
    background: var(--warn-bg);
    border-color: var(--warn-bdr);
}

.citation-first-note--err {
    color: var(--err);
    background: var(--err-bg);
    border-color: var(--err-bdr);
}

/* structured sections rendered from done event fields */
.answer-section { margin-bottom: 1.1rem; }
.answer-section:last-child { margin-bottom: 0; }
.answer-section-label {
    font-size: 0.63rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-3);
    margin-bottom: 4px;
}
.answer-section-body {
    font-size: 0.85rem;
    line-height: 1.75;
    color: var(--text);
    word-break: break-word;
    max-width: var(--legal-measure);
}
.answer-section-body p { margin: 0 0 0.68em; }
.answer-section-body p:last-child { margin-bottom: 0; }
.answer-section-body ul,
.answer-section-body ol {
    margin: 0 0 0.68em 0;
    padding-left: 1.6em;
}
.answer-section-body ul { list-style-type: disc; }
.answer-section-body ol { list-style-type: decimal; }
.answer-section-body li { margin: 0.22em 0; }
.answer-section-body strong { color: var(--text-1); }
.answer-section-body h1,
.answer-section-body h2,
.answer-section-body h3,
.answer-section-body h4 {
    margin: 0.62em 0 0.3em;
    line-height: 1.36;
    color: var(--text-1);
    font-weight: 700;
}
.answer-section-body h1 { font-size: 1.15rem; }
.answer-section-body h2 { font-size: 1.05rem; }
.answer-section-body h3 { font-size: 0.97rem; }
.answer-section-body h4 { font-size: 0.9rem; }
.answer-section-body blockquote {
    margin: 0.8em 0;
    padding: 0.45em 0.8em;
    border-left: 3px solid rgba(201, 138, 76, 0.24);
    background: rgba(201, 138, 76, 0.05);
    border-radius: 0 8px 8px 0;
    color: var(--text-2);
}
.answer-section-body code {
    font-family: inherit;
    font-size: 0.88em;
    padding: 0.05em 0.3em;
    border-radius: 4px;
    background: rgba(13, 28, 59, 0.06);
}
.answer-section-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 0.84em;
}
.answer-section-body th,
.answer-section-body td {
    border: 1px solid var(--border);
    padding: 0.38em 0.48em;
    text-align: left;
}
.answer-section-body th {
    background: var(--surface-2);
    color: var(--text-1);
    font-weight: 700;
}
/* pre fallback (server-rendered / history turns) */
pre, pre#answer-pre {
    font-family: inherit;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.75;
    padding: 0.1em 0.4em;
    background: rgba(13, 28, 59, 0.06);
    border: none;
    border-radius: 4px;
    color: var(--text);
    margin: 0 0 1.1em 0;
    overflow-x: auto;
    max-width: var(--legal-measure);
}

pre code {
    font-family: inherit;
    font-size: inherit;
    padding: inherit;
    background: transparent;
    border: none;
    border-radius: 0;
}

#answer-pre {
    margin: 0;
    max-width: var(--legal-measure);
    padding: 0;
    border-radius: 0;
    border: none;
    background: var(--surface);
}
/* when structured HTML is injected, pre acts as a plain div */
pre#answer-pre.answer-structured {
    white-space: normal;
    overflow-y: visible;
    max-height: none;
}

.followup-chips {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.followup-chips-label {
    font-size: 0.63rem;
    font-weight: 700;
    color: var(--text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 1px;
}
.followup-chip {
    font-size: var(--reading-followup-size, var(--answer-followup-size, 0.72rem));
    font-weight: 400;
    color: var(--blue);
    background: transparent;
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    padding: var(--reading-followup-pad-y, 6px) var(--reading-followup-pad-x, 10px);
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s;
    text-align: left;
    white-space: normal;
    width: 100%;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: none;
    overflow-wrap: anywhere;
}
.followup-chip:hover {
    background: var(--blue-bg);
    border-color: rgba(201, 138, 76, 0.28);
}

@keyframes chipFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
.followup-chip--anim {
    opacity: 0;
    animation: chipFadeIn 0.22s ease forwards;
}

.section-copy-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-right: auto;
}

.section-copy-btn {
    border: 1px solid var(--border-2);
    background: transparent;
    color: var(--text-2);
    border-radius: var(--r-sm);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 4px 7px;
    cursor: pointer;
}

.answer-actions .corpus-filter-toggle {
    width: 34px;
    height: 34px;
}

.answer-actions .corpus-filter-toggle svg {
    width: 13px;
    height: 13px;
}

.copy-answer-btn--prominent,
.conv-turn-copy-btn {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    padding: 0 !important;
}

.conv-turn-copy-label,
#copy-answer-label {
    display: none !important;
}

.section-copy-btn:hover {
    background: var(--blue-bg);
    border-color: rgba(201, 138, 76, 0.3);
}

.answer-card.reading-size-s #answer-pre,
.answer-card.reading-size-s .answer-section-body,
.answer-card.reading-size-s .answer-story-scroll .conv-turn-answer {
    font-size: 0.76rem;
}

.answer-card.reading-size-s {
    --answer-followup-size: 0.68rem;
    --reading-followup-size: 0.64rem;
    --reading-followup-pad-y: 5px;
    --reading-followup-pad-x: 9px;
}

.answer-card.reading-size-m {
    --answer-followup-size: 0.72rem;
    --reading-followup-size: 0.69rem;
    --reading-followup-pad-y: 6px;
    --reading-followup-pad-x: 10px;
}

.answer-card.reading-size-l #answer-pre,
.answer-card.reading-size-l .answer-section-body,
.answer-card.reading-size-l .answer-story-scroll .conv-turn-answer {
    font-size: 1.04rem;
}

.answer-card.reading-size-l {
    --answer-followup-size: 0.84rem;
    --reading-followup-size: 0.78rem;
    --reading-followup-pad-y: 7px;
    --reading-followup-pad-x: 11px;
}

.answer-card.reading-spacing-compact #answer-pre,
.answer-card.reading-spacing-compact .answer-section-body,
.answer-card.reading-spacing-compact .answer-story-scroll .conv-turn-answer {
    line-height: 1.58;
}

.answer-card.reading-spacing-comfortable #answer-pre,
.answer-card.reading-spacing-comfortable .answer-section-body,
.answer-card.reading-spacing-comfortable .answer-story-scroll .conv-turn-answer {
    line-height: 1.86;
}

.empty-msg {
    font-size: 0.84rem;
    color: var(--text-3);
    font-style: italic;
    margin: 8px 0;
}

/* ── Answer pre — scrollable ─────────────────────────────── */

pre#answer-pre {
    max-height: none;
    overflow-y: visible;
}

.stream-output {
    max-height: 52vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

/* ── Fixed ask bar ───────────────────────────────────────── */

.app-layout, .app-main {
    padding-bottom: var(--ask-bar-h) !important;
}

.ask-bar-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(236, 238, 241, 0.94); /* matches --bg: #ECEEF1 */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-2);
    box-shadow: 0 -4px 24px rgba(0, 17, 23, 0.09);
}

.ask-bar-inner {
    width: 100%;
    margin: 0;
    padding: 6px 24px 6px;
    box-sizing: border-box;
}

@media (min-width: 821px) {
    /* Constrain only the chat page to full-height/overflow:hidden so the
       sticky 3-column layout works. Other pages (settings, library, etc.)
       must NOT get overflow:hidden on html/body — they need to scroll.
       :has() is supported in all modern browsers (Chrome 105+, Firefox 121+). */
    html:has(.app-main--chat),
    html:has(.app-main--chat) body {
        height: 100%;
        overflow: hidden;
    }

    .app-main--chat {
        box-sizing: border-box;
        height: calc(100dvh - var(--chat-main-top, 0px));
        overflow: hidden;
    }

    .app-main--chat .home-grid {
        height: 100%;
        min-height: 0;
        align-items: stretch;
        overflow: hidden;
    }

    .app-main--chat .conv-sidebar,
    .app-main--chat .home-sidebar {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        top: 0;
    }

    .app-main--chat .conv-sidebar {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .app-main--chat .home-sidebar {
        overflow: hidden;
    }

    .app-main--chat .home-main {
        height: 100%;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .app-main--chat #references-card {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .app-main--chat #references-content {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(42, 47, 54, 0.24) transparent;
    }

    .app-main--chat .home-main,
    .app-main--chat #references-content {
        scrollbar-gutter: stable;
    }

    .app-main--chat .home-main::-webkit-scrollbar,
    .app-main--chat #references-content::-webkit-scrollbar {
        width: 6px;
    }

    .app-main--chat .home-main::-webkit-scrollbar-track,
    .app-main--chat #references-content::-webkit-scrollbar-track {
        background: transparent;
    }

    .app-main--chat .home-main::-webkit-scrollbar-thumb,
    .app-main--chat #references-content::-webkit-scrollbar-thumb {
        background: rgba(42, 47, 54, 0.22);
        border-radius: 999px;
        border: 1px solid transparent;
        background-clip: padding-box;
    }

    .app-main--chat .home-main:hover::-webkit-scrollbar-thumb,
    .app-main--chat #references-content:hover::-webkit-scrollbar-thumb {
        background: rgba(42, 47, 54, 0.32);
    }

    /* The bar's background spans the full screen width, but the input row and
       its buttons align with the middle (chat) column of the 3-column grid.
       width must be auto (not 100%) so the margins actually shrink the box
       instead of adding on top of a full-width box and overflowing. */
    .ask-bar-inner {
        width: auto;
        margin-left: var(--ask-main-left, calc(18px + var(--conv-w) + 14px));
        margin-right: var(--ask-main-right, calc(18px + var(--sidebar-w) + 14px));
        padding-left: 0;
        padding-right: 0;
    }
}

.ask-label {
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--text-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 4px;
}

/* ── Header nav dropdown ─────────────────────────────────── */

.nav-dropdown { position: relative; z-index: 401; }

.header-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(200, 218, 255, 0.85);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 6px 13px;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
    box-shadow: none !important;
}

.header-nav-btn:hover {
    background: rgba(255, 255, 255, 0.10) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
}

.nav-dropdown-chevron {
    font-size: 0.68rem;
    color: color-mix(in srgb, var(--vf-orange) 70%, #fff);
    transition: transform 0.15s;
}
.header-nav-btn[aria-expanded="true"] .nav-dropdown-chevron { transform: rotate(180deg); }

/* ── Header nav icon buttons ─────────────────────────────── */

.nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    background: transparent;
    color: rgba(200, 218, 255, 0.85);
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    box-shadow: none !important;
    outline: none;
}
.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.10) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
}
.nav-icon-btn[href] svg {
    width: 32px !important;
    height: 32px !important;
}

/* Avatar button replacing the gear icon */
.nav-avatar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 32px;
    min-width: 64px;        /* wide enough for two-character initials + chevron */
    padding: 0 12px 0 11px;
    border-radius: 999px;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.14);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.14s, border-color 0.14s;
    box-shadow: none !important;
    outline: none;
}
.nav-avatar-btn:hover {
    background: rgba(255, 255, 255, 0.24) !important;
    border-color: rgba(255, 255, 255, 0.55) !important;
}
.nav-avatar-initials {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    box-shadow: 0 8px 28px rgba(0, 17, 23, 0.14);
    overflow: hidden;
    z-index: 400;
    animation: fadeIn 0.14s ease;
}

@media (max-width: 560px) {
    .nav-dropdown-menu {
        position: fixed;
        top: 64px;
        right: 10px;
        left: auto;
        min-width: min(280px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .nav-dropdown-item,
    .nav-dropdown a.nav-dropdown-item,
    .nav-inline-form .nav-dropdown-item {
        min-height: 42px;
    }
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    border-bottom: 1px solid var(--border);
}

.nav-dropdown-item:last-child { border-bottom: none; }
.nav-dropdown-item:hover { background: var(--blue-bg); color: var(--blue); }

.nav-dropdown-item svg { flex-shrink: 0; opacity: 0.65; }

/* Fix: .header-nav a (0,1,1) overrides .nav-dropdown-item (0,1,0) for <a> children,
   causing pale-blue text and wrong padding. These rules win at (0,2,1) / (0,3,1). */
.nav-dropdown a.nav-dropdown-item {
    color: var(--text);
    padding: 10px 14px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}
.nav-dropdown a.nav-dropdown-item:last-child { border-bottom: none; }
.nav-dropdown a.nav-dropdown-item:hover {
    background: var(--blue-bg);
    color: var(--blue);
}

.nav-avatar-btn:focus-visible,
.nav-dropdown-item:focus-visible,
.nav-dropdown a.nav-dropdown-item:focus-visible,
.conv-drawer-toggle:focus-visible,
.ref-drawer-toggle:focus-visible,
.pinned-drawer-toggle:focus-visible,
.home-sidebar-close:focus-visible,
.persona-option:focus-visible,
.corpus-filter-toggle:focus-visible {
    outline: 2px solid rgba(201, 138, 76, 0.65);
    outline-offset: 2px;
}

/* ── Manual page ─────────────────────────────────────────── */

.manual-lead {
    font-size: 0.95rem;
    color: var(--text-2);
    line-height: 1.7;
    margin: 0 0 6px;
}

.manual-toc {
    background: var(--blue-bg);
    border: 1px solid rgba(201, 138, 76, 0.16);
    border-radius: var(--r);
    padding: 14px 18px;
    margin-bottom: 4px;
}

.manual-toc-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 8px;
}

.manual-toc ol {
    margin: 0;
    padding-left: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 24px;
}

.manual-toc li { font-size: 0.82rem; }
.manual-toc a { color: var(--blue-2); text-decoration: none; }
.manual-toc a:hover { text-decoration: underline; }

.manual-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
    font-size: 1.0rem;
    font-weight: 700;
    color: var(--text);
}

.manual-section-num {
    flex-shrink: 0;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
}

.manual-section p, .manual-section li {
    font-size: 0.86rem;
    line-height: 1.7;
    color: var(--text-2);
}

.manual-section ul, .manual-section ol {
    padding-left: 18px;
    margin: 6px 0;
}

.manual-section li { margin-bottom: 4px; }

.manual-section h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    margin: 14px 0 6px;
}

.manual-tip {
    background: var(--ok-bg);
    border: 1px solid var(--ok-bdr);
    border-left: 3px solid var(--ok);
    border-radius: var(--r-sm);
    padding: 8px 13px;
    font-size: 0.83rem;
    color: var(--ok);
    margin: 10px 0 4px;
    line-height: 1.55;
}

.manual-warn {
    background: var(--warn-bg);
    border: 1px solid var(--warn-bdr);
    border-left: 3px solid var(--warn);
    border-radius: var(--r-sm);
    padding: 8px 13px;
    font-size: 0.83rem;
    color: var(--warn);
    margin: 10px 0 4px;
    line-height: 1.55;
}

.manual-pipeline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
    align-items: center;
}

.manual-pipeline-step {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.manual-pipeline-arrow { color: var(--text-3); font-size: 0.9rem; }

.pipe-researcher  { background: rgba(201, 138, 76, 0.09); color: #C98A4C; border: 1px solid rgba(201, 138, 76, 0.18); }
.pipe-auditor     { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-bdr); }
.pipe-judge       { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-bdr); }
.pipe-guardrail   { background: rgba(100,120,160,0.09); color: var(--text-2); border: 1px solid var(--border-2); }

.manual-kbd {
    display: inline-block;
    background: rgba(42, 47, 54, 0.07);
    border: 1px solid var(--border-2);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.78rem;
    font-family: 'Consolas', monospace;
    color: var(--text-2);
}

@media (max-width: 600px) {
    .manual-toc ol { grid-template-columns: 1fr; }
}

/* ── Persona selector ────────────────────────────────────── */

/* ── Persona icon button + dropdown ─────────────────────── */
.persona-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: flex-end;
}

.persona-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    /* Anchor from the right edge of the toggle button rather than the left —
       the button sits toward the right side of the ask-bar controls, so a
       left-anchored menu of fixed width can run off the right edge of the
       viewport on narrow/medium screens. Width is viewport-relative so it
       never overflows even on the smallest screens. */
    left: auto;
    right: 0;
    background: var(--surface);
    border: 1.5px solid var(--border-2);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    padding: 4px;
    width: max-content;
    min-width: 176px;
    max-width: min(220px, calc(100vw - 24px));
    max-height: min(52vh, 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: none;
    flex-direction: column;
    gap: 1px;
    z-index: 300;
}

.persona-menu--open {
    display: flex;
}

.persona-option {
    display: flex !important;
    align-items: center !important;
    gap: 7px !important;
    width: 100% !important;
    padding: 7px 10px !important;
    border: none !important;
    background: transparent !important;
    border-radius: var(--r-sm) !important;
    color: var(--text-2) !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    cursor: pointer !important;
    text-align: left !important;
    transition: background 0.12s, color 0.12s !important;
    box-shadow: none !important;
    height: auto !important;
}

.persona-check { flex-shrink: 0; opacity: 0; color: var(--blue-2); }
.persona-option--active .persona-check { opacity: 1; }
.persona-option--active { color: var(--text-1) !important; }
.persona-option:hover { background: var(--blue-bg) !important; color: var(--text-1) !important; }

/* ── Corpus filter toggle ────────────────────────────────── */

.corpus-filter-toggle {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    padding: 0 !important;
    border-radius: var(--r) !important;
    background: transparent !important;
    border: 1.5px solid var(--border-2) !important;
    color: var(--text-3) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
    box-shadow: none !important;
    position: relative;
    align-self: flex-end;
}

.corpus-filter-toggle:hover {
    background: var(--blue-bg) !important;
    border-color: rgba(201, 138, 76, 0.28) !important;
    color: var(--blue) !important;
}

.copy-answer-btn--prominent {
    width: auto !important;
    padding: 0 12px !important;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--blue) !important;
    border-color: rgba(201, 138, 76, 0.35) !important;
}

.corpus-filter-toggle--active {
    background: var(--blue-bg) !important;
    border-color: var(--blue-2) !important;
    color: var(--blue-2) !important;
}

.corpus-filter-toggle--dim {
    opacity: 0.35;
    pointer-events: none;
}

.corpus-filter-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy);
    color: #FFFFFF;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s;
    z-index: 200;
    max-width: 200px;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    box-shadow: var(--shadow-md);
}

.corpus-filter-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--navy);
}

.corpus-filter-toggle:hover .corpus-filter-tooltip,
.corpus-filter-toggle:focus-visible .corpus-filter-tooltip {
    opacity: 1;
}

@media (hover: none), (pointer: coarse) {
    .corpus-filter-tooltip {
        display: none;
    }
}

.ask-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.ask-controls-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
}

.ask-controls-row .stream-error-banner {
    margin-left: 0;
    flex: 1 1 260px;
    min-height: 26px;
    align-self: center;
}

.ask-controls-row .corpus-filter-toggle {
    width: 26px;
    height: 26px;
    border-width: 1.2px !important;
    border-radius: 8px !important;
    align-self: auto;
}

.ask-controls-row .corpus-filter-toggle svg {
    width: 12px;
    height: 12px;
}

.ask-controls-row .persona-wrap {
    align-self: auto;
}

.ask-input-row textarea {
    flex: 1;
    resize: none;
    overflow-y: hidden;
    min-height: 30px;
    max-height: 76px;
    border: 1.5px solid transparent;
    border-radius: var(--r);
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--text);
    background:
        linear-gradient(var(--ask-input-fill), var(--ask-input-fill)) padding-box,
        conic-gradient(from 0deg, rgba(201, 138, 76, 0.22), rgba(201, 138, 76, 0.55), rgba(201, 138, 76, 0.22)) border-box;
    transition: box-shadow 0.2s, filter 0.2s;
    outline: none;
}

.ask-input-row textarea:focus {
    animation: question-ring-spin 2.2s linear infinite, question-ring-glow 1.8s ease-in-out infinite;
    box-shadow: 0 0 0 2px rgba(201, 138, 76, 0.18), 0 0 18px rgba(201, 138, 76, 0.24);
    filter: saturate(1.05);
}

body.answer-generating .ask-input-row textarea,
body.answer-generating .ask-input-row textarea:focus {
    animation: question-ring-spin-orange 2.4s linear infinite, question-ring-glow-orange 2.2s ease-in-out infinite;
    box-shadow: 0 0 0 1.5px rgba(201, 138, 76, 0.32), 0 0 12px rgba(201, 138, 76, 0.28);
    filter: saturate(1.04);
}

@keyframes question-ring-spin {
    0% {
        background:
            linear-gradient(var(--ask-input-fill), var(--ask-input-fill)) padding-box,
            conic-gradient(from 0deg, rgba(201, 138, 76, 0.22), rgba(201, 138, 76, 0.58), rgba(201, 138, 76, 0.22)) border-box;
    }
    100% {
        background:
            linear-gradient(var(--ask-input-fill), var(--ask-input-fill)) padding-box,
            conic-gradient(from 360deg, rgba(201, 138, 76, 0.22), rgba(201, 138, 76, 0.58), rgba(201, 138, 76, 0.22)) border-box;
    }
}

@keyframes question-ring-glow {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(201, 138, 76, 0.14), 0 0 10px rgba(201, 138, 76, 0.16);
    }
    50% {
        box-shadow: 0 0 0 2px rgba(201, 138, 76, 0.24), 0 0 22px rgba(201, 138, 76, 0.3);
    }
}

@keyframes question-ring-spin-orange {
    0% {
        background:
            linear-gradient(var(--ask-input-fill), var(--ask-input-fill)) padding-box,
            conic-gradient(from 0deg, rgba(201, 138, 76, 0.22), rgba(201, 138, 76, 0.55), rgba(201, 138, 76, 0.22)) border-box;
    }
    100% {
        background:
            linear-gradient(var(--ask-input-fill), var(--ask-input-fill)) padding-box,
            conic-gradient(from 360deg, rgba(201, 138, 76, 0.22), rgba(201, 138, 76, 0.55), rgba(201, 138, 76, 0.22)) border-box;
    }
}

@keyframes question-ring-glow-orange {
    0%, 100% {
        box-shadow: 0 0 0 1px rgba(201, 138, 76, 0.22), 0 0 8px rgba(201, 138, 76, 0.2);
    }
    50% {
        box-shadow: 0 0 0 2px rgba(201, 138, 76, 0.36), 0 0 16px rgba(201, 138, 76, 0.32);
    }
}

.ask-input-row button {
    flex-shrink: 0;
    height: 30px;
    padding: 0 14px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    align-self: flex-end;
}

.ask-send-btn {
    width: 30px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.ask-send-btn--loading {
    opacity: 0.55;
}

/* ── References panel ────────────────────────────────────── */

.references-card h2 { margin-bottom: 10px; }

#references-content {
    overflow-x: hidden;
}

/* Reference groups (Wetgeving / Jurisprudentie / Bronpassages) */
.refs-group { margin-bottom: 14px; }
.refs-group:last-child { margin-bottom: 0; }

.refs-group-header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

.refs-group-label {
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    flex: 1;
}

.refs-group-count {
    font-size: 0.67rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(201, 138, 76, 0.18);
    flex-shrink: 0;
}

/* Law / case-law items */
.refs-law-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 3px 2px;
    font-size: 0.77rem;
    color: var(--text-2);
    line-height: 1.45;
    border-bottom: 1px solid transparent;
}

.refs-law-item:last-child { border-bottom: none; }

.refs-law-icon {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    border-radius: 3px;
    background: var(--blue-bg);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.70rem;
    font-weight: 800;
    margin-top: 1px;
}

.refs-law-icon--case {
    background: var(--warn-bg);
    color: var(--warn);
}

/* Passage citation cards */
.ref-item {
    padding: 9px 11px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
    margin-bottom: 6px;
    transition: background 0.18s, border-color 0.18s, border-left-color 0.18s, box-shadow 0.18s;
    cursor: pointer;
}

.ref-item:hover {
    background: rgba(201, 138, 76, 0.05);
    border-color: rgba(201, 138, 76, 0.18);
    border-left-color: var(--blue);
}

.ref-item:last-child { margin-bottom: 0; }

.ref-item--visible {
    background: rgba(201, 138, 76, 0.05);
    border-color: rgba(201, 138, 76, 0.18);
    border-left-color: var(--blue);
    box-shadow: 0 1px 6px rgba(201, 138, 76, 0.07);
}

@keyframes ref-flash {
    0%   { background: rgba(201, 138, 76, 0.16); border-left-color: var(--blue-2); }
    60%  { background: rgba(201, 138, 76, 0.08); }
    100% { background: rgba(255, 255, 255, 0.55); border-left-color: transparent; }
}

.ref-item--flash { animation: ref-flash 1.1s ease forwards; }

.ref-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    line-height: 1.3;
}

.ref-num-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    border-radius: 4px;
    background: var(--blue);
    color: #fff;
    font-size: 0.64rem;
    font-weight: 800;
}

.ref-source-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ref-page {
    font-size: 0.70rem;
    font-weight: 500;
    color: var(--text-3);
    white-space: nowrap;
    flex-shrink: 0;
}

.ref-external-link {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    color: var(--text-3);
    font-size: 0.72rem;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.ref-external-link:hover {
    background: var(--blue-bg);
    color: var(--blue);
}

.ref-text {
    font-size: 0.77rem;
    color: var(--text-2);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
    padding-left: 22px;
    font-style: italic;
}

/* Inline citation badge inside the answer text */
.ref-inline {
    display: inline;
    background: var(--blue-bg);
    color: var(--blue-2);
    border: 1px solid rgba(201, 138, 76, 0.28);
    border-radius: 3px;
    padding: 0 3px;
    font-size: 0.78em;
    font-weight: 700;
    cursor: pointer;
    margin: 0 1px;
    vertical-align: baseline;
    transition: background 0.12s, border-color 0.12s;
    user-select: none;
}

.ref-inline:hover {
    background: rgba(201, 138, 76, 0.15);
    border-color: var(--blue-2);
}

/* Preliminary loading state */
.refs-preliminary-note {
    font-size: 0.76rem;
    color: var(--text-3);
    font-style: italic;
    margin: 0 0 6px;
}

.ref-item--preliminary { opacity: 0.72; }

.ref-type-pill {
    display: inline-block;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(201, 138, 76, 0.18);
    margin-right: 5px;
    vertical-align: middle;
}

/* ── Mode card ───────────────────────────────────────────── */

.mode-card { padding: 12px 16px; }

.mode-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    border-radius: var(--r);
    border: 1.5px solid var(--border-2) !important;
    background: rgba(255, 255, 255, 0.45) !important;
    color: var(--text-2) !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s;
    flex: 1;
    min-width: 130px;
    text-align: left;
    font-family: inherit;
}

.mode-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.80) !important;
    border-color: var(--border-2) !important;
}

.mode-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.mode-btn-icon {
    flex-shrink: 0;
    opacity: 0.55;
    transition: opacity 0.14s, color 0.14s;
}

.mode-btn-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mode-btn-label {
    font-size: 0.83rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    transition: color 0.14s;
}

.mode-btn-sub {
    font-size: 0.68rem;
    color: var(--text-3);
    white-space: nowrap;
    font-weight: 400;
}

/* Active states */
.mode-btn--active.mode-btn--claude {
    background: var(--ok-bg) !important;
    border-color: var(--ok-bdr) !important;
    box-shadow: var(--shadow-sm) !important;
}
.mode-btn--active.mode-btn--claude .mode-btn-label { color: var(--ok); }
.mode-btn--active.mode-btn--claude .mode-btn-icon  { opacity: 1; color: var(--ok); }

.mode-btn--active.mode-btn--mistral {
    background: var(--blue-bg) !important;
    border-color: var(--blue-2) !important;
    box-shadow: var(--shadow-sm) !important;
}
.mode-btn--active.mode-btn--mistral .mode-btn-label { color: var(--blue-2); }
.mode-btn--active.mode-btn--mistral .mode-btn-icon  { opacity: 1; color: var(--blue-2); }

.mode-status-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.mode-status-chip {
    font-size: 0.75rem;
    padding: 2px 9px;
    border-radius: var(--r-sm);
    font-weight: 600;
    white-space: nowrap;
}

.chip-ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-bdr);   }
.chip-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-bdr); }

.mode-error {
    margin: 7px 0 0;
    font-size: 0.82rem;
    color: var(--err);
    background: var(--err-bg);
    border: 1px solid var(--err-bdr);
    border-radius: var(--r-sm);
    padding: 6px 12px;
}

/* ── Stream card ─────────────────────────────────────────── */

.stream-card {
    display: none !important;
    position: relative;
    border-color: var(--border);
    background: transparent;
    display: grid;
    grid-template-columns: minmax(130px, 34%) 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
    padding: 6px 10px;
}

.stream-current-question {
    grid-column: 1 / -1;
    margin: 0 auto 0 0;
    width: min(74%, 620px);
}

body.stream-question-pinned .stream-card {
    position: sticky;
    top: 68px;
    z-index: 12;
    margin: 0;
    min-height: 34px;
    padding: 6px 10px;
}

body.stream-question-pinned .stream-current-question {
    position: static;
    width: min(74%, 620px);
    max-width: 100%;
    margin: 0 auto 0 0;
    box-shadow: 0 8px 22px rgba(0, 17, 23, 0.16);
}

@media (max-width: 960px) {
    body.stream-question-pinned .stream-card {
        top: 62px;
        min-height: 32px;
        grid-template-columns: minmax(110px, 42%) 1fr;
    }

    body.stream-question-pinned .stream-current-question {
        width: min(88%, 620px);
        max-width: 100%;
    }
}

.stream-card--fading {
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

/* ── Step progress dots ───────────────────────────────────── */

.stream-steps {
    margin: 0;
    grid-column: 1;
}

.steps-track {
    height: 5px;
    background: rgba(42, 47, 54, 0.09);
    border-radius: 5px;
    overflow: hidden;
}

.steps-fill {
    height: 100%;
    width: 0%;
    border-radius: 5px;
    background: linear-gradient(
        90deg,
        var(--ok) 0%,
        #c98a4c 30%,
        #c98a4c 60%,
        #c98a4c 100%
    );
    background-size: 300% 100%;
    transition: width 0.85s cubic-bezier(0.4, 0, 0.2, 1);
    animation: flow-breath 3s ease-in-out infinite;
}

.steps-fill.steps-done {
    animation: none;
    background: var(--ok);
    transition: width 0.5s ease;
}

@keyframes flow-breath {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.stream-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    color: var(--text-2);
    font-size: 0.78rem;
    line-height: 1.2;
    grid-column: 2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stream-phase-icon {
    font-size: 0.9rem;
    display: inline-block;
    width: 1.05em;
    text-align: center;
    transition: color 0.28s;
}

.stream-phase-icon[data-phase="connecting"]  { color: var(--vf-orange);  animation: pulse 1.2s ease-in-out infinite; }
.stream-phase-icon[data-phase="retrieving"]  { color: var(--vf-orange); animation: pulse 1.0s ease-in-out infinite; }
.stream-phase-icon[data-phase="ranking"]     { color: var(--warn);   animation: pulse 1.0s ease-in-out infinite; }
.stream-phase-icon[data-phase="researching"] { color: #C98A4C; animation: pulse 1.0s ease-in-out infinite; }
.stream-phase-icon[data-phase="auditing"]    { color: #8a5c10; animation: pulse 1.0s ease-in-out infinite; }
.stream-phase-icon[data-phase="judging"]     { color: var(--ok); animation: pulse 0.8s ease-in-out infinite; }
.stream-phase-icon[data-phase="generating"]  { color: var(--ok); animation: pulse 0.8s ease-in-out infinite; }
.stream-phase-icon[data-phase="done"]        { color: var(--ok); animation: none; }
.stream-phase-icon[data-phase="error"]       { color: var(--err); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.28; }
}

.stream-output {
    font-family: inherit;
    font-size: 0.83rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.57;
    padding: 0 14px;
    margin-top: 8px;
    background: none;
    border: none;
    border-radius: 0;
    min-height: 2em;
    color: var(--text);
}

.stream-cursor {
    display: inline-block;
    width: 2px; height: 1.1em;
    background: var(--blue-2);
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.9s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Agent section wrapper ───────────────────────────────── */

.agent-panel-section {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

/* ── Auditor inline warning ──────────────────────────────── */

.auditor-warning {
    background: var(--warn-bg);
    border: 1px solid var(--warn-bdr);
    border-radius: var(--r-sm);
    color: var(--warn);
    font-size: 0.83rem;
    line-height: 1.6;
    padding: 9px 13px;
}

.auditor-warning-icon { margin-right: 4px; }

.auditor-warning-flag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 3px;
    padding: 1px 6px;
    margin-right: 4px;
    vertical-align: middle;
}

.auditor-warning-flag--medium {
    background: var(--warn-bg);
    border: 1px solid var(--warn-bdr);
    color: var(--warn);
}

.auditor-warning-flag--high {
    background: var(--err-bg);
    border: 1px solid var(--err-bdr);
    color: var(--err);
}

/* ── Guardrail badge ─────────────────────────────────────── */

#guardrail-badge-wrap {
    margin-top: 8px;
    padding: 8px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--surface);
}

.guardrail-badge {
    display: inline-block;
    font-size: 0.80rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--r-sm);
}

.guardrail-badge--ok       { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-bdr);   }
.guardrail-badge--repaired { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-bdr); }
.guardrail-badge--fail     { background: var(--err-bg);  color: var(--err);  border: 1px solid var(--err-bdr);  }

.guardrail-violations { margin-top: 6px; font-size: 0.79rem; color: var(--text-2); }
.guardrail-violations ul { margin: 3px 0 0; padding-left: 17px; }
.guardrail-violations li { margin-bottom: 2px; }

/* ── Connection panel (Verbanden & bronkwaliteit) ────────── */

.connection-panel {
    margin-top: 8px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    padding: 0;
    overflow: hidden;
}

.connection-panel-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    user-select: none;
    list-style: none;
}

.connection-panel-summary::-webkit-details-marker { display: none; }

.connection-panel[open] .connection-panel-summary {
    border-bottom: 1px solid var(--border);
}

.connection-body {
    padding: 9px 13px;
    font-size: 0.80rem;
    color: var(--text-2);
}

.connection-body p { margin: 3px 0; }
.connection-body strong { color: var(--text); }
.connection-repaired { color: var(--warn); font-weight: 600; }

.xref-details { margin-top: 7px; }
.xref-details summary {
    cursor: pointer;
    font-size: 0.79rem;
    color: var(--text-2);
    margin-bottom: 4px;
}
.xref-details ul { margin: 4px 0 0; padding-left: 16px; }
.xref-details li { margin-bottom: 3px; line-height: 1.4; }

/* ── Generate AV page ────────────────────────────────────── */

.av-disclaimer-box {
    background: var(--warn-bg);
    border: 1px solid var(--warn-bdr);
    border-radius: var(--r-sm);
    padding: 9px 14px;
    font-size: 0.85rem;
    color: var(--warn);
    margin-top: 11px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.av-form-grid { display: grid; gap: 15px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-field { display: flex; flex-direction: column; gap: 5px; }

.av-progress-bar { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 9px; }

.av-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--blue), var(--blue-2));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.av-section-card { margin-bottom: 13px; animation: fadeIn 0.28s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.av-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }

.av-section-badge {
    flex-shrink: 0;
    width: 25px; height: 25px;
    border-radius: var(--r-sm);
    background: var(--blue);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.78rem;
}

.av-section-title { margin: 0; font-size: 0.93rem; color: var(--text); font-weight: 700; }

.av-section-body {
    font-size: 0.89rem;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    max-width: var(--legal-measure);
}

/* AV generator honours the same S/M/L reading-size preference as the
   conversation panel — applied via reading-size-s/m/l on <body> by JS. */
body.reading-size-s .av-section-body { font-size: 0.80rem; }
body.reading-size-m .av-section-body { font-size: 0.89rem; }
body.reading-size-l .av-section-body { font-size: 1.02rem; }
body.reading-size-s .av-form-grid,
body.reading-size-s .av-form-grid input,
body.reading-size-s .av-form-grid select,
body.reading-size-s .av-form-grid textarea,
body.reading-size-s .settings-hint,
body.reading-size-s .av-disclaimer-box,
body.reading-size-s #progress-label,
body.reading-size-s #export-form button,
body.reading-size-s .inline-actions button {
    font-size: 0.8rem;
}
body.reading-size-m .av-form-grid,
body.reading-size-m .av-form-grid input,
body.reading-size-m .av-form-grid select,
body.reading-size-m .av-form-grid textarea,
body.reading-size-m .settings-hint,
body.reading-size-m .av-disclaimer-box,
body.reading-size-m #progress-label,
body.reading-size-m #export-form button,
body.reading-size-m .inline-actions button {
    font-size: 0.89rem;
}
body.reading-size-l .av-form-grid,
body.reading-size-l .av-form-grid input,
body.reading-size-l .av-form-grid select,
body.reading-size-l .av-form-grid textarea,
body.reading-size-l .settings-hint,
body.reading-size-l .av-disclaimer-box,
body.reading-size-l #progress-label,
body.reading-size-l #export-form button,
body.reading-size-l .inline-actions button {
    font-size: 1.02rem;
}
body.reading-size-s .av-form-grid h2,
body.reading-size-s #result-section h2 { font-size: 1.02rem; }
body.reading-size-m .av-form-grid h2,
body.reading-size-m #result-section h2 { font-size: 1.11rem; }
body.reading-size-l .av-form-grid h2,
body.reading-size-l #result-section h2 { font-size: 1.24rem; }

/* ── Library page ────────────────────────────────────────── */

.lib-source-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 13px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
}

.lib-source-tab {
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(201, 138, 76, 0.15);
    border-radius: var(--r-sm);
    padding: 5px 12px;
    font-size: 0.80rem;
    cursor: pointer;
    width: auto;
    box-shadow: none !important;
    transition: background 0.12s;
}

.lib-source-tab:hover { background: rgba(201, 138, 76, 0.13); }

.lib-tab-active {
    background: var(--blue) !important;
    color: #fff !important;
    border-color: var(--blue) !important;
}

.lib-source-panel { margin-top: 4px; }

.lib-docs-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

.lib-col { min-width: 0; }
.lib-col-header { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.lib-col-header h2 { margin: 0; }

.lib-col-badge {
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    padding: 2px 7px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
    white-space: nowrap;
}

.lib-col-badge-static  { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(201, 138, 76,0.16); }
.lib-col-badge-dynamic { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-bdr);        }

.lib-empty { font-size: 0.82rem; color: var(--text-3); font-style: italic; margin: 8px 0 0; }

.lib-dropzone-compact { min-height: 68px; padding: 11px 10px; margin-bottom: 9px; }

.bundle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 7px; }

/* ── Fetch row ───────────────────────────────────────────── */

.fetch-row {
    display: flex;
    gap: 7px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.fetch-row input, .fetch-row select { flex: 1; min-width: 110px; }
.fetch-row button { flex-shrink: 0; white-space: nowrap; }

/* ── Answer actions bar ──────────────────────────────────── */

/* Persistent footer outside the scroll area — always visible, never buried. */
.answer-actions-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    padding: 8px 14px 6px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.answer-actions-bar[hidden] { display: none; }

/* Inner wrapper created by JS (answer-actions div inside the bar) */
.answer-actions-bar .answer-actions {
    display: contents; /* flatten into the bar's own flex context */
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Legacy: answer-actions when still used inside scroll (historical turns etc.) */
.answer-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ── Answer confidence row ───────────────────────────────── */

.answer-confidence-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 11px;
    flex-wrap: wrap;
}

.conf-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.conf-sep {
    color: var(--border-2);
    font-size: 0.80rem;
    user-select: none;
}

.conf-stat {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    cursor: help;
}

.conf-stat--ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-bdr);   }
.conf-stat--warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-bdr); }
.conf-stat--err  { background: var(--err-bg);  color: var(--err);  border: 1px solid var(--err-bdr);  }

.flag-trigger-btn {
    flex-shrink: 0;
    background: none !important;
    border: 1px solid var(--border-2) !important;
    color: var(--text-3) !important;
    font-size: 0.76rem !important;
    font-weight: 600 !important;
    padding: 2px 9px !important;
    border-radius: var(--r-sm) !important;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none !important;
    transition: border-color 0.13s, color 0.13s, background 0.13s;
}

.flag-trigger-btn:hover {
    border-color: var(--warn-bdr) !important;
    color: var(--warn) !important;
    background: var(--warn-bg) !important;
}

/* ── Flag form panel ─────────────────────────────────────── */

.flag-form-panel {
    margin: 12px 0 8px;
    padding: 13px 15px;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeIn 0.15s ease;
}

.flag-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.flag-form-header strong { font-size: 0.86rem; color: var(--text); }

.flag-close-btn {
    background: none !important;
    border: none !important;
    color: var(--text-3) !important;
    font-size: 1.1rem !important;
    cursor: pointer;
    padding: 0 3px !important;
    line-height: 1;
    box-shadow: none !important;
}
.flag-close-btn:hover { color: var(--text) !important; }

.flag-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 2px;
    display: block;
}

.flag-select,
.flag-input,
.flag-textarea {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: rgba(255,255,255,0.90);
    color: var(--text);
    font-family: inherit;
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.13s, box-shadow 0.13s;
    box-sizing: border-box;
}
.flag-select:focus,
.flag-input:focus,
.flag-textarea:focus {
    border-color: var(--blue-2);
    box-shadow: 0 0 0 3px rgba(201, 138, 76,0.10);
}
.flag-textarea { resize: vertical; line-height: 1.5; }

.flag-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.flag-submit-btn {
    padding: 6px 16px;
    background: var(--blue) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--r-sm) !important;
    font-size: 0.83rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    box-shadow: none !important;
    transition: background 0.13s;
}
.flag-submit-btn:hover { background: var(--blue-2) !important; }
.flag-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.flag-cancel-btn {
    padding: 6px 14px;
    background: transparent !important;
    color: var(--text-2) !important;
    border: 1px solid var(--border-2) !important;
    border-radius: var(--r-sm) !important;
    font-size: 0.83rem !important;
    font-weight: 500 !important;
    cursor: pointer;
    box-shadow: none !important;
    transition: background 0.13s;
}
.flag-cancel-btn:hover { background: var(--blue-bg) !important; }

.flag-status {
    font-size: 0.79rem;
    margin: 0;
    padding: 4px 8px;
    border-radius: var(--r-sm);
}
.flag-status--err { background: var(--err-bg); color: var(--err); border: 1px solid var(--err-bdr); }

.flag-saved-msg {
    font-size: 0.83rem;
    color: var(--ok);
    font-weight: 600;
    margin: 0;
}

/* ── Citation popover ────────────────────────────────────── */

.ref-popover {
    position: fixed;
    z-index: 1200;
    width: 420px;
    max-width: calc(100vw - 20px);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    box-shadow: 0 6px 24px rgba(42, 47, 54, 0.14), 0 1px 5px rgba(0,0,0,0.08);
    padding: 12px 14px 10px;
    font-size: 0.84rem;
    line-height: 1.52;
    animation: pop-in 0.13s ease;
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.ref-popover-header {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 7px;
}

.ref-popover-num {
    flex-shrink: 0;
    background: var(--blue-2);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 3px;
    padding: 1px 5px;
    margin-top: 1px;
}

.ref-popover-title {
    flex: 1;
    font-weight: 700;
    color: var(--blue-2);
    font-size: 0.83rem;
    word-break: break-word;
}

.ref-popover-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    margin: -3px -4px 0 0;
}
.ref-popover-close:hover { color: var(--text); }

.ref-popover-sentence {
    color: var(--text);
    font-style: italic;
    margin-bottom: 8px;
    border-left: 2px solid var(--border-2);
    padding-left: 8px;
}

.ref-popover-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
}

.ref-popover-toggle {
    background: none;
    border: none;
    color: var(--blue-2);
    cursor: pointer;
    font-size: 0.79rem;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ref-popover-toggle:hover { color: var(--blue); }

.ref-popover-goto {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 0.79rem;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-left: auto;
}
.ref-popover-goto:hover { color: var(--text-2); }

.ref-popover-external {
    background: none;
    border: none;
    color: var(--blue-2);
    cursor: pointer;
    font-size: 0.79rem;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ref-popover-external:hover { color: var(--blue); }

/* Highlighted passage within the full text */
.ref-passage-highlight {
    background: rgba(201, 138, 76, 0.14);
    border-radius: 2px;
    font-weight: 700;
    font-style: normal;
    color: inherit;
    padding: 0 1px;
}
[data-theme="dark"] .ref-passage-highlight {
    background: rgba(99, 148, 249, 0.22);
}

/* ECLI paragraph/article badge in the ref panel */
.ref-ecli-lbl {
    display: inline-block;
    background: var(--blue-bg);
    color: var(--blue-2);
    border: 1px solid rgba(201, 138, 76, 0.22);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.70rem;
    font-weight: 700;
    white-space: nowrap;
    margin-left: 4px;
    flex-shrink: 0;
    vertical-align: middle;
}
[data-theme="dark"] .ref-ecli-lbl {
    background: rgba(99, 148, 249, 0.12);
    border-color: rgba(99, 148, 249, 0.28);
    color: #D9A070;
}

/* Court authority level display for ECLI citations */
.ref-court-authority {
    font-size: 0.67rem;
    color: var(--text-3);
    font-weight: 500;
    white-space: nowrap;
    margin-left: 4px;
}

/* Kamerstuk non-binding label */
.ref-kamerstuk-badge {
    display: inline-block;
    background: rgba(140, 96, 32, 0.08);
    color: var(--warn);
    border: 1px solid rgba(140, 96, 32, 0.22);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.67rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 4px;
    vertical-align: middle;
    font-style: italic;
}

/* Citator-lite: later rulings mention this ECLI */
.ref-later-citations-badge {
    display: inline-block;
    background: rgba(32, 96, 140, 0.08);
    color: var(--accent, #20608c);
    border: 1px solid rgba(32, 96, 140, 0.22);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.67rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 4px;
    vertical-align: middle;
}

/* Truncate long ECLI source names gracefully */
.ref-source-ecli {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    display: inline-block;
    vertical-align: middle;
}

.ref-popover-full {
    margin-top: 9px;
    border-top: 1px solid var(--border);
    padding-top: 9px;
    color: var(--text-2);
    max-height: 60vh;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.6;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}
.ref-popover-full p {
    margin: 0 0 0.65em 0;
    white-space: normal;
}
.ref-popover-full p:last-child { margin-bottom: 0; }
.ref-passage-ellipsis {
    color: var(--text-3, #aaa);
    font-style: italic;
    text-align: center;
    margin: 0.25em 0 0.5em !important;
    letter-spacing: 0.08em;
}

/* ── Actions log ─────────────────────────────────────────── */

.actions-log { max-height: 170px; overflow-y: auto; padding: 0; margin: 0; list-style: none; }
.actions-log li {
    font-size: 0.77rem;
    color: var(--text-2);
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}
.actions-log li:last-child { border-bottom: none; }

/* ── Utility ─────────────────────────────────────────────── */

.hidden { display: none !important; }

/* Hides legacy cappuccino SVG if it somehow appears */
.cappuccino-art { display: none !important; }

/* ── Conversation history ────────────────────────────────── */

.conv-history {
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
}

.conv-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(42, 47, 54, 0.03);
}

.conv-history-title {
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--text-2);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex: 1;
}

.conv-turn-count {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: var(--r-sm);
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(201, 138, 76, 0.18);
    white-space: nowrap;
}

.clear-history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-3);
    font-size: 0;
    font-weight: 600;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
    box-shadow: none;
}
.clear-history-btn svg { width: 12px; height: 12px; }
.clear-history-btn:hover {
    color: var(--err);
    background: var(--err-bg);
    border-color: rgba(220, 38, 38, 0.2);
}

.conv-day-separator {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 6px 0 8px;
    text-align: center;
    pointer-events: none;
}

.conv-day-separator-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.86);
    color: var(--text-3);
    font-size: 0.64rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.conv-turn:last-child { border-bottom: none; }
.conv-turn--active .conv-turn-toggle { background: var(--blue-bg) !important; }

.conv-turn-followups,
.conv-turn-actions {
    margin-top: 10px;
    padding-top: 8px;
}

.conv-turn-actions { justify-content: flex-start; }

.conv-turn-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 3px 10px;
    cursor: pointer;
    text-align: left;
}

.conv-turn-toggle:hover { background: rgba(201, 138, 76, 0.03) !important; }

.conv-turn-num-badge {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(201, 138, 76, 0.18);
    font-size: 0.55rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conv-turn-q-text {
    flex: 1;
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-turn-chevron {
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--vf-orange) 72%, var(--text-3));
    flex-shrink: 0;
}

.conv-turn-body {
    padding: 0 14px 12px 40px;
}

.conv-turn-answer {
    font-family: inherit;
    font-size: 0.86rem;
    color: var(--text-2);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.75;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    max-height: none;
    overflow: visible;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

.conv-turn-answer h1,
.conv-turn-answer h2,
.conv-turn-answer h3,
.conv-turn-answer h4,
.conv-turn-answer .answer-inline-heading {
    margin: 1.3em 0 0.6em;
    line-height: 1.4;
    font-weight: 700;
    color: var(--text);
    clear: both;
}
.conv-turn-answer h1 { font-size: 1.08rem; }
.conv-turn-answer h2,
.conv-turn-answer .answer-inline-heading { font-size: 0.97rem; }
.conv-turn-answer h3 { font-size: 0.90rem; }
.conv-turn-answer h4 { font-size: 0.86rem; }

.conv-turn-answer blockquote {
    margin: 0.7em 0;
    padding: 0.4em 0.7em;
    border-left: 3px solid rgba(201, 138, 76, 0.2);
    background: rgba(201, 138, 76, 0.05);
    border-radius: 0 7px 7px 0;
}

.conv-turn-answer p {
    margin: 0 0 1.2em 0;
    line-height: 1.7;
    color: var(--text);
}
.conv-turn-answer p:last-child {
    margin-bottom: 0;
}
.conv-turn-answer ul,
.conv-turn-answer ol {
    margin: 0 0 1.2em 0;
    padding-left: 1.8em;
    line-height: 1.7;
}
.conv-turn-answer ul {
    list-style-type: disc;
}
.conv-turn-answer ol {
    list-style-type: decimal;
}
.conv-turn-answer li {
    margin: 0.4em 0;
}

.conv-turn-answer code {
    font-family: inherit;
    font-size: 0.88em;
    padding: 0.05em 0.3em;
    border-radius: 4px;
    background: rgba(13, 28, 59, 0.06);
}

/* Conversation thread rendered inside the answer panel scroll area. */
.answer-story-scroll .conv-history {
    border: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: visible;
    margin: 0 0 12px;
}

.answer-story-scroll .conv-history-header {
    display: none;
}

.conv-turn-answer table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 0.84em;
}

.conv-turn-answer th,
.conv-turn-answer td {
    border: 1px solid var(--border);
    padding: 0.38em 0.48em;
    text-align: left;
}

.conv-turn-answer th {
    background: var(--surface-2);
    color: var(--text-1);
    font-weight: 700;
}

.answer-story-scroll #conv-turns {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-story-scroll .conv-turn {
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.answer-story-scroll .conv-turn:first-child {
    border-top: none;
    padding-top: 0;
}

.answer-story-scroll .conv-turn-toggle {
    justify-content: flex-start;
    padding: 0;
}

.answer-story-scroll .conv-turn-toggle:hover {
    background: transparent !important;
}

.answer-story-scroll .conv-turn-avatar,
.answer-story-scroll .conv-turn-num-badge,
.answer-story-scroll .conv-turn-chevron {
    display: none;
}

.answer-story-scroll .conv-turn-q-text {
    flex: 0 1 auto;
    margin-left: 0;
    margin-right: auto;
    max-width: min(78%, 58ch);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: left;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    font-size: 0.82rem;
    line-height: 1.6;
    padding: 9px 12px;
    border-radius: 14px 14px 4px 14px;
    border: 1px solid rgba(201, 138, 76, 0.2);
    background: rgba(201, 138, 76, 0.12);
    color: var(--text-2);
    /* Ensure robust left alignment */
    align-self: flex-start;
    clear: both;
}

.answer-story-scroll .conv-turn-body {
    padding: 0;
}

.answer-story-scroll .conv-turn-answer,
.answer-story-scroll pre.conv-turn-answer {
    margin: 8px 0 4px;
    width: 100%;
    max-width: 100%;          /* full-width, spans entire middle panel */
    max-height: none;
    overflow: visible;
    padding: 12px 14px;        /* consistent padding for readability */
    border-radius: 0;
    background: var(--surface);  /* same as middle panel background */
    border: none;
    text-align: left;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    font-size: 0.88rem;
    line-height: 1.8;
    color: var(--text);
    word-break: break-word;
    white-space: normal;      /* always render as formatted HTML */
}

.answer-story-scroll .conv-turn-followups,
.answer-story-scroll .conv-turn-actions {
    margin: 8px 0 0;
    max-width: 100%;
}

#answer-pre,
.answer-section-body,
.answer-current-question,
.answer-story-scroll .conv-turn-answer,
.answer-story-scroll .conv-turn-q-text {
    touch-action: pan-y;
}

/* ===================================================================
   PHASE 1 & 2: Conversation Experience Optimizations
   =================================================================== */

/* --- Phase 1: Typographic Hierarchy --- */

/* Modular scale for headings in conversation panel */
.answer-story-scroll .conv-turn-answer h1,
.answer-story-scroll pre.conv-turn-answer h1,
.answer-current-question h1 {
    font-size: 1.3rem;           /* 20.8px - Main answer headings */
    font-weight: 700;
    color: var(--text);
    margin: 1.5em 0 0.8em;
    line-height: 1.35;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.6em;
    clear: both;
}

.answer-story-scroll .conv-turn-answer h2,
.answer-story-scroll pre.conv-turn-answer h2,
.answer-current-question h2 {
    font-size: 1.1rem;           /* 17.6px - Section headings */
    font-weight: 600;
    color: var(--text);
    margin: 1.4em 0 0.7em;
    line-height: 1.4;
    clear: both;
}

.answer-story-scroll .conv-turn-answer h3,
.answer-story-scroll pre.conv-turn-answer h3,
.answer-current-question h3 {
    font-size: 1rem;             /* 16px - Subsections */
    font-weight: 600;
    color: var(--text-2);
    margin: 1.2em 0 0.6em;
    line-height: 1.45;
    clear: both;
}

.answer-story-scroll .conv-turn-answer h4,
.answer-story-scroll pre.conv-turn-answer h4,
.answer-current-question h4 {
    font-size: 0.9rem;           /* 14.4px - Fine print */
    font-weight: 600;
    color: var(--text-3);
    margin: 1.1em 0 0.5em;
    line-height: 1.5;
    clear: both;
}

/* Legal text styling - serif for citations and formal text */
.answer-story-scroll .conv-turn-answer .legal-citation,
.answer-story-scroll pre.conv-turn-answer .legal-citation,
.answer-story-scroll .conv-turn-answer blockquote,
.answer-story-scroll pre.conv-turn-answer blockquote {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-weight: 400;
    color: var(--vf-orange);
    border-left: 2px solid var(--vf-orange);
    padding-left: 12px;
    margin: 1.2em 0;
    line-height: 1.7;
    font-style: normal;
}

/* Enhanced blockquote styling */
.answer-story-scroll .conv-turn-answer blockquote,
.answer-story-scroll pre.conv-turn-answer blockquote {
    background: rgba(201, 138, 76, 0.04);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px 12px 14px;
}

/* --- Phase 1: Spacing Consistency --- */

/* Consistent spacing within answer content */
.answer-story-scroll .conv-turn-answer p,
.answer-story-scroll pre.conv-turn-answer p {
    margin: 0.9em 0;
    line-height: 1.8;
    text-align: left;
}

.answer-story-scroll .conv-turn-answer p:first-child,
.answer-story-scroll pre.conv-turn-answer p:first-child {
    margin-top: 0;
}

.answer-story-scroll .conv-turn-answer p:last-child,
.answer-story-scroll pre.conv-turn-answer p:last-child {
    margin-bottom: 0;
}

/* List spacing */
.answer-story-scroll .conv-turn-answer ul,
.answer-story-scroll pre.conv-turn-answer ul,
.answer-story-scroll .conv-turn-answer ol,
.answer-story-scroll pre.conv-turn-answer ol {
    margin: 1em 0;
    padding-left: 2em;
}

.answer-story-scroll .conv-turn-answer ul,
.answer-story-scroll pre.conv-turn-answer ul {
    list-style-type: disc;
}

.answer-story-scroll .conv-turn-answer ol,
.answer-story-scroll pre.conv-turn-answer ol {
    list-style-type: decimal;
}

.answer-story-scroll .conv-turn-answer li,
.answer-story-scroll pre.conv-turn-answer li {
    margin: 0.5em 0;
    line-height: 1.7;
}

/* Consistent turn spacing */
.answer-story-scroll .conv-turn {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-bottom: 8px;
    position: relative;
}

.answer-story-scroll .conv-turn:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Visual divider between Q&A pairs */
.answer-story-scroll .conv-turn:not(:last-child) {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

/* --- Phase 1: Hover Effects & Active States --- */

/* Question bubble hover effect */
.answer-story-scroll .conv-turn-q-text:hover,
.answer-current-question:hover {
    background: rgba(201, 138, 76, 0.18);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

/* Subtle shadow on answer hover */
.answer-story-scroll .conv-turn-answer:hover {
    box-shadow: 0 1px 4px rgba(201, 138, 76, 0.08);
}

/* Active/selected turn state */
.answer-story-scroll .conv-turn--active .conv-turn-q-text,
.answer-story-scroll .conv-turn--active .conv-turn-answer {
    background: rgba(201, 138, 76, 0.06);
}

/* Focus states for accessibility */
.answer-story-scroll .conv-turn-q-text:focus,
.answer-story-scroll .conv-turn-answer:focus,
.answer-current-question:focus {
    outline: 2px solid var(--vf-orange);
    outline-offset: 2px;
}

/* --- Phase 1: Loading Skeletons --- */

@keyframes skeleton-loading {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.answer-busy-placeholder {
    color: var(--text-3) !important;
    font-style: italic;
    animation: answer-busy-pulse 1.2s ease-in-out infinite;
}

/* Enhanced skeleton loader for answers */
.conversation-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 0;
}

.skeleton-turn {
    background: linear-gradient(
        90deg,
        var(--surface) 25%,
        var(--border) 50%,
        var(--surface) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 12px;
}

.skeleton-question {
    height: 40px;
    width: 70%;
    margin-bottom: 8px;
}

.skeleton-answer {
    height: 120px;
    width: 100%;
}

.skeleton-answer.short {
    height: 60px;
}

.skeleton-answer.long {
    height: 200px;
}

/* --- Phase 2: Citation Highlighting & Linking --- */

/* Citation styling - works with both ref-inline and citation-ref classes */
.answer-story-scroll .conv-turn-answer .citation-ref,
.answer-story-scroll .conv-turn-answer .ref-inline,
.answer-story-scroll pre.conv-turn-answer .citation-ref,
.answer-story-scroll pre.conv-turn-answer .ref-inline {
    color: var(--vf-orange);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px dotted rgba(201, 138, 76, 0.4);
    transition: all 0.2s ease;
    padding: 0 2px;
}

.answer-story-scroll .conv-turn-answer .citation-ref:hover,
.answer-story-scroll .conv-turn-answer .ref-inline:hover,
.answer-story-scroll pre.conv-turn-answer .citation-ref:hover,
.answer-story-scroll pre.conv-turn-answer .ref-inline:hover {
    color: var(--vf-orange-2);
    border-bottom-color: var(--vf-orange);
    background: rgba(201, 138, 76, 0.08);
}

.answer-story-scroll .conv-turn-answer .citation-ref:focus,
.answer-story-scroll .conv-turn-answer .ref-inline:focus,
.answer-story-scroll pre.conv-turn-answer .citation-ref:focus,
.answer-story-scroll pre.conv-turn-answer .ref-inline:focus {
    outline: 2px solid var(--vf-orange);
    outline-offset: 2px;
    border-bottom-color: transparent;
}

/* Highlight active citation references */
.answer-story-scroll .conv-turn-answer .citation-ref.active,
.answer-story-scroll .conv-turn-answer .citation-ref:active,
.answer-story-scroll .conv-turn-answer .ref-inline.active,
.answer-story-scroll .conv-turn-answer .ref-inline:active,
.answer-story-scroll pre.conv-turn-answer .citation-ref.active,
.answer-story-scroll pre.conv-turn-answer .citation-ref:active,
.answer-story-scroll pre.conv-turn-answer .ref-inline.active,
.answer-story-scroll pre.conv-turn-answer .ref-inline:active {
    background: rgba(201, 138, 76, 0.2);
    color: var(--navy);
    border-bottom-color: transparent;
}

/* --- Phase 2: Conversation Timeline --- */

/* Timeline indicator on left edge */
.answer-story-scroll {
    position: relative;
}

.answer-story-scroll::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--border) 10%,
        var(--border) 90%,
        transparent 100%
    );
}

/* Turn indicator dots on timeline */
.answer-story-scroll .conv-turn::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 24px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
}

.answer-story-scroll .conv-turn:nth-child(odd)::before {
    background: var(--vf-orange-soft);
    border-color: var(--vf-orange);
}

.answer-story-scroll .conv-turn:hover::before {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(201, 138, 76, 0.15);
    transition: all 0.2s ease;
}

/* --- Phase 2: Context Summary Bar --- */

/* Context summary at top of conversation */
.conversation-context-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(201, 138, 76, 0.08);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.8rem;
    border-left: 3px solid var(--vf-orange);
}

.conversation-context-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
}

.conversation-context-item strong {
    color: var(--vf-orange);
}

.conversation-context-item svg {
    width: 14px;
    height: 14px;
    color: var(--vf-orange);
}

/* --- Phase 2: Accessibility Enhancements --- */

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .answer-story-scroll .conv-turn-answer,
    .answer-current-question,
    .answer-busy-placeholder,
    .answer-current-question--busy::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (forced-colors: active) {
    .answer-story-scroll .conv-turn-q-text {
        border: 2px solid !important;
        forced-color-adjust: none;
    }
    
    .answer-story-scroll .conv-turn-answer {
        border: 1px solid !important;
        forced-color-adjust: none;
    }
    
    .citation-ref {
        text-decoration: underline !important;
        forced-color-adjust: none;
    }
}

/* Focus visible for keyboard users */
:focus-visible {
    outline: 2px solid var(--vf-orange);
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-to-latest {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--vf-orange);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.3s ease;
}

.skip-to-latest:focus {
    top: 8px;
}

/* --- Phase 1: Keyboard Navigation --- */

/* Focus styles for conversation elements */
.answer-story-scroll .conv-turn:focus-within {
    background: rgba(201, 138, 76, 0.04);
}

/* Tab order for conversation elements */
.answer-story-scroll .conv-turn {
    outline: none;
}

.answer-story-scroll .conv-turn:focus-visible {
    outline: 2px solid var(--vf-orange);
    outline-offset: -2px;
}

/* --- Legal UX Pro Tips Implementation --- */

/* Pro Tip 1: Color Psychology - Use orange sparingly for emphasis */
.answer-story-scroll .conv-turn-answer .highlight-emphasis {
    background: rgba(201, 138, 76, 0.15);
    padding: 0 4px;
    border-radius: 2px;
    color: var(--text);
}

.answer-story-scroll .conv-turn-answer strong,
.answer-story-scroll .conv-turn-answer b {
    color: var(--vf-orange);
    font-weight: 600;
}

/* Pro Tip 2: Information Density - Layer information */
.answer-summary {
    background: rgba(201, 138, 76, 0.08);
    border-left: 3px solid var(--vf-orange);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 0 4px 4px 0;
}

.answer-summary h3 {
    color: var(--vf-orange);
    font-size: 0.9rem;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.answer-summary p {
    margin: 0;
    color: var(--text-2);
    font-size: 0.85rem;
    line-height: 1.6;
}

.details-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--vf-orange);
    font-size: 0.8rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.details-toggle:hover {
    background: rgba(201, 138, 76, 0.1);
}

.details-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.details-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Pro Tip 3: Precision Matters - Show exact source references */
.source-reference {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(201, 138, 76, 0.05);
    border-radius: 6px;
    margin: 12px 0;
    font-size: 0.8rem;
}

.source-reference-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.source-reference-title {
    font-weight: 600;
    color: var(--text);
}

.source-reference-url {
    font-size: 0.75rem;
    color: var(--text-3);
    word-break: break-all;
}

.source-reference-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-3);
}

.source-reference-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.source-reference-meta svg {
    width: 12px;
    height: 12px;
}

/* Pro Tip 4: Time Sensitivity - Show answer date and source freshness */
.answer-meta {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(201, 138, 76, 0.04);
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-3);
}

.answer-timestamp {
    display: flex;
    align-items: center;
    gap: 6px;
}

.answer-freshness {
    display: flex;
    align-items: center;
    gap: 6px;
}

.freshness-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.freshness-current {
    background: rgba(31, 122, 82, 0.1);
    color: var(--ok);
}

.freshness-recent {
    background: rgba(201, 138, 76, 0.15);
    color: var(--vf-orange);
}

.freshness-old {
    background: rgba(140, 96, 32, 0.1);
    color: var(--warn);
}

/* Pro Tip 5: Mobile Considerations */
@media (max-width: 768px) {
    /* Adjust typographic scale for mobile */
    .answer-story-scroll .conv-turn-answer h1 {
        font-size: 1.2rem;
    }
    
    .answer-story-scroll .conv-turn-answer h2 {
        font-size: 1rem;
    }
    
    .answer-story-scroll .conv-turn-answer h3 {
        font-size: 0.9rem;
    }
    
    /* Make timeline more subtle on mobile */
    .answer-story-scroll::before {
        left: 4px;
        width: 1px;
    }
    
    .answer-story-scroll .conv-turn::before {
        left: -14px;
        width: 10px;
        height: 10px;
    }
    
    /* Adjust spacing for touch targets */
    .answer-story-scroll .conv-turn-answer {
        padding: 10px 12px;
    }
    
    .conversation-context-summary {
        flex-direction: column;
        gap: 8px;
    }
}

/* Additional styles for JavaScript features */

/* New messages indicator */
.new-messages-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--vf-orange);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(201, 138, 76, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.new-messages-indicator:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(201, 138, 76, 0.4);
}

/* Just-scrolled highlight animation */
@keyframes justScrolledHighlight {
    0% { background: rgba(201, 138, 76, 0.2); }
    100% { background: transparent; }
}

.answer-story-scroll .conv-turn--just-scrolled {
    animation: justScrolledHighlight 2s ease-out forwards;
}

/* Reference item active state */
.ref-item.active {
    background: rgba(201, 138, 76, 0.12);
    border-left: 3px solid var(--vf-orange);
}

/* Timeline indicator animation */
.answer-story-scroll .conv-turn::before {
    transition: all 0.2s ease;
}

/* ===================================================================
   End of Phase 1 & 2 Optimizations
   =================================================================== */

/* ── Conversation sidebar (left column) ──────────────────── */

.conv-sidebar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: sticky;
    top: 14px;
    max-height: calc(100vh - 76px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

.conv-sidebar::-webkit-scrollbar { width: 4px; }
.conv-sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.conv-sidebar::-webkit-scrollbar-track { background: transparent; }

.conv-sidebar-top { padding: 0 0 8px; border-bottom: 1px solid var(--border); }

.conv-new-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--r);
    background: var(--blue-bg);
    border: 1px solid rgba(201, 138, 76,0.18);
    color: var(--blue);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.13s, border-color 0.13s;
}
.conv-new-btn:hover { background: rgba(201, 138, 76,0.13); border-color: var(--blue-2); }
.conv-new-btn svg { flex-shrink: 0; }

.menu-icon-btn {
    position: relative;
    width: 30px;
    height: 30px;
    padding: 0;
    gap: 0;
    justify-content: center;
}

.menu-icon-btn .conv-new-label,
.menu-icon-btn .conv-export-label {
    display: none;
}

.clear-history-btn,
.citation-first-toggle {
    position: relative;
}

.menu-icon-btn::after,
.clear-history-btn::after,
.citation-first-toggle::after {
    content: attr(aria-label);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 7px);
    transform: translateX(-50%) translateY(3px);
    padding: 5px 8px;
    border-radius: 7px;
    border: 1px solid rgba(42, 47, 54, 0.18);
    background: rgba(0, 17, 23, 0.92);
    color: rgba(255, 255, 255, 0.96);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 250;
}

.menu-icon-btn[data-tip-side="left"]::after,
.clear-history-btn[data-tip-side="left"]::after,
.citation-first-toggle[data-tip-side="left"]::after {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(3px);
}

.menu-icon-btn[data-tip-side="right"]::after,
.clear-history-btn[data-tip-side="right"]::after,
.citation-first-toggle[data-tip-side="right"]::after {
    left: 0;
    transform: translateX(0) translateY(3px);
}

.menu-icon-btn::before,
.clear-history-btn::before,
.citation-first-toggle::before {
    pointer-events: none;
}

.menu-icon-btn:hover::after,
.menu-icon-btn:focus-visible::after,
.clear-history-btn:hover::after,
.clear-history-btn:focus-visible::after,
.citation-first-toggle:hover::after,
.citation-first-toggle:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.menu-icon-btn[data-tip-side="left"]:hover::after,
.menu-icon-btn[data-tip-side="left"]:focus-visible::after,
.clear-history-btn[data-tip-side="left"]:hover::after,
.clear-history-btn[data-tip-side="left"]:focus-visible::after,
.citation-first-toggle[data-tip-side="left"]:hover::after,
.citation-first-toggle[data-tip-side="left"]:focus-visible::after,
.menu-icon-btn[data-tip-side="right"]:hover::after,
.menu-icon-btn[data-tip-side="right"]:focus-visible::after,
.clear-history-btn[data-tip-side="right"]:hover::after,
.clear-history-btn[data-tip-side="right"]:focus-visible::after,
.citation-first-toggle[data-tip-side="right"]:hover::after,
.citation-first-toggle[data-tip-side="right"]:focus-visible::after {
    transform: translateX(0) translateY(0);
}

@media (hover: none), (pointer: coarse) {
    .menu-icon-btn::after,
    .clear-history-btn::after,
    .citation-first-toggle::after {
        display: none;
    }
}

.conv-search-wrap { padding: 6px 0 4px; }
.conv-search-row {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
}
.conv-search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}
.conv-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    line-height: 0;
    pointer-events: none;
}
.conv-search {
    flex: 1;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 5px 30px 5px 27px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--bg-2);
    color: var(--text-1);
    font-size: 0.72rem;
    outline: none;
    transition: border-color 0.13s;
}
.conv-search:focus { border-color: var(--blue-2); }
.conv-search::placeholder { color: var(--text-3); }

/* Fires an animation the instant the browser autofills this field, so JS can
   detect it and clear the value (autocomplete="off" alone is not honored). */
@keyframes conv-search-autofill-start { from {} to {} }
.conv-search:-webkit-autofill {
    animation-name: conv-search-autofill-start;
    -webkit-text-fill-color: var(--text-1);
    box-shadow: 0 0 0 1000px var(--bg-2) inset;
}

.conv-search-menu-btn {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: var(--vf-orange);
    border-radius: 6px;
    cursor: pointer;
    box-shadow: none;
    transition: color 0.14s, opacity 0.14s;
    padding: 0;
    opacity: 0.85;
}

.conv-search-menu-btn:hover {
    color: var(--vf-orange-2);
    opacity: 1;
}

.conv-search-menu-btn[aria-expanded="true"] {
    color: var(--vf-orange-2);
    opacity: 1;
}

.conv-search-menu-btn:focus-visible {
    opacity: 1;
    outline: none;
}

.conv-search-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    bottom: auto;
    right: 0;
    z-index: 20;
    min-width: 176px;
    width: max-content;
    max-width: min(220px, calc(100vw - 24px));
    max-height: min(52vh, 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
    border: 1.5px solid var(--border-2);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.conv-search-menu--open { display: flex; flex-direction: column; gap: 1px; }

.conv-search-menu--up {
    top: auto;
    bottom: calc(100% + 4px);
}

.conv-search-menu-option {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text-2);
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 7px 10px;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.12s, color 0.12s;
}

.conv-search-menu-option::before {
    content: "✓";
    flex-shrink: 0;
    width: 12px;
    text-align: center;
    color: var(--blue-2);
    opacity: 0;
    transform: translateX(-1px);
}

.conv-search-menu-option:hover { background: var(--blue-bg); color: var(--text-1); }

.conv-search-menu-option--active {
    color: var(--text-1);
    font-weight: 600;
    background: rgba(201, 138, 76, 0.10);
}

.conv-search-menu-option--active::before {
    opacity: 1;
}

.conv-search-highlight {
    background: rgba(250, 204, 21, 0.34);
    color: inherit;
    border-radius: 4px;
    padding: 0 1px;
}

[data-theme="dark"] .conv-search-highlight {
    background: rgba(250, 204, 21, 0.28);
}

.conv-list { display: flex; flex-direction: column; gap: 3px; padding-top: 6px; }

.conv-group-label {
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 8px 4px 3px;
    margin-top: 4px;
}
.conv-group-label:first-child { margin-top: 0; padding-top: 4px; }

.conv-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 1px 6px;
    padding: 7px 9px;
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    position: relative;
    cursor: pointer;
}
.conv-item:hover { background: rgba(255,255,255,0.70); border-color: var(--border); }
.conv-item--active {
    background: rgba(201, 138, 76,0.07);
    border-color: rgba(201, 138, 76,0.18);
}

.conv-item-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    grid-column: 1;
    grid-row: 1;
}
.conv-item--active .conv-item-name { color: var(--blue-2); font-weight: 600; }

.conv-item-meta {
    font-size: 0.68rem;
    color: var(--text-3);
    grid-column: 1;
    grid-row: 2;
}

.conv-item-del {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    background: none !important;
    border: none !important;
    color: var(--text-3) !important;
    opacity: 0;
    cursor: pointer;
    padding: 3px 4px !important;
    border-radius: 3px !important;
    transition: opacity 0.12s, color 0.12s;
    box-shadow: none !important;
    font-size: 0.8rem;
    line-height: 1;
}
.conv-item:hover .conv-item-del { opacity: 1; }
.conv-item-del:hover { color: var(--err) !important; background: var(--err-bg) !important; }

.conv-rename-input {
    width: 100%;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--blue-2);
    background: rgba(255,255,255,0.90);
    border: 1px solid var(--blue-2);
    border-radius: 3px;
    padding: 1px 5px;
    outline: none;
    box-shadow: 0 0 0 2px rgba(201, 138, 76,0.12);
    grid-column: 1 / span 2;
    grid-row: 1;
}

.conv-sidebar-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.conv-export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-3);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    transition: background 0.12s, color 0.12s;
}
.conv-export-btn:hover { background: var(--blue-bg); color: var(--blue); }

/* ── Conv empty state ────────────────────────────────────── */

.conv-empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-3);
    animation: fadeIn 0.3s ease;
}
.conv-empty-icon { font-size: 2rem; margin-bottom: 10px; opacity: 0.4; }
.conv-empty-title { font-size: 0.92rem; font-weight: 700; color: var(--text-2); margin: 0 0 6px; }
.conv-empty-hint { font-size: 0.80rem; line-height: 1.6; margin: 0 auto; max-width: 340px; }

/* ── Mobile drawer toggle ────────────────────────────────── */

/* Hidden by default on all screens; shown only when the sidebar
   is not visible in the grid (set to display:flex in the 820px breakpoint). */
.conv-drawer-toggle {
    display: none;
    position: fixed;
    top: 80px;
    left: 0;
    z-index: 498;
    align-items: center;
    justify-content: center;
    padding: 9px 11px !important;
    background: rgba(255, 255, 255, 0.90) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-2) !important;
    border-left: none !important;
    border-top-right-radius: var(--r) !important;
    border-bottom-right-radius: var(--r) !important;
    box-shadow: 3px 2px 10px rgba(0, 17, 23, 0.10) !important;
    color: var(--text-2) !important;
    cursor: pointer;
}

.conv-drawer-toggle:hover {
    background: rgba(255, 255, 255, 1) !important;
    color: var(--blue) !important;
}

/* Right panel (references/docs) toggle — mirror of conv-drawer-toggle, right side */
.ref-drawer-toggle {
    display: none;
    position: fixed;
    top: 80px;
    right: 0;
    z-index: 498;
    align-items: center;
    justify-content: center;
    padding: 9px 11px !important;
    background: rgba(255, 255, 255, 0.90) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-2) !important;
    border-right: none !important;
    border-top-left-radius: var(--r) !important;
    border-bottom-left-radius: var(--r) !important;
    box-shadow: -3px 2px 10px rgba(0, 17, 23, 0.10) !important;
    color: var(--text-2) !important;
    cursor: pointer;
}

.ref-drawer-toggle:hover {
    background: rgba(255, 255, 255, 1) !important;
    color: var(--blue) !important;
}

.pinned-drawer-toggle {
    display: flex;
    position: fixed;
    top: 132px;
    right: 0;
    z-index: 498;
    align-items: center;
    justify-content: center;
    padding: 9px 11px !important;
    background: rgba(255, 255, 255, 0.90) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-2) !important;
    border-right: none !important;
    border-top-left-radius: var(--r) !important;
    border-bottom-left-radius: var(--r) !important;
    box-shadow: -3px 2px 10px rgba(0, 17, 23, 0.10) !important;
    color: var(--text-2) !important;
    cursor: pointer;
}

.pinned-drawer-toggle:hover {
    background: rgba(255, 255, 255, 1) !important;
    color: var(--blue) !important;
}

.drawer-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-size: 0.60rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

.pinned-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 92vw);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 12px;
    background: var(--surface);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    box-shadow: -4px 0 24px rgba(0, 17, 23,0.14);
    transform: translateX(105%);
    transition: transform 0.22s ease;
    will-change: transform;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-menu-lock {
    overflow: hidden;
    touch-action: none;
}

.pinned-drawer--open { transform: translateX(0); }

.pinned-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.conv-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 17, 23,0.28);
    z-index: 499;
    animation: fadeIn 0.18s ease;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.conv-drawer-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.conv-drawer-overlay[hidden] {
    display: none !important;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (min-width: 821px) {
    .home-main {
        position: sticky;
        top: 14px;
        height: calc(100dvh - 76px - var(--ask-bar-h));
        overflow: hidden;
    }

    .answer-card {
        height: 100%;
        min-height: 0;
    }

    .answer-content-scroll,
    .answer-story-scroll {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .answer-content-scroll #answer-pre,
    .answer-content-scroll .answer-section-body,
    .answer-content-scroll .answer-story-scroll .conv-turn-answer {
        font-size: 0.8rem;
        line-height: 1.58;
    }

    .answer-content-scroll .followup-chip {
        font-size: var(--reading-followup-size, var(--answer-followup-size, 0.72rem));
    }

    .answer-content-scroll .empty-msg,
    .answer-content-scroll .answer-current-question {
        font-size: 0.8rem;
    }
}

@media (max-width: 1280px) {
    :root { --sidebar-w: 360px; }
}

@media (max-width: 1060px) {
    :root { --conv-w: 175px; --sidebar-w: 300px; }
    .conv-item-name { font-size: 0.74rem; }
    .conv-new-btn .conv-new-label { display: none; }
}

@media (max-width: 820px) {
    .home-grid { grid-template-columns: 1fr; }
    .home-sidebar-header { display: flex; }

    .answer-card {
        gap: 8px;
    }

    .answer-card {
        height: clamp(360px, calc(100dvh - 190px), 760px);
    }

    .answer-story-scroll {
        padding-right: 2px;
    }

    .answer-story-scroll #conv-turns {
        gap: 10px;
    }

    .answer-story-scroll .conv-turn-q-text {
        max-width: 84%;
        font-size: 0.78rem;
        line-height: 1.45;
        padding: 8px 10px;
    }

    .answer-story-scroll .conv-turn-answer {
        max-width: 90%;
        font-size: 0.84rem;
        line-height: 1.66;
        padding: 10px 11px;
    }

    .answer-story-scroll,
    .answer-card--long .answer-story-scroll {
        max-height: min(62vh, calc(100dvh - 320px));
    }

    .answer-actions {
        margin-top: 2px;
        padding-top: 8px;
    }

    /* Left conversation drawer */
    .conv-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: min(280px, 85vw);
        z-index: 500;
        background: var(--surface);
        -webkit-backdrop-filter: blur(18px);
        backdrop-filter: blur(18px);
        box-shadow: 4px 0 24px rgba(0, 17, 23,0.14);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        will-change: transform;
        max-height: 100vh;
        padding: 16px 12px;
        overflow-y: auto;
        border-radius: 0;
    }
    .conv-sidebar--open { transform: translateX(0); }
    .conv-drawer-toggle { display: flex; }

    /* Right references/docs drawer */
    .home-sidebar {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        width: min(310px, 88vw);
        z-index: 500;
        background: var(--surface);
        -webkit-backdrop-filter: blur(18px);
        backdrop-filter: blur(18px);
        box-shadow: -4px 0 24px rgba(0, 17, 23,0.14);
        transform: translateX(100%);
        transition: transform 0.22s ease;
        will-change: transform;
        max-height: 100vh;
        padding: 16px 12px;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: 0;
        /* Reset sticky positioning */
        top: 0;
    }
    .home-sidebar--open { transform: translateX(0); }
    .ref-drawer-toggle { display: flex; }
}

@media (max-width: 660px) {
    .lib-docs-split { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    header { padding: 0 12px; }
    .header-inner, .header-top {
        padding: 11px 0;
        flex-wrap: nowrap;
        align-items: flex-start;
    }
    .header-brand {
        flex: 0 0 auto;
        min-width: 0;
        gap: 8px;
    }
    /* Logo text disappears on small screens — keep just the mark, so the
       pill-shaped avatar/menu button on the right has room to stay put. */
    .header-brand h1 {
        display: none;
    }
    .header-top h1, header h1 {
        font-size: 0.9rem;
        line-height: 1.15;
    }
    .header-sub, .header-top p, header p {
        display: none;
    }
    .header-nav {
        width: auto;
        margin-left: auto;
        gap: 0;
        flex-wrap: nowrap;
        align-self: flex-start;
    }
    .header-nav a { flex: 0 0 auto; text-align: center; font-size: 0.76rem; padding: 6px 4px; }
    .nav-avatar-btn {
        height: 30px;
        padding: 0 9px 0 8px;
    }
    .app-layout, .app-main { padding: 10px 10px 132px; }
    .conv-drawer-toggle { top: 82px; }
    .ref-drawer-toggle  { top: 82px; }
    .pinned-drawer-toggle { top: 118px; }
    .card { padding: 13px 14px; }
    .form-row { grid-template-columns: 1fr; }
    .fetch-row { flex-direction: column; }
    .fetch-row button { width: 100%; text-align: center; }
    .ask-input-row { gap: 7px; }
    .ask-input-row button { padding: 0 10px; font-size: 0.76rem; }
    .ask-send-btn { padding: 0 !important; }
    #question::placeholder,
    .av-form-grid input::placeholder,
    .av-form-grid textarea::placeholder {
        font-size: 0.75rem;
        line-height: 1.35;
    }
    .ask-controls-row { gap: 5px; margin-top: 4px; }
    .ask-controls-row .corpus-filter-toggle {
        width: 24px;
        height: 24px;
        border-radius: 7px !important;
    }
    .ask-controls-row .corpus-filter-toggle svg {
        width: 11px;
        height: 11px;
    }

    .ask-controls-row .stream-error-banner {
        width: 100%;
        max-width: none;
        margin-left: 0;
    }

    .answer-card-header h2 {
        font-size: 0.98rem;
    }

    .answer-card {
        height: clamp(320px, calc(100dvh - 175px), 680px);
    }

    .answer-story-scroll {
        padding-right: 0;
    }

    .answer-story-scroll #conv-turns {
        gap: 9px;
    }

    .answer-story-scroll .conv-turn-q-text {
        max-width: 88%;
        font-size: 0.75rem;
        line-height: 1.42;
        padding: 7px 9px;
        text-align: left;
        margin-left: 0;
        margin-right: auto;
        align-self: flex-start;
    }

    .answer-story-scroll .conv-turn-answer {
        max-width: 94%;
        font-size: 0.82rem;
        line-height: 1.62;
        padding: 9px 10px;
    }

    .answer-current-question {
        max-width: 88%;
        font-size: 0.75rem;
        line-height: 1.45;
        padding: 7px 9px;
        margin: 0 0 9px 0;
        text-align: left;
    }

    .answer-story-scroll,
    .answer-card--long .answer-story-scroll {
        max-height: min(58vh, calc(100dvh - 290px));
        padding-right: 1px;
    }

    .answer-section-body,
    pre {
        font-size: 0.84rem;
        line-height: 1.66;
    }

    .followup-chip {
        font-size: var(--reading-followup-size, var(--answer-followup-size, 0.72rem));
        padding: var(--reading-followup-pad-y, 6px) var(--reading-followup-pad-x, 10px);
        min-height: 36px;
    }

    .answer-section-body table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    .conv-turn-answer {
        font-size: 0.82rem;
        line-height: 1.64;
        max-height: 30vh;
    }
}

@media (max-width: 420px) {
    .card {
        padding: 12px;
    }

    .answer-card-header {
        align-items: flex-start;
    }

    .answer-card-header h2 {
        font-size: 0.93rem;
        line-height: 1.25;
    }

    .answer-story-scroll .conv-turn-q-text {
        max-width: 92%;
        font-size: 0.73rem;
        line-height: 1.4;
        padding: 7px 8px;
    }

    .answer-story-scroll .conv-turn-answer {
        max-width: 96%;
        font-size: 0.8rem;
        line-height: 1.58;
        padding: 8px 9px;
    }

    .answer-story-scroll,
    .answer-card--long .answer-story-scroll {
        max-height: min(56vh, calc(100dvh - 276px));
    }

    .answer-actions {
        justify-content: flex-start;
        gap: 6px;
    }

    .answer-actions .corpus-filter-toggle {
        width: 34px;
        height: 34px;
    }

    .answer-section-body,
    pre,
    pre#answer-pre {
        font-size: 0.82rem;
        line-height: 1.62;
    }

    .followup-chip {
        font-size: var(--reading-followup-size, var(--answer-followup-size, 0.72rem));
        padding: var(--reading-followup-pad-y, 6px) var(--reading-followup-pad-x, 9px);
    }

    .conv-turn-body {
        padding: 0 12px 10px 34px;
    }
}

/* ── Nav gear dropdown additions ─────────────────────────── */

.nav-dropdown-sep {
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.nav-dropdown-mode {
    padding: 8px 14px 12px;
}

button.nav-dropdown-item {
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

button.nav-dropdown-item--logout {
    color: var(--err);
}

button.nav-dropdown-item--logout:hover {
    background: var(--err-bg);
    color: var(--err);
}

[data-theme="dark"] button.nav-dropdown-item--logout:hover {
    background: rgba(185, 28, 28, 0.15);
}

.nav-dropdown-about {
    padding: 7px 14px 8px;
    color: var(--text-3);
    font-size: 0.67rem;
    line-height: 1.45;
}

.nav-dropdown-about-line {
    margin: 1px 0;
    opacity: 0.88;
}

.nav-dropdown-about-line strong {
    color: var(--text-2);
    font-weight: 700;
}

.nav-dropdown-about-line a {
    color: var(--text-3);
    text-decoration: none;
    border-bottom: 1px solid rgba(201, 138, 76, 0.18);
}

.nav-dropdown-about-line a:hover {
    color: var(--blue);
    border-bottom-color: rgba(201, 138, 76, 0.34);
}

.nav-dropdown-about-line--version {
    font-size: 0.62rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    opacity: 0.72;
}

.nav-dropdown-mode-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 7px;
}

.nav-dropdown-mode-btns {
    display: flex;
    gap: 5px;
}

.about-modal {
    position: fixed;
    inset: 0;
    z-index: 4100;
    display: grid;
    place-items: center;
}

.about-modal[hidden] {
    display: none;
}

.about-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 18, 30, 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.about-modal-card {
    position: relative;
    width: min(92vw, 400px);
    border-radius: var(--r);
    border: 1px solid var(--border-2);
    background: var(--surface);
    box-shadow: var(--shadow-md), 0 28px 80px rgba(0, 17, 23, 0.22);
    padding: 24px 24px 20px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.about-modal-card h2 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.about-modal-subtitle {
    margin: 0 0 10px;
    color: var(--text-2);
    font-size: 0.8rem;
    line-height: 1.45;
}

.about-modal-section {
    margin: 9px 0;
    padding-top: 9px;
    border-top: 1px solid var(--border);
}

.about-modal-section:first-of-type {
    margin-top: 0;
}

.about-modal-line {
    margin: 6px 0;
    color: var(--text-2);
    font-size: 0.84rem;
    line-height: 1.5;
}

.about-modal-line a {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(201, 138, 76, 0.28);
}

.about-modal-line a:hover {
    border-bottom-color: rgba(201, 138, 76, 0.55);
}

.about-modal-links {
    margin: 6px 0 0;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.about-modal-links span {
    color: var(--text-3);
}

.about-modal-links a {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(201, 138, 76, 0.28);
}

.about-modal-links a:hover {
    border-bottom-color: rgba(201, 138, 76, 0.55);
}

.about-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    font-size: 0.86rem;
    line-height: 1;
}

.about-modal-close:hover {
    border-color: var(--blue-2);
    color: var(--blue-2);
}

.nav-mode-btn {
    flex: 1;
    padding: 5px 8px;
    border-radius: var(--r-sm);
    border: 1.5px solid var(--border-2);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-2);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    text-align: center;
    font-family: inherit;
    box-shadow: none;
    line-height: 1.3;
}

.nav-mode-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--border-2);
}

.nav-mode-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.nav-mode-btn--active.nav-mode-btn--claude {
    background: var(--ok-bg);
    border-color: var(--ok-bdr);
    color: var(--ok);
}

.nav-mode-btn--active.nav-mode-btn--mistral {
    background: var(--blue-bg);
    border-color: var(--blue-2);
    color: var(--blue-2);
}

.nav-mode-error {
    font-size: 0.74rem;
    color: var(--err);
    margin: 5px 0 0;
    line-height: 1.4;
}

/* ── User avatar in conversation turns ───────────────────── */

.conv-turn-avatar {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    overflow: hidden;
    object-fit: cover;
}

.conv-turn-avatar--initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue);
    color: #fff;
    font-size: 0.60rem;
    font-weight: 800;
    letter-spacing: 0;
    user-select: none;
}

/* ── Settings page ───────────────────────────────────────── */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.settings-section h2 { margin-bottom: 16px; }

.settings-group-title {
    padding: 14px 16px;
    border: 1px dashed var(--border-2);
    background: linear-gradient(180deg, rgba(201, 138, 76,0.04), rgba(201, 138, 76,0.01));
}

.settings-group-title h2 {
    margin: 0 0 6px;
    font-size: 0.98rem;
}

.settings-group-title .settings-desc {
    margin: 0;
    font-size: 0.80rem;
}

.settings-desc {
    font-size: 0.84rem;
    color: var(--text-2);
    line-height: 1.6;
    margin: -6px 0 14px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 16px;
}

.settings-field--reading-size {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.reading-size-row {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.reading-size-preview {
    margin: 0;
    color: var(--text-2);
    font-style: italic;
    line-height: 1.4;
    transition: font-size 0.12s ease;
    font-size: 0.84rem;
}

.reading-size-preview[data-reading-size="s"] { font-size: 0.76rem; }
.reading-size-preview[data-reading-size="m"] { font-size: 0.91rem; }
.reading-size-preview[data-reading-size="l"] { font-size: 1.08rem; }

.settings-field label {
    font-size: 0.81rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0;
}

.settings-field-hint {
    font-size: 0.73rem;
    color: var(--text-3);
    margin: 1px 0 0;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-status {
    font-size: 0.80rem;
    font-weight: 600;
    margin: 0;
}

.profile-status--ok  { color: var(--ok); }
.profile-status--err { color: var(--err); }

.settings-mode-ok {
    margin: 8px 0 0;
    font-size: 0.82rem;
    color: var(--ok);
    background: var(--ok-bg);
    border: 1px solid var(--ok-bdr);
    border-radius: var(--r-sm);
    padding: 6px 12px;
    font-weight: 600;
}

/* Avatar section */
.avatar-section {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.avatar-preview {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-bg);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-initials-large {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.02em;
    user-select: none;
}

.avatar-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.avatar-hint {
    font-size: 0.73rem;
    color: var(--text-3);
    margin: 0;
}

.btn-danger-sm {
    display: inline-block;
    padding: 5px 12px;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--err);
    font-size: 0.80rem;
    font-weight: 600;
    border: 1px solid var(--err-bdr);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s;
    box-shadow: none;
}

.btn-danger-sm:hover { background: var(--err-bg); }

@media (max-width: 760px) {
    .settings-grid { grid-template-columns: 1fr; }
}

/* ── Settings redesign — grouped cards ──────────────────────────────────── */

.settings-groups {
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 960px;
    margin: 0 auto;
}

.settings-group {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    overflow: hidden;
}

.settings-group__hd {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    background: linear-gradient(90deg, rgba(201, 138, 76,.06) 0%, rgba(201, 138, 76,.02) 100%);
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .settings-group__hd {
    background: linear-gradient(90deg, rgba(201, 138, 76,.10) 0%, rgba(201, 138, 76,.03) 100%);
}

.settings-group__hd-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--blue-bg);
    border: 1px solid rgba(201, 138, 76,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
}

[data-theme="dark"] .settings-group__hd-icon {
    background: rgba(201, 138, 76,.15);
    border-color: rgba(201, 138, 76,.28);
}

.settings-group__hd h2 {
    margin: 0 0 2px;
    font-size: 1.0rem;
    font-weight: 700;
    color: var(--text);
}

.settings-group__hd p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.45;
}

.settings-group__body {
    padding: 24px;
}

.settings-group__cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    align-items: start;
}

.settings-group__col {
    padding: 0 24px 0 0;
}

.settings-group__col--sep {
    padding: 0 0 0 24px;
    border-left: 1px solid var(--border);
}

.settings-subsec-title {
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-3);
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-plan-status {
    margin-bottom: 6px;
}

.trial-meter { display: flex; flex-direction: column; gap: 4px; }
.trial-meter__bar { height: 6px; border-radius: 3px; background: var(--border-2); overflow: hidden; }
.trial-meter__fill { height: 100%; border-radius: 3px; background: var(--blue); transition: width 0.4s ease; }
.trial-meter__fill--warn { background: #f59e0b; }
.trial-meter__label { font-size: 0.70rem; color: var(--text-3); }

@media (max-width: 760px) {
    .settings-group__cols { grid-template-columns: 1fr; }
    .settings-group__col { padding: 0; }
    .settings-group__col--sep {
        padding: 20px 0 0;
        border-left: none;
        border-top: 1px solid var(--border);
        margin-top: 20px;
    }
    .settings-group__hd { padding: 14px 18px; }
    .settings-group__body { padding: 18px; }
}

/* ── Center upload zone (empty-state dropzone) ────────────── */

.conv-upload-zone {
    border: 1.5px dashed var(--border-2);
    border-radius: var(--r);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.conv-upload-zone:hover,
.conv-upload-zone.dropzone-active {
    border-color: var(--blue-2);
    background: rgba(201, 138, 76, 0.04);
}

.conv-upload-zone-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    opacity: 0.32;
    color: var(--blue-2);
    pointer-events: none;
}

/* ── Document panel header (right sidebar) ────────────────── */

.doc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.doc-panel-header h2 { margin: 0; }

.add-doc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    background: var(--blue-bg) !important;
    border: 1px solid rgba(201, 138, 76,0.18) !important;
    border-radius: var(--r-sm) !important;
    color: var(--blue) !important;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    box-shadow: none !important;
    padding: 0 !important;
}
.add-doc-btn:hover {
    background: rgba(201, 138, 76,0.14) !important;
    border-color: var(--blue-2) !important;
}

.doc-list-empty {
    font-size: 0.79rem;
    color: var(--text-3);
    font-style: italic;
    margin: 6px 0;
    text-align: center;
    padding: 10px 0;
}

.doc-indexing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.doc-indexed-ok {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.64rem;
    font-weight: 700;
    color: var(--ok);
    letter-spacing: 0.02em;
}

@keyframes spin { to { transform: rotate(360deg); } }

.doc-indexing-spinner {
    display: inline-block;
    width: 9px;
    height: 9px;
    border: 1.5px solid var(--border-2);
    border-top-color: var(--blue-2);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

/* ── In-app confirm modal ─────────────────────────────────── */

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.app-modal[hidden] { display: none !important; }

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 17, 23, 0.50);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.app-modal-box {
    position: relative;
    z-index: 1;
    background: var(--surface-2);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    box-shadow: 0 8px 40px rgba(0, 17, 23, 0.22), 0 2px 8px rgba(0, 17, 23, 0.10);
    padding: 28px 28px 22px;
    min-width: 280px;
    max-width: 440px;
    width: 100%;
    animation: pop-in 0.16s ease;
}

.app-modal-msg {
    font-size: 0.94rem;
    color: var(--text);
    line-height: 1.6;
    margin: 0 0 22px;
    font-weight: 500;
}

.app-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.app-modal-btn {
    padding: 7px 20px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid var(--border-2);
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    line-height: 1.4;
}

.app-modal-cancel {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border-2);
}
.app-modal-cancel:hover { background: var(--blue-bg); border-color: rgba(201, 138, 76,0.20); }

.app-modal-ok {
    background: var(--blue);
    color: #fff;
    border-color: transparent;
}
.app-modal-ok:hover { background: var(--blue-2); }

.app-modal-ok--danger { background: var(--err) !important; border-color: transparent !important; }
.app-modal-ok--danger:hover { background: #a81c1c !important; }

/* ── Right-sidebar drawer header (mobile only) ────────────── */

.home-sidebar-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.home-sidebar-close {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0 !important;
    background: transparent !important;
    border: 1px solid var(--border-2) !important;
    border-radius: var(--r-sm) !important;
    color: var(--text-3) !important;
    cursor: pointer;
    box-shadow: none !important;
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
}
.home-sidebar-close:hover {
    background: var(--blue-bg) !important;
    color: var(--blue) !important;
    border-color: rgba(201, 138, 76,0.22) !important;
}

/* ── Approve button ──────────────────────────────────────── */

.approve-trigger-btn {
    flex-shrink: 0;
    background: none !important;
    border: 1px solid var(--border-2) !important;
    color: var(--text-3) !important;
    font-size: 0.76rem !important;
    font-weight: 600 !important;
    padding: 2px 9px !important;
    border-radius: var(--r-sm) !important;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none !important;
    transition: border-color 0.13s, color 0.13s, background 0.13s;
}

.approve-trigger-btn:hover {
    border-color: var(--ok-bdr) !important;
    color: var(--ok) !important;
    background: var(--ok-bg) !important;
}

.approve-trigger-btn--done {
    color: var(--ok) !important;
    border-color: var(--ok-bdr) !important;
    background: var(--ok-bg) !important;
    cursor: default;
}

/* ── Verified match banner ───────────────────────────────── */

.verified-match-banner {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--ok-bg);
    border: 1px solid var(--ok-bdr);
    border-radius: var(--r-sm);
    font-size: 0.81rem;
}

.verified-match-banner summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ok);
    user-select: none;
    list-style: none;
}
.verified-match-banner summary::before { content: ''; }

.verified-match-preview {
    margin: 6px 0 0;
    color: var(--text-2);
    font-style: italic;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ── Verified badge in references ────────────────────────── */

.ref-verified-badge {
    display: inline-block;
    font-size: 0.66rem;
    font-weight: 700;
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid var(--ok-bdr);
    border-radius: 3px;
    padding: 1px 5px;
    margin-right: 5px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════
   Dark mode  —  applied via [data-theme="dark"] on <html>
   ═══════════════════════════════════════════════════════════ */

[data-theme="dark"] {
    --bg:              #001117;                       /* deepest dark — page bg */
    --surface:         rgba(42, 47, 54, 0.96);        /* #2A2F36 — card surface */
    --surface-2:       rgba(20, 27, 34, 0.99);        /* #141B22 — deeper surface */
    --border:          rgba(136, 146, 154, 0.12);     /* #88929A @ 12% */
    --border-2:        rgba(136, 146, 154, 0.24);     /* #88929A @ 24% */
    --navy:            #000B0F;                       /* darker than #001117 */
    --navy-2:          #001117;
    --blue:            #C98A4C;
    --blue-2:          #D9A070;
    --blue-bg:         rgba(201, 138, 76, 0.12);
    --text:            #FFFFFF;
    --text-2:          rgba(255, 255, 255, 0.72);
    --text-3:          #88929A;
    --ok:              #40BF85;
    --ok-bg:           rgba(64, 191, 133, 0.10);
    --ok-bdr:          rgba(64, 191, 133, 0.26);
    --warn:            #D4A050;                       /* light amber, distinct from brand */
    --warn-bg:         rgba(212, 160, 80, 0.12);
    --warn-bdr:        rgba(212, 160, 80, 0.28);
    --err:             #E87070;
    --err-bg:          rgba(232, 112, 112, 0.10);
    --err-bdr:         rgba(232, 112, 112, 0.26);
    --shadow-sm:       0 1px 6px rgba(0, 0, 0, 0.52);
    --shadow-md:       0 4px 22px rgba(0, 0, 0, 0.68);
    color-scheme: dark;
}

[data-theme="dark"] .stream-card {
    background: transparent;
}

[data-theme="dark"] {
    --ask-input-fill:  rgba(20, 27, 34, 0.98);       /* #141B22 for input bg */
}

[data-theme="dark"] .steps-track {
    background: rgba(217, 160, 112, 0.12);
}

[data-theme="dark"] .stream-phase-icon[data-phase="researching"] { color: #C98A4C; }
[data-theme="dark"] .stream-phase-icon[data-phase="auditing"]    { color: #d4a040; }

[data-theme="dark"] .ask-bar-fixed {
    background: rgba(20, 27, 34, 0.97);            /* #141B22 */
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.50);
}

[data-theme="dark"] body {
    background:
        radial-gradient(ellipse at 8%  0%,  rgba(201, 138, 76, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 92% 100%, rgba(201, 138, 76, 0.05) 0%, transparent 50%),
        linear-gradient(160deg, #001117 0%, #121A20 55%, #0D1520 100%);
    background-attachment: fixed;
}

[data-theme="dark"] header {
    background: linear-gradient(135deg, #000B0F 0%, #001117 60%, #141B22 100%);
    border-bottom-color: rgba(136, 146, 154, 0.14);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

/* Form inputs */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: rgba(20, 27, 34, 0.96);
    color-scheme: dark;
}

[data-theme="dark"] .ask-input-row textarea {
    background: rgba(20, 27, 34, 0.96);
}

/* Misc surfaces */
[data-theme="dark"] .dropzone {
    background: rgba(20, 27, 34, 0.45);
}

[data-theme="dark"] .doc-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ── Passage funnel ──────────────────────────────────────────────────────── */
.passage-funnel {
    font-size: 0.74rem;
    padding: 0.45rem 0.75rem 0.5rem;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    margin-bottom: 0.5rem;
}
.funnel-row {
    display: grid;
    grid-template-columns: 6.5rem 1fr 2.2rem;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.funnel-label {
    color: var(--text-3);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.funnel-track {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.funnel-fill {
    height: 100%;
    width: 0%;
    background: var(--blue-2);
    border-radius: 3px;
    transition: width 0.55s cubic-bezier(.4,0,.2,1);
}
.funnel-fill--pending {
    background: var(--text-3);
    width: 28%;
    animation: funnel-pulse 1.3s ease-in-out infinite;
}
@keyframes funnel-pulse {
    0%, 100% { opacity: 0.35; }
    50%       { opacity: 0.85; }
}
.funnel-num {
    color: var(--text);
    font-weight: 600;
    font-size: 0.72rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
#passage-funnel-compact {
    font-size: 0.71rem;
    color: var(--text-3);
    letter-spacing: 0.01em;
    padding-top: 0.15rem;
}

[data-theme="dark"] .nav-dropdown-menu {
    background: #141B22;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.70);
    border-color: rgba(217, 160, 112, 0.22);
}
[data-theme="dark"] .nav-dropdown-item:hover {
    background: rgba(201, 138, 76, 0.12);
}

[data-theme="dark"] .ref-item {
    background: rgba(255, 255, 255, 0.04);
}

@keyframes ref-flash-dark {
    0%   { background: rgba(201, 138, 76, 0.22); border-left-color: var(--blue-2); }
    60%  { background: rgba(201, 138, 76, 0.10); }
    100% { background: rgba(255, 255, 255, 0.04); border-left-color: transparent; }
}
[data-theme="dark"] .ref-item--flash { animation: ref-flash-dark 1.1s ease forwards; }

[data-theme="dark"] .mode-btn {
    background: rgba(20, 27, 34, 0.80) !important;
}
[data-theme="dark"] .mode-btn:hover:not(:disabled) {
    background: rgba(28, 44, 74, 0.95) !important;
}

/* ── Slaagkans gauge ──────────────────────────────────────────────────────── */
.slaagkans-widget {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.75rem;
}
.slaagkans-ring-wrap {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}
.slaagkans-svg {
    width: 56px;
    height: 56px;
    transform: rotate(-90deg);
}
.slaagkans-fill {
    transition: stroke-dashoffset 0.85s cubic-bezier(.4,0,.2,1),
                stroke 0.4s ease;
}
.slaagkans-fill--warn { stroke: #f90 !important; }
.slaagkans-fill--err  { stroke: #e05 !important; }
.slaagkans-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.slaagkans-pct {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-1, #e8e8e8);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.slaagkans-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding-top: 0.1rem;
}
.slaagkans-title {
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--text-2, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.slaagkans-quality {
    font-size: 0.73rem;
    color: var(--text-1, #e8e8e8);
    line-height: 1.2;
}
.slaagkans-toelichting {
    font-size: 0.67rem;
    color: var(--text-3, #888);
    font-style: italic;
    line-height: 1.35;
    max-width: 20rem;
}

/* ── Slaagkans score breakdown ──────────────────────────────────────────── */
.slaagkans-breakdown { display: inline; }
.slaagkans-breakdown > summary { cursor: pointer; list-style: none; display: inline; }
.slaagkans-breakdown > summary::-webkit-details-marker { display: none; }
.slaagkans-breakdown-list {
    margin: 0.3rem 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--border);
    padding-top: 0.3rem;
}
.slaagkans-breakdown-row {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.73rem;
    color: var(--text-3, #888);
    line-height: 1.7;
}
.slaagkans-breakdown-delta {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 3.2rem;
    text-align: right;
    white-space: nowrap;
}
.slaagkans-breakdown-delta--pos { color: var(--ok,  #4caf7d); }
.slaagkans-breakdown-delta--neg { color: var(--err, #e05); }
.slaagkans-breakdown-total {
    display: flex;
    justify-content: flex-end;
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--text-1, #e8e8e8);
    border-top: 1px solid var(--border);
    margin-top: 0.15rem;
    padding-top: 0.2rem;
}

[data-theme="dark"] .conv-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .conv-rename-input {
    background: rgba(20, 27, 34, 0.96);
}

[data-theme="dark"] .conv-drawer-toggle,
[data-theme="dark"] .ref-drawer-toggle {
    background: rgba(20, 27, 34, 0.93) !important;
    box-shadow: 3px 2px 14px rgba(0, 0, 0, 0.50) !important;
}
[data-theme="dark"] .conv-drawer-toggle:hover,
[data-theme="dark"] .ref-drawer-toggle:hover {
    background: rgba(24, 38, 66, 1) !important;
}

[data-theme="dark"] .pinned-drawer-toggle {
    background: rgba(20, 27, 34, 0.93) !important;
    color: var(--text) !important;
    box-shadow: -3px 2px 14px rgba(0, 0, 0, 0.50) !important;
}

[data-theme="dark"] .pinned-drawer-toggle:hover {
    background: rgba(24, 38, 66, 1) !important;
    color: var(--blue-2) !important;
}

[data-theme="dark"] .nav-mode-btn {
    background: rgba(20, 27, 34, 0.60);
}
[data-theme="dark"] .nav-mode-btn:hover:not(:disabled) {
    background: rgba(28, 44, 74, 0.90);
}

[data-theme="dark"] .flag-input,
[data-theme="dark"] .flag-textarea {
    background: rgba(20, 27, 34, 0.96);
}

/* ── Theme toggle switch (settings page) ─────────────────── */

.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
}

.theme-toggle-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.theme-switch-slider {
    position: absolute;
    inset: 0;
    background: var(--border-2);
    border-radius: 24px;
    transition: background 0.22s;
}

.theme-switch-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.22s, background 0.22s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.20);
}

.theme-switch input:checked + .theme-switch-slider {
    background: var(--blue-2);
}

.theme-switch input:checked + .theme-switch-slider::before {
    transform: translateX(20px);
    background: #fff;
}

.theme-switch input:focus-visible + .theme-switch-slider {
    outline: 2px solid var(--blue-2);
    outline-offset: 2px;
}


/* ── Letter modal ────────────────────────────────────────── */

.app-modal-box--wide {
    max-width: 700px !important;
    padding: 24px 24px 18px !important;
}

.letter-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-2);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.letter-modal-close-x {
    background: transparent !important;
    border: none !important;
    color: var(--text-3) !important;
    font-size: 1rem !important;
    padding: 2px 6px !important;
    cursor: pointer;
    box-shadow: none !important;
    line-height: 1;
}
.letter-modal-close-x:hover { color: var(--text) !important; }

.letter-modal-warn {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--warn-bg);
    border: 1px solid var(--warn-bdr);
    border-radius: var(--r-sm);
    font-size: 0.80rem;
    color: var(--warn);
    line-height: 1.45;
}

.letter-modal-content {
    max-height: 62vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: #fff;
    margin-bottom: 16px;
    padding: 0;
}

/* ── Professional law firm letter ────────────────────────── */

.law-letter {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.88rem;
    color: #001117;
    padding: 32px 38px;
    line-height: 1.65;
    min-height: 100%;
}

.letter-loading {
    padding: 1rem;
    color: var(--text-muted);
}

.letter-error {
    color: var(--err);
}

.ll-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 2px solid #2A2F36;
}

.ll-head-right { text-align: right; }

.ll-firm {
    font-size: 0.80rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #001117;
    text-transform: uppercase;
    line-height: 1.4;
}

.ll-firm-sub {
    font-size: 0.70rem;
    font-weight: 400;
    color: #88929A;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    letter-spacing: 0.02em;
    text-transform: none;
}

.ll-badge {
    display: inline-block;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #92580a;
    border: 1px solid rgba(146,88,10,0.35);
    background: rgba(146,88,10,0.07);
    border-radius: 3px;
    padding: 2px 7px;
    text-transform: uppercase;
    margin-top: 4px;
}

.ll-meta {
    margin-bottom: 18px;
    font-size: 0.84rem;
    color: #2A2F36;
}

.ll-subject {
    margin-bottom: 16px;
    font-size: 0.86rem;
}
.ll-subject-label { font-weight: 700; }

.ll-greeting {
    margin-bottom: 18px;
    font-size: 0.88rem;
}

/* ── Letter paragraphs — three levels ───────────────────── */

.ll-para-l1 { margin-bottom: 18px; }
.ll-para-l2 { margin: 10px 0 10px 18px; }
.ll-para-l3 { margin: 6px 0 6px 36px; }

.ll-para-heading-l1 {
    font-size: 0.86rem;
    font-weight: 700;
    color: #001117;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.ll-para-heading-l2 {
    font-size: 0.84rem;
    font-weight: 700;
    color: #2A2F36;
    margin-bottom: 4px;
}

.ll-para-heading-l3 {
    font-size: 0.83rem;
    font-weight: 600;
    color: #001117;
    margin-bottom: 3px;
    font-style: italic;
}

.ll-body {
    white-space: pre-wrap;
    font-size: 0.86rem;
    color: #001117;
    line-height: 1.7;
    margin: 0;
}

.ll-body-sources {
    white-space: pre-wrap;
    font-size: 0.83rem;
    color: #2A2F36;
    line-height: 1.6;
    margin: 0;
}

.ll-rule {
    border: none;
    border-top: 1px solid rgba(42, 47, 54, 0.30);
    margin: 20px 0;
}

.ll-sign {
    margin-top: 24px;
    font-size: 0.86rem;
}

.ll-sign-name {
    font-weight: 700;
    color: #001117;
    margin-top: 18px;
}

.ll-disclaimer {
    margin-top: 16px;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    font-size: 0.70rem;
    color: #88929A;
    line-height: 1.5;
    border-top: 1px solid #e8edf5;
    padding-top: 10px;
}

[data-theme="dark"] .letter-modal-content    { background: #0f1e34; }
[data-theme="dark"] .law-letter              { color: #FFFFFF; }
[data-theme="dark"] .ll-firm                 { color: #D9A070; }
[data-theme="dark"] .ll-header               { border-bottom-color: #2A2F36; }
[data-theme="dark"] .ll-meta                 { color: #88929A; }
[data-theme="dark"] .ll-subject              { color: #FFFFFF; }
[data-theme="dark"] .ll-para-heading-l1      { color: #C98A4C; }
[data-theme="dark"] .ll-para-heading-l2      { color: #D9A070; }
[data-theme="dark"] .ll-para-heading-l3      { color: #C98A4C; }
[data-theme="dark"] .ll-body                 { color: #FFFFFF; }
[data-theme="dark"] .ll-body-sources         { color: #88929A; }
[data-theme="dark"] .ll-sign-name            { color: #D9A070; }

/* ── Password change modal ───────────────────────────────────────── */

.password-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 17, 23, 0.52);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

/* Ensure the hidden attribute is respected even with display:flex above */
.password-modal-overlay[hidden] { display: none !important; }

.password-modal {
    width: 100%;
    max-width: 360px;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 17, 23, 0.10), 0 1px 4px rgba(0, 17, 23, 0.06);
    overflow: hidden;
    background: #fff;
    position: relative;
}

.password-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    border-radius: 8px;
    transition: color 0.12s, background 0.12s;
    z-index: 2;
}

.password-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .password-modal { background: var(--surface); }

.password-modal-card-header {
    background: linear-gradient(135deg, #001117 0%, #2A2F36 100%);
    padding: 26px 28px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.password-modal-mark {
    width: 62px;
    height: 62px;
    object-fit: contain;
}

.password-modal-brand-name {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
}

.password-modal-brand-name span {
    font-variant: small-caps;
    font-size: 0.72em;
    font-weight: 400;
    opacity: 0.70;
    letter-spacing: 0.08em;
}

.password-modal-brand-tagline {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-align: center;
}

.password-modal-card-body {
    padding: 26px 28px 28px;
}

.password-modal-card-body h2 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: #001117;
}

.password-modal-intro {
    margin: 0 0 14px;
    font-size: 13px;
    color: #88929A;
    line-height: 1.5;
}

.password-modal-field {
    margin-bottom: 12px;
}

.password-modal-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #2A2F36;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.password-modal-field input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.password-modal-field input[type="password"]:focus {
    border-color: #2A2F36;
}

.password-modal-save {
    margin-top: 8px;
    width: 100%;
    padding: 11px;
    background: #001117;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.password-modal-save:hover {
    background: #2A2F36;
}

.modal-status {
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.modal-status--ok {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.modal-status--err {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}
[data-theme="dark"] .ll-disclaimer           { color: #88929A; border-top-color: #2A2F36; }

/* ── Library redesign (v35) ──────────────────────────────────────────────── */

/* Cascade selector section */
.lib-source-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 14px;
}

.lib-cascade {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.lib-cascade-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lib-cascade-row label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    min-width: 72px;
    flex-shrink: 0;
}

.lib-cascade-row[hidden] { display: none !important; }

.lib-cascade select {
    flex: 1;
    padding: 7px 10px;
    border: 1.5px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.86rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.14s;
}

.lib-cascade select:focus { border-color: var(--blue); }
.lib-cascade select:disabled { opacity: 0.5; cursor: default; }

.lib-cascade-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-left: 98px;
}

.lib-bulk-load-btn {
    background: transparent !important;
    color: var(--text-2) !important;
    border: 1.5px dashed var(--border-2) !important;
    font-size: 0.82rem !important;
    padding: 6px 14px !important;
    border-radius: var(--r-sm);
    cursor: pointer;
}
.lib-bulk-load-btn:hover { background: var(--surface-2) !important; }

/* Corpus management collapsed panel */
.lib-corpus-manage {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    margin-top: 14px;
    background: var(--surface-2);
}
.lib-corpus-manage > summary {
    padding: 8px 12px;
    font-size: 0.82rem;
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.lib-corpus-manage > summary::-webkit-details-marker { display: none; }
.lib-corpus-manage > summary::before { content: '▶ '; font-size: 0.7rem; }
.lib-corpus-manage[open] > summary::before { content: '▼ '; }
.lib-cm-list { padding: 4px 8px 8px; }
.lib-cm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    border-bottom: 1px solid var(--border);
}
.lib-cm-row:last-child { border-bottom: none; }
.lib-cm-name {
    flex: 1;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    min-width: 0;
}

/* Index status badge — clickable when red (retry) */
.lib-idx-btn {
    background: none;
    border: none;
    padding: 0 2px;
    font-size: 0.82rem;
    line-height: 1;
    cursor: default;
    flex-shrink: 0;
}
.lib-idx-btn.lib-idx-retry {
    cursor: pointer;
    border-radius: 3px;
}
.lib-idx-btn.lib-idx-retry:hover { background: rgba(200, 60, 60, 0.08); }

/* Trash button — hidden until row hover */
.lib-cm-del {
    background: none;
    border: none;
    padding: 3px 4px;
    border-radius: 4px;
    color: var(--text-3);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.lib-cm-row:hover .lib-cm-del { opacity: 1; }
.lib-cm-del:hover { color: var(--red, #c0392b); }

.lib-stub-msg {
    margin-left: 98px;
    font-size: 0.83rem;
    color: var(--text-3);
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

/* Direct input */
.lib-direct-input { margin: 4px 0 14px; }

.lib-or-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-3);
    font-size: 0.78rem;
    margin: 0 0 8px;
}
.lib-or-divider::before, .lib-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Popular chips */
.lib-popular {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
}

.lib-popular-label {
    font-size: 0.78rem;
    color: var(--text-3);
    font-weight: 600;
}

.lib-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    border: 1.5px solid var(--border-2);
    background: var(--surface-2);
    color: var(--navy);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.lib-chip:hover {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* Custom link details */
.lib-add-link {
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0;
    margin-bottom: 10px;
    background: var(--surface-2);
}
.lib-add-link summary {
    padding: 7px 12px;
    font-size: 0.82rem;
    color: var(--blue);
    cursor: pointer;
    font-weight: 600;
    user-select: none;
}
.lib-add-link-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
}
.lib-add-link-form input {
    flex: 1;
    min-width: 140px;
    padding: 6px 9px;
    border: 1.5px solid var(--border-2);
    border-radius: var(--r-sm);
    font-size: 0.84rem;
    background: var(--surface);
    color: var(--text);
}

.lib-status-msg {
    font-size: 0.81rem;
    color: var(--text-2);
    padding: 4px 0;
}

.lib-runtime-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.lib-runtime-toggle-help {
    font-size: 0.78rem;
    color: var(--text-3);
    line-height: 1.35;
}

/* Jurisdiction filter pills */
.lib-jur-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.lib-jur-pill {
    padding: 3px 11px;
    border-radius: 999px;
    border: 1.5px solid var(--border-2);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.lib-jur-pill.active, .lib-jur-pill:hover {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* Multi-jurisdiction notice banner */
.lib-multi-jur-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--blue-bg);
    border: 1px solid rgba(201, 138, 76,0.18);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    font-size: 0.80rem;
    color: var(--blue);
    margin-bottom: 8px;
}
.lib-multi-jur-banner[hidden] { display: none !important; }
.lib-banner-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

/* List header (count + export) */
.lib-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.lib-list-header[hidden] { display: none !important; }
.lib-loaded-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-2);
}
.lib-export-wrap { position: relative; }
.lib-export-btn {
    background: none;
    border: 1.5px solid var(--border-2);
    border-radius: var(--r-sm);
    padding: 3px 10px;
    font-size: 0.78rem;
    color: var(--text-2);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.12s, color 0.12s;
}
.lib-export-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.lib-export-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1.5px solid var(--border-2);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow);
    z-index: 50;
    min-width: 80px;
    overflow: hidden;
}
.lib-export-menu[hidden] { display: none !important; }
.lib-export-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 12px;
    font-size: 0.82rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
}
.lib-export-menu button:hover { background: var(--blue-bg); color: var(--navy); }

/* Enhanced document row */
.lib-doc-row {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
    transition: background 0.1s;
}
.lib-doc-row:last-child { border-bottom: none; }
.lib-doc-row[hidden] { display: none !important; }

.lib-doc-main {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: var(--r-sm);
    transition: background 0.1s;
}
.lib-doc-main:hover { background: var(--surface-2); }

.lib-doc-flag {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.lib-doc-freshness {
    font-size: 0.74rem;
    color: var(--text-3);
    display: block;
}

.lib-doc-outdated {
    color: var(--warn);
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 4px;
}

.lib-doc-index-badge {
    font-size: 0.72rem;
    margin-left: auto;
    flex-shrink: 0;
    cursor: default;
}

.lib-doc-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    justify-content: flex-end;
    padding: 2px 0 0;
}

.lib-doc-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 2px 5px;
    color: var(--text-3);
    border-radius: var(--r-sm);
    transition: color 0.12s;
    line-height: 1;
}
.lib-doc-star-btn:hover, .lib-doc-star-btn.lib-starred { color: #f59e0b; }

.lib-doc-refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.88rem;
    padding: 2px 5px;
    color: var(--text-3);
    border-radius: var(--r-sm);
    transition: color 0.12s, transform 0.2s;
    line-height: 1;
}
.lib-doc-refresh-btn:hover { color: var(--blue); transform: rotate(180deg); }

/* Indexing progress waitbar */
.lib-index-progress {
    height: 3px;
    border-radius: 99px;
    background: linear-gradient(90deg, transparent 0%, var(--blue) 40%, var(--blue-2) 60%, transparent 100%);
    background-size: 200% 100%;
    animation: lib-progress-slide 1.4s linear infinite;
    margin: 2px 4px 0;
}
.lib-index-progress[hidden] { display: none !important; }

@keyframes lib-progress-slide {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* Document detail expand */
.lib-doc-expand {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    margin: 4px 4px 2px;
    font-size: 0.80rem;
}
.lib-doc-expand[hidden] { display: none !important; }

.lib-detail-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    margin: 0;
}
.lib-detail-dl dt {
    color: var(--text-3);
    font-weight: 600;
    white-space: nowrap;
}
.lib-detail-dl dd {
    color: var(--text);
    margin: 0;
    word-break: break-all;
}

/* Narrow loader card */
.lib-loader-card {
    max-width: 520px;
    padding: 14px 18px;
}

/* Flag badge in jurisdiction row */
.lib-jur-flag {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
    width: 1.5em;
    text-align: center;
    user-select: none;
}

/* Dark mode overrides */
[data-theme="dark"] .lib-cascade select { background: var(--surface); color: var(--text); }
[data-theme="dark"] .lib-chip { background: var(--surface); }
[data-theme="dark"] .lib-add-link { background: var(--surface); }
[data-theme="dark"] .lib-doc-expand { background: var(--surface); }
[data-theme="dark"] .lib-export-menu { background: var(--surface); }

/* ── Global index top-bar ────────────────────────────────────────────────── */
#index-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    background: var(--border);
}

#index-top-bar.index-top-bar--active { opacity: 1; }

#index-top-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--blue) 0%, var(--blue-2) 70%, #D9A070 100%);
    border-radius: 0 2px 2px 0;
}

#index-top-eta {
    position: fixed;
    top: 6px;
    right: 12px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--blue-2);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 4px;
    padding: 1px 6px;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-sm);
}

/* ── Corpus-manage profile tabs ─────────────────────────────────────────── */
.lib-cm-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 8px 5px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.lib-cm-tab {
    font-size: 0.73rem !important;
    font-weight: 600 !important;
    padding: 3px 9px !important;
    border-radius: var(--r-sm) !important;
    border: 1px solid var(--border-2) !important;
    background: transparent !important;
    color: var(--text-2) !important;
    cursor: pointer !important;
    transition: background 0.12s, color 0.12s, border-color 0.12s !important;
    white-space: nowrap;
    box-shadow: none !important;
    line-height: 1.6 !important;
}

.lib-cm-tab:hover {
    background: var(--blue-bg) !important;
    color: var(--blue) !important;
    border-color: rgba(201, 138, 76, 0.28) !important;
}

.lib-cm-tab--active {
    background: var(--blue-bg) !important;
    color: var(--blue) !important;
    border-color: var(--blue) !important;
}

/* Profile view rows */
.lib-cm-profile-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 2px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

.lib-cm-profile-row:last-child { border-bottom: none; }

.lib-cm-profile-row--missing { opacity: 0.55; }

.lib-cm-profile-status {
    font-size: 0.82rem;
    flex-shrink: 0;
    width: 1.5em;
    text-align: center;
    line-height: 1;
}

.lib-cm-profile-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.lib-cm-load-btn {
    font-size: 0.74rem !important;
    padding: 2px 9px !important;
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: auto;
    box-shadow: none !important;
    line-height: 1.6 !important;
}

/* ── Button dark-mode fix ────────────────────────────────────────────────── */
/* Default button uses color:var(--navy) which is #000B0F in dark mode —
   near-black on a dark surface. Override with readable token colors.       */
/* Dark-mode button override — must include ALL :not() exclusions that the
   base light-mode rule has (plus the [data-theme] attribute selector) so
   this rule wins the specificity battle against the base rule. Missing any
   :not() clause reduces specificity and lets the navy-colored base rule win. */
[data-theme="dark"] button[type="submit"],
[data-theme="dark"] button[type="button"]:not(.remove-cross):not(.lib-source-tab):not(.corpus-filter-toggle):not(.nav-mode-btn):not(.btn-danger-sm):not(.add-doc-btn):not(.conv-drawer-toggle):not(.ref-drawer-toggle):not(.pinned-drawer-toggle):not(.app-modal-btn):not(.home-sidebar-close):not(.approve-trigger-btn):not(.nav-icon-btn):not(.nav-avatar-btn):not(.ask-send-btn):not(.password-modal-close):not(.lib-chip):not(.lib-jur-pill):not(.lib-doc-star-btn):not(.lib-doc-refresh-btn):not(.lib-export-btn):not(.lib-banner-close):not(.lib-bulk-load-btn):not(.lib-cm-del):not(.lib-idx-btn):not(.conv-search-menu-btn):not(.doc-expand-btn):not(.conv-turn-toggle) {
    color: var(--text);
    border-color: var(--border-2);
    background: transparent;
}

[data-theme="dark"] button[type="submit"]:hover,
[data-theme="dark"] button[type="button"]:not(.remove-cross):not(.lib-source-tab):not(.corpus-filter-toggle):not(.nav-mode-btn):not(.btn-danger-sm):not(.add-doc-btn):not(.conv-drawer-toggle):not(.ref-drawer-toggle):not(.pinned-drawer-toggle):not(.app-modal-btn):not(.home-sidebar-close):not(.approve-trigger-btn):not(.nav-icon-btn):not(.nav-avatar-btn):not(.ask-send-btn):not(.password-modal-close):not(.lib-chip):not(.lib-jur-pill):not(.lib-doc-star-btn):not(.lib-doc-refresh-btn):not(.lib-export-btn):not(.lib-banner-close):not(.lib-bulk-load-btn):not(.lib-cm-del):not(.lib-idx-btn):not(.conv-search-menu-btn):not(.doc-expand-btn):not(.conv-turn-toggle):hover {
    background: rgba(201, 138, 76, 0.14);
    color: var(--blue-2);
    border-color: rgba(201, 138, 76, 0.40);
    box-shadow: none;
}

/* Dark mode — pricing / subscription cards */
[data-theme="dark"] .pricing-card {
    border-color: var(--border-2);
    background: var(--surface);
}
[data-theme="dark"] .pricing-card:hover {
    border-color: var(--vf-orange);
}
[data-theme="dark"] .pricing-card--featured {
    border-color: var(--vf-orange);
    background: rgba(42, 47, 54, 0.80);
}
[data-theme="dark"] .pricing-card__name,
[data-theme="dark"] .pricing-card__amount,
[data-theme="dark"] .pricing-card__desc strong {
    color: var(--text);
}
[data-theme="dark"] .pricing-card__desc,
[data-theme="dark"] .pricing-card__period,
[data-theme="dark"] .pricing-card__billing-note {
    color: var(--text-3);
}
[data-theme="dark"] .pricing-team-label {
    color: var(--text-2);
}
[data-theme="dark"] .pricing-card__features li {
    color: var(--text-2);
}
[data-theme="dark"] .pricing-card__features li::before {
    color: var(--vf-orange);
}
[data-theme="dark"] .pricing-stepper {
    border-color: var(--border-2);
}
[data-theme="dark"] .pricing-stepper-btn {
    background: rgba(42, 47, 54, 0.60);
    color: var(--text);
}
[data-theme="dark"] .pricing-stepper-btn:hover {
    background: rgba(42, 47, 54, 0.90);
}
[data-theme="dark"] .pricing-stepper-input {
    background: transparent;
    border-color: var(--border-2);
    color: var(--text);
}
[data-theme="dark"] .pricing-card__btn {
    background: var(--vf-orange);
    color: #001117;
    border: none;
}
[data-theme="dark"] .pricing-card__btn:hover {
    background: var(--vf-orange-2);
}
[data-theme="dark"] .pricing-card__btn--featured {
    background: var(--vf-orange);
}
[data-theme="dark"] .pricing-card__btn--featured:hover {
    background: var(--vf-orange-2);
}

/* ── Trial banner ────────────────────────────────────────────────────────── */
.trial-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0;
    border-bottom: 1px solid transparent;
}
.trial-banner a { font-weight: 600; text-decoration: underline; }
.trial-banner--info {
    background: rgba(201, 138, 76, 0.06);
    border-color: rgba(201, 138, 76, 0.28);
    color: #C98A4C;
}
.trial-banner--info a { color: #C98A4C; }
.trial-banner--warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}
.trial-banner--warning a { color: #b45309; }
.trial-banner--urgent {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}
.trial-banner--urgent a { color: #b91c1c; }
[data-theme="dark"] .trial-banner--info    { background: rgba(201, 138, 76,0.18); border-color: rgba(217, 160, 112,0.3); color: #D9A070; }
[data-theme="dark"] .trial-banner--warning { background: rgba(146,64,14,0.18); border-color: rgba(253,230,138,0.3); color: #fde68a; }
[data-theme="dark"] .trial-banner--urgent  { background: rgba(153,27,27,0.18); border-color: rgba(252,165,165,0.3); color: #fca5a5; }

/* ── Role badges ─────────────────────────────────────────────────────────── */
.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.role-badge--admin {
    background: rgba(201, 138, 76, 0.10);
    color: #C98A4C;
    border: 1px solid rgba(201, 138, 76, 0.28);
}
.role-badge--user {
    background: #f3f4f6;
    color: #2A2F36;
    border: 1px solid #e5e7eb;
}
[data-theme="dark"] .role-badge--admin { background: rgba(201, 138, 76,0.25); color: #D9A070; border-color: rgba(217, 160, 112,0.3); }
[data-theme="dark"] .role-badge--user  { background: rgba(75,85,99,0.25);  color: #d1d5db; border-color: rgba(209,213,219,0.2); }

/* ── Contract info block (settings account card) ────────────────────────── */
.contract-info-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.contract-info-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.contract-info-price {
    font-size: 13px;
    color: #2A2F36;
    font-weight: 500;
}
.contract-info-expires {
    font-size: 12px;
    color: #88929A;
}
[data-theme="dark"] .contract-info-price { color: #d1d5db; }
[data-theme="dark"] .contract-info-expires { color: #9ca3af; }

/* ── Status badges (active/suspended) ───────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.status-badge--active    { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.status-badge--suspended { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
[data-theme="dark"] .status-badge--active    { background: rgba(21,128,61,0.2);  color: #86efac; border-color: rgba(134,239,172,0.3); }
[data-theme="dark"] .status-badge--suspended { background: rgba(185,28,28,0.2);  color: #fca5a5; border-color: rgba(252,165,165,0.3); }

/* ── Contract badges ─────────────────────────────────────────────────────── */
.contract-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: #f3f4f6;
    color: #88929A;
    border: 1px solid #e5e7eb;
}
.contract-badge--paid { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
[data-theme="dark"] .contract-badge      { background: rgba(75,85,99,0.25);  color: #9ca3af; border-color: rgba(156,163,175,0.2); }
[data-theme="dark"] .contract-badge--paid { background: rgba(109,40,217,0.2); color: #c4b5fd; border-color: rgba(196,181,253,0.3); }

/* ── User management table ───────────────────────────────────────────────── */
.settings-section--wide { grid-column: 1 / -1; }
.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.settings-section-header h2 { margin-bottom: 0; }
.user-table-wrap {
    overflow-x: auto;
    margin-top: 12px;
    border: 1px solid var(--border-1, #e5e7eb);
    border-radius: 8px;
}
.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.user-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #88929A);
    background: var(--surface-2, #f9fafb);
    border-bottom: 1px solid var(--border-1, #e5e7eb);
    white-space: nowrap;
}
.user-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-1, #e5e7eb);
    vertical-align: middle;
    color: var(--text, #111827);
}
.user-table tr:last-child td { border-bottom: none; }
.user-table tr:hover td { background: var(--surface-2, #f9fafb); }
.user-table-loading { text-align: center; color: var(--text-muted, #9ca3af); padding: 20px !important; }
.tokens-cell { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12px; }
.actions-cell { white-space: nowrap; }

/* ── Action buttons (table) ──────────────────────────────────────────────── */
.btn-action {
    padding: 3px 10px;
    border: 1.5px solid var(--border-1, #e5e7eb);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: transparent;
    color: var(--text, #2A2F36);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.btn-action:hover { background: var(--surface-2, #f3f4f6); }
.btn-action--warn { color: #b45309; border-color: #fde68a; }
.btn-action--warn:hover { background: #fffbeb; }
.btn-action--danger { color: #b91c1c; border-color: #fecaca; }
.btn-action--danger:hover { background: #fef2f2; }

/* ── Secondary button (small) ────────────────────────────────────────────── */
.btn-secondary--sm {
    font-size: 12px !important;
    padding: 5px 12px !important;
}

/* ── Audit log ───────────────────────────────────────────────────────────── */
.audit-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0 12px;
}
.audit-summary::-webkit-details-marker { display: none; }
.audit-summary::before {
    content: '▶';
    font-size: 10px;
    color: var(--text-muted, #9ca3af);
    transition: transform 0.15s;
}
details[open] .audit-summary::before { transform: rotate(90deg); }
.audit-summary-hint {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    margin-left: 4px;
}
.audit-table-wrap {
    margin-top: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-1, #e5e7eb);
    border-radius: 8px;
}


/* ── Admin documentation page ─────────────────────────────────────────────── */
.admin-docs-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.admin-docs-tab {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid var(--border, #d5d0c8);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text, #2b2b2b);
    background: transparent;
}
.admin-docs-tab--active {
    background: var(--accent, #20608c);
    border-color: var(--accent, #20608c);
    color: #fff;
}
.admin-docs-content {
    line-height: 1.65;
    font-size: 0.93rem;
    overflow-wrap: break-word;
}
.admin-docs-content h1 { font-size: 1.5rem; margin: 0 0 14px; }
.admin-docs-content h2 { font-size: 1.2rem; margin: 28px 0 10px; padding-top: 14px; border-top: 1px solid var(--border, #e2ddd4); }
.admin-docs-content h3 { font-size: 1.02rem; margin: 20px 0 8px; }
.admin-docs-content h4 { font-size: 0.95rem; margin: 16px 0 6px; }
.admin-docs-content p, .admin-docs-content ul, .admin-docs-content ol { margin: 0 0 10px; }
.admin-docs-content li { margin: 3px 0; }
.admin-docs-content code {
    background: rgba(120, 110, 90, 0.10);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.85em;
}
.admin-docs-content pre {
    background: rgba(120, 110, 90, 0.08);
    border: 1px solid var(--border, #e2ddd4);
    border-radius: 6px;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.5;
}
.admin-docs-content pre code { background: none; padding: 0; }
.admin-docs-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0 16px;
    font-size: 0.86rem;
    display: block;
    overflow-x: auto;
}
.admin-docs-content th, .admin-docs-content td {
    border: 1px solid var(--border, #d5d0c8);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.admin-docs-content th { background: rgba(120, 110, 90, 0.08); font-weight: 700; }
.admin-docs-content blockquote {
    border-left: 3px solid var(--accent, #20608c);
    margin: 10px 0;
    padding: 4px 14px;
    opacity: 0.9;
}
.admin-docs-content hr { border: none; border-top: 1px solid var(--border, #e2ddd4); margin: 22px 0; }
[data-theme="dark"] .admin-docs-content code,
[data-theme="dark"] .admin-docs-content pre,
[data-theme="dark"] .admin-docs-content th { background: rgba(255, 255, 255, 0.07); }
