/* ============================================================================
   Legal-Reviewer — Editorial Law design system
   Hand-rolled. No Tailwind. No utility classes leaking from elsewhere.
   ----------------------------------------------------------------------------
   Aesthetic: warm-paper background, ink-blue text, oxblood accent.
   Typography: Fraunces (display serif) + IBM Plex Sans (UI) + IBM Plex Mono.
   ============================================================================ */

/* ── Reset & box model ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: inherit; }
p { margin: 0; }
table { border-collapse: collapse; width: 100%; }

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
    /* Palette — warm paper / ink / oxblood */
    --paper: #fbfaf6;
    --paper-tint: #f4f0e6;
    --paper-deep: #ece6d6;
    --hairline: #d8d2c2;
    --hairline-soft: #e8e3d4;

    --ink: #1a1d24;
    --ink-soft: #3a3f4a;
    --ink-mute: #6b6f78;
    --ink-faint: #9a9da3;

    --accent: #7a1f2b;          /* oxblood — brand mark, primary CTA */
    --accent-deep: #5a1522;
    --accent-soft: #f5e8ea;     /* oxblood tinted */

    --gold: #a86a1f;            /* warnings, "unverified" tags */
    --gold-soft: #f7eddb;
    --forest: #2a5a3d;          /* success / validated */
    --forest-soft: #e6f0e8;
    --burgundy: #5a1822;        /* errors */
    --burgundy-soft: #f3e1e3;

    /* Citation kind tints (subdued, on warm paper) */
    --cite-doc-bg: #e8eef8;     --cite-doc-fg: #1e3a6b;
    --cite-cuad-bg: #efe6f3;    --cite-cuad-fg: #4a2566;
    --cite-case-bg: #e3eee5;    --cite-case-fg: #1f4a2d;
    --cite-statute-bg: #f5ecd7; --cite-statute-fg: #6a4b13;
    --cite-market-bg: #f7e2eb;  --cite-market-fg: #7a2350;
    --cite-trust-bg: #f5ddc8;   --cite-trust-fg: #7a3a14;
    --cite-template-bg: #d8ecf3; --cite-template-fg: #155069;

    /* Typography stacks */
    --font-display: "Fraunces", "Iowan Old Style", "Apple Garamond", Garamond, Cambria, Georgia, serif;
    --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
    --font-mono: "IBM Plex Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;

    /* Type scale (clamp for fluidity) */
    --fs-display: clamp(2.2rem, 1.6rem + 2.4vw, 3.4rem);
    --fs-h1: clamp(1.65rem, 1.4rem + 1vw, 2.1rem);
    --fs-h2: 1.35rem;
    --fs-h3: 1.1rem;
    --fs-body: 0.97rem;
    --fs-small: 0.86rem;
    --fs-micro: 0.74rem;
    --fs-data: 0.82rem;

    /* Layout */
    --rhythm: 1.5rem;
    --rhythm-tight: 0.85rem;
    --radius: 4px;
    --radius-lg: 8px;
    --gutter: clamp(1.25rem, 2vw + 0.5rem, 2.5rem);
    --shell-max: 1180px;
    --shadow-soft: 0 1px 2px rgba(26, 29, 36, 0.04), 0 6px 22px -10px rgba(26, 29, 36, 0.10);
    --shadow-medium: 0 2px 4px rgba(26, 29, 36, 0.06), 0 16px 36px -16px rgba(26, 29, 36, 0.18);
}

/* ── Body / page chrome ─────────────────────────────────────────────────── */
body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--fs-body);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Very faint paper grain */
    background-image:
        radial-gradient(rgba(122, 31, 43, 0.012) 1px, transparent 1px),
        radial-gradient(rgba(26, 29, 36, 0.018) 1px, transparent 1px);
    background-size: 22px 22px, 31px 31px;
    background-position: 0 0, 11px 15px;
}

/* ── Top navigation ─────────────────────────────────────────────────────── */
.site-nav {
    border-bottom: 1px solid var(--hairline);
    background: var(--paper);
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
}
.nav-inner {
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 0.95rem var(--gutter);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 2rem;
}
.brand {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    display: inline-flex;
    align-items: baseline;
    gap: 0.55rem;
}
.brand .mark {
    color: var(--accent);
    font-size: 1.7rem;
    font-style: italic;
    font-weight: 600;
    line-height: 1;
    position: relative;
    top: 0.15em;
}
.brand .wordmark {
    line-height: 1;
}
.brand .wordmark em {
    font-style: italic;
    font-weight: 400;
    color: var(--ink-soft);
}

.nav-primary {
    display: flex;
    gap: 1.5rem;
    margin-left: 1rem;
    font-size: var(--fs-small);
    color: var(--ink-mute);
    align-items: baseline;
}
.nav-primary a {
    position: relative;
    padding-bottom: 0.1rem;
    transition: color 120ms ease;
}
.nav-primary a:hover,
.nav-primary a.is-current {
    color: var(--ink);
}
.nav-primary a.is-current::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -0.95rem;
    height: 2px;
    background: var(--accent);
}

.nav-utility {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: var(--fs-small);
    color: var(--ink-mute);
}
.nav-utility a:hover { color: var(--ink); }
/* P4.10 — logout is now a POST form; btn-link makes the button look like a nav link */
.btn-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--ink-mute);
    cursor: pointer;
    font-size: var(--fs-small);
}
.btn-link:hover { color: var(--ink); }

/* ── Shell + page heading ───────────────────────────────────────────────── */
.shell {
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 2rem var(--gutter) 4rem;
}
.shell--wide { max-width: 1320px; }
.shell--narrow { max-width: 540px; }

.page-head {
    margin-bottom: 1.6rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-head .eyebrow {
    font-family: var(--font-ui);
    font-size: var(--fs-micro);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 500;
}
.page-head h1 {
    font-family: var(--font-display);
    font-size: var(--fs-h1);
    font-weight: 500;
    letter-spacing: -0.015em;
    line-height: 1.05;
    color: var(--ink);
    font-variation-settings: "opsz" 72;
}
.page-head .lead {
    color: var(--ink-mute);
    font-size: var(--fs-small);
    margin-top: 0.4rem;
    max-width: 56ch;
}

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash-stack {
    max-width: var(--shell-max);
    margin: 1.25rem auto 0;
    padding: 0 var(--gutter);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.flash {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    font-size: var(--fs-small);
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.flash::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-top: 0.55em;
    flex-shrink: 0;
}
.flash--success { background: var(--forest-soft); border-color: #c7d8c9; color: var(--forest); }
.flash--success::before { background: var(--forest); }
.flash--error { background: var(--burgundy-soft); border-color: #dcc2c4; color: var(--burgundy); }
.flash--error::before { background: var(--burgundy); }
.flash--neutral { background: var(--paper-tint); border-color: var(--hairline); color: var(--ink-soft); }
.flash--neutral::before { background: var(--ink-mute); }

/* ── Card / panel ───────────────────────────────────────────────────────── */
.panel {
    background: #ffffff;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 1.6rem 1.7rem;
    box-shadow: var(--shadow-soft);
}
.panel--tight { padding: 1.1rem 1.2rem; }

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline-soft);
}
.panel-head .section-marker {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    color: var(--accent);
    font-size: 1.4rem;
    line-height: 1;
    margin-right: 0.4rem;
    display: inline-block;
    transform: translateY(2px);
}
.panel-head h2 {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.005em;
    display: flex;
    align-items: baseline;
}
.panel-head .lead {
    font-size: var(--fs-small);
    color: var(--ink-mute);
    margin-top: 0.25rem;
    max-width: 52ch;
}

/* ── Form primitives ────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: var(--rhythm-tight); }
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}
@media (max-width: 540px) {
    .field-row { grid-template-columns: 1fr; }
}
.field-label {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--fs-micro);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-mute);
    font-weight: 500;
    margin-bottom: 0.35rem;
}
.input,
.select,
.textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    color: var(--ink);
    font-size: var(--fs-body);
    transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(122, 31, 43, 0.12);
}
.input::placeholder,
.textarea::placeholder { color: var(--ink-faint); }
.input--mono { font-family: var(--font-mono); font-size: 0.9rem; }

.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5l5 5 5-5' stroke='%236b6f78' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 1.8rem;
}

/* Segment buttons (for intent + sensitivity choice) */
.segment {
    display: inline-flex;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--paper);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px transparent;
}
.segment label {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.95rem;
    font-size: var(--fs-small);
    color: var(--ink-soft);
    cursor: pointer;
    border-right: 1px solid var(--hairline);
    transition: background 120ms ease, color 120ms ease;
    user-select: none;
}
.segment label:last-child { border-right: none; }
.segment input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.segment label:hover { background: var(--paper-tint); color: var(--ink); }
.segment input[type="radio"]:checked + span,
.segment label:has(input[type="radio"]:checked) {
    background: var(--ink);
    color: var(--paper);
}
.segment label:focus-within {
    box-shadow: 0 0 0 3px rgba(122, 31, 43, 0.18);
    border-radius: var(--radius);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: var(--fs-small);
    font-weight: 500;
    line-height: 1;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform 80ms ease;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-secondary {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--hairline);
}
.btn-secondary:hover { background: var(--paper-tint); border-color: var(--ink-mute); }
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--paper-tint); color: var(--ink); }
.btn-ink {
    background: var(--ink);
    color: var(--paper);
}
.btn-ink:hover { background: #000; }
.btn--lg { padding: 0.75rem 1.4rem; font-size: var(--fs-body); }
.btn--sm { padding: 0.4rem 0.7rem; font-size: var(--fs-micro); }

/* ── Drop zone ──────────────────────────────────────────────────────────── */
.drop-zone {
    position: relative;
    border: 2px dashed var(--hairline);
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 14px,
            rgba(122, 31, 43, 0.018) 14px,
            rgba(122, 31, 43, 0.018) 16px
        ),
        var(--paper);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}
.drop-zone:hover {
    border-color: var(--accent);
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 14px,
            rgba(122, 31, 43, 0.04) 14px,
            rgba(122, 31, 43, 0.04) 16px
        ),
        var(--paper);
}
.drop-zone--active {
    border-color: var(--accent);
    background: rgba(122, 31, 43, 0.04);
    border-style: solid;
}
.drop-zone .glyph {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--accent);
    font-size: 2rem;
    line-height: 1;
    display: block;
    margin-bottom: 0.5rem;
}
.drop-zone .primary-text {
    color: var(--ink);
    font-size: 1rem;
    margin-bottom: 0.3rem;
    font-family: var(--font-display);
    font-weight: 500;
}
.drop-zone .secondary-text {
    color: var(--ink-mute);
    font-size: var(--fs-small);
}
.drop-zone .filename {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
    word-break: break-all;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* ── Tags / chips / badges ──────────────────────────────────────────────── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: var(--fs-micro);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--paper-tint);
    color: var(--ink-soft);
    font-weight: 500;
    border: 1px solid var(--hairline-soft);
}
.tag--accent { background: var(--accent-soft); color: var(--accent); border-color: #e6cdd0; }
.tag--forest { background: var(--forest-soft); color: var(--forest); border-color: #c7d8c9; }
.tag--gold { background: var(--gold-soft); color: var(--gold); border-color: #e8d8b8; }
.tag--ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.route-tag {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--paper-tint);
    color: var(--ink-soft);
    border: 1px solid var(--hairline-soft);
    text-transform: none;
    letter-spacing: 0;
}
.route-tag--subscription { color: #1e3a6b; background: var(--cite-doc-bg); border-color: #c7d3e8; }
.route-tag--baa-direct { color: #4a2566; background: var(--cite-cuad-bg); border-color: #d7cadd; }
.route-tag--baa-platform { color: #1f4a2d; background: var(--cite-case-bg); border-color: #c7d6c9; }
.route-tag--openrouter { color: var(--gold); background: var(--gold-soft); border-color: #e8d8b8; }
.route-tag--fallback::after { content: "*"; margin-left: 1px; color: var(--accent); }

/* ── Tables (used by contracts.html) ────────────────────────────────────── */
.data-table {
    font-size: var(--fs-data);
}
.data-table thead th {
    text-align: left;
    font-size: var(--fs-micro);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-mute);
    font-weight: 500;
    padding: 0 0.8rem 0.55rem;
    border-bottom: 1px solid var(--hairline);
}
.data-table tbody td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--hairline-soft);
    vertical-align: top;
    color: var(--ink-soft);
}
.data-table tbody tr:hover td { background: var(--paper-tint); }
.data-table tbody tr.data-row--link { cursor: pointer; }
.data-table tbody tr.data-row--link:focus-visible { outline: 2px solid var(--accent, #7a1f2b); outline-offset: -2px; }
.data-table .mono { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink); }
.data-table a.mono { text-decoration: none; }
.data-table a.mono:hover { text-decoration: underline; }

/* --- Jurisdiction multi-select picker (shared: New Project modal + chat) --- */
.jp { position: relative; }
.jp__chips {
    display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.35rem; min-height: 1.4rem;
}
.jp__placeholder { color: var(--ink-mute); font-size: 0.82rem; }
.jp__chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: var(--paper-tint); border: 1px solid var(--hairline);
    border-radius: 999px; padding: 0.12rem 0.2rem 0.12rem 0.55rem;
    font-size: 0.78rem; color: var(--ink);
}
.jp__chip-x {
    border: none; background: transparent; cursor: pointer; font-size: 0.95rem;
    line-height: 1; color: var(--ink-mute); padding: 0 0.25rem; border-radius: 999px;
}
.jp__chip-x:hover { color: var(--ink); }
.jp__search {
    width: 100%; box-sizing: border-box; padding: 0.4rem 0.55rem;
    border: 1px solid var(--hairline); border-radius: 5px; font: inherit; font-size: 0.85rem;
    background: var(--paper); color: var(--ink); outline: none;
}
.jp__search:focus { border-color: var(--accent, #7a1f2b); }
.jp__menu {
    position: absolute; z-index: 50; left: 0; right: 0; top: 100%; margin-top: 0.2rem;
    max-height: 16rem; overflow-y: auto; background: var(--paper);
    border: 1px solid var(--hairline); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.jp__group {
    font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--ink-mute); padding: 0.45rem 0.6rem 0.2rem; position: sticky; top: 0;
    background: var(--paper);
}
.jp__opt {
    display: grid; grid-template-columns: 1.2rem 1fr auto; align-items: center;
    gap: 0.4rem; padding: 0.35rem 0.6rem; cursor: pointer; font-size: 0.85rem; color: var(--ink-soft);
}
.jp__opt:hover { background: var(--paper-tint); }
.jp__opt--on { color: var(--ink); }
.jp__check { color: var(--accent, #7a1f2b); font-weight: 700; }
.jp__opt-code { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-mute); }
.jp__none { padding: 0.5rem 0.6rem; color: var(--ink-mute); font-size: 0.82rem; }

/* Dark theme for the chat settings panel */
.jp--dark .jp__chip { background: #1f2937; border-color: #374151; color: #f9fafb; }
.jp--dark .jp__chip-x { color: #9ca3af; }
.jp--dark .jp__chip-x:hover { color: #f9fafb; }
.jp--dark .jp__placeholder { color: #9ca3af; }
.jp--dark .jp__search { background: #111827; color: #f9fafb; border-color: #374151; }
.jp--dark .jp__search:focus { border-color: #93c5fd; }
.jp--dark .jp__menu { background: #111827; border-color: #374151; }
.jp--dark .jp__group { background: #111827; color: #9ca3af; }
.jp--dark .jp__opt { color: #e5e7eb; }
.jp--dark .jp__opt:hover { background: #1f2937; }
.jp--dark .jp__opt--on { color: #fff; }
.jp--dark .jp__check { color: #93c5fd; }
.jp--dark .jp__opt-code { color: #9ca3af; }

/* ── Analyses list (dashboard right column) ─────────────────────────────── */
.analyses-list { display: flex; flex-direction: column; gap: 0; }
.analyses-list .month-divider {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 1.25rem 0 0.6rem;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    color: var(--ink-mute);
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}
.analyses-list .month-divider:first-child { margin-top: 0; }
.analyses-list .month-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--hairline-soft);
    margin-left: 0.2rem;
}

.analysis-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--hairline-soft);
    transition: background 100ms ease;
}
.analysis-row:hover { background: var(--paper-tint); }
.analysis-row:last-child { border-bottom: none; }

.analysis-row .title {
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.005em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.analysis-row .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.7rem;
    margin-top: 0.3rem;
    font-size: var(--fs-micro);
    color: var(--ink-mute);
    align-items: center;
}
.analysis-row .meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-faint); display: inline-block; }
.analysis-row .actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* P3.58 sharing */
.analysis-row { grid-template-columns: 1fr auto; }
.share-panel {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.6rem 0 0.4rem;
    border-top: 1px solid var(--hairline-soft);
}
.share-panel.hidden { display: none; }
.share-form { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.share-user-select, .share-perm-select {
    font-size: var(--fs-micro);
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}
.share-result { font-size: var(--fs-micro); color: var(--ink-mute); }
.shared-by-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--cite-case-bg, #eaf5ec);
    color: #1f4a2d;
    border: 1px solid #c7d6c9;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.analyses-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-mute);
    font-family: var(--font-display);
    font-style: italic;
    border: 1px dashed var(--hairline);
    border-radius: var(--radius);
}

/* ── Dashboard grid ─────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 1.75rem;
    align-items: flex-start;
}
@media (max-width: 980px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.dashboard-form { display: flex; flex-direction: column; gap: 1.25rem; }
.dashboard-form .context-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.25rem 0;
    color: var(--ink-mute);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.95rem;
}
.dashboard-form .context-divider::before,
.dashboard-form .context-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--hairline-soft);
}

/* ── Focus modes section (P3.61) ────────────────────────────────────────── */
.focus-modes-section { margin: 0.25rem 0; }
.focus-mode-item { margin-bottom: 0.6rem; }
.focus-mode-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    font-size: var(--fs-base);
}
.focus-mode-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--forest);
    flex-shrink: 0;
}
.focus-mode-name { font-weight: 500; }
.focus-ctx-textarea {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--hairline-soft);
    border-radius: var(--radius-sm, 4px);
    font-size: var(--fs-micro);
    font-family: var(--font-body);
    background: var(--paper-tint);
    color: var(--ink);
    resize: vertical;
    box-sizing: border-box;
}
.focus-ctx-textarea:focus { outline: 2px solid var(--forest); outline-offset: 1px; }

.intent-row .help, .sensitivity-row .help {
    font-size: var(--fs-micro);
    color: var(--ink-mute);
    margin-top: 0.4rem;
    font-style: italic;
}

/* ── Upload result block ────────────────────────────────────────────────── */
.upload-result { margin-top: 1.25rem; }
.result-ok {
    border: 1px solid #c7d8c9;
    background: var(--forest-soft);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.result-ok .label {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--forest);
}
.result-ok .id {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--forest);
    opacity: 0.85;
    word-break: break-all;
    margin-top: 0.25rem;
}
.result-ok .note {
    color: var(--forest);
    font-size: var(--fs-small);
    margin-top: 0.4rem;
}
.result-err {
    border: 1px solid #dcc2c4;
    background: var(--burgundy-soft);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
}
.result-err .label {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--burgundy);
    margin-bottom: 0.35rem;
}
.result-err .body {
    color: var(--burgundy);
    font-size: var(--fs-small);
    font-family: var(--font-mono);
    line-height: 1.4;
    word-break: break-word;
}

/* Traceback details (the explicit "show full traceback" component) */
.traceback {
    margin-top: 0.6rem;
    border-top: 1px dashed #dcc2c4;
    padding-top: 0.5rem;
}
.traceback summary {
    cursor: pointer;
    font-size: var(--fs-micro);
    color: var(--burgundy);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    user-select: none;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.traceback summary::-webkit-details-marker { display: none; }
.traceback summary::before {
    content: "›";
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1;
    transition: transform 120ms ease;
}
.traceback[open] summary::before { transform: rotate(90deg); }
.traceback pre {
    margin: 0.5rem 0 0;
    background: #ffffff;
    border: 1px solid #dcc2c4;
    border-radius: var(--radius);
    padding: 0.75rem;
    overflow: auto;
    max-height: 400px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--burgundy);
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.traceback .copy-btn,
.traceback .btn-copy-tb {
    float: right;
    font-size: var(--fs-micro);
    color: var(--burgundy);
    opacity: 0.7;
    border: 1px solid #dcc2c4;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
}
.traceback .copy-btn:hover,
.traceback .btn-copy-tb:hover { opacity: 1; background: #fff; }
.traceback-toolbar { display: flex; justify-content: flex-end; padding: 0.25rem 0.5rem 0; }

/* ── HTMX loading indicator ─────────────────────────────────────────────── */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }
.spinner-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--gold);
    font-size: var(--fs-small);
    font-style: italic;
    font-family: var(--font-display);
}
.spinner-inline::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.auth-shell {
    min-height: calc(100vh - 110px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2.25rem;
    box-shadow: var(--shadow-medium);
    position: relative;
}
.auth-card::before {
    content: "§";
    position: absolute;
    top: -0.95rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 2rem;
    background: var(--paper);
    color: var(--accent);
    padding: 0 0.5rem;
    line-height: 1;
}
.auth-title {
    font-family: var(--font-display);
    font-size: var(--fs-display);
    font-weight: 400;
    letter-spacing: -0.025em;
    line-height: 1;
    color: var(--ink);
    text-align: center;
    margin-bottom: 0.3rem;
    font-variation-settings: "opsz" 144, "SOFT" 50;
}
.auth-title em {
    font-style: italic;
    color: var(--accent);
    font-weight: 500;
}
.auth-subtitle {
    text-align: center;
    color: var(--ink-mute);
    font-size: var(--fs-small);
    margin-bottom: 2rem;
    letter-spacing: 0.04em;
}
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footnote {
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--hairline-soft);
    font-size: var(--fs-micro);
    color: var(--ink-mute);
    line-height: 1.5;
}
.auth-footnote code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--paper-tint);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    color: var(--accent);
}

/* ── Analysis viewer (two-column editorial layout) ──────────────────────── */
.analysis-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2.5rem;
    align-items: flex-start;
}
@media (max-width: 1100px) {
    .analysis-shell { grid-template-columns: 1fr; }
    .analysis-sidebar { position: static; }
}

.analysis-doc {
    background: #ffffff;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 2.5rem clamp(1.5rem, 3vw, 3rem);
    box-shadow: var(--shadow-soft);
    position: relative;
}
.analysis-doc::before {
    /* Page-edge mark (book-spine reference) */
    content: "";
    position: absolute;
    top: 1.5rem; bottom: 1.5rem;
    left: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    opacity: 0.7;
}

.analysis-meta-strip {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline-soft);
}
.analysis-meta-strip .breadcrumb {
    font-size: var(--fs-micro);
    color: var(--ink-mute);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.analysis-meta-strip .breadcrumb a { color: var(--accent); }
.analysis-meta-strip .breadcrumb a:hover { text-decoration: underline; }
.analysis-meta-strip h1 {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2.05rem);
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.015em;
    line-height: 1.1;
    margin-top: 0.35rem;
    font-variation-settings: "opsz" 60;
    word-break: break-all;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--ink-soft);
    font-weight: 500;
}
.analysis-meta-strip .intent-pill {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--accent);
}

/* Analysis sidebar */
.analysis-sidebar {
    position: sticky;
    top: 5.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.sidebar-section {
    background: #ffffff;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-soft);
}
.sidebar-section h3 {
    font-family: var(--font-ui);
    font-size: var(--fs-micro);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 0.7rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--hairline-soft);
}
.sidebar-section .row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: var(--fs-small);
}
.sidebar-section .row .k { color: var(--ink-mute); }
.sidebar-section .row .v { color: var(--ink); font-family: var(--font-mono); font-size: 0.8rem; text-align: right; word-break: break-all; }
.sidebar-section .actions-stack { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Markdown body (analysis content) ───────────────────────────────────── */
.markdown-body {
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--fs-body);
    line-height: 1.7;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.012em;
    line-height: 1.2;
    margin-top: 1.6em;
    margin-bottom: 0.55em;
    font-variation-settings: "opsz" 36;
}
.markdown-body h1 {
    font-size: 1.85em;
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 0.3em;
    font-variation-settings: "opsz" 72;
}
.markdown-body h2 {
    font-size: 1.4em;
    border-bottom: 1px solid var(--hairline-soft);
    padding-bottom: 0.2em;
    color: var(--accent);
}
.markdown-body h3 {
    font-size: 1.15em;
    color: var(--ink);
}
.markdown-body h4 {
    font-size: 1em;
    color: var(--ink-soft);
    font-style: italic;
    font-weight: 500;
}
.markdown-body p { margin: 0.7em 0; }
.markdown-body p:first-of-type::first-letter,
.markdown-body h2 + p::first-letter {
    /* Drop cap on the first paragraph of major sections */
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 3em;
    float: left;
    line-height: 0.85;
    margin: 0.15em 0.12em 0 0;
    color: var(--accent);
    font-variation-settings: "opsz" 144;
}
.markdown-body ul,
.markdown-body ol { margin: 0.7em 0 0.7em 1.4em; }
.markdown-body ul { list-style: disc; }
.markdown-body ol { list-style: decimal; }
.markdown-body li { margin: 0.3em 0; }
.markdown-body li::marker { color: var(--accent); }
.markdown-body a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.markdown-body a:hover { color: var(--accent-deep); }
.markdown-body strong { color: var(--ink); font-weight: 600; }
.markdown-body em { color: var(--ink-soft); }
.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.4em 1.1em;
    margin: 1em 0;
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05em;
    background: var(--paper-tint);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--paper-tint);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--hairline-soft);
}
.markdown-body pre {
    background: var(--paper-tint);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 0.85em 1em;
    overflow-x: auto;
    margin: 1em 0;
    line-height: 1.55;
}
.markdown-body pre code {
    background: transparent;
    color: var(--ink);
    padding: 0;
    border: none;
    font-size: 0.82em;
}
.markdown-body table {
    margin: 1em 0;
    font-size: 0.93em;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    overflow: hidden;
}
.markdown-body th,
.markdown-body td {
    padding: 0.55em 0.85em;
    text-align: left;
    border-bottom: 1px solid var(--hairline-soft);
    border-right: 1px solid var(--hairline-soft);
}
.markdown-body th:last-child, .markdown-body td:last-child { border-right: none; }
.markdown-body tr:last-child td { border-bottom: none; }
.markdown-body th {
    background: var(--paper-tint);
    color: var(--ink);
    font-weight: 600;
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.markdown-body tr:nth-child(even) td { background: rgba(122, 31, 43, 0.018); }
.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--hairline-soft);
    margin: 2em 0;
    text-align: center;
}
.markdown-body hr::after {
    content: "§";
    display: inline-block;
    background: #ffffff;
    color: var(--accent);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.1em;
    padding: 0 0.6em;
    position: relative;
    top: -0.7em;
}

/* ── Citation references (preserve all kinds from ui.js) ────────────────── */
.citation-ref {
    display: inline;
    padding: 0 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.84em;
    cursor: help;
    border-bottom: 1px dotted currentColor;
    transition: background 100ms ease, color 100ms ease;
    background: var(--cite-doc-bg);
    color: var(--cite-doc-fg);
}
.citation-ref:hover { filter: brightness(0.92); border-bottom-style: solid; }
.citation-ref--doc      { background: var(--cite-doc-bg);     color: var(--cite-doc-fg); }
.citation-ref--cuad     { background: var(--cite-cuad-bg);    color: var(--cite-cuad-fg); }
.citation-ref--case     { background: var(--cite-case-bg);    color: var(--cite-case-fg); }
.citation-ref--statute  { background: var(--cite-statute-bg); color: var(--cite-statute-fg); }
.citation-ref--market   { background: var(--cite-market-bg);  color: var(--cite-market-fg); }
.citation-ref--trust    { background: var(--cite-trust-bg);   color: var(--cite-trust-fg); }
.citation-ref--template { background: var(--cite-template-bg); color: var(--cite-template-fg); }

/* ── Citation tooltip ───────────────────────────────────────────────────── */
.citation-tooltip {
    position: absolute;
    z-index: 50;
    max-width: 380px;
    pointer-events: none;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    background: var(--ink);
    color: var(--paper);
    border: 1px solid #000;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
    font-size: var(--fs-small);
    line-height: 1.4;
}
.citation-tooltip .tooltip-kind {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--paper);
    opacity: 0.7;
    margin-bottom: 0.2rem;
    font-family: var(--font-ui);
}
.citation-tooltip .tooltip-text {
    font-family: var(--font-mono);
    word-break: break-all;
    color: var(--paper);
    font-size: 0.82rem;
}
.citation-tooltip .tooltip-link { margin-top: 0.4rem; }
.citation-tooltip .tooltip-link a { color: #a8cfff; font-size: 0.78rem; text-decoration: none; }
.citation-tooltip .tooltip-link a:hover { text-decoration: underline; }

/* ── Timer widget ───────────────────────────────────────────────────────── */
.timer-widget { display: flex; align-items: center; gap: 0.5rem; }
.timer-widget input[type="text"] {
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 0.35rem 0.55rem;
    font-size: var(--fs-micro);
    font-family: var(--font-mono);
    width: 7.5rem;
}
.timer-widget input::placeholder { color: var(--ink-faint); }
.timer-widget input:focus { outline: none; border-color: var(--accent); }
.timer-active {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--fs-micro);
    color: var(--gold);
    font-family: var(--font-mono);
}
.timer-active::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--gold);
    animation: pulse 1.6s ease-in-out infinite;
}

/* ── Workflows grid ─────────────────────────────────────────────────────── */
.wf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.wf-card {
    background: #ffffff;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
    transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.wf-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-medium);
    transform: translateY(-1px);
}
.wf-card h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.15rem;
}
.wf-card .id {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--ink-mute);
    margin-bottom: 0.6rem;
}
.wf-card .desc {
    font-size: var(--fs-small);
    color: var(--ink-soft);
    margin-bottom: 0.8rem;
    flex-grow: 1;
}
.wf-card .meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.wf-card .foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid var(--hairline-soft);
    font-size: var(--fs-micro);
    color: var(--ink-mute);
}

.wf-filter {
    width: 22rem;
    max-width: 100%;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-foot {
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 1.5rem var(--gutter) 2.5rem;
    border-top: 1px solid var(--hairline-soft);
    color: var(--ink-mute);
    font-size: var(--fs-micro);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.site-foot .legal-note { font-style: italic; font-family: var(--font-display); }

/* ── Collaboration / presence (preserve hooks from analysis.html) ───────── */
.collab-bar { display: flex; align-items: center; gap: 0.4rem; }
#collab-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ink-faint);
    display: inline-block;
}
#collab-status[data-status="connected"] { background: var(--forest); }
#collab-status[data-status="connecting"] { background: var(--gold); animation: pulse 1.4s ease-in-out infinite; }
#collab-status[data-status="disconnected"] { background: var(--burgundy); }

.collab-pill {
    width: 22px; height: 22px;
    border-radius: 50%;
    color: var(--paper);
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: -4px;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.collab-empty .collab-pill { display: none; }

#collab-annotations-panel summary {
    cursor: pointer;
    font-size: var(--fs-small);
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-style: italic;
    list-style: none;
    user-select: none;
    padding: 0.4rem 0;
}
#collab-annotations-panel summary::-webkit-details-marker { display: none; }
.collab-empty-note { color: var(--ink-faint); font-style: italic; font-size: var(--fs-small); }
.collab-annotation { margin-bottom: 0.85rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--hairline-soft); }
.collab-annotation-anchor {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent);
    cursor: pointer;
    display: inline-block;
    margin-bottom: 0.2rem;
}
.collab-annotation-anchor:hover { text-decoration: underline; }
.collab-annotation-text { color: var(--ink); font-size: var(--fs-small); margin-top: 0.15rem; }

/* ── Helpers ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.muted { color: var(--ink-mute); }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-display); }
.small { font-size: var(--fs-small); }
.micro { font-size: var(--fs-micro); }
.text-accent { color: var(--accent); }
.text-burgundy { color: var(--burgundy); }
.text-forest { color: var(--forest); }
.no-margin { margin: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.italic { font-style: italic; }

/* Print friendly */
@media print {
    .site-nav, .site-foot, .analysis-sidebar, .panel-head .btn { display: none; }
    body { background: white; }
    .analysis-doc { box-shadow: none; border: none; }
}

/* ── Intake auto-detection (P3.60) ──────────────────────────────────────── */
.detect-status {
    font-size: var(--fs-small);
    color: var(--ink-soft);
    padding: 0.35rem 0;
    font-style: italic;
}
.detect-status.detecting { color: var(--accent); }
.detect-status.detect-error { color: var(--burgundy); }

.detect-badge {
    display: inline-block;
    font-size: var(--fs-micro);
    font-style: normal;
    font-weight: 500;
    padding: 0.1em 0.45em;
    border-radius: 3px;
    margin-left: 0.4rem;
    vertical-align: middle;
    cursor: default;
    position: relative;
}
.detect-badge--high   { background: var(--forest-soft); color: var(--forest); }
.detect-badge--medium { background: #fef8e6; color: #7a5a10; }
.detect-badge--low    { background: var(--hairline); color: var(--ink-faint); }
.detect-badge--overridden { background: var(--hairline); color: var(--ink-mute); }

.detect-tooltip {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 6px);
    background: var(--ink-soft);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 400;
    padding: 0.4em 0.65em;
    border-radius: 4px;
    white-space: pre-wrap;
    max-width: 260px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    text-align: left;
}
.detect-badge:hover .detect-tooltip { opacity: 1; }

/* ── Playbooks (P3.68) ──────────────────────────────────────────────────────── */

/* Page header extensions */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; }
.page-head-actions, .page-head-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding-top: 0.25rem; }
.page-head-meta .meta-item { color: var(--ink-mute); font-size: 0.85rem; }

/* Outline button */
.btn-outline {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4em 0.9em;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    background: transparent;
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.12s, color 0.12s;
}
.btn-outline:hover { border-color: var(--ink-mute); color: var(--ink); }

/* Section head */
.section-head { margin: 2rem 0 1rem; }
.section-head h2 { margin: 0 0 0.25rem; font-size: 1.1rem; color: var(--ink); }
.section-sub { margin: 0; color: var(--ink-mute); font-size: 0.875rem; }

/* Empty state */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--ink-mute); }
.empty-state .glyph { display: block; font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.3; }

/* Badges */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.15em 0.55em;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge--verified { background: var(--forest-soft); color: var(--forest); }
.badge--draft    { background: #fef3e2; color: #7a5110; border: 1px solid #f3dba0; }
.badge--ai       { background: #eef2fe; color: #3a52b0; }
.badge--sev-high   { background: #fde8e8; color: #a02020; }
.badge--sev-medium { background: #fef3e2; color: #7a5110; }
.badge--sev-low    { background: var(--hairline-soft); color: var(--ink-mute); }

/* Playbook grid */
.playbook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* Playbook card */
.playbook-card {
    display: flex; flex-direction: column;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    background: var(--paper);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.playbook-card:hover { border-color: var(--ink-mute); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.playbook-card--draft { border-style: dashed; background: #fffdf7; }

.playbook-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.playbook-card-type { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-mute); text-transform: uppercase; }
.playbook-card-id { font-size: 1rem; font-weight: 500; color: var(--ink); margin-bottom: 0.4rem; font-family: 'IBM Plex Mono', monospace; }
.playbook-card-desc { font-size: 0.825rem; color: var(--ink-mute); line-height: 1.45; margin: 0 0 auto; }
.playbook-card-footer { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px solid var(--hairline-soft); font-size: 0.8rem; color: var(--ink-mute); }

/* Draft strip / promote instructions */
.playbook-draft-strip { padding: 1rem 1.25rem; background: #fffdf7; border: 1px dashed #e3c87a; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.promote-banner { padding: 1rem 1.25rem; background: #fff8e6; border: 1px solid #e3c87a; border-radius: 6px; margin-bottom: 1.5rem; }
.promote-instructions { background: var(--paper-tint, #f8f6f1); }

/* Code block with copy button */
.code-block {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5em 0.75em;
    background: #f0ede4;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    margin-top: 0.5rem;
}
.code-block code { flex: 1; font-family: 'IBM Plex Mono', monospace; font-size: 0.8rem; word-break: break-all; }
.btn-copy {
    flex-shrink: 0; padding: 0.2em 0.5em;
    border: 1px solid var(--hairline);
    border-radius: 3px;
    background: var(--paper);
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--ink-mute);
    transition: color 0.12s;
}
.btn-copy:hover { color: var(--ink); }

/* Promote cmd block in draft card */
.promote-cmd-block { margin-top: 0.75rem; }
.promote-cmd-label { font-size: 0.75rem; color: var(--ink-mute); margin-bottom: 0.25rem; }

/* Playbook detail two-column layout */
.playbook-detail-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
    align-items: start;
}
@media (max-width: 720px) {
    .playbook-detail-layout { grid-template-columns: 1fr; }
    .playbook-entry-nav { display: none; }
}

/* Entry navigation (left column) */
.playbook-entry-nav {
    position: sticky; top: 1rem;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    overflow: hidden;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}
.entry-nav-head { padding: 0.6rem 0.75rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-mute); border-bottom: 1px solid var(--hairline); }
.entry-nav-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none; color: var(--ink-soft);
    font-size: 0.8rem; line-height: 1.35;
    border-bottom: 1px solid var(--hairline-soft);
    cursor: pointer;
    transition: background 0.1s;
}
.entry-nav-item:hover, .entry-nav-item.is-active { background: var(--paper-tint, #f8f6f1); color: var(--ink); }
.entry-nav-item.is-active { border-left: 3px solid var(--ink); padding-left: calc(0.75rem - 3px); }
.entry-nav-name { flex: 1; }
.entry-nav-sev { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.1em 0.4em; border-radius: 2px; margin-left: 0.4rem; flex-shrink: 0; }
.sev-high   { background: #fde8e8; color: #a02020; }
.sev-medium { background: #fef3e2; color: #7a5110; }
.sev-low    { background: var(--hairline-soft); color: var(--ink-faint); }

/* Entry panels (right column) */
.entry-panel { display: none; }
.entry-panel.is-active { display: block; }

.entry-header { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--hairline); }
.entry-header h2 { margin: 0; font-size: 1.1rem; flex: 1; min-width: 200px; }

.entry-section { margin-bottom: 1.25rem; }
.entry-section-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 0.4rem; }

.standard-language {
    background: var(--paper-tint, #f8f6f1);
    border-left: 3px solid var(--hairline);
    padding: 0.75rem 1rem;
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--ink-soft);
    white-space: pre-wrap;
    border-radius: 0 4px 4px 0;
}

/* Citation chips (reuse existing design) */
.citation-chip {
    display: inline-block;
    padding: 0.15em 0.5em;
    border-radius: 3px;
    font-size: 0.78rem;
    font-family: 'IBM Plex Mono', monospace;
    margin: 0.1em 0.2em;
}
.citation-chip--statute { background: #eef6ee; color: #2a5a3d; border: 1px solid #c4d9c6; }
.citation-chip--cuad    { background: #f0f0f8; color: #3a3a8a; border: 1px solid #c8c8e8; }
.citation-chip--case    { background: #fff8ee; color: #7a5110; border: 1px solid #e8d8a0; }

/* Keyword tag chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag-chip {
    display: inline-block; padding: 0.15em 0.5em;
    background: var(--hairline-soft); color: var(--ink-soft);
    border-radius: 3px; font-size: 0.78rem;
}
.tag-chip--more { background: transparent; border: 1px dashed var(--hairline); color: var(--ink-faint); }

/* Action chips */
.action-chip {
    display: inline-block; padding: 0.15em 0.6em;
    border-radius: 3px; font-size: 0.8rem; font-weight: 500;
}
.action-amend  { background: #fef8e6; color: #7a5a10; }
.action-insert_after, .action-insert { background: #eef6ee; color: var(--forest); }
.action-strike, .action-delete { background: #fde8e8; color: #a02020; }
.action-comment_only { background: var(--hairline-soft); color: var(--ink-mute); }
.action-fallback { background: var(--paper-tint, #f8f6f1); color: var(--ink-mute); margin-left: 0.3rem; }

/* Entry footer */
.entry-footer { margin-top: 1.5rem; padding-top: 0.75rem; border-top: 1px solid var(--hairline-soft); display: flex; gap: 1rem; flex-wrap: wrap; }
.meta-item { font-size: 0.8rem; color: var(--ink-mute); }
.meta-item code { font-size: 0.78rem; background: var(--hairline-soft); padding: 0.1em 0.35em; border-radius: 2px; }

/* Separator in breadcrumbs */
.sep { color: var(--ink-faint); margin: 0 0.15rem; }

/* Playbook filter bar */
.playbook-filter-bar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.75rem 0; margin-bottom: 0.5rem; border-bottom: 1px solid var(--hairline-soft);
}
.filter-input {
    flex: 1; min-width: 180px;
    padding: 0.4em 0.7em;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    font-family: inherit; font-size: 0.875rem;
    background: var(--paper); color: var(--ink);
}
.filter-input:focus { outline: none; border-color: var(--ink-mute); }
.filter-select {
    padding: 0.4em 0.6em;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    font-family: inherit; font-size: 0.875rem;
    background: var(--paper); color: var(--ink);
    cursor: pointer;
}
.filter-checkbox { display: flex; align-items: center; gap: 0.35rem; font-size: 0.875rem; color: var(--ink-soft); cursor: pointer; }
.filter-count { font-size: 0.8rem; color: var(--ink-mute); margin-left: auto; }

/* ── Playbook editor (P3.69) ─────────────────────────────────────────────── */

/* Modal overlay */
.pb-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 900;
}
.pb-modal-open { overflow: hidden; }

/* Modal container */
.pb-modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 901; width: min(640px, 95vw); max-height: 90vh;
    background: var(--paper); border: 1px solid var(--hairline);
    border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex; flex-direction: column;
}
.pb-modal-inner { display: flex; flex-direction: column; max-height: 90vh; }
.pb-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem; border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
}
.pb-modal-header h3 { margin: 0; font-size: 1rem; }
.pb-modal-close {
    background: none; border: none; cursor: pointer; font-size: 1.1rem;
    color: var(--ink-soft); padding: 0.2rem 0.4rem; border-radius: 4px;
    line-height: 1;
}
.pb-modal-close:hover { color: var(--ink); background: var(--surface); }
.pb-modal-body { padding: 1rem 1.25rem; overflow-y: auto; flex: 1; }
.pb-modal-footer {
    padding: 0.75rem 1.25rem; border-top: 1px solid var(--hairline);
    display: flex; gap: 0.5rem; justify-content: flex-end; flex-shrink: 0;
}

/* Form elements */
.pb-form-label {
    display: flex; flex-direction: column; gap: 0.3rem;
    font-size: 0.85rem; font-weight: 600; color: var(--ink-soft);
    margin-bottom: 0.9rem;
}
.pb-form-row {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem;
    margin-bottom: 0.9rem;
}
.pb-form-row .pb-form-label { margin-bottom: 0; }
.pb-hint { font-weight: 400; color: var(--ink-mute); font-size: 0.8rem; }
.pb-input, .pb-select {
    padding: 0.4em 0.6em; border: 1px solid var(--hairline); border-radius: 4px;
    font-family: inherit; font-size: 0.875rem;
    background: var(--paper); color: var(--ink);
    width: 100%;
}
.pb-input:focus, .pb-select:focus, .pb-textarea:focus {
    outline: 2px solid var(--accent, #2563eb); outline-offset: 1px;
}
.pb-textarea {
    padding: 0.4em 0.6em; border: 1px solid var(--hairline); border-radius: 4px;
    font-family: inherit; font-size: 0.875rem;
    background: var(--paper); color: var(--ink);
    width: 100%; resize: vertical;
}

/* Error box */
.pb-error-box {
    background: #fef2f2; border: 1px solid #fca5a5; border-radius: 4px;
    padding: 0.6rem 0.75rem; font-size: 0.85rem; color: #dc2626;
    margin-bottom: 0.9rem;
}
.pb-error-box ul { margin: 0.3rem 0 0 1rem; padding: 0; }

/* Conflict banner */
.conflict-banner {
    background: #fffbeb; border: 1px solid #fbbf24; border-radius: 6px;
    padding: 0.75rem 1rem; margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

/* Entry action buttons */
.entry-actions {
    display: flex; gap: 0.4rem; margin-left: auto; align-items: center;
}
.btn--sm { padding: 0.25em 0.6em; font-size: 0.8rem; }
.btn--verify { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.btn--verify:hover { background: var(--accent, #2563eb); color: #fff; }
.btn--danger { border-color: #dc2626; color: #dc2626; }
.btn--danger:hover { background: #dc2626; color: #fff; }
.btn-primary {
    padding: 0.45em 1em; background: var(--ink); color: var(--paper);
    border: none; border-radius: 4px; cursor: pointer;
    font-family: inherit; font-size: 0.875rem; font-weight: 600;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

/* New-playbook form panel */
.pb-form-panel { max-width: 540px; margin-top: 2rem; padding: 1.5rem 2rem; }
.pb-form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ── P3.71 — Project list (dashboard rewrite) ───────────────────────────── */

/* Toolbar row above the grid */
.project-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.project-search {
    flex: 1 1 240px;
    min-width: 0;
    max-width: 360px;
}
.project-toolbar-right {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: wrap;
}

/* Project grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.1rem;
}
@media (max-width: 600px) {
    .project-grid { grid-template-columns: 1fr; }
}

/* Project card */
.project-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 1.15rem 1.3rem;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.13s ease, box-shadow 0.13s ease, transform 0.1s ease;
    cursor: pointer;
    min-height: 130px;
}
.project-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}
.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.55rem;
}
.project-card-type {
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--paper);
    background: var(--accent);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    line-height: 1.5;
}
.project-card-type--none {
    background: var(--hairline);
    color: var(--ink-mute);
}
.project-card-badges {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}
.project-card-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin-bottom: auto;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.project-card-footer {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--hairline-soft);
    font-size: var(--fs-micro);
    color: var(--ink-mute);
}
.project-card-footer .dot {
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--ink-faint);
    display: inline-block;
    align-self: center;
}

/* Project card wrapper — holds card + hover-reveal delete button (P3.102) */
.project-card-wrap {
    position: relative;
}
.project-card-wrap .project-card {
    height: 100%;
}
.project-card-delete {
    position: absolute;
    bottom: 0.8rem;
    right: 1rem;
    font-size: var(--fs-micro);
    opacity: 0;
    transition: opacity 0.15s;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 1;
}
.project-card-wrap:hover .project-card-delete,
.project-card-wrap:focus-within .project-card-delete {
    opacity: 1;
}

/* CLM metadata row inside project card */
.project-card-clm {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.35rem;
    font-size: var(--fs-micro);
    color: var(--ink-mute);
}
.project-card-counterparty {
    font-style: italic;
    color: var(--ink-soft);
}

/* Share / ownership badges on project cards */
.share-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.5;
}
.share-badge--owner {
    background: var(--forest-soft);
    color: var(--forest);
    border: 1px solid #c7d8c9;
}
.share-badge--shared {
    background: var(--cite-doc-bg);
    color: var(--cite-doc-fg);
    border: 1px solid #c7d3e8;
}
.share-badge--collab {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid #e6cdd0;
}

/* Empty state */
.project-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--ink-mute);
    border: 1px dashed var(--hairline);
    border-radius: var(--radius-lg);
    background: var(--paper-tint);
}
.project-empty-icon {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    line-height: 1;
}
.project-empty-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.35rem;
}
.project-empty-sub {
    font-size: var(--fs-small);
    color: var(--ink-mute);
}
.project-no-results {
    border-style: dashed;
}

/* ── P3.71 — New-project modal ──────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(26, 29, 36, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal-box {
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-medium);
    padding: 1.75rem 2rem;
    width: 100%;
    max-width: 460px;
}
.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.4rem;
    gap: 0.75rem;
}
.modal-title {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.modal-close {
    color: var(--ink-mute);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: background 0.1s;
}
.modal-close:hover { background: var(--paper-tint); color: var(--ink); }
.modal-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}
.modal-feedback {
    font-size: var(--fs-small);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid;
}
.modal-feedback--error {
    background: var(--burgundy-soft);
    border-color: #dcc2c4;
    color: var(--burgundy);
}
.field-error {
    font-size: var(--fs-micro);
    color: var(--burgundy);
    margin-top: 0.3rem;
}
.required-star { color: var(--accent); }

/* Page-head actions (New project button) */
.page-head-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

/* ── P3.72: Project file rail ────────────────────────────────────────────────── */

/* Three-region layout: file-rail | editor | actions-placeholder */
.project-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
  height: 100%;
}

.project-editor {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.project-actions-placeholder {
  border-left: 1px solid var(--color-border, #e0ddd8);
  background: var(--color-bg-secondary, #f8f8f6);
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted, #888);
  min-width: 200px;
  display: none; /* shown when actions panel lands (P3.74/P3.75) */
}

/* File rail */
.file-rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border, #e0ddd8);
  background: var(--color-bg-secondary, #f8f8f6);
  overflow: hidden;
}

.file-rail .rail-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border, #e0ddd8);
  flex-shrink: 0;
}

.file-rail .rail-header span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
  flex: 1;
}

#pf-add-file-btn {
  font-size: 0.72rem;
  padding: 2px 6px;
  border: 1px solid var(--color-border, #e0ddd8);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: var(--color-text-muted, #666);
  white-space: nowrap;
}
#pf-add-file-btn:hover { background: var(--color-hover, #eeede9); }

/* File rows in rail */
.file-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.1s;
  font-size: 0.8rem;
  min-width: 0;
}
.file-row:hover { background: var(--color-hover, #eeede9); }
.file-row.active-file {
  border-left-color: var(--color-primary, #1a56db);
  background: var(--color-hover, #eeede9);
  font-weight: 600;
}

/* Extension badge chip */
.type-badge {
  flex-shrink: 0;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 3px;
  background: #e2e8f0;
  color: #334155;
  min-width: 2rem;
  text-align: center;
}

/* Per-type badge colours */
.type-badge[data-ext="pdf"]  { background: #fee2e2; color: #991b1b; }
.type-badge[data-ext="docx"],
.type-badge[data-ext="doc"]  { background: #dbeafe; color: #1e40af; }
.type-badge[data-ext="xlsx"],
.type-badge[data-ext="csv"]  { background: #dcfce7; color: #166534; }
.type-badge[data-ext="pptx"] { background: #fed7aa; color: #9a3412; }
.type-badge[data-ext="eml"],
.type-badge[data-ext="msg"]  { background: #f3e8ff; color: #6b21a8; }
.type-badge[data-ext="png"],
.type-badge[data-ext="jpg"],
.type-badge[data-ext="jpeg"],
.type-badge[data-ext="tiff"],
.type-badge[data-ext="bmp"],
.type-badge[data-ext="gif"]  { background: #fef3c7; color: #92400e; }

/* Filename in rail row */
.file-name-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Pin icon */
.pin-icon {
  flex-shrink: 0;
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Delete button on rail row */
.file-delete-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text-muted, #aaa);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.1s;
}
.file-row:hover .file-delete-btn { opacity: 1; }
.file-delete-btn:hover { color: #dc2626; }

/* Upload status bar inside rail footer */
#pf-upload-status {
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Drag-drop overlay */
.drop-overlay,
#pf-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 86, 219, 0.12);
  border: 3px dashed var(--color-primary, #1a56db);
  border-radius: 8px;
  display: none; /* shown by JS during drag */
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
}
.drop-overlay-label {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-primary, #1a56db);
  background: rgba(255, 255, 255, 0.9);
  padding: 1rem 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* ── P3.76: Cloud connectors ─────────────────────────────────────────────── */

/* Rail: cloud import buttons next to "Files" heading */
.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rail-cloud-btns {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin-left: auto;
}
.rail-cloud-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 4px;
  color: var(--ink-soft, #888);
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}
.rail-cloud-btn:hover {
  color: var(--ink, #222);
  border-color: var(--hairline, #ddd);
  background: var(--surface, #f5f4f0);
}

/* Cloud badge on file rail rows */
.cloud-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
}
.cloud-badge--gdrive {
  background: #e8f0fe;
  color: #1a73e8;
}
.cloud-badge--onedrive {
  background: #e3f2fd;
  color: #0078d4;
}

/* Cloud picker overlay (full-screen backdrop) */
.cloud-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.cloud-overlay[hidden] { display: none; }

/* Picker dialog box */
.cloud-picker-dialog {
  background: var(--paper, #fafaf8);
  border: 1px solid var(--hairline, #e0ddd8);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  width: 520px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cloud-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline, #e0ddd8);
  background: var(--surface, #f5f4f0);
}
.cloud-picker-title { font-weight: 600; font-size: 0.9rem; }
.cloud-picker-close {
  background: none; border: none; cursor: pointer; font-size: 1.2rem;
  color: var(--ink-soft, #888); padding: 0.1rem 0.35rem; border-radius: 4px; line-height: 1;
}
.cloud-picker-close:hover { background: var(--surface, #eeede9); color: var(--ink, #222); }

.cloud-picker-body {
  padding: 1.25rem 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 160px;
}

/* Auth gate */
.cloud-auth-gate { text-align: center; padding: 1rem 0; }
.cloud-auth-msg { margin: 0 0 1rem; font-size: 0.9rem; color: var(--ink-soft, #555); }
.cloud-auth-hint { margin: 0.75rem 0 0; font-size: 0.78rem; color: var(--ink-mute, #999); }

/* Loading spinner */
.cloud-picker-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 0;
  font-size: 0.85rem;
  color: var(--ink-soft, #666);
}
.cloud-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--hairline, #ddd);
  border-top-color: var(--accent, #2563eb);
  border-radius: 50%;
  animation: cloud-spin 0.75s linear infinite;
}
@keyframes cloud-spin { to { transform: rotate(360deg); } }

/* Picker mount area */
.cloud-picker-mount { min-height: 200px; }

/* Manual entry fallback */
.cloud-manual-entry { padding: 0.25rem 0; }
.cloud-manual-msg { font-size: 0.85rem; color: var(--ink-soft, #666); margin: 0 0 0.75rem; }
.cloud-manual-label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft, #555);
  margin-bottom: 0.75rem;
}
.cloud-manual-input {
  padding: 0.4em 0.6em;
  border: 1px solid var(--hairline, #ddd);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--paper, #fff);
  color: var(--ink, #222);
}

/* Status / error */
.cloud-picker-status {
  margin-top: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.82rem;
  background: #f0f9ff;
  color: var(--ink-soft, #555);
}
.cloud-picker-status--error { background: #fef2f2; color: #dc2626; }

/* ── Conflict resolution modal ──────────────────────────────────────────── */
.conflict-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.conflict-modal[hidden] { display: none; }
.conflict-modal-dialog {
  background: var(--paper, #fafaf8);
  border: 1px solid var(--hairline, #e0ddd8);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  width: 400px;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
}
.conflict-modal-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline, #e0ddd8);
  background: #fff7ed;
  color: #92400e;
  font-size: 0.9rem;
}
.conflict-modal-body {
  padding: 1rem;
  font-size: 0.88rem;
  color: var(--ink, #222);
}
.conflict-modal-body p { margin: 0; }
.conflict-modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--hairline, #e0ddd8);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Sync success toast ─────────────────────────────────────────────────── */
.sync-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #166534;
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 1200;
  pointer-events: none;
}
.sync-toast[hidden] { display: none; }
.sync-toast--visible { opacity: 1; transform: translateY(0); }

/* ── P3.75: Playbook eval / benchmark / definitions result styles ────────── */

/* Shared result table */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 0.5rem 0 1rem;
}
.result-table th {
  background: var(--paper-deep, #ece6d6);
  color: var(--ink-soft, #3a3f4a);
  font-weight: 600;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 2px solid var(--hairline, #d8d2c2);
  white-space: nowrap;
}
.result-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--hairline-soft, #e8e3d4);
  vertical-align: top;
  color: var(--ink, #1a1d24);
}
.result-table tr:last-child td { border-bottom: none; }
.result-table tr:hover td { background: var(--paper-tint, #f4f0e6); }

/* Status / result chips */
.chip {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip-pass {
  background: var(--forest-soft, #e6f0e8);
  color: var(--forest, #2a5a3d);
  border: 1px solid #b6d9be;
}
.chip-fail {
  background: var(--burgundy-soft, #f3e1e3);
  color: var(--burgundy, #5a1822);
  border: 1px solid #e8b4ba;
}
.chip-na {
  background: var(--paper-deep, #ece6d6);
  color: var(--ink-mute, #6b6f78);
  border: 1px solid var(--hairline, #d8d2c2);
}

/* Row severity highlights */
.severity-critical td { background: #fdf0f1; }
.severity-high td     { background: #fdf5ec; }
.severity-medium td   { /* no highlight — default paper */ }
.severity-low td      { /* no highlight */ }

/* Severity group headings */
.result-group-heading {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.4rem 0 0.2rem;
  margin: 0.75rem 0 0;
  color: var(--ink-soft, #3a3f4a);
  border-bottom: 1px solid var(--hairline, #d8d2c2);
}
.result-group-heading.severity-critical { color: var(--burgundy, #5a1822); }
.result-group-heading.severity-high     { color: var(--gold, #a86a1f); }

/* P3.126: Playbook eval — error banner, skipped toggle, severity inline labels */

/* Error banner — prominent warning at top of playbook/benchmark results */
.playbook-error-banner {
  background: var(--gold-soft, #f7eddb);
  border: 1px solid #e8c97a;
  border-left: 4px solid var(--gold, #a86a1f);
  border-radius: 4px;
  color: var(--ink-soft, #3a3f4a);
  font-size: 0.83rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
}
.playbook-error-banner strong {
  color: var(--gold, #a86a1f);
}

/* Skipped rules toggle button */
.playbook-skipped-section {
  margin-top: 0.75rem;
}
.playbook-skipped-toggle {
  background: none;
  border: 1px solid var(--hairline, #d8d2c2);
  border-radius: 4px;
  color: var(--ink-mute, #6b6f78);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  transition: background 0.12s, color 0.12s;
}
.playbook-skipped-toggle:hover {
  background: var(--paper-tint, #f4f0e6);
  color: var(--ink, #1a1d24);
}
.playbook-skipped-toggle[aria-expanded="true"] {
  background: var(--paper-deep, #ece6d6);
  color: var(--ink-soft, #3a3f4a);
}

/* Skipped rules body (collapsible) */
.playbook-skipped-body {
  margin-top: 0.4rem;
}

/* Muted table variant for skipped rows */
.result-table--muted td,
.result-table--muted th {
  color: var(--ink-mute, #6b6f78);
}

/* Inline severity labels (replaces per-group headings in flat table) */
.sev-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sev-critical { color: var(--burgundy, #5a1822); }
.sev-high     { color: var(--gold, #a86a1f); }
.sev-medium   { color: var(--ink-soft, #3a3f4a); }
.sev-low      { color: var(--ink-mute, #6b6f78); }
.sev-info     { color: var(--ink-faint, #9a9da3); }

/* Anchor links inside tables */
.anchor-link {
  color: var(--accent, #7a1f2b);
  text-decoration: underline;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.78rem;
  cursor: pointer;
}
.anchor-link:hover { color: var(--accent-deep, #5a1522); }

/* Definitions panel */
.definitions-panel { margin-top: 0.5rem; }

.definition-entry {
  border: 1px solid var(--hairline-soft, #e8e3d4);
  border-radius: 4px;
  margin-bottom: 0.4rem;
  background: var(--paper, #fbfaf6);
  overflow: hidden;
}
.definition-entry summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink, #1a1d24);
  user-select: none;
  background: var(--paper-tint, #f4f0e6);
  list-style: none;
}
.definition-entry summary::-webkit-details-marker { display: none; }
.definition-entry summary::before {
  content: "▶";
  font-size: 0.65rem;
  color: var(--ink-mute, #6b6f78);
  transition: transform 0.15s;
}
.definition-entry[open] summary::before { transform: rotate(90deg); }
.definition-entry[open] summary { background: var(--paper-deep, #ece6d6); }

.def-anchor {
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  color: var(--ink-mute, #6b6f78);
  font-weight: 400;
}
.def-body {
  padding: 0.45rem 0.75rem 0.5rem;
  font-size: 0.83rem;
  line-height: 1.5;
}
.def-text {
  color: var(--ink, #1a1d24);
  margin-bottom: 0.3rem;
}
.def-notes {
  color: var(--gold, #a86a1f);
  font-size: 0.79rem;
  background: var(--gold-soft, #f7eddb);
  border-left: 3px solid var(--gold, #a86a1f);
  padding: 0.25rem 0.5rem;
  border-radius: 0 3px 3px 0;
}
   ============================================================================ */

/* ── Right-side action column inside .project-body ───────────────────────── */
.action-panel {
  width: 180px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border, #e0ddd8);
  background: var(--color-bg-secondary, #f8f8f6);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.action-panel-header {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
  padding: 0.6rem 0.75rem 0.3rem;
  border-bottom: 1px solid var(--color-border, #e0ddd8);
  flex-shrink: 0;
}

/* ── Stacked action buttons ──────────────────────────────────────────────── */
.action-btn-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.55rem 0.75rem;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  cursor: pointer;
  transition: background 0.1s, border-left-color 0.1s;
  border-radius: 0;
}

.action-btn:hover {
  background: var(--color-hover, #eeede9);
  border-left-color: var(--accent, #7a1f2b);
}

.action-btn:active {
  background: var(--paper-deep, #ece6d6);
}

.action-btn-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.action-btn-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink, #1a1d24);
  line-height: 1.2;
}

.action-btn-desc {
  font-size: 0.68rem;
  color: var(--ink-mute, #6b6f78);
  line-height: 1.2;
}

.action-btn--placeholder .action-btn-label,
.action-btn--placeholder .action-btn-desc {
  color: var(--ink-faint, #9a9da3);
}

.action-btn--placeholder {
  cursor: default;
}

.action-btn--placeholder:hover {
  background: none;
  border-left-color: transparent;
}

/* ── Slide-out drawer ────────────────────────────────────────────────────── */
.action-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: #fff;
  border-left: 1px solid var(--hairline, #d8d2c2);
  box-shadow: -4px 0 24px rgba(26, 29, 36, 0.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  /* hidden via [hidden] attr; visible when .drawer-open is added */
}

.action-drawer[hidden] {
  display: flex; /* keep layout for animation */
  visibility: hidden;
  pointer-events: none;
}

.action-drawer.drawer-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline, #d8d2c2);
  background: var(--paper-tint, #f4f0e6);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink, #1a1d24);
  letter-spacing: -0.01em;
}

.drawer-close {
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink-mute, #6b6f78);
  border-radius: var(--radius, 4px);
  transition: background 0.1s, color 0.1s;
}

.drawer-close:hover {
  background: var(--paper-deep, #ece6d6);
  color: var(--ink, #1a1d24);
}

.drawer-body {
  padding: 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--hairline-soft, #e8e3d4);
}

.drawer-hint {
  font-size: 0.82rem;
  color: var(--ink-soft, #3a3f4a);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}

.drawer-hint--muted {
  color: var(--ink-faint, #9a9da3);
}

.drawer-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft, #3a3f4a);
  margin-bottom: 0.6rem;
}

.drawer-input,
.drawer-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--hairline, #d8d2c2);
  border-radius: var(--radius, 4px);
  background: #fff;
  font-size: 0.82rem;
  color: var(--ink, #1a1d24);
  width: 100%;
  transition: border-color 0.12s;
}

.drawer-input:focus,
.drawer-select:focus {
  outline: none;
  border-color: var(--accent, #7a1f2b);
}

.drawer-run-btn {
  margin-top: 0.75rem;
  width: 100%;
}

/* ── Results area ─────────────────────────────────────────────────────────── */
.drawer-results {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  font-size: 0.83rem;
}

.drawer-spinner {
  color: var(--ink-mute, #6b6f78);
  font-style: italic;
  padding: 0.5rem 0;
}

.drawer-spinner .lr-elapsed {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-soft, #3a3f4a);
}

.drawer-spinner .lr-eta {
  font-size: 0.85em;
  color: var(--ink-mute, #6b6f78);
}

.drawer-result-ok {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.drawer-result-field {
  font-size: 0.8rem;
  color: var(--ink-soft, #3a3f4a);
}

.drawer-result-label {
  font-weight: 600;
  color: var(--ink-mute, #6b6f78);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.drawer-result-link {
  margin-top: 0.25rem;
  align-self: flex-start;
  text-decoration: none;
}

.drawer-result-body {
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--paper-tint, #f4f0e6);
  border-radius: var(--radius, 4px);
  font-size: 0.8rem;
  color: var(--ink-soft, #3a3f4a);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.drawer-result-error {
  padding: 0.6rem 0.75rem;
  background: var(--burgundy-soft, #f3e1e3);
  border: 1px solid #dcc2c4;
  border-radius: var(--radius, 4px);
  color: var(--burgundy, #5a1822);
  font-size: 0.82rem;
}

a.citation-doc-link {
  color: var(--cite-doc-fg, #1e3a6b);
  background: var(--cite-doc-bg, #e8eef8);
  padding: 0 3px;
  border-radius: 2px;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}

/* ── Backdrop ─────────────────────────────────────────────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 36, 0.35);
  z-index: 199;
}

.drawer-backdrop[hidden] { display: none; }

/* ── Responsive: hide action panel on narrow screens ─────────────────────── */
@media (max-width: 768px) {
  .action-panel {
    display: none;
  }
  /* On mobile, a floating toggle button instead */
  .action-panel-toggle-mobile {
    display: flex;
  }
}

@media (min-width: 769px) {
  .action-panel-toggle-mobile {
    display: none;
  }
}

/* ============================================================================
   P3.77 — Library, Share Drawer, Trash, Overflow Menu
   ============================================================================ */

/* ── Library page ──────────────────────────────────────────────────────────── */
.library-page .page-head { margin-bottom: 1.25rem; }

.library-list {
  border: 1px solid var(--hairline, #d8d2c2);
  border-radius: var(--radius-lg, 8px);
  overflow: hidden;
}

.library-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline-soft, #e8e3d4);
  font-size: 0.88rem;
  background: var(--paper, #fbfaf6);
  transition: background 0.1s;
}
.library-row:last-child { border-bottom: none; }
.library-row:hover { background: var(--paper-tint, #f4f0e6); }

.tag-chip {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--hairline, #d8d2c2);
  background: var(--paper, #fbfaf6);
  color: var(--ink-soft, #3a3f4a);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.tag-chip:hover,
.tag-chip.active {
  background: var(--accent, #7a1f2b);
  color: #fff;
  border-color: var(--accent, #7a1f2b);
}

/* ── Share drawer ─────────────────────────────────────────────────────────── */
.share-drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 96vw;
  height: 100vh;
  background: var(--paper, #fbfaf6);
  border-left: 1px solid var(--hairline, #d8d2c2);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: right 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(26, 29, 36, 0.12);
  overflow: hidden;
}
.share-drawer.open { right: 0; }

